Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 402:d859306e2db4 | 403:df4a027623d0 |
|---|---|
| 299 std::string Translate(const char *str) | 299 std::string Translate(const char *str) |
| 300 { | 300 { |
| 301 return Strings::ToUtf8String(QCoreApplication::tr(str)); | 301 return Strings::ToUtf8String(QCoreApplication::tr(str)); |
| 302 } | 302 } |
| 303 | 303 |
| 304 /* Moved here from glib code because xsettings parser needs it */ | |
| 305 bool IsGTKThemeDark(const std::string_view str) | |
| 306 { | |
| 307 /* if that doesn't exist, use the GTK theme and check for some known | |
| 308 * suffixes. if one is found, return | |
| 309 * | |
| 310 * XXX probably better to use case folding here */ | |
| 311 static constexpr std::array<std::string_view, 3> suffixes = { | |
| 312 "-dark", /* Adwaita-dark */ | |
| 313 "-Dark", /* Arc-Dark */ | |
| 314 "-Darker", /* Arc-Darker */ | |
| 315 }; | |
| 316 | |
| 317 for (const auto &suffix : suffixes) { | |
| 318 if (str.size() < suffix.size()) | |
| 319 continue; | |
| 320 | |
| 321 if (std::equal(str.data() + str.size() - suffix.length(), str.data() + str.size(), suffix.begin(), | |
| 322 suffix.end())) | |
| 323 return true; | |
| 324 } | |
| 325 | |
| 326 return false; | |
| 327 } | |
| 328 | |
| 304 } // namespace Strings | 329 } // namespace Strings |
