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 | |
| 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')
| -rw-r--r-- | src/ui/widget/ink-select-one-action.cpp | 14 | ||||
| -rw-r--r-- | src/ui/widget/ink-select-one-action.h | 2 | ||||
| -rw-r--r-- | src/ui/widget/unit-tracker.cpp | 181 | ||||
| -rw-r--r-- | src/ui/widget/unit-tracker.h | 21 | ||||
| -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 |
13 files changed, 193 insertions, 133 deletions
diff --git a/src/ui/widget/ink-select-one-action.cpp b/src/ui/widget/ink-select-one-action.cpp index da130ec1d..9ab4a7f45 100644 --- a/src/ui/widget/ink-select-one-action.cpp +++ b/src/ui/widget/ink-select-one-action.cpp @@ -63,6 +63,11 @@ InkSelectOneAction::InkSelectOneAction (const Glib::ustring &name, void InkSelectOneAction::set_active (gint active) { + if (active < 0) { + std::cerr << "InkSelectOneAction::set_active: active < 0: " << active << std::endl; + return; + } + if (_active != active) { _active = active; @@ -229,14 +234,18 @@ Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { void InkSelectOneAction::on_changed_combobox() { - set_active( _combobox->get_active_row_number() ); - _changed.emit (_active); + int row = _combobox->get_active_row_number(); + if (row < 0) row = 0; // Happens when Gtk::ListStore reconstructed + set_active( row ); + _changed.emit (_active); + _changed_after.emit (_active); } void InkSelectOneAction::on_changed_radioaction(const Glib::RefPtr<Gtk::RadioAction>& current) { set_active( current->get_current_value() ); _changed.emit (_active); + _changed_after.emit (_active); } void InkSelectOneAction::on_toggled_radiomenu(int n) { @@ -246,6 +255,7 @@ void InkSelectOneAction::on_toggled_radiomenu(int n) { if ( n < _radiomenuitems.size() &&_radiomenuitems[ n ]->get_active()) { set_active ( n ); _changed.emit (_active); + _changed_after.emit (_active); } } diff --git a/src/ui/widget/ink-select-one-action.h b/src/ui/widget/ink-select-one-action.h index c95407797..5cf7c934a 100644 --- a/src/ui/widget/ink-select-one-action.h +++ b/src/ui/widget/ink-select-one-action.h @@ -76,6 +76,7 @@ public: Glib::RefPtr<Gtk::ListStore> get_store() { return _store; } sigc::signal<void, int> signal_changed() { return _changed; } + sigc::signal<void, int> signal_changed_after() { return _changed_after; } protected: @@ -84,6 +85,7 @@ protected: /* Signals */ sigc::signal<void, int> _changed; + sigc::signal<void, int> _changed_after; // Needed for unit tracker which eats _changed. private: diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 709c365e6..e7e47af4b 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -8,13 +8,18 @@ * * Copyright (C) 2007 Jon A. Cruz * Copyright (C) 2013 Matthew Petroff + * Copyright (C) 2018 Tavmjong Bah * * Released under GNU GPL, read the file 'COPYING' for more information */ +#include <algorithm> +#include <iostream> + #include "unit-tracker.h" -#include <algorithm> +#include "ink-select-one-action.h" + #define COLUMN_STRING 0 @@ -30,21 +35,28 @@ UnitTracker::UnitTracker(UnitType unit_type) : _isUpdating(false), _activeUnit(NULL), _activeUnitInitialized(false), - _store(0), + _store(nullptr), _priorValues() { - _store = gtk_list_store_new(1, G_TYPE_STRING); - - GtkTreeIter iter; UnitTable::UnitMap m = unit_table.units(unit_type); + InkSelectOneActionColumns columns; + _store = Gtk::ListStore::create(columns); + Gtk::TreeModel::Row row; for (UnitTable::UnitMap::iterator m_iter = m.begin(); m_iter != m.end(); ++m_iter) { - Glib::ustring text = m_iter->first; - gtk_list_store_append(_store, &iter); - gtk_list_store_set(_store, &iter, COLUMN_STRING, text.c_str(), -1); + + Glib::ustring unit = m_iter->first; + + row = *(_store->append()); + row[columns.col_label ] = unit; + row[columns.col_tooltip ] = (""); + row[columns.col_icon ] = "NotUsed"; + row[columns.col_sensitive] = true; } - gint count = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(_store), 0); + + // Why? + gint count = _store->children().size(); if ((count > 0) && (_active > count)) { _setActive(--count); } else { @@ -54,11 +66,6 @@ UnitTracker::UnitTracker(UnitType unit_type) : UnitTracker::~UnitTracker() { - // Unhook weak references to GtkActions - for (auto i : _actionList) { - g_signal_handlers_disconnect_by_func(G_OBJECT(i), (gpointer) _unitChangedCB, this); - g_object_weak_unref(G_OBJECT(i), _actionFinalizedCB, this); - } _actionList.clear(); // Unhook weak references to GtkAdjustments @@ -81,18 +88,15 @@ Inkscape::Util::Unit const * UnitTracker::getActiveUnit() const void UnitTracker::setActiveUnit(Inkscape::Util::Unit const *unit) { if (unit) { - GtkTreeIter iter; + + InkSelectOneActionColumns columns; int index = 0; - gboolean found = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(_store), &iter); - while (found) { - gchar *storedUnit = 0; - gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &storedUnit, -1); - if (storedUnit && (!unit->abbr.compare(storedUnit))) { - _setActive(index); + for (auto& row: _store->children() ) { + Glib::ustring storedUnit = row[columns.col_label]; + if (!unit->abbr.compare (storedUnit)) { + _setActive (index); break; } - - found = gtk_tree_model_iter_next(GTK_TREE_MODEL(_store), &iter); index++; } } @@ -109,23 +113,37 @@ void UnitTracker::addAdjustment(GtkAdjustment *adj) if (std::find(_adjList.begin(),_adjList.end(),adj) == _adjList.end()) { g_object_weak_ref(G_OBJECT(adj), _adjustmentFinalizedCB, this); _adjList.push_back(adj); + } else { + std::cerr << "UnitTracker::addAjustment: Ajustment already added!" << std::endl; } } void UnitTracker::addUnit(Inkscape::Util::Unit const *u) { - GtkTreeIter iter; - gtk_list_store_append(_store, &iter); - gtk_list_store_set(_store, &iter, COLUMN_STRING, u ? u->abbr.c_str() : "NULL", -1); + InkSelectOneActionColumns columns; + + Gtk::TreeModel::Row row; + row = *(_store->append()); + row[columns.col_label ] = u ? u->abbr.c_str() : ""; + row[columns.col_tooltip ] = (""); + row[columns.col_icon ] = "NotUsed"; + row[columns.col_sensitive] = true; } void UnitTracker::prependUnit(Inkscape::Util::Unit const *u) { - GtkTreeIter iter; - gtk_list_store_prepend(_store, &iter); - gtk_list_store_set(_store, &iter, COLUMN_STRING, u ? u->abbr.c_str() : "NULL", -1); + InkSelectOneActionColumns columns; + + Gtk::TreeModel::Row row; + row = *(_store->prepend()); + row[columns.col_label ] = u ? u->abbr.c_str() : ""; + row[columns.col_tooltip ] = (""); + row[columns.col_icon ] = "NotUsed"; + row[columns.col_sensitive] = true; + /* Re-shuffle our default selection here (_active gets out of sync) */ setActiveUnit(_activeUnit); + } void UnitTracker::setFullVal(GtkAdjustment *adj, gdouble val) @@ -133,30 +151,28 @@ void UnitTracker::setFullVal(GtkAdjustment *adj, gdouble val) _priorValues[adj] = val; } -GtkAction *UnitTracker::createAction(gchar const *name, gchar const *label, gchar const *tooltip) +InkSelectOneAction *UnitTracker::createAction(Glib::ustring const &name, + Glib::ustring const &label, + Glib::ustring const &tooltip) { - EgeSelectOneAction *act1 = ege_select_one_action_new(name, label, tooltip, NULL, GTK_TREE_MODEL(_store)); - ege_select_one_action_set_label_column(act1, COLUMN_STRING); - if (_active) { - ege_select_one_action_set_active(act1, _active); - } + InkSelectOneAction* act = + InkSelectOneAction::create( name, label, tooltip, "NotUsed", _store); - ege_select_one_action_set_appearance(act1, "minimal"); - g_object_weak_ref(G_OBJECT(act1), _actionFinalizedCB, this); - g_signal_connect(G_OBJECT(act1), "changed", G_CALLBACK(_unitChangedCB), this); - _actionList.push_back(act1); + act->use_radio( false ); + act->use_label( true ); + act->use_icon( false ); + act->use_group_label( false ); + act->set_active( _active ); - return GTK_ACTION(act1); + act->signal_changed().connect(sigc::mem_fun(*this, &UnitTracker::_unitChangedCB)); + _actionList.push_back(act); + + return act; } -void UnitTracker::_unitChangedCB(GtkAction *action, gpointer data) +void UnitTracker::_unitChangedCB(int active) { - if (action && data) { - EgeSelectOneAction *act = EGE_SELECT_ONE_ACTION(action); - gint active = ege_select_one_action_get_active(act); - UnitTracker *self = reinterpret_cast<UnitTracker *>(data); - self->_setActive(active); - } + _setActive(active); } void UnitTracker::_actionFinalizedCB(gpointer data, GObject *where_the_object_was) @@ -177,7 +193,7 @@ void UnitTracker::_adjustmentFinalizedCB(gpointer data, GObject *where_the_objec void UnitTracker::_actionFinalized(GObject *where_the_object_was) { - EgeSelectOneAction* act = (EgeSelectOneAction*)(where_the_object_was); + InkSelectOneAction* act = (InkSelectOneAction*)(where_the_object_was); auto it = std::find(_actionList.begin(),_actionList.end(), act); if (it != _actionList.end()) { _actionList.erase(it); @@ -202,37 +218,49 @@ void UnitTracker::_setActive(gint active) if ( active != _active || !_activeUnitInitialized ) { gint oldActive = _active; - GtkTreeIter iter; - gboolean found = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(_store), &iter, NULL, oldActive); - if (found) { - gchar *abbr; - gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &abbr, -1); - Inkscape::Util::Unit const *unit = unit_table.getUnit(abbr); - - found = gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(_store), &iter, NULL, active); - if (found) { - gchar *newAbbr; - gtk_tree_model_get(GTK_TREE_MODEL(_store), &iter, COLUMN_STRING, &newAbbr, -1); - Inkscape::Util::Unit const *newUnit = unit_table.getUnit(newAbbr); - _activeUnit = newUnit; - - if (!_adjList.empty()) { - _fixupAdjustments(unit, newUnit); + if (_store) { + + // Find old and new units + InkSelectOneActionColumns columns; + int index = 0; + Glib::ustring oldAbbr( "NotFound" ); + Glib::ustring newAbbr( "NotFound" ); + for (auto& row: _store->children() ) { + if (index == _active) { + oldAbbr = row[columns.col_label]; + } + if (index == active) { + newAbbr = row[columns.col_label]; + } + if (newAbbr != "NotFound" && oldAbbr != "NotFound") break; + ++index; + } + + if (oldAbbr != "NotFound") { + + if (newAbbr != "NotFound") { + Inkscape::Util::Unit const *oldUnit = unit_table.getUnit(oldAbbr); + Inkscape::Util::Unit const *newUnit = unit_table.getUnit(newAbbr); + _activeUnit = newUnit; + + if (!_adjList.empty()) { + _fixupAdjustments(oldUnit, newUnit); + } + } else { + std::cerr << "UnitTracker::_setActive: Did not find new unit: " << active << std::endl; } } else { - g_warning("Did not find new unit"); + std::cerr << "UnitTracker::_setActive: Did not find old unit: " << oldActive + << " new: " << active << std::endl; } - } else { - g_warning("Did not find old unit"); } - _active = active; - for (auto act:_actionList) { - ege_select_one_action_set_active(act, active); + for (auto act: _actionList) { + act->set_active (active); } - + _activeUnitInitialized = true; } } @@ -267,3 +295,14 @@ void UnitTracker::_fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscap } // namespace Widget } // namespace UI } // namespace Inkscape + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8 : diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index 8aefab1bb..10c21a7ec 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -18,9 +18,12 @@ #include <map> #include <vector> +#include <gtkmm/liststore.h> +#include <gtkmm/action.h> + #include "util/units.h" -#include "widgets/ege-select-one-action.h" +class InkSelectOneAction; using Inkscape::Util::Unit; using Inkscape::Util::UnitType; @@ -50,17 +53,24 @@ public: void prependUnit(Inkscape::Util::Unit const *u); void setFullVal(GtkAdjustment *adj, gdouble val); - GtkAction *createAction(gchar const *name, gchar const *label, gchar const *tooltip); + InkSelectOneAction *createAction(Glib::ustring const &name, + Glib::ustring const &label, + Glib::ustring const &tooltip); protected: UnitType _type; private: - static void _unitChangedCB(GtkAction *action, gpointer data); + + // Callbacks + void _unitChangedCB(int active); static void _actionFinalizedCB(gpointer data, GObject *where_the_object_was); static void _adjustmentFinalizedCB(gpointer data, GObject *where_the_object_was); + void _setActive(gint index); void _fixupAdjustments(Inkscape::Util::Unit const *oldUnit, Inkscape::Util::Unit const *newUnit); + + // Cleanup void _actionFinalized(GObject *where_the_object_was); void _adjustmentFinalized(GObject *where_the_object_was); @@ -68,8 +78,9 @@ private: bool _isUpdating; Inkscape::Util::Unit const *_activeUnit; bool _activeUnitInitialized; - GtkListStore *_store; - std::vector<EgeSelectOneAction*> _actionList; + + Glib::RefPtr<Gtk::ListStore> _store; + std::vector<InkSelectOneAction*> _actionList; std::vector<GtkAdjustment*> _adjList; std::map <GtkAdjustment *, gdouble> _priorValues; }; 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 ); } |
