summaryrefslogtreecommitdiffstats
path: root/src/helper
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-11-06 22:38:59 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2018-11-06 22:38:59 +0000
commitfe2ff1decd47e6ba50e71b3a4b50fdc6f6f6326a (patch)
tree09e46febf010d01b3cb44896d3f71517f50b6659 /src/helper
parentRemove delete that is causing crash. (diff)
downloadinkscape-fe2ff1decd47e6ba50e71b3a4b50fdc6f6f6326a.tar.gz
inkscape-fe2ff1decd47e6ba50e71b3a4b50fdc6f6f6326a.zip
Fix icon loader to allow inverse color in symbolic icons. Also added searching.svg for loading symbols
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/icon-loader.cpp48
-rw-r--r--src/helper/icon-loader.h19
2 files changed, 40 insertions, 27 deletions
diff --git a/src/helper/icon-loader.cpp b/src/helper/icon-loader.cpp
index 5e33cd920..25c6eb32b 100644
--- a/src/helper/icon-loader.cpp
+++ b/src/helper/icon-loader.cpp
@@ -19,7 +19,7 @@
#include <gtkmm/icontheme.h>
#include <gtkmm/toolitem.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, gint size, bool negative)
{
using namespace Inkscape::IO::Resource;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -34,7 +34,12 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size)
try {
if (prefs->getBool("/theme/symbolicIcons", false)) {
gchar colornamed[64];
- sp_svg_write_color(colornamed, sizeof(colornamed), prefs->getInt("/theme/symbolicColor", 0x000000ff));
+ 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 =
@@ -58,61 +63,63 @@ Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gint size)
return _icon_pixbuf;
}
-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::BuiltinIconSize icon_size, bool negative)
{
int width, height;
Gtk::IconSize::lookup(Gtk::IconSize(icon_size), width, height);
- return sp_get_icon_pixbuf(icon_name, width);
+ return sp_get_icon_pixbuf(icon_name, width, negative);
}
-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, GtkIconSize icon_size, bool negative)
{
gint width, height;
gtk_icon_size_lookup(icon_size, &width, &height);
- return sp_get_icon_pixbuf(icon_name, width);
+ return sp_get_icon_pixbuf(icon_name, width, negative);
}
-Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_size)
+Glib::RefPtr<Gdk::Pixbuf> sp_get_icon_pixbuf(Glib::ustring icon_name, gchar const *prefs_size, bool negative)
{
// 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);
+ return sp_get_icon_pixbuf(icon_name, icon_size, negative);
}
-Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size)
+Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gint size, bool negative)
{
- auto icon = sp_get_icon_pixbuf(icon_name, size);
+ auto icon = sp_get_icon_pixbuf(icon_name, size, negative);
Gtk::Image *image = new Gtk::Image(icon);
return image;
}
-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::BuiltinIconSize icon_size, bool negative)
{
- auto icon = sp_get_icon_pixbuf(icon_name, icon_size);
+ auto icon = sp_get_icon_pixbuf(icon_name, icon_size, negative);
Gtk::Image *image = new Gtk::Image(icon);
return image;
}
-Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size)
+Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, GtkIconSize icon_size, bool negative)
{
- auto icon = sp_get_icon_pixbuf(icon_name, icon_size);
+ auto icon = sp_get_icon_pixbuf(icon_name, icon_size, negative);
Gtk::Image *image = new Gtk::Image(icon);
return image;
}
-Gtk::Image *sp_get_icon_image(Glib::ustring icon_name, gchar const *prefs_size)
+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);
+ 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)
+ Glib::ustring label,
+ Glib::ustring tooltip,
+ bool negative)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/theme/symbolicIcons", false)) {
@@ -124,7 +131,12 @@ std::pair<Glib::RefPtr<Gtk::RadioAction>, Gdk::RGBA> sp_set_radioaction_icon(Gtk
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));
+ 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);
}
diff --git a/src/helper/icon-loader.h b/src/helper/icon-loader.h
index 02b748163..38a41fcfb 100644
--- a/src/helper/icon-loader.h
+++ b/src/helper/icon-loader.h
@@ -15,16 +15,17 @@
#include <gtkmm/image.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);
-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_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);
+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);
+ Glib::ustring tooltip,
+ bool negative = false);
#endif // SEEN_INK_STOCK_ITEMS_H