summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2017-07-24 15:52:10 +0000
committerTavmjong Bah <tavmjong@free.fr>2017-07-24 15:52:10 +0000
commit20b9bb08c9cf6c5023df3fb52c6bb65885057f22 (patch)
tree29a6bdd3afae35468225c6a9c257598654e9f68f /src
parentINSTALL: Add build options (diff)
downloadinkscape-20b9bb08c9cf6c5023df3fb52c6bb65885057f22.tar.gz
inkscape-20b9bb08c9cf6c5023df3fb52c6bb65885057f22.zip
Add C++ based Gtk::Action for choosing one item out of many.
Options: Show icons and/or labels. Use combbox or radio buttons. Replacement for C based ege-select-one-action. Update text toolbar to use this class, allowing bar to be narrower.
Diffstat (limited to 'src')
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/widget/ink-select-one-action.cpp239
-rw-r--r--src/ui/widget/ink-select-one-action.h131
-rw-r--r--src/widgets/text-toolbar.cpp399
4 files changed, 540 insertions, 231 deletions
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 789378e0c..efdb279b4 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -147,6 +147,7 @@ set(ui_SRC
widget/licensor.cpp
widget/notebook-page.cpp
widget/object-composite-settings.cpp
+ widget/ink-select-one-action.cpp
widget/page-sizer.cpp
widget/panel.cpp
widget/point.cpp
@@ -339,6 +340,7 @@ set(ui_SRC
widget/licensor.h
widget/notebook-page.h
widget/object-composite-settings.h
+ widget/ink-select-one-action.h
widget/page-sizer.h
widget/panel.h
widget/point.h
diff --git a/src/ui/widget/ink-select-one-action.cpp b/src/ui/widget/ink-select-one-action.cpp
new file mode 100644
index 000000000..40bafecc2
--- /dev/null
+++ b/src/ui/widget/ink-select-one-action.cpp
@@ -0,0 +1,239 @@
+/*
+ * Authors:
+ * Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Copyright (C) 2017 Tavmjong Bah
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+
+/** \file
+ An action (menu/toolbar item) that allows selecting one choice out of many.
+
+ The choices may be displayed as:
+
+ 1. A group of items in a toolbar with labels and/or icons.
+ 2. As a drop-down menu with a labels and/or icons.
+*/
+
+#include "ink-select-one-action.h"
+
+#include <iostream>
+#include <gtkmm/toolitem.h>
+#include <gtkmm/menuitem.h>
+#include <gtkmm/radioaction.h>
+#include <gtkmm/radiomenuitem.h>
+#include <gtkmm/combobox.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/box.h>
+#include <gtkmm/label.h>
+#include <gtkmm/image.h>
+
+InkSelectOneAction* InkSelectOneAction::create(const Glib::ustring &name,
+ const Glib::ustring &label,
+ const Glib::ustring &tooltip,
+ const Glib::ustring &stock_id,
+ Glib::RefPtr<Gtk::ListStore> store ) {
+
+ return new InkSelectOneAction(name, label, tooltip, stock_id, store);
+}
+
+InkSelectOneAction::InkSelectOneAction (const Glib::ustring &name,
+ const Glib::ustring &label,
+ const Glib::ustring &tooltip,
+ const Glib::ustring &stock_id,
+ Glib::RefPtr<Gtk::ListStore> store ) :
+ Gtk::Action(name, stock_id, label, tooltip),
+ _name( name ),
+ _label( label ),
+ _tooltip( tooltip ),
+ _stock_id( stock_id ),
+ _store (store),
+ _use_radio (true),
+ _use_label (true),
+ _use_icon (true),
+ _icon_size ( Gtk::ICON_SIZE_LARGE_TOOLBAR ),
+ _combobox (nullptr),
+ _radioaction (nullptr),
+ _menuitem (nullptr)
+{
+}
+
+void InkSelectOneAction::set_active (gint active) {
+
+ if (_active != active) {
+
+ _active = active;
+
+ if (_combobox) {
+ _combobox->set_active (active);
+ }
+
+ if (_radioaction) {
+ _radioaction->set_current_value (active);
+ }
+
+ if (active < _radiomenuitems.size()) {
+ _radiomenuitems[ active ]->set_active();
+ }
+ }
+}
+
+Gtk::Widget* InkSelectOneAction::create_menu_item_vfunc() {
+
+ if (_menuitem == nullptr) {
+
+ _menuitem = Gtk::manage (new Gtk::MenuItem);
+ Gtk::Menu *menu = Gtk::manage (new Gtk::Menu);
+
+ Gtk::RadioButton::Group group;
+ int index = 0;
+ auto children = _store->children();
+ for (auto iter = children.begin(); iter != children.end(); ++iter) {
+ Gtk::TreeModel::Row row = *iter;
+
+ InkSelectOneActionColumns columns;
+ Glib::ustring label = row[columns.col_label ];
+ Glib::ustring icon = row[columns.col_icon ];
+ Glib::ustring tooltip = row[columns.col_tooltip ];
+ bool sensitive = row[columns.col_sensitive ];
+
+ Gtk::RadioMenuItem* button = Gtk::manage(new Gtk::RadioMenuItem(group));
+ button->set_label (label);
+ button->set_tooltip_text( tooltip );
+ button->set_sensitive( sensitive );
+
+ button->signal_toggled().connect( sigc::bind<0>(
+ sigc::mem_fun(*this, &InkSelectOneAction::on_toggled_radiomenu), index++)
+ );
+
+ menu->add (*button);
+
+ _radiomenuitems.push_back( button );
+ }
+
+ if ( _active < _radiomenuitems.size()) {
+ _radiomenuitems[ _active ]->set_active();
+ }
+
+ _menuitem->set_submenu (*menu);
+ _menuitem->show_all();
+ }
+
+ return _menuitem;
+}
+
+
+Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() {
+ // Either a group of radio actions or a combobox with labels and/or icons.
+
+ Gtk::ToolItem *tool_item = new Gtk::ToolItem;
+
+ if (_use_radio) {
+ // Create radio actions (note: these are not radio buttons).
+
+ Gtk::Box* box = Gtk::manage(new Gtk::Box());
+ tool_item->add (*box);
+
+ Gtk::RadioAction::Group group;
+ int index = 0;
+ auto children = _store->children();
+ for (auto iter = children.begin(); iter != children.end(); ++iter) {
+ Gtk::TreeModel::Row row = *iter;
+
+ InkSelectOneActionColumns columns;
+ Glib::ustring label = row[columns.col_label ];
+ Glib::ustring icon = row[columns.col_icon ];
+ Glib::ustring tooltip = row[columns.col_tooltip ];
+ bool sensitive = row[columns.col_sensitive];
+ Glib::RefPtr<Gtk::RadioAction> action;
+ if (_use_icon) {
+ action =
+ Gtk::RadioAction::create_with_icon_name (group, "Anonymous", icon, label, tooltip);
+ } else {
+ action =
+ Gtk::RadioAction::create (group, "Anonymous", label, tooltip);
+ }
+ action->set_property( "value", index++ ); // To identify uniquely each radioaction.
+ action->set_sensitive( sensitive );
+
+ // Save first action for use in setting/getting active value.
+ if (!_radioaction) {
+ _radioaction = action;
+ }
+
+ Gtk::ToolItem* item = action->create_tool_item();
+ box->add (*item);
+ }
+
+ _radioaction->signal_changed().connect( sigc::mem_fun(*this, &InkSelectOneAction::on_changed_radioaction));
+
+ } else {
+ // Create combobox
+
+ _combobox = Gtk::manage (new Gtk::ComboBox());
+ _combobox->set_model(_store);
+
+ InkSelectOneActionColumns columns;
+ if (_use_icon ) {
+ Gtk::CellRendererPixbuf *renderer = new Gtk::CellRendererPixbuf;
+ renderer->set_property ("stock_size", Gtk::ICON_SIZE_LARGE_TOOLBAR);
+ _combobox->pack_start (*renderer, false);
+ _combobox->add_attribute (*renderer, "icon_name", columns.col_icon );
+ }
+
+ if (_use_label) {
+ _combobox->pack_start(columns.col_label);
+ }
+
+ std::vector<Gtk::CellRenderer*> cells = _combobox->get_cells();
+ for (auto iter = cells.begin(); iter!= cells.end(); ++iter) {
+ _combobox->add_attribute (**iter, "sensitive", columns.col_sensitive);
+ }
+
+ _combobox->set_active (_active);
+
+ _combobox->signal_changed().connect(
+ sigc::mem_fun(*this, &InkSelectOneAction::on_changed_combobox));
+
+ tool_item->add (*_combobox);
+ }
+
+ tool_item->show_all();
+
+ return tool_item;
+}
+
+void InkSelectOneAction::on_changed_combobox() {
+
+ set_active( _combobox->get_active_row_number() );
+ _changed.emit (_active);
+}
+
+void InkSelectOneAction::on_changed_radioaction(const Glib::RefPtr<Gtk::RadioAction>& current) {
+
+ set_active( current->get_current_value() );
+ _changed.emit (_active);
+}
+
+void InkSelectOneAction::on_toggled_radiomenu(int n) {
+
+ // toggled emitted twice, first for button toggled off, second for button toggled on.
+ // We want to react only to the button turned on.
+ if ( n < _radiomenuitems.size() &&_radiomenuitems[ n ]->get_active()) {
+ set_active ( n );
+ _changed.emit (_active);
+ }
+}
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/ink-select-one-action.h b/src/ui/widget/ink-select-one-action.h
new file mode 100644
index 000000000..194ca8027
--- /dev/null
+++ b/src/ui/widget/ink-select-one-action.h
@@ -0,0 +1,131 @@
+#ifndef SEEN_INK_SELECT_ONE_ACTION
+#define SEEN_INK_SELECT_ONE_ACTION
+
+/*
+ * Authors:
+ * Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Copyright (C) 2017 Tavmjong Bah
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+/**
+ An action (menu/toolbar item) that allows selecting one choice out of many.
+
+ The choices may be displayed as:
+
+ 1. A group of items in a toolbar with labels and/or icons.
+ 2. As a drop-down menu with a labels and/or icons.
+*/
+
+#include <gtkmm/action.h>
+#include <gtkmm/liststore.h>
+#include <sigc++/sigc++.h>
+#include <vector>
+
+namespace Gtk {
+class ComboBox;
+class RadioAction;
+class MenuItem;
+class RadioMenuItem;
+}
+
+class InkSelectOneActionColumns : public Gtk::TreeModel::ColumnRecord {
+
+public:
+ InkSelectOneActionColumns() {
+ add (col_label);
+ add (col_icon);
+ add (col_tooltip);
+ add (col_sensitive);
+ }
+ Gtk::TreeModelColumn<Glib::ustring> col_label;
+ Gtk::TreeModelColumn<Glib::ustring> col_icon;
+ Gtk::TreeModelColumn<Glib::ustring> col_tooltip;
+ Gtk::TreeModelColumn<bool> col_sensitive;
+};
+
+
+class InkSelectOneAction : public Gtk::Action {
+
+public:
+
+ static InkSelectOneAction* create(const Glib::ustring &name,
+ const Glib::ustring &label,
+ const Glib::ustring &tooltip,
+ const Glib::ustring &stock_id,
+ Glib::RefPtr<Gtk::ListStore> store );
+
+ /* Style of action */
+ void use_radio( bool use_radio ) { _use_radio = use_radio; }
+ void use_label( bool use_label ) { _use_label = use_label; }
+ void use_icon( bool use_icon ) { _use_icon = use_icon; }
+
+ gint get_active() { return _active; }
+ void set_active( gint active );
+ void set_icon_size( Gtk::BuiltinIconSize size ) { _icon_size = size; }
+
+ Glib::RefPtr<Gtk::ListStore> get_store() { return _store; }
+
+ sigc::signal<void, int> signal_changed() { return _changed; }
+
+protected:
+
+ virtual Gtk::Widget* create_menu_item_vfunc();
+ virtual Gtk::Widget* create_tool_item_vfunc();
+
+ /* Signals */
+ sigc::signal<void, int> _changed;
+
+private:
+
+ Glib::ustring _name;
+ Glib::ustring _label;
+ Glib::ustring _tooltip;
+ Glib::ustring _stock_id;
+ Glib::RefPtr<Gtk::ListStore> _store;
+
+ gint _active; /* Active menu item/button */
+
+ /* Style */
+ bool _use_radio; // Applies to tool item only
+ bool _use_label;
+ bool _use_icon; // Applies to menu item only
+ Gtk::BuiltinIconSize _icon_size;
+
+ /* Combobox in tool */
+ Gtk::ComboBox* _combobox;
+
+ /* Need to track one action to get active action. */
+ Glib::RefPtr<Gtk::RadioAction> _radioaction;
+
+ Gtk::MenuItem* _menuitem;
+ std::vector<Gtk::RadioMenuItem*> _radiomenuitems;
+
+ /* Internal Callbacks */
+ void on_changed_combobox();
+ void on_changed_radioaction(const Glib::RefPtr<Gtk::RadioAction>& current);
+ void on_toggled_radiomenu(int n);
+
+ InkSelectOneAction (const Glib::ustring &name,
+ const Glib::ustring &label,
+ const Glib::ustring &tooltip,
+ const Glib::ustring &stock_id,
+ Glib::RefPtr<Gtk::ListStore> store );
+
+};
+
+
+#endif /* SEEN_INK_SELECT_ONE_ACTION */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 272125631..0c0e75ad0 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -37,7 +37,6 @@
#include "document-undo.h"
#include "document.h"
#include "widgets/ege-adjustment-action.h"
-#include "widgets/ege-select-one-action.h"
#include "ink-radio-action.h"
#include "ink-toggle-action.h"
#include "widgets/ink-comboboxentry-action.h"
@@ -54,6 +53,7 @@
#include "ui/icon-names.h"
#include "ui/tools/text-tool.h"
#include "ui/widget/unit-tracker.h"
+#include "ui/widget/ink-select-one-action.h"
#include "verbs.h"
using Inkscape::DocumentUndo;
@@ -435,7 +435,7 @@ static void sp_text_script_changed( InkToggleAction* act, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
+static void sp_text_align_mode_changed( GObject *tbl, int mode )
{
// quit if run by the _changed callbacks
if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
@@ -443,8 +443,6 @@ static void sp_text_align_mode_changed( EgeSelectOneAction *act, GObject *tbl )
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- int mode = ege_select_one_action_get_active( act );
-
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt("/tools/text/align_mode", mode);
@@ -1033,7 +1031,7 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl )
+static void sp_writing_mode_changed( GObject* tbl, int mode )
{
// quit if run by the _changed callbacks
if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
@@ -1041,8 +1039,6 @@ static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl )
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- int mode = ege_select_one_action_get_active( act );
-
SPCSSAttr *css = sp_repr_css_attr_new ();
switch (mode)
{
@@ -1058,7 +1054,7 @@ static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl )
break;
}
- case 2:
+ case 2:
{
sp_repr_css_set_property (css, "writing-mode", "vertical-lr");
break;
@@ -1087,7 +1083,7 @@ static void sp_writing_mode_changed( EgeSelectOneAction *act, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl )
+static void sp_text_orientation_changed( GObject* tbl, int mode )
{
// quit if run by the _changed callbacks
if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
@@ -1095,8 +1091,6 @@ static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl )
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- int mode = ege_select_one_action_get_active( act );
-
SPCSSAttr *css = sp_repr_css_attr_new ();
switch (mode)
{
@@ -1141,7 +1135,7 @@ static void sp_text_orientation_changed( EgeSelectOneAction *act, GObject *tbl )
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) );
}
-static void sp_text_direction_changed( EgeSelectOneAction *act, GObject *tbl )
+static void sp_text_direction_changed( GObject *tbl, int mode )
{
// quit if run by the _changed callbacks
if (g_object_get_data(G_OBJECT(tbl), "freeze")) {
@@ -1149,7 +1143,6 @@ static void sp_text_direction_changed( EgeSelectOneAction *act, GObject *tbl )
}
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE) );
- int mode = ege_select_one_action_get_active( act );
SPCSSAttr *css = sp_repr_css_attr_new ();
switch (mode)
{
@@ -1396,24 +1389,18 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
// Alignment
- EgeSelectOneAction* textAlignAction = EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextAlignAction" ) );
+ InkSelectOneAction* textAlignAction =
+ static_cast<InkSelectOneAction*>( g_object_get_data( tbl, "TextAlignAction" ) );
// Note: SVG 1.1 doesn't include text-align, SVG 1.2 Tiny doesn't include text-align="justify"
// text-align="justify" was a draft SVG 1.2 item (along with flowed text).
// Only flowed text can be left and right justified at the same time.
// Disable button if we don't have flowed text.
- // The GtkTreeModel class doesn't have a set function so we can't
- // simply add an ege_select_one_action_set_sensitive method!
- // We must set values directly with the GtkListStore and then
- // ask that the GtkAction update the sensitive parameters.
- GtkListStore * model = GTK_LIST_STORE( ege_select_one_action_get_model( textAlignAction ) );
- GtkTreePath * path = gtk_tree_path_new_from_string("3"); // Justify entry
- GtkTreeIter iter;
- gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
- gtk_list_store_set( model, &iter, /* column */ 3, isFlow, -1 );
- ege_select_one_action_update_sensitive( textAlignAction );
- // ege_select_one_action_set_sensitive( textAlignAction, 3, isFlow );
+ Glib::RefPtr<Gtk::ListStore> store = textAlignAction->get_store();
+ Gtk::TreeModel::Row row = *(store->get_iter("3")); // Justify entry
+ InkSelectOneActionColumns columns;
+ row[columns.col_sensitive] = isFlow;
int activeButton = 0;
if (query.text_align.computed == SP_CSS_TEXT_ALIGN_JUSTIFY)
@@ -1425,8 +1412,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_MIDDLE) activeButton = 1;
if (query.text_anchor.computed == SP_CSS_TEXT_ANCHOR_END) activeButton = 2;
}
- ege_select_one_action_set_active( textAlignAction, activeButton );
-
+ textAlignAction->set_active( activeButton );
// Line height (spacing) and line height unit
double height;
@@ -1520,9 +1506,9 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
if (query.writing_mode.computed == SP_CSS_WRITING_MODE_TB_RL) activeButton2 = 1;
if (query.writing_mode.computed == SP_CSS_WRITING_MODE_TB_LR) activeButton2 = 2;
- EgeSelectOneAction* writingModeAction =
- EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextWritingModeAction" ) );
- ege_select_one_action_set_active( writingModeAction, activeButton2 );
+ InkSelectOneAction* writingModeAction =
+ static_cast<InkSelectOneAction*>( g_object_get_data( tbl, "TextWritingModeAction" ) );
+ writingModeAction->set_active( activeButton2 );
// Orientation
int activeButton3 = 0;
@@ -1530,35 +1516,20 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
if (query.text_orientation.computed == SP_CSS_TEXT_ORIENTATION_UPRIGHT ) activeButton3 = 1;
if (query.text_orientation.computed == SP_CSS_TEXT_ORIENTATION_SIDEWAYS) activeButton3 = 2;
- EgeSelectOneAction* textOrientationAction =
- EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextOrientationAction" ) );
- ege_select_one_action_set_active( textOrientationAction, activeButton3 );
-
- // Disable text orientation for horizontal text.. See above for why this nonsense
- model = GTK_LIST_STORE( ege_select_one_action_get_model( textOrientationAction ) );
-
- path = gtk_tree_path_new_from_string("0");
- gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
- gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 );
-
- path = gtk_tree_path_new_from_string("1");
- gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
- gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 );
+ InkSelectOneAction* textOrientationAction =
+ static_cast<InkSelectOneAction*>( g_object_get_data( tbl, "TextOrientationAction" ) );
+ textOrientationAction->set_active( activeButton3 );
- path = gtk_tree_path_new_from_string("2");
- gtk_tree_model_get_iter( GTK_TREE_MODEL (model), &iter, path );
- gtk_list_store_set( model, &iter, /* column */ 3, activeButton2 != 0, -1 );
-
- ege_select_one_action_update_sensitive( textOrientationAction );
+ // Disable text orientation for horizontal text...
+ textOrientationAction->set_sensitive( activeButton2 != 0 );
// Direction
int activeButton4 = 0;
if (query.direction.computed == SP_CSS_DIRECTION_LTR ) activeButton4 = 0;
if (query.direction.computed == SP_CSS_DIRECTION_RTL ) activeButton4 = 1;
- EgeSelectOneAction* textDirectionAction =
- EGE_SELECT_ONE_ACTION( g_object_get_data( tbl, "TextDirectionAction" ) );
- ege_select_one_action_set_active( textDirectionAction, activeButton4 );
-
+ InkSelectOneAction* textDirectionAction =
+ static_cast<InkSelectOneAction*>( g_object_get_data( tbl, "TextDirectionAction" ) );
+ textDirectionAction->set_active( activeButton4 );
}
#ifdef DEBUG_TEXT
@@ -1832,209 +1803,175 @@ void sp_text_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje
/* Alignment */
{
- GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
-
- GtkTreeIter iter;
+ InkSelectOneActionColumns columns;
+
+ Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns);
+
+ Gtk::TreeModel::Row row;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Align left");
+ row[columns.col_tooltip ] = _("Align left");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-justify-left");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Align center");
+ row[columns.col_tooltip ] = _("Align center");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-justify-center");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Align right");
+ row[columns.col_tooltip ] = _("Align right");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-justify-right");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Justify");
+ row[columns.col_tooltip ] = _("Justify (only flowed text)");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-justify-fill");
+ row[columns.col_sensitive] = false;
+
+ InkSelectOneAction* act =
+ InkSelectOneAction::create( "TextAlignAction", // Name
+ _("Alignment"), // Label
+ _("Text alignment"), // Tooltip
+ "Not Used", // Icon
+ store ); // Tree store
+ act->use_radio( false );
+ act->use_label( false );
+ gint mode = prefs->getInt("/tools/text/align_mode", 0);
+ act->set_active( mode );
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Align left"),
- 1, _("Align left"),
- 2, INKSCAPE_ICON("format-justify-left"),
- 3, true,
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Align center"),
- 1, _("Align center"),
- 2, INKSCAPE_ICON("format-justify-center"),
- 3, true,
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Align right"),
- 1, _("Align right"),
- 2, INKSCAPE_ICON("format-justify-right"),
- 3, true,
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Justify"),
- 1, _("Justify (only flowed text)"),
- 2, INKSCAPE_ICON("format-justify-fill"),
- 3, false,
- -1 );
-
- EgeSelectOneAction* act = ege_select_one_action_new( "TextAlignAction", // Name
- _("Alignment"), // Label
- _("Text alignment"), // Tooltip
- NULL, // Icon name
- GTK_TREE_MODEL(model) ); // Model
- g_object_set( act, "short_label", "NotUsed", NULL );
- gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() ));
g_object_set_data( holder, "TextAlignAction", act );
- ege_select_one_action_set_appearance( act, "full" );
- ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
- g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
- ege_select_one_action_set_icon_column( act, 2 );
- ege_select_one_action_set_icon_size( act, secondarySize );
- ege_select_one_action_set_tooltip_column( act, 1 );
- ege_select_one_action_set_sensitive_column( act, 3 );
- gint mode = prefs->getInt("/tools/text/align_mode", 0);
- ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_align_mode_changed), holder );
+ act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_align_mode_changed), holder));
}
/* Writing mode (Horizontal, Vertical-LR, Vertical-RL) */
{
- GtkListStore* model = gtk_list_store_new( 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING );
-
- GtkTreeIter iter;
+ InkSelectOneActionColumns columns;
+
+ Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns);
+
+ Gtk::TreeModel::Row row;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Horizontal");
+ row[columns.col_tooltip ] = _("Horizontal text");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-horizontal");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Vertical — RL");
+ row[columns.col_tooltip ] = _("Vertical text — lines: right to left");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-vertical");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Vertical — LR");
+ row[columns.col_tooltip ] = _("Vertical text — lines: left to right");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-vertical-lr");
+ row[columns.col_sensitive] = true;
+
+ InkSelectOneAction* act =
+ InkSelectOneAction::create( "TextWritingModeAction", // Name
+ _("Writing mode"), // Label
+ _("Block progression"), // Tooltip
+ "Not Used", // Icon
+ store ); // Tree store
+ act->use_radio( false );
+ act->use_label( false );
+ gint mode = prefs->getInt("/tools/text/writing_mode", 0);
+ act->set_active( mode );
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Horizontal"),
- 1, _("Horizontal text"),
- 2, INKSCAPE_ICON("format-text-direction-horizontal"),
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Vertical — RL"),
- 1, _("Vertical text — lines: right to left"),
- 2, INKSCAPE_ICON("format-text-direction-vertical"),
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Vertical — LR"),
- 1, _("Vertical text — lines: left to right"), // Mongolian!
- 2, INKSCAPE_ICON("format-text-direction-vertical-lr"),
- -1 );
-
- EgeSelectOneAction* act = ege_select_one_action_new( "TextWritingModeAction", // Name
- _("Writing mode"), // Label
- _("Block progression"), // Tooltip
- NULL, // Icon name
- GTK_TREE_MODEL(model) ); // Model
-
- g_object_set( act, "short_label", "NotUsed", NULL );
- gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() ));
g_object_set_data( holder, "TextWritingModeAction", act );
- ege_select_one_action_set_appearance( act, "full" );
- ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
- g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
- ege_select_one_action_set_icon_column( act, 2 );
- ege_select_one_action_set_icon_size( act, secondarySize );
- ege_select_one_action_set_tooltip_column( act, 1 );
-
- gint mode = prefs->getInt("/tools/text/writing_mode", 0);
- ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_writing_mode_changed), holder );
+ act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_writing_mode_changed), holder));
}
/* Text (glyph) orientation (Auto (mixed), Upright, Sideways) */
{
- GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
-
- GtkTreeIter iter;
+ InkSelectOneActionColumns columns;
+
+ Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns);
+
+ Gtk::TreeModel::Row row;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Auto");
+ row[columns.col_tooltip ] = _("Auto glyph orientation");
+ row[columns.col_icon ] = INKSCAPE_ICON("text-orientation-auto");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Upright");
+ row[columns.col_tooltip ] = _("Upright glyph orientation");
+ row[columns.col_icon ] = INKSCAPE_ICON("text-orientation-upright");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("Sideways");
+ row[columns.col_tooltip ] = _("Sideways glyph orientation");
+ row[columns.col_icon ] = INKSCAPE_ICON("text-orientation-sideways");
+ row[columns.col_sensitive] = true;
+
+ InkSelectOneAction* act =
+ InkSelectOneAction::create( "TextOrientationAction", // Name
+ _("Text orientation"), // Label
+ _("Text (glyph) orientation in vertical text."), // Tooltip
+ "Not Used", // Icon
+ store ); // List store
+ act->use_radio( false );
+ act->use_label( false );
+ gint mode = prefs->getInt("/tools/text/text_orientation", 0);
+ act->set_active( mode );
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Auto"),
- 1, _("Auto glyph orientation"),
- 2, INKSCAPE_ICON("text-orientation-auto"),
- 3, true,
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Upright"),
- 1, _("Upright glyph orientation"),
- 2, INKSCAPE_ICON("text-orientation-upright"),
- 3, true,
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("Sideways"),
- 1, _("Sideways glyph orientation"),
- 2, INKSCAPE_ICON("text-orientation-sideways"),
- 3, true,
- -1 );
-
- EgeSelectOneAction* act = ege_select_one_action_new( "TextOrientationAction", // Name
- _("Text orientation"), // Label
- _("Text (glyph) orientation in vertical text."), // Tooltip
- NULL, // Icon name
- GTK_TREE_MODEL(model) ); // Model
-
- g_object_set( act, "short_label", "NotUsed", NULL );
- gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() ));
g_object_set_data( holder, "TextOrientationAction", act );
- ege_select_one_action_set_appearance( act, "full" );
- ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
- g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
- ege_select_one_action_set_icon_column( act, 2 );
- ege_select_one_action_set_icon_size( act, secondarySize );
- ege_select_one_action_set_tooltip_column( act, 1 );
- ege_select_one_action_set_sensitive_column( act, 3 );
-
- gint mode = prefs->getInt("/tools/text/text_orientation", 0);
- ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_orientation_changed), holder );
+ act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_orientation_changed), holder));
}
// Text direction (predominant direction of horizontal text).
{
- GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN );
-
- GtkTreeIter iter;
+ InkSelectOneActionColumns columns;
+
+ Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns);
+
+ Gtk::TreeModel::Row row;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("LTR");
+ row[columns.col_tooltip ] = _("Left to right text");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-horizontal");
+ row[columns.col_sensitive] = true;
+
+ row = *(store->append());
+ row[columns.col_label ] = _("RTL");
+ row[columns.col_tooltip ] = _("Right to left text");
+ row[columns.col_icon ] = INKSCAPE_ICON("format-text-direction-r2l");
+ row[columns.col_sensitive] = true;
+
+ InkSelectOneAction* act =
+ InkSelectOneAction::create( "TextDirectionAction", // Name
+ _("Text direction"), // Label
+ _("Text direction for normally horizontal text."), // Tooltip
+ "Not Used", // Icon
+ store ); // List store
+ act->use_radio( false );
+ act->use_label( false );
+ gint mode = prefs->getInt("/tools/text/text_direction", 0);
+ act->set_active( mode );
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("LTR"),
- 1, _("Left to right text"),
- 2, INKSCAPE_ICON("format-text-direction-horizontal"),
- 3, true,
- -1 );
-
- gtk_list_store_append( model, &iter );
- gtk_list_store_set( model, &iter,
- 0, _("RTL"),
- 1, _("Right to left text"),
- 2, INKSCAPE_ICON("format-text-direction-r2l"),
- 3, true,
- -1 );
-
- EgeSelectOneAction* act = ege_select_one_action_new( "TextDirectionAction", // Name
- _("Text direction"), // Label
- _("Text direction for normally horizontal text."), // Tooltip
- NULL, // Icon name
- GTK_TREE_MODEL(model) ); // Model
-
- g_object_set( act, "short_label", "NotUsed", NULL );
- gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() ));
g_object_set_data( holder, "TextDirectionAction", act );
- ege_select_one_action_set_appearance( act, "full" );
- ege_select_one_action_set_radio_action_type( act, INK_RADIO_ACTION_TYPE );
- g_object_set( G_OBJECT(act), "icon-property", "iconId", NULL );
- ege_select_one_action_set_icon_column( act, 2 );
- ege_select_one_action_set_icon_size( act, secondarySize );
- ege_select_one_action_set_tooltip_column( act, 1 );
- ege_select_one_action_set_sensitive_column( act, 3 );
-
- gint mode = prefs->getInt("/tools/text/text_direction", 0);
- ege_select_one_action_set_active( act, mode );
- g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_text_direction_changed), holder );
+ act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_text_direction_changed), holder));
}
/* Line height unit tracker */