Commit 937d201d authored by Shlomi Fish's avatar Shlomi Fish

Extract a subroutine from two places.

There was a lot of duplicate code.

(bzr r15100.1.35)
parent 2c6e50c5
......@@ -87,15 +87,8 @@ static void sp_erc_tremor_value_changed( GtkAdjustment *adj, GObject* tbl )
update_presets_list(tbl);
}
static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
static void sp_set_tbl_eraser_mode_visibility(GObject *const tbl, const guint eraser_mode)
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
guint eraser_mode = ege_select_one_action_get_active( act );
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt( "/tools/eraser/mode", eraser_mode );
}
GtkAction *split = GTK_ACTION( g_object_get_data(tbl, "split") );
GtkAction *mass = GTK_ACTION( g_object_get_data(tbl, "mass") );
GtkAction *width = GTK_ACTION( g_object_get_data(tbl, "width") );
......@@ -124,6 +117,17 @@ static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
gtk_action_set_visible( mass, FALSE );
gtk_action_set_visible( width, FALSE );
}
}
static void sp_erasertb_mode_changed( EgeSelectOneAction *act, GObject *tbl )
{
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
guint eraser_mode = ege_select_one_action_get_active( act );
if (DocumentUndo::getUndoSensitive(desktop->getDocument())) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt( "/tools/eraser/mode", eraser_mode );
}
sp_set_tbl_eraser_mode_visibility(tbl, eraser_mode);
// only take action if run by the attr_changed listener
if (!g_object_get_data( tbl, "freeze" )) {
// in turn, prevent listener from responding
......@@ -305,35 +309,7 @@ void sp_eraser_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toogle_break_apart), holder) ;
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
}
GtkAction *split = GTK_ACTION( g_object_get_data(holder, "split") );
GtkAction *mass = GTK_ACTION( g_object_get_data(holder, "mass") );
GtkAction *width = GTK_ACTION( g_object_get_data(holder, "width") );
GtkAction *usepressure = GTK_ACTION( g_object_get_data(holder, "usepressure") );
GtkAction *cap_rounding = GTK_ACTION( g_object_get_data(holder, "cap_rounding") );
GtkAction *thinning = GTK_ACTION( g_object_get_data(holder, "thinning") );
GtkAction *tremor = GTK_ACTION( g_object_get_data(holder, "tremor") );
if (eraser_mode != ERASER_MODE_DELETE) {
if(eraser_mode == ERASER_MODE_CUT) {
gtk_action_set_visible( split, TRUE );
} else {
gtk_action_set_visible( split, FALSE );
}
gtk_action_set_visible(usepressure, TRUE );
gtk_action_set_visible(tremor, TRUE );
gtk_action_set_visible(cap_rounding, TRUE );
gtk_action_set_visible(thinning, TRUE );
gtk_action_set_visible( mass, TRUE );
gtk_action_set_visible( width, TRUE );
} else {
gtk_action_set_visible(usepressure, FALSE );
gtk_action_set_visible(tremor, FALSE );
gtk_action_set_visible(cap_rounding, FALSE );
gtk_action_set_visible(thinning, FALSE );
gtk_action_set_visible( split, FALSE );
gtk_action_set_visible( mass, FALSE );
gtk_action_set_visible( width, FALSE );
}
sp_set_tbl_eraser_mode_visibility(holder, eraser_mode);
}
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment