Code

Make all icons themable (except the filter icons).
[inkscape.git] / src / widgets / paint-selector.cpp
index de9dd367c81007461cf72def672306d54f55cbea..f888555c91a9b73c4b0c8ee0a936655c6520afb9 100644 (file)
@@ -16,7 +16,8 @@
 # include "config.h"
 #endif
 
-
+#include <cstring>
+#include <string>
 
 #include <gtk/gtkhbox.h>
 #include <gtk/gtkradiobutton.h>
@@ -30,7 +31,6 @@
 #include "../sp-pattern.h"
 #include <glibmm/i18n.h>
 #include "../widgets/icon.h"
-#include "../inkscape-stock.h"
 #include "widgets/widget-sizes.h"
 #include "xml/repr.h"
 
@@ -48,6 +48,7 @@
 #include "path-prefix.h"
 #include "io/sys.h"
 #include "helper/stock-items.h"
+#include "ui/icon-names.h"
 
 #include "paint-selector.h"
 
@@ -87,20 +88,23 @@ static void sp_paint_selector_set_style_buttons(SPPaintSelector *psel, GtkWidget
 static GtkVBoxClass *parent_class;
 static guint psel_signals[LAST_SIGNAL] = {0};
 
-GtkType
-sp_paint_selector_get_type(void)
+GType sp_paint_selector_get_type(void)
 {
     static GtkType type = 0;
     if (!type) {
-        GtkTypeInfo info = {
-            "SPPaintSelector",
-            sizeof(SPPaintSelector),
+        GTypeInfo info = {
             sizeof(SPPaintSelectorClass),
-            (GtkClassInitFunc) sp_paint_selector_class_init,
-            (GtkObjectInitFunc) sp_paint_selector_init,
-            NULL, NULL, NULL
+            0, // base_init
+            0, // base_finalize
+            (GClassInitFunc)sp_paint_selector_class_init,
+            0, // class_finalize
+            0, // class_data
+            sizeof(SPPaintSelector),
+            0, // n_preallocs
+            (GInstanceInitFunc)sp_paint_selector_init,
+            0 // value_table
         };
-        type = gtk_type_unique(GTK_TYPE_VBOX, &info);
+        type = g_type_register_static(GTK_TYPE_VBOX, "SPPaintSelector", &info, static_cast<GTypeFlags>(0));
     }
     return type;
 }
@@ -173,17 +177,17 @@ sp_paint_selector_init(SPPaintSelector *psel)
     gtk_box_pack_start(GTK_BOX(psel), psel->style, FALSE, FALSE, 0);
 
     /* Buttons */
-    psel->none = sp_paint_selector_style_button_add(psel, INKSCAPE_STOCK_FILL_NONE,
+    psel->none = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_NONE,
                                                     SP_PAINT_SELECTOR_MODE_NONE, tt, _("No paint"));
-    psel->solid = sp_paint_selector_style_button_add(psel, INKSCAPE_STOCK_FILL_SOLID,
+    psel->solid = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_SOLID,
                                                      SP_PAINT_SELECTOR_MODE_COLOR_RGB, tt, _("Flat color"));
-    psel->gradient = sp_paint_selector_style_button_add(psel, INKSCAPE_STOCK_FILL_GRADIENT,
+    psel->gradient = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_GRADIENT_LINEAR,
                                                         SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR, tt, _("Linear gradient"));
-    psel->radial = sp_paint_selector_style_button_add(psel, INKSCAPE_STOCK_FILL_RADIAL,
+    psel->radial = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_GRADIENT_RADIAL,
                                                       SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL, tt, _("Radial gradient"));
-    psel->pattern = sp_paint_selector_style_button_add(psel, INKSCAPE_STOCK_FILL_PATTERN,
+    psel->pattern = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_PATTERN,
                                                        SP_PAINT_SELECTOR_MODE_PATTERN, tt, _("Pattern"));
-    psel->unset = sp_paint_selector_style_button_add(psel, INKSCAPE_STOCK_FILL_UNSET,
+    psel->unset = sp_paint_selector_style_button_add(psel, INKSCAPE_ICON_PAINT_UNKNOWN,
                                                      SP_PAINT_SELECTOR_MODE_UNSET, tt, _("Unset paint (make it undefined so it can be inherited)"));
 
     /* Fillrule */
@@ -198,7 +202,7 @@ sp_paint_selector_init(SPPaintSelector *psel)
         // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
         gtk_tooltips_set_tip(tt, psel->evenodd, _("Any path self-intersections or subpaths create holes in the fill (fill-rule: evenodd)"), NULL);
         gtk_object_set_data(GTK_OBJECT(psel->evenodd), "mode", GUINT_TO_POINTER(SP_PAINT_SELECTOR_FILLRULE_EVENODD));
-        w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, "fillrule_evenodd");
+        w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_EVEN_ODD);
         gtk_container_add(GTK_CONTAINER(psel->evenodd), w);
         gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->evenodd, FALSE, FALSE, 0);
         gtk_signal_connect(GTK_OBJECT(psel->evenodd), "toggled", GTK_SIGNAL_FUNC(sp_paint_selector_fillrule_toggled), psel);
@@ -209,7 +213,7 @@ sp_paint_selector_init(SPPaintSelector *psel)
         // TRANSLATORS: for info, see http://www.w3.org/TR/2000/CR-SVG-20000802/painting.html#FillRuleProperty
         gtk_tooltips_set_tip(tt, psel->nonzero, _("Fill is solid unless a subpath is counterdirectional (fill-rule: nonzero)"), NULL);
         gtk_object_set_data(GTK_OBJECT(psel->nonzero), "mode", GUINT_TO_POINTER(SP_PAINT_SELECTOR_FILLRULE_NONZERO));
-        w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, "fillrule_nonzero");
+        w = sp_icon_new(Inkscape::ICON_SIZE_DECORATION, INKSCAPE_ICON_FILL_RULE_NONZERO);
         gtk_container_add(GTK_CONTAINER(psel->nonzero), w);
         gtk_box_pack_start(GTK_BOX(psel->fillrulebox), psel->nonzero, FALSE, FALSE, 0);
         gtk_signal_connect(GTK_OBJECT(psel->nonzero), "toggled", GTK_SIGNAL_FUNC(sp_paint_selector_fillrule_toggled), psel);
@@ -784,9 +788,13 @@ sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument */*source*
                 gtk_widget_show(hb);
 
         // create label
-                GtkWidget *l = gtk_label_new(repr->attribute("id"));
+                GtkWidget *l;
+                if (repr->attribute("inkscape:stockid"))
+                    l = gtk_label_new(repr->attribute("inkscape:stockid"));
+                else
+                    l = gtk_label_new(repr->attribute("id"));
                 gtk_widget_show(l);
-        gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.5);
+                gtk_misc_set_alignment(GTK_MISC(l), 0.0, 0.5);
 
                 gtk_box_pack_start(GTK_BOX(hb), l, TRUE, TRUE, 0);
 
@@ -849,7 +857,7 @@ ink_pattern_menu_populate_menu(GtkWidget *m, SPDocument *doc)
     // add separator
     {
         GtkWidget *i = gtk_separator_menu_item_new();
-        gchar const *patid = "None as I'm not a pattern I'm a sperator";
+        gchar const *patid = "";
         g_object_set_data (G_OBJECT(i), "pattern", (void *) patid);
         gtk_widget_show(i);
         gtk_menu_append(GTK_MENU(m), i);
@@ -973,7 +981,7 @@ sp_paint_selector_set_mode_pattern(SPPaintSelector *psel, SPPaintSelectorMode mo
         {
             GtkWidget *hb = gtk_hbox_new(FALSE, 0);
             GtkWidget *l = gtk_label_new(NULL);
-            gtk_label_set_markup(GTK_LABEL(l), _("Use <b>Object &gt; Pattern &gt; Objects to Pattern</b> to create a new pattern from selection."));
+            gtk_label_set_markup(GTK_LABEL(l), _("Use the <b>Node tool</b> to adjust position, scale, and rotation of the pattern on canvas. Use <b>Object &gt; Pattern &gt; Objects to Pattern</b> to create a new pattern from selection."));
             gtk_label_set_line_wrap(GTK_LABEL(l), true);
             gtk_widget_set_size_request(l, 180, -1);
             gtk_box_pack_start(GTK_BOX(hb), l, TRUE, TRUE, AUX_BETWEEN_BUTTON_GROUPS);