From 88bc8d77cc809cc1597823667c142d3c1eee3434 Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Tue, 28 May 2019 10:52:31 +0100 Subject: Hackfest2019: TextToolbar: Start GtkAction migration --- src/ui/widget/combo-tool-item.cpp | 43 ++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'src/ui/widget/combo-tool-item.cpp') diff --git a/src/ui/widget/combo-tool-item.cpp b/src/ui/widget/combo-tool-item.cpp index a6c44f7eb..a9952fce6 100644 --- a/src/ui/widget/combo-tool-item.cpp +++ b/src/ui/widget/combo-tool-item.cpp @@ -66,6 +66,42 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label, _combobox = Gtk::manage (new Gtk::ComboBox()); _combobox->set_model(_store); + populate_combobox(); + + _combobox->signal_changed().connect( + sigc::mem_fun(*this, &ComboToolItem::on_changed_combobox)); + + box->add (*_combobox); + + show_all(); +} + +void +ComboToolItem::use_label(bool use_label) +{ + _use_label = use_label; + populate_combobox(); +} + +void +ComboToolItem::use_icon(bool use_icon) +{ + _use_icon = use_icon; + populate_combobox(); +} + +void +ComboToolItem::use_pixbuf(bool use_pixbuf) +{ + _use_pixbuf = use_pixbuf; + populate_combobox(); +} + +void +ComboToolItem::populate_combobox() +{ + _combobox->clear(); + ComboToolItemColumns columns; if (_use_icon) { Gtk::CellRendererPixbuf *renderer = new Gtk::CellRendererPixbuf; @@ -89,13 +125,6 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label, } _combobox->set_active (_active); - - _combobox->signal_changed().connect( - sigc::mem_fun(*this, &ComboToolItem::on_changed_combobox)); - - box->add (*_combobox); - - show_all(); } void -- cgit v1.2.3 From 10b1aecd8d885414229807196018cd32582bb085 Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Tue, 28 May 2019 17:38:25 +0100 Subject: Hackfest2019: Add an entry to ComboBoxToolItem --- src/ui/widget/combo-tool-item.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/ui/widget/combo-tool-item.cpp') diff --git a/src/ui/widget/combo-tool-item.cpp b/src/ui/widget/combo-tool-item.cpp index a9952fce6..b8638ba72 100644 --- a/src/ui/widget/combo-tool-item.cpp +++ b/src/ui/widget/combo-tool-item.cpp @@ -34,15 +34,17 @@ ComboToolItem* ComboToolItem::create(const Glib::ustring &group_label, const Glib::ustring &tooltip, const Glib::ustring &stock_id, - Glib::RefPtr store ) + Glib::RefPtr store, + bool has_entry) { - return new ComboToolItem(group_label, tooltip, stock_id, store); + return new ComboToolItem(group_label, tooltip, stock_id, store, has_entry); } ComboToolItem::ComboToolItem(Glib::ustring group_label, Glib::ustring tooltip, Glib::ustring stock_id, - Glib::RefPtr store ) : + Glib::RefPtr store, + bool has_entry) : _group_label(std::move( group_label )), _tooltip(std::move( tooltip )), _stock_id(std::move( stock_id )), @@ -63,7 +65,7 @@ ComboToolItem::ComboToolItem(Glib::ustring group_label, } // Create combobox - _combobox = Gtk::manage (new Gtk::ComboBox()); + _combobox = Gtk::manage (new Gtk::ComboBox(has_entry)); _combobox->set_model(_store); populate_combobox(); -- cgit v1.2.3