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/ui/widget/combo-tool-item.cpp | |
| 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/ui/widget/combo-tool-item.cpp')
| -rw-r--r-- | src/ui/widget/combo-tool-item.cpp | 33 |
1 files changed, 24 insertions, 9 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(); |
