diff options
| author | Jabiertxof <jabier.arraiza@marker.es> | 2018-11-08 18:36:18 +0000 |
|---|---|---|
| committer | Jabiertxof <jabier.arraiza@marker.es> | 2018-11-09 10:44:36 +0000 |
| commit | 0ddbdf18a2cfcf54f591b1372bb3eb9dde9728e2 (patch) | |
| tree | 90fe83ef220a34b5df3877e7b7dc01af82b78a4c /src/helper | |
| parent | Add README to src/ui/view (diff) | |
| download | inkscape-0ddbdf18a2cfcf54f591b1372bb3eb9dde9728e2.tar.gz inkscape-0ddbdf18a2cfcf54f591b1372bb3eb9dde9728e2.zip | |
This improve symbolic icon rendering moving it to CSS only. There is places in the UI whar we claim for a Pixbuf. Currently its not possible render them as symbolic without the previos hack
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/icon-loader.cpp | 112 | ||||
| -rw-r--r-- | src/helper/icon-loader.h | 22 |
2 files changed, 40 insertions, 94 deletions
diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp index 7116c2eaf..39918d8ff 100644 --- a/src/helper/icon-loader.cpp +++ b/src/helper/icon-loader.cpp @@ -20,11 +20,14 @@ #include <gtkmm/icontheme.h> #include <gtkmm/toolitem.h> -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size, bool negative) +void sp_load_theme() { + } + +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(); - Glib::RefPtr<Gdk::Pixbuf> _icon_pixbuf; static auto icon_theme = Gtk::IconTheme::get_default(); static bool icon_theme_set; if (!icon_theme_set) { @@ -32,114 +35,63 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size, icon_theme->prepend_search_path(get_path_ustring(SYSTEM, ICONS)); icon_theme->prepend_search_path(get_path_ustring(USER, ICONS)); } - 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 - if (negative) { - colorset = colorset ^ 0xffffff00; - } - 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)) { - // 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 = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); - } - } - else { - _icon_pixbuf = icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); - } - } - catch (const Gtk::IconThemeError &e) { - std::cout << "Icon Loader: " << e.what() << std::endl; - } - return _icon_pixbuf; + return icon_theme->load_icon(icon_name, size, Gtk::ICON_LOOKUP_FORCE_SIZE); } -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size, bool negative) +Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size) { int width, height; Gtk::IconSize::lookup(Gtk::IconSize(icon_size), width, height); - return sp_get_icon_pixbuf(icon_name, width, negative); + return sp_get_icon_pixbuf(icon_name, width); } -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, GtkIconSize icon_size, bool negative) +Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, GtkIconSize icon_size) { gint width, height; gtk_icon_size_lookup(icon_size, &width, &height); - return sp_get_icon_pixbuf(icon_name, width, negative); + return sp_get_icon_pixbuf(icon_name, width); } -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_size, bool negative) +Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_size) { // Load icon based in preference size defined allowed values are: //"/toolbox/tools/small" Toolbox icon size //"/toolbox/small" Control bar icon size //"/toolbox/secondary" Secondary toolbar icon size GtkIconSize icon_size = Inkscape::UI::ToolboxFactory::prefToSize(prefs_size); - return sp_get_icon_pixbuf(icon_name, icon_size, negative); + return sp_get_icon_pixbuf(icon_name, icon_size); } -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size, bool negative) +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size) { - auto icon = sp_get_icon_pixbuf(icon_name, size, negative); - Gtk::Image *image = new Gtk::Image(icon); - return image; + + Gtk::Image *icon = new Gtk::Image(); + icon->set_from_icon_name(icon_name, Gtk::IconSize(size)); + return icon; } -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size, bool negative) +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size) { - auto icon = sp_get_icon_pixbuf(icon_name, icon_size, negative); - Gtk::Image *image = new Gtk::Image(icon); - return image; + + 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, GtkIconSize icon_size, bool negative) +Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_size) { - auto icon = sp_get_icon_pixbuf(icon_name, icon_size, negative); - Gtk::Image *image = new Gtk::Image(icon); - return image; + + 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; } -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_size, bool negative) -{ - auto icon = sp_get_icon_pixbuf(icon_name, prefs_size, negative); - Gtk::Image *image = new Gtk::Image(icon); - 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, - bool negative) +GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size) { - 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]; - int colorset = prefs->getInt("/theme/symbolicColor", 0x000000ff); - // Use in case the special widgets have inverse theme background and symbolic - if (negative) { - colorset = colorset ^ 0xffffff00; - } - sp_svg_write_color(colornamed, sizeof(colornamed), colorset); - color.set(colornamed); - return std::make_pair(action, color); + + return gtk_image_new_from_icon_name(icon_name.c_str(), icon_size); } /* diff --git a/src/helper/icon-loader.h b/src/helper/icon-loader.h index 1555871c3..22658225e 100644 --- a/src/helper/icon-loader.h +++ b/src/helper/icon-loader.h @@ -15,19 +15,13 @@ #include <gdkmm/pixbuf.h> #include <gtkmm/box.h> #include <gtkmm/image.h> -#include <gtkmm/radioaction.h> -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size, bool negative = false); -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size, bool negative = false); -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, GtkIconSize icon_size, bool negative = false); -Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_sice, bool negative = false); -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size, bool negative = false); -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, Gtk::BuiltinIconSize icon_size, bool negative = false); -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size, bool negative = false); -Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_sice, bool negative = false); -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, - bool negative = false); +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, 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, 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, gchar const *prefs_sice); +GtkWidget *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size); #endif // SEEN_INK_STOCK_ITEMS_H |
