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/spin-button-tool-item.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/ui/widget/spin-button-tool-item.cpp') diff --git a/src/ui/widget/spin-button-tool-item.cpp b/src/ui/widget/spin-button-tool-item.cpp index f8c285344..e190d8dd2 100644 --- a/src/ui/widget/spin-button-tool-item.cpp +++ b/src/ui/widget/spin-button-tool-item.cpp @@ -3,6 +3,7 @@ #include "spin-button-tool-item.h" #include +#include #include #include @@ -390,14 +391,28 @@ SpinButtonToolItem::SpinButtonToolItem(const Glib::ustring name, _btn->add_events(Gdk::KEY_PRESS_MASK); // Create a label - auto label = Gtk::manage(new Gtk::Label(label_text)); + _label = Gtk::manage(new Gtk::Label(label_text)); // Arrange the widgets in a horizontal box - auto hbox = Gtk::manage(new Gtk::Box()); - hbox->set_spacing(3); - hbox->pack_start(*label); - hbox->pack_start(*_btn); - add(*hbox); + _hbox = Gtk::manage(new Gtk::Box()); + _hbox->set_spacing(3); + _hbox->pack_start(*_label); + _hbox->pack_start(*_btn); + add(*_hbox); + show_all(); +} + +void +SpinButtonToolItem::set_icon(const Glib::ustring& icon_name) +{ + _hbox->remove(*_label); + _icon = Gtk::manage(new Gtk::Image(icon_name, Gtk::ICON_SIZE_SMALL_TOOLBAR)); + + if(_icon) { + _hbox->pack_start(*_icon); + _hbox->reorder_child(*_icon, 0); + } + show_all(); } -- cgit v1.2.3