From 5c6d1acd44119651c66f4310d03621338e5b1be2 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 25 Apr 2007 22:52:27 +0000 Subject: Set up toolbox so that paint bucket defaults can be reset (bzr r2963) --- src/widgets/toolbox.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'src/widgets') 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 ); + } + } /* -- cgit v1.2.3