summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Bintz <me@johnbintz.com>2007-04-25 22:52:27 +0000
committerjohncoswell <johncoswell@users.sourceforge.net>2007-04-25 22:52:27 +0000
commit5c6d1acd44119651c66f4310d03621338e5b1be2 (patch)
treec8b463fab0ab6279c2d2f23e0a04c4aa220d0cd9 /src
parenta better way to start rubberband (diff)
downloadinkscape-5c6d1acd44119651c66f4310d03621338e5b1be2.tar.gz
inkscape-5c6d1acd44119651c66f4310d03621338e5b1be2.zip
Set up toolbox so that paint bucket defaults can be reset
(bzr r2963)
Diffstat (limited to 'src')
-rw-r--r--src/flood-context.cpp11
-rw-r--r--src/flood-context.h11
-rw-r--r--src/widgets/toolbox.cpp38
3 files changed, 49 insertions, 11 deletions
diff --git a/src/flood-context.cpp b/src/flood-context.cpp
index dbfc6df8e..3b7cc8d74 100644
--- a/src/flood-context.cpp
+++ b/src/flood-context.cpp
@@ -238,17 +238,6 @@ inline unsigned char * get_pixel(guchar *px, int x, int y, int width) {
return px + (x + y * width) * 4;
}
-enum PaintBucketChannels {
- FLOOD_CHANNELS_RGB,
- FLOOD_CHANNELS_R,
- FLOOD_CHANNELS_G,
- FLOOD_CHANNELS_B,
- FLOOD_CHANNELS_H,
- FLOOD_CHANNELS_S,
- FLOOD_CHANNELS_L,
- FLOOD_CHANNELS_ALPHA
-};
-
GList * flood_channels_dropdown_items_list() {
GList *glist = NULL;
diff --git a/src/flood-context.h b/src/flood-context.h
index fd26403b5..10de77896 100644
--- a/src/flood-context.h
+++ b/src/flood-context.h
@@ -52,4 +52,15 @@ GtkType sp_flood_context_get_type (void);
GList* flood_channels_dropdown_items_list (void);
void flood_channels_set_channels( gint channels );
+enum PaintBucketChannels {
+ FLOOD_CHANNELS_RGB,
+ FLOOD_CHANNELS_R,
+ FLOOD_CHANNELS_G,
+ FLOOD_CHANNELS_B,
+ FLOOD_CHANNELS_H,
+ FLOOD_CHANNELS_S,
+ FLOOD_CHANNELS_L,
+ FLOOD_CHANNELS_ALPHA
+};
+
#endif
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 6d486b902..91b94fe4d 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -324,6 +324,8 @@ static gchar const * ui_descr =
" <separator />"
" <toolitem action='OffsetAction' />"
" <toolitem action='PaintbucketUnitsAction' />"
+ " <separator />"
+ " <toolitem action='PaintbucketResetAction' />"
" </toolbar>"
" <toolbar name='DropperToolbar'>"
@@ -4280,6 +4282,29 @@ static void paintbucket_offset_changed(GtkAdjustment *adj, GObject *tbl)
prefs_set_double_attribute("tools.paintbucket", "offset", (gdouble)sp_units_get_pixels(adj->value, *unit));
}
+static void paintbucket_defaults(GtkWidget *, GObject *dataKludge)
+{
+ // FIXME: make defaults settable via Inkscape Options
+ struct KeyValue {
+ char const *key;
+ double value;
+ } const key_values[] = {
+ {"threshold", 15},
+ {"offset", 0.0}
+ };
+
+ for (unsigned i = 0; i < G_N_ELEMENTS(key_values); ++i) {
+ KeyValue const &kv = key_values[i];
+ GtkAdjustment* adj = static_cast<GtkAdjustment *>(g_object_get_data(dataKludge, kv.key));
+ if ( adj ) {
+ gtk_adjustment_set_value(adj, kv.value);
+ }
+ }
+
+ EgeSelectOneAction* channels_action = EGE_SELECT_ONE_ACTION( g_object_get_data( dataKludge, "channels_action" ) );
+ ege_select_one_action_set_active( channels_action, FLOOD_CHANNELS_RGB );
+}
+
static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder)
{
EgeAdjustmentAction* eact = 0;
@@ -4302,6 +4327,7 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
ege_select_one_action_set_active( act1, prefs_get_int_attribute("tools.paintbucket", "channels", 0) );
g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(paintbucket_channels_changed), holder );
gtk_action_group_add_action( mainActions, GTK_ACTION(act1) );
+ g_object_set_data( holder, "channels_action", act1 );
}
// Spacing spinbox
@@ -4341,6 +4367,18 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
}
+
+ /* Reset */
+ {
+ GtkAction* act = gtk_action_new( "PaintbucketResetAction",
+ _("Defaults"),
+ _("Reset paint bucket parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
+ GTK_STOCK_CLEAR );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(paintbucket_defaults), holder );
+ gtk_action_group_add_action( mainActions, act );
+ gtk_action_set_sensitive( act, TRUE );
+ }
+
}
/*