diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2018-02-04 19:14:50 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2018-02-04 19:14:50 +0000 |
| commit | 2b79799fff8ed89c649a934186c176cb2765823c (patch) | |
| tree | 1e1da695a98ab4f0fbdb7f07fcd37d0e56730e8d /src/widgets | |
| parent | New "Simple Blend" custom predefined filter effect (original idea by Ivan Lou... (diff) | |
| download | inkscape-2b79799fff8ed89c649a934186c176cb2765823c.tar.gz inkscape-2b79799fff8ed89c649a934186c176cb2765823c.zip | |
Convert UnitTracker to use ink-select-one-action.
Additional code clean up.
Diffstat (limited to 'src/widgets')
| -rw-r--r-- | src/widgets/arc-toolbar.cpp | 6 | ||||
| -rw-r--r-- | src/widgets/desktop-widget.cpp | 3 | ||||
| -rw-r--r-- | src/widgets/lpe-toolbar.cpp | 30 | ||||
| -rw-r--r-- | src/widgets/measure-toolbar.cpp | 21 | ||||
| -rw-r--r-- | src/widgets/node-toolbar.cpp | 7 | ||||
| -rw-r--r-- | src/widgets/paintbucket-toolbar.cpp | 7 | ||||
| -rw-r--r-- | src/widgets/rect-toolbar.cpp | 9 | ||||
| -rw-r--r-- | src/widgets/select-toolbar.cpp | 7 | ||||
| -rw-r--r-- | src/widgets/text-toolbar.cpp | 18 |
9 files changed, 53 insertions, 55 deletions
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp index cd4f4c4d3..d19b8672c 100644 --- a/src/widgets/arc-toolbar.cpp +++ b/src/widgets/arc-toolbar.cpp @@ -466,7 +466,6 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_arctb_rx_value_changed, tracker); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "rx_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); @@ -483,7 +482,6 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_arctb_ry_value_changed, tracker); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "ry_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); @@ -491,8 +489,8 @@ void sp_arc_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObjec // add the units menu { - GtkAction* act = tracker->createAction( "ArcUnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( mainActions, act ); + Gtk::Action* act = tracker->createAction( "ArcUnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( mainActions, act->gobj() ); } /* Start */ diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index a5cef6815..1a2f13e1c 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -1576,9 +1576,6 @@ void SPDesktopWidget::setToolboxSelectOneValue (gchar const *id, int value) { gpointer hb = sp_search_by_data_recursive(aux_toolbox, (gpointer) id); - if (IS_EGE_SELECT_ONE_ACTION(hb)) { - ege_select_one_action_set_active(EGE_SELECT_ONE_ACTION(hb), value); - } if (static_cast<InkSelectOneAction*>(hb)) { static_cast<InkSelectOneAction*>(hb)->set_active( value ); } diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index aa8aaa30e..4d0c3837d 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -164,18 +164,20 @@ static void lpetool_toggle_show_measuring_info(GtkToggleAction *act, GObject *tb return; } - GtkAction *unitact = static_cast<GtkAction*>(g_object_get_data(tbl, "lpetool_units_action")); + bool show = gtk_toggle_action_get_active( act ); + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setBool("/tools/lpetool/show_measuring_info", show); + LpeTool *lc = SP_LPETOOL_CONTEXT(desktop->event_context); - if (tools_isactive(desktop, TOOLS_LPETOOL)) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool show = gtk_toggle_action_get_active( act ); - prefs->setBool("/tools/lpetool/show_measuring_info", show); - lpetool_show_measuring_info(lc, show); - gtk_action_set_sensitive(GTK_ACTION(unitact), show); - } + lpetool_show_measuring_info(lc, show); + + InkSelectOneAction* unitact = + static_cast<InkSelectOneAction*>(g_object_get_data(tbl, "lpetool_units_action")); + unitact->set_sensitive( show ); } -static void lpetool_unit_changed(GtkAction* /*act*/, GObject* tbl) +static void lpetool_unit_changed(GObject* tbl, int /* NotUsed */) { UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker")); Unit const *unit = tracker->getActiveUnit(); @@ -397,13 +399,13 @@ void sp_lpetool_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GO gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool( "/tools/lpetool/show_measuring_info", true ) ); } - // add the units menu + // Add the units menu { - GtkAction* act = tracker->createAction( "LPEToolUnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( mainActions, act ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(lpetool_unit_changed), holder ); + InkSelectOneAction* act = tracker->createAction( "LPEToolUnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( mainActions, act->gobj() ); + act->signal_changed_after().connect(sigc::bind<0>(sigc::ptr_fun(&lpetool_unit_changed), holder)); g_object_set_data(holder, "lpetool_units_action", act); - gtk_action_set_sensitive(act, prefs->getBool("/tools/lpetool/show_measuring_info", true)); + act->set_sensitive( prefs->getBool("/tools/lpetool/show_measuring_info", true)); } /* Open LPE dialog (to adapt parameters numerically) */ diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp index 4973a2dd3..06b173e4b 100644 --- a/src/widgets/measure-toolbar.cpp +++ b/src/widgets/measure-toolbar.cpp @@ -33,18 +33,21 @@ #include "measure-toolbar.h" #include "desktop.h" -#include "inkscape.h" -#include "message-stack.h" #include "document-undo.h" -#include "widgets/ege-adjustment-action.h" -#include "widgets/ege-output-action.h" -#include "toolbox.h" #include "ink-action.h" #include "ink-toggle-action.h" +#include "inkscape.h" +#include "message-stack.h" +#include "toolbox.h" + #include "ui/icon-names.h" #include "ui/tools/measure-tool.h" +#include "ui/widget/ink-select-one-action.h" #include "ui/widget/unit-tracker.h" +#include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" + using Inkscape::UI::Widget::UnitTracker; using Inkscape::Util::Unit; using Inkscape::DocumentUndo; @@ -134,7 +137,7 @@ sp_measure_precision_value_changed(GtkAdjustment *adj, GObject *tbl) } static void -sp_measure_unit_changed(GtkAction* /*act*/, GObject* tbl) +sp_measure_unit_changed(GObject* tbl, int /* notUsed */) { UnitTracker* tracker = reinterpret_cast<UnitTracker*>(g_object_get_data(tbl, "tracker")); Glib::ustring const unit = tracker->getActiveUnit()->abbr; @@ -309,9 +312,9 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G /* units menu */ { - GtkAction* act = tracker->createAction( "MeasureUnitsAction", _("Units:"), _("The units to be used for the measurements") ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_measure_unit_changed), holder ); - gtk_action_group_add_action( mainActions, act ); + InkSelectOneAction* act = tracker->createAction( "MeasureUnitsAction", _("Units:"), _("The units to be used for the measurements") ); + act->signal_changed_after().connect(sigc::bind<0>(sigc::ptr_fun(&sp_measure_unit_changed), holder)); + gtk_action_group_add_action( mainActions, act->gobj() ); } /* Precision */ diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index b1091ac69..2e80b77d8 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -47,6 +47,7 @@ #include "ui/tool/control-point-selection.h" #include "ui/tool/multi-path-manipulator.h" #include "ui/tools/node-tool.h" +#include "ui/widget/ink-select-one-action.h" #include "ui/widget/unit-tracker.h" #include "widgets/ege-adjustment-action.h" @@ -586,7 +587,6 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_node_path_x_value_changed, tracker ); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "nodes_x_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); @@ -604,7 +604,6 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_node_path_y_value_changed, tracker ); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "nodes_y_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); @@ -612,8 +611,8 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje // add the units menu { - GtkAction* act = tracker->createAction( "NodeUnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( mainActions, act ); + InkSelectOneAction* act = tracker->createAction( "NodeUnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( mainActions, act->gobj() ); } sp_node_toolbox_sel_changed(desktop->getSelection(), holder); diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp index d6c2cfd8f..280cf0eb1 100644 --- a/src/widgets/paintbucket-toolbar.cpp +++ b/src/widgets/paintbucket-toolbar.cpp @@ -179,9 +179,10 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions tracker->setActiveUnit(u); } g_object_set_data( holder, "tracker", tracker ); + { - GtkAction* act = tracker->createAction( "PaintbucketUnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( mainActions, act ); + InkSelectOneAction* act = tracker->createAction( "PaintbucketUnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( mainActions, act->gobj() ); } // Offset spinbox @@ -194,8 +195,6 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions "inkscape:paintbucket-offset", -1e4, 1e4, 0.1, 0.5, 0, 0, 0, paintbucket_offset_changed, tracker, 1, 2); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); - gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp index df6abf9da..afa090ba7 100644 --- a/src/widgets/rect-toolbar.cpp +++ b/src/widgets/rect-toolbar.cpp @@ -45,6 +45,7 @@ #include "ui/icon-names.h" #include "ui/tools/rect-tool.h" #include "ui/uxmanager.h" +#include "ui/widget/ink-select-one-action.h" #include "ui/widget/unit-tracker.h" #include "widgets/ege-adjustment-action.h" @@ -327,7 +328,6 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_width_value_changed, tracker); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "width_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); @@ -344,7 +344,6 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_height_value_changed, tracker); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "height_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); @@ -361,7 +360,6 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_rx_value_changed, tracker); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } @@ -376,14 +374,13 @@ void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_ry_value_changed, tracker); - tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } // add the units menu { - GtkAction* act = tracker->createAction( "RectUnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( mainActions, act ); + InkSelectOneAction* act = tracker->createAction( "RectUnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( mainActions, act->gobj() ); } /* Reset */ diff --git a/src/widgets/select-toolbar.cpp b/src/widgets/select-toolbar.cpp index df90d3d12..b968bf4da 100644 --- a/src/widgets/select-toolbar.cpp +++ b/src/widgets/select-toolbar.cpp @@ -42,6 +42,7 @@ #include "object/sp-namedview.h" #include "ui/icon-names.h" +#include "ui/widget/ink-select-one-action.h" #include "ui/widget/spinbutton.h" #include "ui/widget/unit-tracker.h" @@ -523,8 +524,10 @@ void sp_select_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb contextActions->push_back( GTK_ACTION(eact) ); // Add the units menu. - act = tracker->createAction( "UnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( selectionActions, act ); + { + InkSelectOneAction* act = tracker->createAction( "UnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( selectionActions, act->gobj() ); + } g_object_set_data( G_OBJECT(spw), "selectionActions", selectionActions ); g_object_set_data( G_OBJECT(spw), "contextActions", contextActions ); diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp index 6288999a6..db3311ab9 100644 --- a/src/widgets/text-toolbar.cpp +++ b/src/widgets/text-toolbar.cpp @@ -733,7 +733,7 @@ static void sp_text_lineheight_value_changed( GtkAdjustment *adj, GObject *tbl ) } -static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl ) +static void sp_text_lineheight_unit_changed( GObject *tbl, int /* Not Used */ ) { // quit if run by the _changed callbacks if (g_object_get_data(G_OBJECT(tbl), "freeze")) { @@ -1778,12 +1778,12 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/ } // In Minimum and Adaptive modes, don't allow unit change (must remain unitless). - GtkAction* textLineHeightUnitsAction = - static_cast<GtkAction*>(g_object_get_data( tbl, "TextLineHeightUnitsAction") ); + InkSelectOneAction* textLineHeightUnitsAction = + static_cast<InkSelectOneAction*>(g_object_get_data( tbl, "TextLineHeightUnitsAction") ); if (activeButtonLS == 0 || (activeButtonLS == 1 && outer)) { - gtk_action_set_sensitive (textLineHeightUnitsAction, false); + textLineHeightUnitsAction->set_sensitive(false); } else { - gtk_action_set_sensitive (textLineHeightUnitsAction, true); + textLineHeightUnitsAction->set_sensitive(true); } // Word spacing @@ -2279,7 +2279,7 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() )); g_object_set_data( holder, "TextDirectionAction", act ); - act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_direction_changed), holder)); + act->signal_changed_after().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_direction_changed), holder)); } /* Line height unit tracker */ @@ -2325,9 +2325,9 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje /* Line height units */ { - GtkAction* act = tracker->createAction( "TextLineHeightUnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( mainActions, act ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_lineheight_unit_changed), holder ); + InkSelectOneAction* act = tracker->createAction( "TextLineHeightUnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( mainActions, act->gobj() ); + act->signal_changed_after().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_lineheight_unit_changed), holder)); g_object_set_data( holder, "TextLineHeightUnitsAction", act ); } |
