From aa6dde633662cf5fecea6425b7367eb2b93d53fb Mon Sep 17 00:00:00 2001 From: Alexander Valavanis Date: Sun, 29 Jul 2018 14:56:29 +0100 Subject: DropperToolbar: GtkAction migration --- src/ui/toolbar/toolbar.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/ui/toolbar/toolbar.cpp') diff --git a/src/ui/toolbar/toolbar.cpp b/src/ui/toolbar/toolbar.cpp index e1c9d082f..8a17dcbea 100644 --- a/src/ui/toolbar/toolbar.cpp +++ b/src/ui/toolbar/toolbar.cpp @@ -1,6 +1,8 @@ #include "toolbar.h" +#include #include +#include #include "desktop.h" @@ -10,17 +12,52 @@ namespace Inkscape { namespace UI { namespace Toolbar { +Gtk::ToolItem * +Toolbar::add_label(const Glib::ustring &label_text) +{ + auto ti = Gtk::manage(new Gtk::ToolItem()); + + // For now, we always enable mnemonic + auto label = Gtk::manage(new Gtk::Label(label_text, true)); + + ti->add(*label); + add(*ti); + + return ti; +} + +/** + * \brief Add a toggle toolbutton to the toolbar + * + * \param[in] label_text The text to display in the toolbar + * \param[in] tooltip_text The tooltip text for the toolitem + * + * \returns The toggle button + */ +Gtk::ToggleToolButton * +Toolbar::add_toggle_button(const Glib::ustring &label_text, + const Glib::ustring &tooltip_text) +{ + auto btn = Gtk::manage(new Gtk::ToggleToolButton(label_text)); + btn->set_tooltip_text(tooltip_text); + add(*btn); + return btn; +} + /** * \brief Add a toolbutton that performs a given verb * * \param[in] verb_code The code for the verb (e.g., SP_VERB_EDIT_SELECT_ALL) + * + * \returns a pointer to the toolbutton */ -void +Gtk::ToolButton * Toolbar::add_toolbutton_for_verb(unsigned int verb_code) { auto context = Inkscape::ActionContext(_desktop); auto button = SPAction::create_toolbutton_for_verb(verb_code, context); add(*button); + return button; } /** -- cgit v1.2.3