summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2019-05-28 09:52:31 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2019-05-28 09:52:31 +0000
commit88bc8d77cc809cc1597823667c142d3c1eee3434 (patch)
tree2f158d44d41a58c0f310364f77828d9c909bdce5 /src/ui/widget
parentStrip out all content from TextToolbar (diff)
downloadinkscape-88bc8d77cc809cc1597823667c142d3c1eee3434.tar.gz
inkscape-88bc8d77cc809cc1597823667c142d3c1eee3434.zip
Hackfest2019: TextToolbar: Start GtkAction migration
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/combo-tool-item.cpp43
-rw-r--r--src/ui/widget/combo-tool-item.h9
-rw-r--r--src/ui/widget/spin-button-tool-item.cpp27
-rw-r--r--src/ui/widget/spin-button-tool-item.h6
4 files changed, 68 insertions, 17 deletions
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
diff --git a/src/ui/widget/combo-tool-item.h b/src/ui/widget/combo-tool-item.h
index 1e4590163..8ace006a1 100644
--- a/src/ui/widget/combo-tool-item.h
+++ b/src/ui/widget/combo-tool-item.h
@@ -56,10 +56,10 @@ public:
const Glib::ustring &stock_id,
Glib::RefPtr<Gtk::ListStore> store );
- /* Style of action */
- void use_label( bool use_label ) { _use_label = use_label; }
- void use_icon( bool use_icon ) { _use_icon = use_icon; }
- void use_pixbuf( bool use_pixbuf ) { _use_pixbuf = use_pixbuf; }
+ /* Style of combobox */
+ void use_label( bool use_label );
+ void use_icon( bool use_icon );
+ void use_pixbuf( bool use_pixbuf );
void use_group_label( bool use_group_label ) { _use_group_label = use_group_label; }
gint get_active() { return _active; }
@@ -74,6 +74,7 @@ public:
protected:
bool on_create_menu_proxy() override;
+ void populate_combobox();
/* Signals */
sigc::signal<void, int> _changed;
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 <gtkmm/box.h>
+#include <gtkmm/image.h>
#include <gtkmm/radiomenuitem.h>
#include <gtkmm/toolbar.h>
@@ -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();
}
diff --git a/src/ui/widget/spin-button-tool-item.h b/src/ui/widget/spin-button-tool-item.h
index 1b33e8580..4386d4799 100644
--- a/src/ui/widget/spin-button-tool-item.h
+++ b/src/ui/widget/spin-button-tool-item.h
@@ -5,6 +5,7 @@
#include <gtkmm/toolitem.h>
namespace Gtk {
+class Box;
class RadioButtonGroup;
class RadioMenuItem;
}
@@ -29,6 +30,10 @@ private:
double _last_val; ///< The last value of the adjustment
bool _transfer_focus; ///< Whether or not to transfer focus
+ Gtk::Box *_hbox; ///< Horizontal box, to store widgets
+ Gtk::Widget *_label; ///< A text label to describe the setting
+ Gtk::Widget *_icon; ///< An icon to describe the setting
+
/** A widget that grabs focus when this one loses it */
Gtk::Widget * _focus_widget;
@@ -72,6 +77,7 @@ public:
void set_custom_numeric_menu_data(std::vector<double>& values,
const std::vector<Glib::ustring>& labels = std::vector<Glib::ustring>());
Glib::RefPtr<Gtk::Adjustment> get_adjustment();
+ void set_icon(const Glib::ustring& icon_name);
};
} // namespace Widget
} // namespace UI