diff options
| author | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-10-11 13:23:33 +0000 |
|---|---|---|
| committer | Nathan Lee <2431820-nathanal@users.noreply.gitlab.com> | 2019-10-17 00:10:56 +0000 |
| commit | 51ae0e3b2cf4ac63f20a9b6daf1c9acbae5e0613 (patch) | |
| tree | 6911082b37a8ec4f8c485be7f786e3d5b39b2b34 /src | |
| parent | Inkscape::XML::Node::addChildAtPos (diff) | |
| download | inkscape-51ae0e3b2cf4ac63f20a9b6daf1c9acbae5e0613.tar.gz inkscape-51ae0e3b2cf4ac63f20a9b6daf1c9acbae5e0613.zip | |
Fix logic for Tool Combobox's group label
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/widget/combo-tool-item.cpp | 33 | ||||
| -rw-r--r-- | src/ui/widget/combo-tool-item.h | 9 |
2 files changed, 30 insertions, 12 deletions
diff --git a/src/ui/widget/combo-tool-item.cpp b/src/ui/widget/combo-tool-item.cpp index 205c17cdd..4a1da560b 100644 --- a/src/ui/widget/combo-tool-item.cpp +++ b/src/ui/widget/combo-tool-item.cpp @@ -55,15 +55,12 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label, _use_pixbuf (true), _icon_size ( Gtk::ICON_SIZE_LARGE_TOOLBAR ), _combobox (nullptr), - _menuitem (nullptr), - _use_group_label(false) + _group_label_widget(nullptr), + _container(Gtk::manage(new Gtk::Box())), + _menuitem (nullptr) { - Gtk::Box* box = Gtk::manage(new Gtk::Box()); - add(*box); - if (_use_group_label) { - Gtk::Label *group_label = Gtk::manage (new Gtk::Label( _group_label + ": " )); - box->add( *group_label ); - } + add(*_container); + _container->set_spacing(3); // Create combobox _combobox = Gtk::manage (new Gtk::ComboBox(has_entry)); @@ -73,7 +70,7 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label, _combobox->signal_changed().connect( sigc::mem_fun(*this, &ComboToolItem::on_changed_combobox)); - box->add (*_combobox); + _container->pack_start(*_combobox); show_all(); } @@ -107,6 +104,24 @@ ComboToolItem::use_pixbuf(bool use_pixbuf) } void +ComboToolItem::use_group_label(bool use_group_label) +{ + if (use_group_label == (_group_label_widget != nullptr)) { + return; + } + if (use_group_label) { + _container->remove(*_combobox); + _group_label_widget = Gtk::manage(new Gtk::Label(_group_label + ": ")); + _container->pack_start(*_group_label_widget); + _container->pack_start(*_combobox); + } else { + _container->remove(*_group_label_widget); + delete _group_label_widget; + _group_label_widget = nullptr; + } +} + +void ComboToolItem::populate_combobox() { _combobox->clear(); diff --git a/src/ui/widget/combo-tool-item.h b/src/ui/widget/combo-tool-item.h index 125208239..1fc8b00a1 100644 --- a/src/ui/widget/combo-tool-item.h +++ b/src/ui/widget/combo-tool-item.h @@ -21,7 +21,9 @@ #include <vector> namespace Gtk { +class Box; class ComboBox; +class Label; class MenuItem; class RadioMenuItem; } @@ -64,7 +66,7 @@ public: void use_icon( bool use_icon ); void focus_on_click( bool focus_on_click ); void use_pixbuf( bool use_pixbuf ); - void use_group_label( bool use_group_label ) { _use_group_label = use_group_label; } + void use_group_label( bool use_group_label ); // Applies to tool item only gint get_active() { return _active; } Glib::ustring get_active_text(); @@ -97,12 +99,13 @@ private: bool _use_label; bool _use_icon; // Applies to menu item only bool _use_pixbuf; - bool _use_group_label; // Applies to tool item only Gtk::BuiltinIconSize _icon_size; /* Combobox in tool */ Gtk::ComboBox* _combobox; - + Gtk::Label* _group_label_widget; + Gtk::Box* _container; + Gtk::MenuItem* _menuitem; std::vector<Gtk::RadioMenuItem*> _radiomenuitems; |
