diff options
| -rw-r--r-- | src/helper/icon-loader.cpp | 24 | ||||
| -rw-r--r-- | src/helper/icon-loader.h | 5 | ||||
| -rw-r--r-- | src/inkscape.cpp | 2 | ||||
| -rw-r--r-- | src/io/resource.cpp | 69 | ||||
| -rw-r--r-- | src/io/resource.h | 13 | ||||
| -rw-r--r-- | src/preferences-skeleton.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 12 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 2 | ||||
| -rw-r--r-- | src/ui/interface.cpp | 2 |
9 files changed, 116 insertions, 15 deletions
diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index b19b19582..3a7d459b3 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -21,6 +21,7 @@ #include "widgets/toolbox.h" #include <gtkmm/iconinfo.h> #include <gtkmm/icontheme.h> +#include <gtkmm/toolitem.h> Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) { @@ -45,7 +46,10 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size) icon_name = "preferences-system"; } sp_svg_write_color(colornamed, sizeof(colornamed), prefs->getInt("/theme/symbolicColor", - 0x000000ff)); Gdk::RGBA color; color.set(colornamed); Gtk::IconInfo iconinfo = + 0x000000ff)); + Gdk::RGBA color; + color.set(colornamed); + Gtk::IconInfo iconinfo = iconTheme->lookup_icon(icon_name + Glib::ustring("-symbolic"), size, Gtk::ICON_LOOKUP_FORCE_SIZE); if (bool(iconinfo)) { @@ -119,6 +123,24 @@ Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_size) return image; } +std::pair<Glib::RefPtr<Gtk::RadioAction>, Gdk::RGBA > sp_set_radioaction_icon(Gtk::RadioAction::Group group, Glib::ustring icon_name, Glib::ustring label, Glib::ustring tooltip) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + if (prefs->getBool("/theme/symbolicIcons", false)) { + icon_name = icon_name + Glib::ustring("-symbolic"); + } + + Glib::RefPtr<Gtk::RadioAction> action = + Gtk::RadioAction::create_with_icon_name (group, "Anonymous", icon_name.c_str(), label.c_str(), tooltip.c_str()); + Gtk::ToolItem* item = action->create_tool_item(); + Gdk::RGBA color; + gchar colornamed[64]; + sp_svg_write_color(colornamed, sizeof(colornamed), prefs->getInt("/theme/symbolicColor", + 0x000000ff)); + color.set(colornamed); + return std::make_pair(action, color); +} + /* Local Variables: mode:c++ diff --git a/src/helper/icon-loader.h b/src/helper/icon-loader.h index 5b6af546f..ef7dbd110 100644 --- a/src/helper/icon-loader.h +++ b/src/helper/icon-loader.h @@ -12,6 +12,9 @@ */ #include <gdkmm/pixbuf.h> #include <gtkmm/image.h> +#include <gtkmm/box.h> +#include <gtkmm/radioaction.h> +#include <gtkmm/radioaction.h> 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); @@ -21,5 +24,5 @@ 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_sice); Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_sice); Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_sice); - +std::pair<Glib::RefPtr<Gtk::RadioAction>,Gdk::RGBA > sp_set_radioaction_icon(Gtk::RadioAction::Group group, Glib::ustring icon_name, Glib::ustring label, Glib::ustring tooltip); #endif // SEEN_INK_STOCK_ITEMS_H diff --git a/src/inkscape.cpp b/src/inkscape.cpp index 2fb11444e..59f503bf7 100644 --- a/src/inkscape.cpp +++ b/src/inkscape.cpp @@ -479,7 +479,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/theme").c_str(), NULL); + 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); InkErrorHandler* handler = new InkErrorHandler(use_gui); prefs->setErrorHandler(handler); diff --git a/src/io/resource.cpp b/src/io/resource.cpp index f8cf9fce4..127b92b76 100644 --- a/src/io/resource.cpp +++ b/src/io/resource.cpp @@ -213,7 +213,6 @@ Glib::ustring get_filename(Glib::ustring path, Glib::ustring filename) * * domain - Optional domain (overload), will check return domains if not. * type - The type of files, e.g. TEMPLATES - * path - Instead of Domain and Type, specify the path to get the files from. * extensions - A list of extensions to return, e.g. xml, svg * exclusions - A list of names to exclude e.g. default.xml */ @@ -225,6 +224,7 @@ std::vector<Glib::ustring> get_filenames(Type type, std::vector<const char *> ex get_filenames_from_path(ret, get_path_ustring(CREATE, type), extensions, exclusions); return ret; } + std::vector<Glib::ustring> get_filenames(Domain domain, Type type, std::vector<const char *> extensions, std::vector<const char *> exclusions) { std::vector<Glib::ustring> ret; @@ -239,9 +239,40 @@ std::vector<Glib::ustring> get_filenames(Glib::ustring path, std::vector<const c } /* + * Gets all folders inside each type, for all domain types. + * + * domain - Optional domain (overload), will check return domains if not. + * type - The type of files, e.g. TEMPLATES + * extensions - A list of extensions to return, e.g. xml, svg + * exclusions - A list of names to exclude e.g. default.xml + */ +std::vector<Glib::ustring> get_foldernames(Type type, std::vector<const char *> exclusions) +{ + std::vector<Glib::ustring> ret; + get_foldernames_from_path(ret, get_path_ustring(USER, type), exclusions); + get_foldernames_from_path(ret, get_path_ustring(SYSTEM, type), exclusions); + get_foldernames_from_path(ret, get_path_ustring(CREATE, type), exclusions); + return ret; +} + +std::vector<Glib::ustring> get_foldernames(Domain domain, Type type, std::vector<const char *> exclusions) +{ + std::vector<Glib::ustring> ret; + get_foldernames_from_path(ret, get_path_ustring(domain, type), exclusions); + return ret; +} +std::vector<Glib::ustring> get_foldernames(Glib::ustring path, std::vector<const char *> exclusions) +{ + std::vector<Glib::ustring> ret; + get_foldernames_from_path(ret, path, exclusions); + return ret; +} + + +/* * Get all the files from a specific path and any sub-dirs, populating &files vector * - * &files - Output list to populate, will be opoulated with full paths + * &files - Output list to populate, will be poulated with full paths * path - The directory to parse, will add nothing if directory doesn't exist * extensions - Only add files with these extensions, they must be duplicated * exclusions - Exclude files that exactly match these names. @@ -280,6 +311,40 @@ void get_filenames_from_path(std::vector<Glib::ustring> &files, Glib::ustring pa } } +/* + * Get all the files from a specific path and any sub-dirs, populating &files vector + * + * &folders - Output list to populate, will be poulated with full paths + * path - The directory to parse, will add nothing if directory doesn't exist + * exclusions - Exclude files that exactly match these names. + */ +void get_foldernames_from_path(std::vector<Glib::ustring> &folders, Glib::ustring path, std::vector<const char *> exclusions) +{ + if(!Glib::file_test(path, Glib::FILE_TEST_IS_DIR)) { + return; + } + + Glib::Dir dir(path); + std::string file = dir.read_name(); + while (!file.empty()){ + // If not extensions are specified, don't reject ANY files. + bool reject = false; + + // Reject any file which matches the exclusions. + for (auto &exc: exclusions) { + reject |= Glib::str_has_prefix(file, exc); + } + + // Reject any filename which isn't a regular file + Glib::ustring filename = Glib::build_filename(path, file); + + if(Glib::file_test(filename, Glib::FILE_TEST_IS_DIR) && !reject) { + folders.push_back(filename); + } + file = dir.read_name(); + } +} + /** * Get, or guess, or decide the location where the preferences.xml diff --git a/src/io/resource.h b/src/io/resource.h index dae43ec8f..f70e55447 100644 --- a/src/io/resource.h +++ b/src/io/resource.h @@ -79,11 +79,24 @@ std::vector<Glib::ustring> get_filenames(Glib::ustring path, std::vector<const char *> extensions={}, std::vector<const char *> exclusions={}); +std::vector<Glib::ustring> get_foldernames(Type type, + std::vector<const char *> exclusions={}); + +std::vector<Glib::ustring> get_foldernames(Domain domain, Type type, + std::vector<const char *> exclusions={}); + +std::vector<Glib::ustring> get_foldernames(Glib::ustring path, + std::vector<const char *> exclusions={}); + void get_filenames_from_path(std::vector<Glib::ustring> &files, Glib::ustring path, std::vector<const char *> extensions={}, std::vector<const char *> exclusions={}); +void get_foldernames_from_path(std::vector<Glib::ustring> &files, + Glib::ustring path, + std::vector<const char *> exclusions={}); + char *profile_path(const char *filename); char *homedir_path(const char *filename); diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 2bff8d634..2a6083e55 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -73,7 +73,7 @@ static char const preferences_skeleton[] = " inkscape:window-height=\"480\" />\n" " </group>\n" " <group id=\"theme\" \n" -" theme=\"Adwaita\" iconTheme=\"hicolor\" symbolicIcons=\"0\" darkTheme=\"0\" symbolicColor=\"0x000000ff\" >\n" +" gtkTheme=\"Adwaita\" iconTheme=\"hicolor\" symbolicIcons=\"0\" darkTheme=\"0\" symbolicColor=\"0x000000ff\" >\n" " </group>\n" "\n" " <group id=\"tools\"\n" diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 5bf594c38..f31b443fb 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -803,17 +803,13 @@ void InkscapePreferences::initPageUI() g_list_free (list); g_hash_table_destroy (t); -// g_object_bind_property (gtk_settings_get_default (), "gtk-theme-name", -// (gpointer *)&_theme, "active-id", -// (GBindingFlags)(G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE)); - - _theme.init("/theme/theme", labels, values, "Adwaita"); - _page_theme.add_line(false, _("Change theme:"), _theme, "", "", false); + _gtk_theme.init("/theme/gtkTheme", labels, values, "Adwaita"); + _page_theme.add_line(false, _("Change Gtk theme:"), _gtk_theme, "", "", false); } { using namespace Inkscape::IO::Resource; - auto files = get_filenames(UIS, {".css"}, {"style.css","dark.css","symbolic.css"}); + auto files = get_foldernames(ICONS, {"application"}); std::vector<Glib::ustring> labels; std::vector<Glib::ustring> values; for(auto &filename: files) { @@ -836,6 +832,8 @@ void InkscapePreferences::initPageUI() labels.push_back(filename); values.push_back(filename); } + labels.erase(unique(labels.begin(), labels.end()), labels.end()); + values.erase(unique(values.begin(), values.end()), values.end()); _icon_theme.init("/theme/iconTheme", labels, values, "hicolor"); _page_theme.add_line(false, _("Change icon theme:"), _icon_theme, "", "", false); } diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index f705d8e29..d172687fa 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -240,7 +240,7 @@ protected: UI::Widget::PrefCheckButton _t_node_delete_preserves_shape; UI::Widget::PrefColorPicker _t_node_pathoutline_color; - UI::Widget::PrefCombo _theme; + UI::Widget::PrefCombo _gtk_theme; UI::Widget::PrefCombo _icon_theme; UI::Widget::PrefCheckButton _dark_theme; UI::Widget::PrefCheckButton _symbolic_icons; diff --git a/src/ui/interface.cpp b/src/ui/interface.cpp index 9f5d2d38c..89f2c3d8a 100644 --- a/src/ui/interface.cpp +++ b/src/ui/interface.cpp @@ -269,7 +269,7 @@ sp_ui_reload() Inkscape::Preferences *prefs = Inkscape::Preferences::get(); 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/theme").c_str(), NULL); + 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); prefs->setInt("/options/savewindowgeometry/value", PREFS_WINDOW_GEOMETRY_LAST); prefs->save(); |
