Mercurial > minori
diff src/sys/glib/dark_theme.cc @ 379:5eaafed6c10b
*: clang-format
| author | Paper <paper@tflc.us> |
|---|---|
| date | Wed, 05 Nov 2025 12:59:46 -0500 |
| parents | 99c961c91809 |
| children |
line wrap: on
line diff
--- a/src/sys/glib/dark_theme.cc Wed Nov 05 12:50:35 2025 -0500 +++ b/src/sys/glib/dark_theme.cc Wed Nov 05 12:59:46 2025 -0500 @@ -1,27 +1,27 @@ #include "sys/glib/dark_theme.h" +#include <array> #include <cstring> #include <gio/gio.h> +#include <memory> #include <string_view> -#include <memory> -#include <array> namespace glib { /* deleters */ template<typename T> struct g_object_del { - void operator()(T* p) const { ::g_object_unref(p); }; + void operator()(T *p) const { ::g_object_unref(p); }; }; template<typename T> struct g_variant_del { - void operator()(T* p) const { ::g_variant_unref(p); }; + void operator()(T *p) const { ::g_variant_unref(p); }; }; template<typename T> struct g_malloc_del { - void operator()(T* p) const { ::g_free(p); }; + void operator()(T *p) const { ::g_free(p); }; }; template<typename T> @@ -34,29 +34,32 @@ using GMallocPtr = std::unique_ptr<T, g_malloc_del<T>>; /* not really "glib" but GNOME-related enough */ -bool IsGTKThemeDark(const std::string_view str) { +bool IsGTKThemeDark(const std::string_view str) +{ /* if that doesn't exist, use the GTK theme and check for some known * suffixes. if one is found, return * * XXX probably better to use case folding here */ static constexpr std::array<std::string_view, 3> suffixes = { - "-dark", /* Adwaita-dark */ - "-Dark", /* Arc-Dark */ - "-Darker", /* Arc-Darker */ + "-dark", /* Adwaita-dark */ + "-Dark", /* Arc-Dark */ + "-Darker", /* Arc-Darker */ }; - for (const auto& suffix : suffixes) { + for (const auto &suffix : suffixes) { if (str.size() < suffix.size()) continue; - if (std::equal(str.data() + str.size() - suffix.length(), str.data() + str.size(), suffix.begin(), suffix.end())) + if (std::equal(str.data() + str.size() - suffix.length(), str.data() + str.size(), suffix.begin(), + suffix.end())) return true; } return false; } -bool IsInDarkTheme() { +bool IsInDarkTheme() +{ GObjectPtr<GSettings> settings(::g_settings_new("org.gnome.desktop.interface")); if (!settings) return false; @@ -69,7 +72,7 @@ /* this is free'd upon deconstruction of the GVariantPtr */ gsize size; - const gchar* str = ::g_variant_get_string(val.get(), &size); + const gchar *str = ::g_variant_get_string(val.get(), &size); if (!str) return false; @@ -86,7 +89,7 @@ return false; gsize size; - const gchar* str = ::g_variant_get_string(gtk_theme.get(), &size); + const gchar *str = ::g_variant_get_string(gtk_theme.get(), &size); if (!str) return false;
