From: johncoswell Date: Wed, 25 Apr 2007 22:52:27 +0000 (+0000) Subject: Set up toolbox so that paint bucket defaults can be reset X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f9cb5a9e9d6ea60cd2e8e3dc63cb070fa10f9650;p=inkscape.git Set up toolbox so that paint bucket defaults can be reset --- 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 = " " " " " " + " " + " " " " " " @@ -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(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 ); + } + } /*