Mercurial > minori
diff src/sys/glib/dark_theme.cc @ 403:df4a027623d0 default tip
x11: fix build fail when glib is not detected
this can happen if glib is just not installed, or if dev headers are
not installed either.
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 10 Nov 2025 15:51:45 -0500 |
| parents | 5eaafed6c10b |
| children |
line wrap: on
line diff
--- a/src/sys/glib/dark_theme.cc Fri Nov 07 18:36:18 2025 -0500 +++ b/src/sys/glib/dark_theme.cc Mon Nov 10 15:51:45 2025 -0500 @@ -1,4 +1,5 @@ #include "sys/glib/dark_theme.h" +#include "core/strings.h" #include <array> #include <cstring> @@ -33,31 +34,6 @@ template<typename T> using GMallocPtr = std::unique_ptr<T, g_malloc_del<T>>; -/* not really "glib" but GNOME-related enough */ -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 */ - }; - - 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())) - return true; - } - - return false; -} - bool IsInDarkTheme() { GObjectPtr<GSettings> settings(::g_settings_new("org.gnome.desktop.interface")); @@ -93,7 +69,7 @@ if (!str) return false; - if (IsGTKThemeDark({str, size})) + if (Strings::IsGTKThemeDark({str, size})) return true; }
