diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2019-01-27 10:43:05 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2019-01-27 10:43:05 +0000 |
| commit | c4a6cf08d98d1b1239aefbb5a8b05f7c3f9294bf (patch) | |
| tree | d3532f1b95025706cebb81e0e354002a405dd834 /src | |
| parent | toolbox - add comment (diff) | |
| parent | Finich CSS refactor (diff) | |
| download | inkscape-c4a6cf08d98d1b1239aefbb5a8b05f7c3f9294bf.tar.gz inkscape-c4a6cf08d98d1b1239aefbb5a8b05f7c3f9294bf.zip | |
Merge branch 'master' of gitlab.com:inkscape/inkscape
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop.cpp | 6 | ||||
| -rw-r--r-- | src/desktop.h | 1 | ||||
| -rw-r--r-- | src/inkscape.cpp | 68 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 79 | ||||
| -rw-r--r-- | src/ui/dialog/symbols.cpp | 5 | ||||
| -rw-r--r-- | src/ui/icon-loader.cpp | 118 | ||||
| -rw-r--r-- | src/ui/icon-loader.h | 15 | ||||
| -rw-r--r-- | src/ui/widget/dash-selector.cpp | 2 | ||||
| -rw-r--r-- | src/widgets/desktop-widget.cpp | 25 | ||||
| -rw-r--r-- | src/widgets/stroke-marker-selector.cpp | 2 |
10 files changed, 190 insertions, 131 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp index 4e3a28243..20c4914a4 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1293,6 +1293,12 @@ SPDesktop::is_iconified() return 0!=(window_state & GDK_WINDOW_STATE_ICONIFIED); } +bool +SPDesktop::is_darktheme() +{ + return getToplevel()->get_style_context()->has_class("dark"); +} + void SPDesktop::iconify() { diff --git a/src/desktop.h b/src/desktop.h index 539e55935..d4babf61f 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -417,6 +417,7 @@ public: void toggleToolbar(gchar const *toolbar_name); bool is_iconified(); + bool is_darktheme(); bool is_maximized(); bool is_fullscreen(); bool is_focusMode(); diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 1418f5c3b..5c6f29c3f 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -378,6 +378,13 @@ Application::add_gtk_css() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); auto provider = Gtk::CssProvider::create(); Glib::ustring css_str = ""; + gchar colornamed[64]; + gchar colornamed_inverse[64]; + int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); + sp_svg_write_color(colornamed, sizeof(colornamed), colorset); + // Use in case the special widgets have inverse theme background and symbolic + int colorset_inverse = colorset ^ 0xffffff00; + sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse); if (prefs->getBool("/theme/symbolicIcons", false)) { int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); gchar colornamed[64]; @@ -388,12 +395,13 @@ Application::add_gtk_css() sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse); if (prefs->getBool("/theme/symbolicIconsDefaultColor", true)) { css_str += "*{ -gtk-icon-style: symbolic;}"; - css_str += "image{ color: @theme_fg_color}"; + css_str += ".dark,.bright,.dark image,.bright image{ color: @theme_fg_color}"; css_str += "iconinverse{ color: @theme_bg_color;}"; css_str += "iconregular{ -gtk-icon-style: regular;}"; } else { css_str += "*{ -gtk-icon-style: symbolic;}"; - css_str += "image{ color:"; + css_str += ".dark *,.bright *{ color: @theme_fg_color;}"; + css_str += ".dark,.bright,.dark image,.bright image{ color:"; css_str += colornamed; css_str += ";}"; css_str += "#iconinverse{ color:"; @@ -404,9 +412,36 @@ Application::add_gtk_css() } else { css_str += "*{-gtk-icon-style: regular;}"; } - GtkSettings *settings = gtk_settings_get_default(); + css_str += ".iconcolornamed, .iconcolornamed image{ color:"; + css_str += colornamed; + css_str += ";}"; + css_str += ".iconcolornamedinverse, .colornamedinverse image{ color:"; + css_str += colornamed_inverse; + css_str += ";}"; const gchar *gtk_font_name = ""; + const gchar *gtkThemeName; + const gchar *gtkIconThemeName; + gboolean gtkApplicationPreferDarkTheme; + GtkSettings *settings = gtk_settings_get_default(); if (settings) { + g_object_get(settings, "gtk-icon-theme-name", >kIconThemeName, NULL); + g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); + g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); + g_object_set(settings, "gtk-application-prefer-dark-theme", + prefs->getBool("/theme/darkTheme", gtkApplicationPreferDarkTheme), NULL); + prefs->setString("/theme/defaultIconTheme", Glib::ustring(gtkIconThemeName)); + if (prefs->getString("/theme/gtkTheme") != "") { + g_object_set(settings, "gtk-theme-name", prefs->getString("/theme/gtkTheme").c_str(), NULL); + } else { + prefs->setString("/theme/gtkTheme", Glib::ustring(gtkThemeName)); + } + + Glib::ustring themeiconname = prefs->getString("/theme/iconTheme"); + if (themeiconname != "") { + g_object_set(settings, "gtk-icon-theme-name", themeiconname.c_str(), NULL); + } else { + prefs->setString("/theme/iconTheme", Glib::ustring(gtkIconThemeName)); + } g_object_get(settings, "gtk-font-name", >k_font_name, NULL); } if (!strncmp(gtk_font_name, "Cantarell", 9)) { @@ -509,33 +544,6 @@ Application::Application(const char* argv, bool use_gui) : icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); add_gtk_css(); /* Load the preferences and menus */ - GtkSettings *settings = gtk_settings_get_default(); - if (settings) { - const gchar *gtkThemeName; - const gchar *gtkIconThemeName; - gboolean gtkApplicationPreferDarkTheme; - g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); - g_object_get(settings, "gtk-icon-theme-name", >kIconThemeName, NULL); - g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); - g_object_set(settings, "gtk-application-prefer-dark-theme", - prefs->getBool("/theme/darkTheme", gtkApplicationPreferDarkTheme), NULL); - prefs->setString("/theme/defaultIconTheme", Glib::ustring(gtkIconThemeName)); - if (prefs->getString("/theme/gtkTheme") != "") { - g_object_set(settings, "gtk-theme-name", prefs->getString("/theme/gtkTheme").c_str(), NULL); - } - else { - prefs->setString("/theme/gtkTheme", Glib::ustring(gtkThemeName)); - } - - Glib::ustring themeiconname = prefs->getString("/theme/iconTheme"); - if (themeiconname != "") { - g_object_set(settings, "gtk-icon-theme-name", themeiconname.c_str(), NULL); - } - else { - prefs->setString("/theme/iconTheme", Glib::ustring(gtkIconThemeName)); - } - } - load_menus(); Inkscape::DeviceManager::getManager().loadConfig(); } diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 6634ef170..191182528 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -34,6 +34,7 @@ #include "cms-system.h" #include "document.h" #include "enums.h" +#include "inkscape-window.h" #include "inkscape.h" #include "message-stack.h" #include "path-prefix.h" @@ -59,6 +60,7 @@ #include "svg/svg-color.h" #include "ui/interface.h" #include "ui/widget/style-swatch.h" +#include "widgets/desktop-widget.h" #ifdef HAVE_ASPELL # include <aspell.h> @@ -654,7 +656,7 @@ void InkscapePreferences::symbolicDefaultColor(){ Glib::ustring css_str = ""; if (prefs->getBool("/theme/symbolicIcons", false)) { css_str += "*{ -gtk-icon-style: symbolic;}"; - css_str += "image{ color: @theme_fg_color}"; + css_str += ".dark,.bright,.dark image,.bright image{ color: @theme_fg_color;}"; css_str += "iconinverse{ color: @theme_bg_color;}"; css_str += "iconregular{ -gtk-icon-style: regular;}"; } else { @@ -679,30 +681,35 @@ void InkscapePreferences::symbolicDefaultColor(){ void InkscapePreferences::symbolicAddClass() { + using namespace Inkscape::IO::Resource; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setBool("/theme/symbolicIconsDefaultColor", false); auto const screen = Gdk::Screen::get_default(); auto provider = Gtk::CssProvider::create(); Glib::ustring css_str = ""; + + gchar colornamed[64]; + gchar colornamed_inverse[64]; + int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); + sp_svg_write_color(colornamed, sizeof(colornamed), colorset); + // Use in case the special widgets have inverse theme background and symbolic + int colorset_inverse = colorset ^ 0xffffff00; + sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse); if (prefs->getBool("/theme/symbolicIcons", false)) { - int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); - gchar colornamed[64]; - sp_svg_write_color(colornamed, sizeof(colornamed), colorset); - // Use in case the special widgets have inverse theme background and symbolic - int colorset_inverse = colorset ^ 0xffffff00; - gchar colornamed_inverse[64]; - sp_svg_write_color(colornamed_inverse, sizeof(colornamed_inverse), colorset_inverse); css_str += "*{ -gtk-icon-style: symbolic;}"; - css_str += "image{ color:"; + css_str += ".dark *,.bright *{ color: @theme_fg_color;}"; + css_str += ".dark,.bright,.dark image,.bright image{ color:"; css_str += colornamed; css_str += ";}"; - css_str += "iconinverse{ color:"; - css_str += colornamed_inverse; - css_str += ";}"; - css_str += "iconregular{ -gtk-icon-style: regular;}"; } else { css_str += "*{-gtk-icon-style: regular;}"; } + css_str += ".iconcolornamed, .iconcolornamed image{ color:"; + css_str += colornamed; + css_str += ";}"; + css_str += ".iconcolornamedinverse, .colornamedinverse image{ color:"; + css_str += colornamed_inverse; + css_str += ";}"; // From 3.16, throws an error which we must catch. try { provider->load_from_data(css_str); @@ -717,6 +724,28 @@ void InkscapePreferences::symbolicAddClass() } #endif Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + // we want a tiny file with 3 or 4 lines, so we can load without removing context + // is more understandable than record previously applied + Glib::ustring style = get_filename(UIS, "style.css"); + if (!style.empty()) { + auto provider = Gtk::CssProvider::create(); + + // From 3.16, throws an error which we must catch. + try { + provider->load_from_path(style); + } +#if GTK_CHECK_VERSION(3, 16, 0) + // Gtk::CssProviderError not defined until 3.16. + catch (const Gtk::CssProviderError &ex) { + g_critical("CSSProviderError::load_from_path(): failed to load '%s'\n(%s)", style.c_str(), + ex.what().c_str()); + } +#else + catch (...) { + } +#endif + Gtk::StyleContext::add_provider_for_screen(screen, provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); + } } void InkscapePreferences::themeChange() { @@ -724,6 +753,30 @@ void InkscapePreferences::themeChange() g_object_set(gtk_settings_get_default(), "gtk-theme-name", prefs->getString("/theme/gtkTheme").c_str(), NULL); g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", prefs->getBool("/theme/darkTheme", false), NULL); + gchar *gtkThemeName; + gboolean gtkApplicationPreferDarkTheme; + Gtk::Window *window = SP_ACTIVE_DESKTOP->getToplevel(); + GtkSettings *settings = gtk_settings_get_default(); + if (window && settings) { + g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); + g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); + bool dark = gtkApplicationPreferDarkTheme || Glib::ustring(gtkThemeName).find(":dark") != -1; + if (!dark) { + Glib::RefPtr<Gtk::StyleContext> 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) { + dark = true; + } + } + if (dark) { + window->get_style_context()->add_class("dark"); + window->get_style_context()->remove_class("bright"); + } else { + window->get_style_context()->add_class("bright"); + window->get_style_context()->remove_class("dark"); + } + } } void InkscapePreferences::initPageUI() diff --git a/src/ui/dialog/symbols.cpp b/src/ui/dialog/symbols.cpp index fa76fc31a..06a76605b 100644 --- a/src/ui/dialog/symbols.cpp +++ b/src/ui/dialog/symbols.cpp @@ -186,7 +186,6 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : icon_view = new Gtk::IconView(static_cast<Glib::RefPtr<Gtk::TreeModel> >(store)); //icon_view->set_text_column( columns->symbol_id ); icon_view->set_tooltip_column( 1 ); - icon_view->set_name( "symbolsView" ); icon_view->set_pixbuf_column( columns->symbol_image ); // Giving the iconview a small minimum size will help users understand // What the dialog does. @@ -214,6 +213,8 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : overlay->set_hexpand(); overlay->set_vexpand(); overlay->add(* scroller); + overlay->get_style_context()->add_class("colorbright"); + overlay->get_style_context()->add_class("backgroundbright"); scroller->set_size_request(100, 250); table->attach(*Gtk::manage(overlay),0,row,2,1); @@ -227,7 +228,7 @@ SymbolsDialog::SymbolsDialog( gchar const* prefsPath ) : iconsize = Gtk::IconSize().register_new(Glib::ustring("ICON_SIZE_DIALOG_EXTRA"), 110, 110); } overlay_icon = sp_get_icon_image("searching", iconsize); - overlay_icon->set_name("iconinverse"); + overlay_icon->get_style_context()->add_class("iconsymbolic"); overlay_icon->set_halign(Gtk::ALIGN_CENTER ); overlay_icon->set_valign(Gtk::ALIGN_START ); overlay_icon->set_margin_top(45); diff --git a/src/ui/icon-loader.cpp b/src/ui/icon-loader.cpp index a6011773d..e2aaf5093 100644 --- a/src/ui/icon-loader.cpp +++ b/src/ui/icon-loader.cpp @@ -10,64 +10,63 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ + #include "icon-loader.h" #include "inkscape.h" -#include "io/resource.h" -#include "preferences.h" -#include "svg/svg-color.h" #include "widgets/toolbox.h" +#include <gtkmm/iconinfo.h> #include <gdkmm/display.h> #include <gdkmm/screen.h> #include <gtkmm/iconinfo.h> #include <gtkmm/icontheme.h> -#include <gtkmm/toolitem.h> -void sp_load_theme() {} +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size) +{ + Gtk::Image *icon = new Gtk::Image(); + icon->set_from_icon_name(icon_name, Gtk::IconSize(Gtk::ICON_SIZE_BUTTON)); + icon->set_pixel_size(size); + return icon; +} + +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::IconSize icon_size) +{ + Gtk::Image *icon = new Gtk::Image(); + icon->set_from_icon_name(icon_name, icon_size); + return icon; +} + +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size) +{ + Gtk::Image *icon = new Gtk::Image(); + icon->set_from_icon_name(icon_name, icon_size); + return icon; +} + +GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size) +{ + return gtk_image_new_from_icon_name(icon_name.c_str(), icon_size); +} + +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_size) +{ + Gtk::IconSize icon_size = Inkscape::UI::ToolboxFactory::prefToSize_mm(prefs_size); + return sp_get_icon_image(icon_name, icon_size); +} Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) { Glib::RefPtr<Gdk::Display> display = Gdk::Display::get_default(); Glib::RefPtr<Gdk::Screen> screen = display->get_default_screen(); Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_for_screen(screen); - // TODO all calls to "sp_get_icon_pixbuf" need to be removed in thew furture - // Put here temporary for allow use symbolic in a few icons require pixbug instead Gtk::Image - // We coulden't acces to pixbuf of a symbolic ones with the next order - // icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); - // Maybe we can do with Gio, but not sure. Also can render a icon to pixbuf but need to be - // a stock-icon not on named ones I think or access directly to the icon.svg file - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf; - try { - if (prefs->getBool("/theme/symbolicIcons", false)) { - gchar colornamed[64]; - int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); - // Use in case the special widgets have inverse theme background and symbolic - sp_svg_write_color(colornamed, sizeof(colornamed), colorset); - Gdk::RGBA color; - color.set(colornamed); - Gtk::IconInfo iconinfo = - icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); - if (bool(iconinfo)) { - bool was_symbolic = false; - _icon_pixbuf = iconinfo.load_symbolic(color, color, color, color, was_symbolic); - } - else { - _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); - } - // g_warning("Icon Loader using a future dead function in this icon: %s", icon_name.c_str()); - // limit warns to 1 per run - static bool tmp_warn = true; - if (tmp_warn) { - tmp_warn = false; - g_warning("Icon Loader using a legacy function (sp_get_icon_pixbuf)."); - } - } - else { - _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); - } - } - catch (const Gtk::IconThemeError &e) { - g_warning("Icon Loader error loading icon file: %s", e.what().c_str()); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/theme/symbolicIcons", false)) { + Gtk::IconInfo iconinfo = icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); + bool was_sumbolic = false; + _icon_pixbuf = iconinfo.load_symbolic(SP_ACTIVE_DESKTOP->getToplevel()->get_style_context(), was_sumbolic); + } else { + Gtk::IconInfo iconinfo = icon_theme->lookup_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); + _icon_pixbuf = iconinfo.load_icon(); } return _icon_pixbuf; } @@ -103,39 +102,6 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gchar cons return sp_get_icon_pixbuf(icon_name, icon_size); } - -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size) -{ - - Gtk::Image *icon = new Gtk::Image(); - icon->set_from_icon_name(icon_name, Gtk::IconSize(icon_size)); - return icon; -} - -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::IconSize icon_size) -{ - - Gtk::Image *icon = new Gtk::Image(); - icon->set_from_icon_name(icon_name, icon_size); - return icon; -} - -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_size) -{ - - Gtk::IconSize icon_size = Inkscape::UI::ToolboxFactory::prefToSize_mm(prefs_size); - Gtk::Image *icon = new Gtk::Image(); - icon->set_from_icon_name(icon_name, icon_size); - return icon; -} - - -GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size) -{ - - return gtk_image_new_from_icon_name(icon_name.c_str(), icon_size); -} - /* Local Variables: mode:c++ diff --git a/src/ui/icon-loader.h b/src/ui/icon-loader.h index 3f7f1fcb8..78975e210 100644 --- a/src/ui/icon-loader.h +++ b/src/ui/icon-loader.h @@ -13,16 +13,17 @@ #define SEEN_INK_ICON_LOADER_H #include <gdkmm/pixbuf.h> -#include <gtkmm/box.h> #include <gtkmm/image.h> +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size); +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size); +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::IconSize icon_size); +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_sice); +GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size); Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size); -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size); Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::IconSize icon_size); +Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size); Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, GtkIconSize icon_size); Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_sice); -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size); -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::IconSize icon_size); -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_sice); -GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size); -#endif // SEEN_INK_STOCK_ITEMS_H + +#endif // SEEN_INK_ICON_LOADER_H diff --git a/src/ui/widget/dash-selector.cpp b/src/ui/widget/dash-selector.cpp index 81e7881b6..ea5cc57d2 100644 --- a/src/ui/widget/dash-selector.cpp +++ b/src/ui/widget/dash-selector.cpp @@ -61,7 +61,7 @@ DashSelector::DashSelector() dash_combo.pack_start(image_renderer); dash_combo.set_cell_data_func(image_renderer, sigc::mem_fun(*this, &DashSelector::prepareImageRenderer)); dash_combo.set_tooltip_text(_("Dash pattern")); - dash_combo.set_name("dashCombo"); + dash_combo.get_style_context()->add_class("combobright"); dash_combo.show(); dash_combo.signal_changed().connect( sigc::mem_fun(*this, &DashSelector::on_selection) ); diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index b7b9d2ce0..9db8b2af4 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -693,7 +693,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw ) } overallTimer = nullptr; } - // Ensure that ruler ranges are updated correctly whenever the canvas table // is resized dtw->_canvas_tbl_size_allocate_connection = dtw->_canvas_tbl->signal_size_allocate().connect(sigc::mem_fun(dtw, &SPDesktopWidget::canvas_tbl_size_allocate)); @@ -890,6 +889,30 @@ sp_desktop_widget_realize (GtkWidget *widget) dtw->desktop->set_display_area (d, 10); dtw->updateNamedview(); + gchar *gtkThemeName; + gboolean gtkApplicationPreferDarkTheme; + GtkSettings *settings = gtk_settings_get_default(); + Gtk::Window *window = SP_ACTIVE_DESKTOP->getToplevel(); + if (settings && window) { + g_object_get(settings, "gtk-theme-name", >kThemeName, NULL); + g_object_get(settings, "gtk-application-prefer-dark-theme", >kApplicationPreferDarkTheme, NULL); + bool dark = gtkApplicationPreferDarkTheme || Glib::ustring(gtkThemeName).find(":dark") != -1; + if (!dark) { + Glib::RefPtr<Gtk::StyleContext> 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) { + dark = true; + } + } + if (dark) { + window->get_style_context()->add_class("dark"); + window->get_style_context()->remove_class("bright"); + } else { + window->get_style_context()->add_class("bright"); + window->get_style_context()->remove_class("dark"); + } + } } /* This is just to provide access to common functionality from sp_desktop_widget_realize() above diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index 5bfebb799..095653cb3 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -52,7 +52,6 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : pack_start(image_renderer, false); set_cell_data_func(image_renderer, sigc::mem_fun(*this, &MarkerComboBox::prepareImageRenderer)); gtk_combo_box_set_row_separator_func(GTK_COMBO_BOX(gobj()), MarkerComboBox::separator_cb, nullptr, nullptr); - gtk_widget_set_name(GTK_WIDGET(gobj()), "markerCombo"); empty_image = sp_get_icon_image("no-marker", Gtk::ICON_SIZE_SMALL_TOOLBAR); sandbox = ink_markers_preview_doc (); @@ -62,6 +61,7 @@ MarkerComboBox::MarkerComboBox(gchar const *id, int l) : modified_connection = doc->getDefs()->connectModified( sigc::hide(sigc::hide(sigc::bind(sigc::ptr_fun(&MarkerComboBox::handleDefsModified), this))) ); init_combo(); + this->get_style_context()->add_class("combobright"); show(); } |
