From 0f80916091147545b2e186af406d7f1aa6e72452 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 29 Jul 2018 00:04:59 +0200 Subject: Allow to change dark teme and GtkTheme at instant --- src/ui/dialog/inkscape-preferences.cpp | 15 ++++++++++++--- src/ui/dialog/inkscape-preferences.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index eb958dfa5..790a025e6 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -601,7 +601,6 @@ static void _inkscape_fill_gtk(const gchar *path, GHashTable *t) g_dir_close(dir); } -//TODO: this check only inkscape based folders dont check if icons are system wide void InkscapePreferences::symbolicThemeCheck() { using namespace Inkscape::IO::Resource; @@ -640,6 +639,14 @@ void InkscapePreferences::symbolicThemeCheck() } } +void InkscapePreferences::themeChange() +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + 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); +} + void InkscapePreferences::initPageUI() { Gtk::TreeModel::iterator iter_ui = this->AddPage(_page_ui, _("Interface"), PREFS_PAGE_UI); @@ -771,7 +778,7 @@ void InkscapePreferences::initPageUI() } // Theme - _page_theme.add_group_header(_("Theme changes")); + _page_theme.add_group_header(_("Theme changes, icon changes need reload or restart")); { using namespace Inkscape::IO::Resource; GHashTable *t; @@ -824,6 +831,7 @@ void InkscapePreferences::initPageUI() _gtk_theme.init("/theme/gtkTheme", labels, values, "Adwaita"); _page_theme.add_line(false, _("Change Gtk theme:"), _gtk_theme, "", "", false); + _gtk_theme.signal_changed().connect(sigc::mem_fun(*this, &InkscapePreferences::themeChange)); } { @@ -929,6 +937,7 @@ void InkscapePreferences::initPageUI() _dark_theme.init(_("Use dark theme"), "/theme/darkTheme", true); _page_theme.add_line(true, "", _dark_theme, "", _("Use dark theme"), true); + _dark_theme.signal_clicked().connect(sigc::mem_fun(*this, &InkscapePreferences::themeChange)); _symbolic_icons.init(_("Use symbolic icons"), "/theme/symbolicIcons", true); _page_theme.add_line(true, "", _symbolic_icons, "", "", true), _symbolic_color.init(_("Color for symbolic icons:"), "/theme/symbolicColor", 0x000000ff); @@ -951,7 +960,7 @@ void InkscapePreferences::initPageUI() _page_theme.add_line(false, _("Secondary toolbar icon size:"), _misc_small_secondary, "", _("Set the size for the icons in secondary toolbars to use (requires restart)"), false); } - _apply_theme.set_label(_("Apply theme")); + _apply_theme.set_label(_("Reload icons")); _apply_theme.set_tooltip_text(_("It apply slow")); _page_theme.add_line(false, "", _apply_theme, "", "", false); _apply_theme.signal_clicked().connect(sigc::ptr_fun(sp_ui_reload)); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index f36b3d944..cce2509d7 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -574,6 +574,7 @@ protected: private: void symbolicThemeCheck(); + void themeChange(); InkscapePreferences(); InkscapePreferences(InkscapePreferences const &d); InkscapePreferences operator=(InkscapePreferences const &d); -- cgit v1.2.3