Mercurial > minori
diff src/core/strings.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 | 47c9f8502269 |
| children |
line wrap: on
line diff
--- a/src/core/strings.cc Fri Nov 07 18:36:18 2025 -0500 +++ b/src/core/strings.cc Mon Nov 10 15:51:45 2025 -0500 @@ -301,4 +301,29 @@ return Strings::ToUtf8String(QCoreApplication::tr(str)); } +/* Moved here from glib code because xsettings parser needs it */ +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; +} + } // namespace Strings
