diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-07-27 22:27:38 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-07-27 22:27:38 +0000 |
| commit | 04656355bd73375a6666c212b02be07a89808811 (patch) | |
| tree | 37e69bf3bb83cfe7842e747614352aaa9860abb2 /src | |
| parent | Working on icons (diff) | |
| download | inkscape-04656355bd73375a6666c212b02be07a89808811.tar.gz inkscape-04656355bd73375a6666c212b02be07a89808811.zip | |
Refactor fo theme switcher
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/icon-loader.cpp | 17 | ||||
| -rw-r--r-- | src/inkscape.cpp | 17 | ||||
| -rw-r--r-- | src/main.cpp | 13 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 6 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 1 | ||||
| -rw-r--r-- | src/ui/widget/color-notebook.cpp | 2 |
6 files changed, 17 insertions, 39 deletions
diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index 1c21a492d..68326bdc9 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -27,13 +27,7 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) { using namespace Inkscape::IO::Resource; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (prefs->getString("/theme/iconTheme") == "") { - prefs->setString("/theme/iconTheme", "hicolor"); - } - auto iconTheme = Gtk::IconTheme::create(); - iconTheme->set_custom_theme(prefs->getString("/theme/iconTheme")); - iconTheme->append_search_path(get_path_ustring(SYSTEM, ICONS)); - iconTheme->append_search_path(get_path_ustring(USER, ICONS)); + auto icon_theme = Gtk::IconTheme::get_default(); Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf; try { if (prefs->getBool("/theme/symbolicIcons", false)) { @@ -41,25 +35,22 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) if (icon_name == "gtk-preferences") { icon_name = "preferences-system"; } - iconTheme->append_search_path(get_path_ustring(SYSTEM, ICONS) + "hicolor/symbolic"); - iconTheme->append_search_path(get_path_ustring(USER, ICONS)+ "hicolor/symbolic"); sp_svg_write_color(colornamed, sizeof(colornamed), prefs->getInt("/theme/symbolicColor", 0x000000ff)); Gdk::RGBA color; color.set(colornamed); Gtk::IconInfo iconinfo = - iconTheme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); + icon_theme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); if (bool(iconinfo)) { // TODO: view if we need parametrice other colors - bool was_symbolic = false; _icon_pixbuf = iconinfo.load_symbolic(color, color, color, color, was_symbolic); } else { - _icon_pixbuf = iconTheme->load_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); + _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); } } else { - _icon_pixbuf = iconTheme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); + _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); } } catch (const Gtk::IconThemeError &e) { diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 0887bc2ef..b2f032d47 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -365,21 +365,6 @@ void Application::argv0(char const* argv) } /** - * \brief Add our icon theme to the search path - */ -void -Application::add_icon_theme() -{ - using namespace Inkscape::IO::Resource; - // Get list of the possible folders containing the theme - auto icon_theme = Gtk::IconTheme::get_default(); - // We used to add get_system_data_dirs and get_user_data_dir, but these - // folders didn't seem to make much sense for Linux. More testing needed. - icon_theme->append_search_path(get_path_ustring(SYSTEM, ICONS)); - icon_theme->append_search_path(get_path_ustring(USER, ICONS)); -} - -/** * \brief Add our CSS style sheets */ void @@ -473,6 +458,7 @@ Application::Application(const char* argv, bool use_gui) : /* Load the preferences and menus */ 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-icon-theme-name", prefs->getString("/theme/iconTheme").c_str(), NULL); g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", prefs->getBool("/theme/darkTheme", false), NULL); InkErrorHandler* handler = new InkErrorHandler(use_gui); @@ -486,7 +472,6 @@ Application::Application(const char* argv, bool use_gui) : } if (use_gui) { - add_icon_theme(); add_style_sheet(); load_menus(); Inkscape::DeviceManager::getManager().loadConfig(); diff --git a/src/main.cpp b/src/main.cpp index 4376979db..d9a1d37df 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -621,12 +621,7 @@ static void set_extensions_env() static void set_datadir_env() { gchar const *xgd = g_getenv("XDG_DATA_DIRS"); - Glib::ustring datadir = ""; - if (xgd) { - datadir += xgd; - datadir += ":"; - } - datadir += get_datadir_path(); + Glib::ustring datadir = get_datadir_path(); datadir += ":"; datadir += INKSCAPE_DATADIR; #ifdef WIN32 @@ -634,8 +629,12 @@ static void set_datadir_env() #else datadir += "/inkscape"; #endif + if (xgd) { + datadir += ":"; + datadir += xgd; + } g_setenv("XDG_DATA_DIRS", datadir.c_str(), TRUE); - printf("XDG_DATA_DIRS = %s\n", g_getenv("XDG_DATA_DIRS")); + // printf("XDG_DATA_DIRS = %s\n", g_getenv("XDG_DATA_DIRS")); } /** diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index b2020fa5f..2be489c23 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -610,11 +610,13 @@ static void _inkscape_fill_icons(const gchar *path, GHashTable *t) if (!dir) { return; } - std::cout << path << "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" << std::endl; while ((dir_entry = g_dir_read_name(dir))) { gchar *filename = g_build_filename(path, dir_entry, "index.theme", NULL); gchar *scalable = g_build_filename(path, dir_entry, "scalable", NULL); - if (g_file_test(filename, G_FILE_TEST_IS_REGULAR) && g_file_test(scalable, G_FILE_TEST_IS_DIR) && + gchar *symbolic = g_build_filename(path, dir_entry, "symbolic", NULL); + if (g_file_test(filename, G_FILE_TEST_IS_REGULAR) && + (g_file_test(scalable, G_FILE_TEST_IS_DIR) || + g_file_test(symbolic, G_FILE_TEST_IS_DIR)) && g_strcmp0(dir_entry, "default") != 0 && !g_hash_table_contains(t, dir_entry)) { g_hash_table_add(t, g_strdup(dir_entry)); } diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index f8d48a2d0..18ac19ecd 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -276,6 +276,7 @@ void sp_ui_reload() SP_ACTIVE_DESKTOP->disableInteraction(); int window_geometry = prefs->getInt("/options/savewindowgeometry/value", PREFS_WINDOW_GEOMETRY_NONE); 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-icon-theme-name", prefs->getString("/theme/iconTheme").c_str(), NULL); g_object_set(gtk_settings_get_default(), "gtk-application-prefer-dark-theme", prefs->getBool("/theme/darkTheme", false), NULL); prefs->setInt("/options/savewindowgeometry/value", PREFS_WINDOW_GEOMETRY_LAST); diff --git a/src/ui/widget/color-notebook.cpp b/src/ui/widget/color-notebook.cpp index 2d8dcc310..1b3c8ff2e 100644 --- a/src/ui/widget/color-notebook.cpp +++ b/src/ui/widget/color-notebook.cpp @@ -161,7 +161,7 @@ void ColorNotebook::_initUI() /* Create color management icons */ _box_colormanaged = gtk_event_box_new(); GtkWidget *colormanaged = - GTK_WIDGET(sp_get_icon_image("color-management-icon", GTK_ICON_SIZE_SMALL_TOOLBAR)->gobj()); + GTK_WIDGET(sp_get_icon_image("color-management", GTK_ICON_SIZE_SMALL_TOOLBAR)->gobj()); gtk_container_add(GTK_CONTAINER(_box_colormanaged), colormanaged); gtk_widget_set_tooltip_text(_box_colormanaged, _("Color Managed")); gtk_widget_set_sensitive(_box_colormanaged, false); |
