summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2015-04-14 12:44:34 +0000
committertavmjong-free <tavmjong@free.fr>2015-04-14 12:44:34 +0000
commit0f8b775f3a02380dd593ae58ad3b989f58aec643 (patch)
treea909c92a8e985a5889539d418c7bb0a0772020b1 /src
parentFix for the bug 1443039. Now reset old perspective-envelope effects and preve... (diff)
downloadinkscape-0f8b775f3a02380dd593ae58ad3b989f58aec643.tar.gz
inkscape-0f8b775f3a02380dd593ae58ad3b989f58aec643.zip
Replace GList by std::vector
(bzr r14057)
Diffstat (limited to 'src')
-rw-r--r--src/ui/tools/flood-tool.cpp54
-rw-r--r--src/ui/tools/flood-tool.h6
-rw-r--r--src/widgets/paintbucket-toolbar.cpp21
3 files changed, 34 insertions, 47 deletions
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index bb8782dfa..ffd41d97d 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -84,6 +84,28 @@ const std::string& FloodTool::getPrefsPath() {
const std::string FloodTool::prefsPath = "/tools/paintbucket";
+// TODO: Replace by C++11 initialization
+// Must match PaintBucketChannels enum
+Glib::ustring ch_init[8] = {
+ _("Visible Colors"),
+ _("Red"),
+ _("Green"),
+ _("Blue"),
+ _("Hue"),
+ _("Saturation"),
+ _("Lightness"),
+ _("Alpha"),
+};
+const std::vector<Glib::ustring> FloodTool::channel_list( ch_init, ch_init+8 );
+
+Glib::ustring gap_init[4] = {
+ C_("Flood autogap", "None"),
+ C_("Flood autogap", "Small"),
+ C_("Flood autogap", "Medium"),
+ C_("Flood autogap", "Large")
+};
+const std::vector<Glib::ustring> FloodTool::gap_list( gap_init, gap_init+4 );
+
FloodTool::FloodTool()
: ToolBase(cursor_paintbucket_xpm, 11, 30)
, item(NULL)
@@ -174,38 +196,6 @@ inline unsigned char * get_trace_pixel(guchar *trace_px, int x, int y, int width
}
/**
- * Generate the list of trace channel selection entries.
- */
-GList * flood_channels_dropdown_items_list() {
- GList *glist = NULL;
-
- glist = g_list_append (glist, _("Visible Colors"));
- glist = g_list_append (glist, _("Red"));
- glist = g_list_append (glist, _("Green"));
- glist = g_list_append (glist, _("Blue"));
- glist = g_list_append (glist, _("Hue"));
- glist = g_list_append (glist, _("Saturation"));
- glist = g_list_append (glist, _("Lightness"));
- glist = g_list_append (glist, _("Alpha"));
-
- return glist;
-}
-
-/**
- * Generate the list of autogap selection entries.
- */
-GList * flood_autogap_dropdown_items_list() {
- GList *glist = NULL;
-
- glist = g_list_append (glist, (void*) C_("Flood autogap", "None"));
- glist = g_list_append (glist, (void*) C_("Flood autogap", "Small"));
- glist = g_list_append (glist, (void*) C_("Flood autogap", "Medium"));
- glist = g_list_append (glist, (void*) C_("Flood autogap", "Large"));
-
- return glist;
-}
-
-/**
* Compare a pixel in a pixel buffer with another pixel to determine if a point should be included in the fill operation.
* @param check The pixel in the pixel buffer to check.
* @param orig The original selected pixel to use as the fill target color.
diff --git a/src/ui/tools/flood-tool.h b/src/ui/tools/flood-tool.h
index 5104a42e9..100875f22 100644
--- a/src/ui/tools/flood-tool.h
+++ b/src/ui/tools/flood-tool.h
@@ -13,6 +13,7 @@
#include <sigc++/connection.h>
#include "ui/tools/tool-base.h"
+#include <vector>
#define SP_FLOOD_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::FloodTool*>((Inkscape::UI::Tools::ToolBase*)obj))
#define SP_IS_FLOOD_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::FloodTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
@@ -39,15 +40,14 @@ public:
virtual const std::string& getPrefsPath();
static void set_channels(gint channels);
+ static const std::vector<Glib::ustring> channel_list;
+ static const std::vector<Glib::ustring> gap_list;
private:
void selection_changed(Inkscape::Selection* selection);
void finishItem();
};
-GList* flood_channels_dropdown_items_list (void);
-GList* flood_autogap_dropdown_items_list (void);
-
enum PaintBucketChannels {
FLOOD_CHANNELS_RGB,
FLOOD_CHANNELS_R,
diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp
index d8edeb9f6..eb55287c4 100644
--- a/src/widgets/paintbucket-toolbar.cpp
+++ b/src/widgets/paintbucket-toolbar.cpp
@@ -121,17 +121,16 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT );
- GList* items = 0;
gint count = 0;
- for ( items = Inkscape::UI::Tools::flood_channels_dropdown_items_list(); items ; items = g_list_next(items) )
- {
+ const std::vector<Glib::ustring>& channel_list = Inkscape::UI::Tools::FloodTool::channel_list;
+ for (std::vector<Glib::ustring>::const_iterator iterator = channel_list.begin();
+ iterator != channel_list.end(); ++iterator ) {
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, reinterpret_cast<gchar*>(items->data), 1, count, -1 );
+ gtk_list_store_set( model, &iter, 0, (*iterator).c_str(), 1, count, -1 );
count++;
}
- g_list_free( items );
- items = 0;
+
EgeSelectOneAction* act1 = ege_select_one_action_new( "ChannelsAction", _("Fill by"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act1, "short_label", _("Fill by:"), NULL );
ege_select_one_action_set_appearance( act1, "compact" );
@@ -188,17 +187,15 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
{
GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT );
- GList* items = 0;
gint count = 0;
- for ( items = Inkscape::UI::Tools::flood_autogap_dropdown_items_list(); items ; items = g_list_next(items) )
- {
+ const std::vector<Glib::ustring>& gap_list = Inkscape::UI::Tools::FloodTool::gap_list;
+ for (std::vector<Glib::ustring>::const_iterator iterator = gap_list.begin();
+ iterator != gap_list.end(); ++iterator ) {
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter, 0, reinterpret_cast<gchar*>(items->data), 1, count, -1 );
+ gtk_list_store_set( model, &iter, 0, (*iterator).c_str(), 1, count, -1 );
count++;
}
- g_list_free( items );
- items = 0;
EgeSelectOneAction* act2 = ege_select_one_action_new( "AutoGapAction", _("Close gaps"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act2, "short_label", _("Close gaps:"), NULL );
ege_select_one_action_set_appearance( act2, "compact" );