diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-03 18:42:15 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-03 18:42:15 +0000 |
| commit | 75064d97c015e5ed87de38411fbd8b046d450793 (patch) | |
| tree | 49d675b66f85ec788b64761409e9fbc3892c7c0f /src/ui/widget | |
| parent | Merge branch 'master' of gitlab.com:inkscape/inkscape (diff) | |
| download | inkscape-75064d97c015e5ed87de38411fbd8b046d450793.tar.gz inkscape-75064d97c015e5ed87de38411fbd8b046d450793.zip | |
UnitTracker: Create tool item without using GtkAction
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/unit-tracker.cpp | 20 | ||||
| -rw-r--r-- | src/ui/widget/unit-tracker.h | 6 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/ui/widget/unit-tracker.cpp b/src/ui/widget/unit-tracker.cpp index 4114ed378..665bb7497 100644 --- a/src/ui/widget/unit-tracker.cpp +++ b/src/ui/widget/unit-tracker.cpp @@ -20,7 +20,7 @@ #include "unit-tracker.h" #include "ink-select-one-action.h" - +#include "combo-tool-item.h" #define COLUMN_STRING 0 @@ -68,6 +68,7 @@ UnitTracker::UnitTracker(UnitType unit_type) : UnitTracker::~UnitTracker() { _actionList.clear(); + _combo_list.clear(); // Unhook weak references to GtkAdjustments for (auto i : _adjList) { @@ -152,6 +153,9 @@ void UnitTracker::setFullVal(GtkAdjustment *adj, gdouble val) _priorValues[adj] = val; } +/** + * \deprecated Use create_tool_item instead + */ InkSelectOneAction *UnitTracker::createAction(Glib::ustring const &name, Glib::ustring const &label, Glib::ustring const &tooltip) @@ -171,6 +175,16 @@ InkSelectOneAction *UnitTracker::createAction(Glib::ustring const &name, return act; } +ComboToolItem * +UnitTracker::create_tool_item(Glib::ustring const &label, + Glib::ustring const &tooltip) +{ + auto combo = ComboToolItem::create(label, tooltip, "NotUsed", _store); + combo->signal_changed().connect(sigc::mem_fun(*this, &UnitTracker::_unitChangedCB)); + _combo_list.push_back(combo); + return combo; +} + void UnitTracker::_unitChangedCB(int active) { _setActive(active); @@ -262,6 +276,10 @@ void UnitTracker::_setActive(gint active) act->set_active (active); } + for (auto combo : _combo_list) { + if(combo) combo->set_active(active); + } + _activeUnitInitialized = true; } } diff --git a/src/ui/widget/unit-tracker.h b/src/ui/widget/unit-tracker.h index f4d3b114d..c876d8224 100644 --- a/src/ui/widget/unit-tracker.h +++ b/src/ui/widget/unit-tracker.h @@ -37,6 +37,7 @@ typedef struct _GtkListStore GtkListStore; namespace Inkscape { namespace UI { namespace Widget { +class ComboToolItem; class UnitTracker { public: @@ -58,11 +59,13 @@ public: Glib::ustring const &label, Glib::ustring const &tooltip); + ComboToolItem *create_tool_item(Glib::ustring const &label, + Glib::ustring const &tooltip); + protected: UnitType _type; private: - // Callbacks void _unitChangedCB(int active); static void _actionFinalizedCB(gpointer data, GObject *where_the_object_was); @@ -82,6 +85,7 @@ private: Glib::RefPtr<Gtk::ListStore> _store; std::vector<InkSelectOneAction*> _actionList; + std::vector<ComboToolItem *> _combo_list; std::vector<GtkAdjustment*> _adjList; std::map <GtkAdjustment *, gdouble> _priorValues; }; |
