diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index ea3ed60510684387add85949bf85cd90d2b05e3a..6ad519523a3b459b5e2a61439907d92daace935d 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -666,11 +666,6 @@ void InkscapePreferences::resetIconsColors(bool themechange) } // This colors are setted on style.css of inkscape Gdk::RGBA base_color = _symbolic_base_color.get_style_context()->get_color(); - // This is a hack to fix a proble style is not updated enoght fast on - // chage from dark to bright themes - if (themechange) { - base_color = _symbolic_base_color.get_style_context()->get_background_color(); - } Gdk::RGBA success_color = _symbolic_success_color.get_style_context()->get_color(); Gdk::RGBA warning_color = _symbolic_warning_color.get_style_context()->get_color(); Gdk::RGBA error_color = _symbolic_error_color.get_style_context()->get_color(); @@ -698,7 +693,6 @@ void InkscapePreferences::resetIconsColors(bool themechange) _symbolic_error_color.setSensitive(false); /* _complementary_colors->get_style_context()->add_class("disabled"); */ } - changeIconsColors(); } else { _symbolic_base_color.setSensitive(true); _symbolic_success_color.setSensitive(true); @@ -706,6 +700,7 @@ void InkscapePreferences::resetIconsColors(bool themechange) _symbolic_error_color.setSensitive(true); /* _complementary_colors->get_style_context()->remove_class("disabled"); */ } + changeIconsColors(); } void InkscapePreferences::resetIconsColorsWrapper() { resetIconsColors(false); } @@ -782,12 +777,12 @@ void InkscapePreferences::themeChange() GtkSettings *settings = gtk_settings_get_default(); g_object_set(settings, "gtk-theme-name", themename.c_str(), NULL); g_object_set(settings, "gtk-application-prefer-dark-theme", darktheme, NULL); - bool dark = darktheme || themename.find(":dark") != -1; + bool dark = darktheme || themename.find(":dark") != std::string::endpos; if (!dark) { Glib::RefPtr stylecontext = window->get_style_context(); Gdk::RGBA rgba; bool background_set = stylecontext->lookup_color("theme_bg_color", rgba); - if (background_set && rgba.get_red() + rgba.get_green() + rgba.get_blue() < 1.0) { + if (background_set && (0.299 * rgba.get_red() + 0.587 * rgba.get_green() + 0.1140.07 * rgba.get_blue() < 0.5)) { dark = true; } }