diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2017-12-25 17:16:52 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2017-12-25 17:16:52 +0000 |
| commit | 07f2215a49a314c89e68b0e3a381fc0be25dcb00 (patch) | |
| tree | 46c50d891c45430d67a884cdc6b586e02ee19e87 /src | |
| parent | Use a macro for GtkMM version checks (diff) | |
| parent | Convert spray tool to use ink-select-one-action. (diff) | |
| download | inkscape-07f2215a49a314c89e68b0e3a381fc0be25dcb00.tar.gz inkscape-07f2215a49a314c89e68b0e3a381fc0be25dcb00.zip | |
Merge branch 'master' of gitlab.com:inkscape/inkscape
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/widget/ink-select-one-action.cpp | 19 | ||||
| -rw-r--r-- | src/ui/widget/ink-select-one-action.h | 6 | ||||
| -rw-r--r-- | src/widgets/spray-toolbar.cpp | 93 |
3 files changed, 63 insertions, 55 deletions
diff --git a/src/ui/widget/ink-select-one-action.cpp b/src/ui/widget/ink-select-one-action.cpp index 40bafecc2..dedfb8894 100644 --- a/src/ui/widget/ink-select-one-action.cpp +++ b/src/ui/widget/ink-select-one-action.cpp @@ -31,22 +31,22 @@ #include <gtkmm/image.h> InkSelectOneAction* InkSelectOneAction::create(const Glib::ustring &name, - const Glib::ustring &label, + const Glib::ustring &group_label, const Glib::ustring &tooltip, const Glib::ustring &stock_id, Glib::RefPtr<Gtk::ListStore> store ) { - return new InkSelectOneAction(name, label, tooltip, stock_id, store); + return new InkSelectOneAction(name, group_label, tooltip, stock_id, store); } InkSelectOneAction::InkSelectOneAction (const Glib::ustring &name, - const Glib::ustring &label, + const Glib::ustring &group_label, const Glib::ustring &tooltip, const Glib::ustring &stock_id, Glib::RefPtr<Gtk::ListStore> store ) : - Gtk::Action(name, stock_id, label, tooltip), + Gtk::Action(name, stock_id, group_label, tooltip), _name( name ), - _label( label ), + _group_label( group_label ), _tooltip( tooltip ), _stock_id( stock_id ), _store (store), @@ -136,6 +136,11 @@ Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { Gtk::Box* box = Gtk::manage(new Gtk::Box()); tool_item->add (*box); + if (_use_group_label) { + Gtk::Label *group_label = Gtk::manage (new Gtk::Label( _group_label + ": " )); + box->add( *group_label ); + } + Gtk::RadioAction::Group group; int index = 0; auto children = _store->children(); @@ -167,6 +172,10 @@ Gtk::Widget* InkSelectOneAction::create_tool_item_vfunc() { box->add (*item); } + if (_radioaction) { + _radioaction->set_current_value (_active); + } + _radioaction->signal_changed().connect( sigc::mem_fun(*this, &InkSelectOneAction::on_changed_radioaction)); } else { diff --git a/src/ui/widget/ink-select-one-action.h b/src/ui/widget/ink-select-one-action.h index 194ca8027..0b1b08de4 100644 --- a/src/ui/widget/ink-select-one-action.h +++ b/src/ui/widget/ink-select-one-action.h @@ -61,6 +61,7 @@ public: 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; } + void use_group_label( bool use_group_label ) { _use_group_label = use_group_label; } gint get_active() { return _active; } void set_active( gint active ); @@ -81,7 +82,7 @@ protected: private: Glib::ustring _name; - Glib::ustring _label; + Glib::ustring _group_label; Glib::ustring _tooltip; Glib::ustring _stock_id; Glib::RefPtr<Gtk::ListStore> _store; @@ -92,6 +93,7 @@ private: bool _use_radio; // Applies to tool item only bool _use_label; bool _use_icon; // Applies to menu item only + bool _use_group_label; // Applies to tool item only Gtk::BuiltinIconSize _icon_size; /* Combobox in tool */ @@ -109,7 +111,7 @@ private: void on_toggled_radiomenu(int n); InkSelectOneAction (const Glib::ustring &name, - const Glib::ustring &label, + const Glib::ustring &group_label, const Glib::ustring &tooltip, const Glib::ustring &stock_id, Glib::RefPtr<Gtk::ListStore> store ); diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp index 2a56d81cb..140c60ef6 100644 --- a/src/widgets/spray-toolbar.cpp +++ b/src/widgets/spray-toolbar.cpp @@ -35,13 +35,13 @@ #include "desktop.h" #include "inkscape.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 "toolbox.h" #include "ui/dialog/clonetiler.h" #include "ui/dialog/dialog-manager.h" #include "ui/dialog/panel-dialog.h" +#include "ui/widget/ink-select-one-action.h" #include "ui/icon-names.h" #include <glibmm/i18n.h> @@ -101,6 +101,7 @@ static void sp_stb_update_widgets( GObject *tbl ) static void sp_spray_init( GObject *tbl){ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int mode = prefs->getInt("/tools/spray/mode", 0); + bool show = true; if(mode == 3 || mode == 2){ show = false; @@ -161,9 +162,8 @@ static void sp_spray_standard_deviation_value_changed( GtkAdjustment *adj, GObje gtk_adjustment_get_value(adj)); } -static void sp_spray_mode_changed( EgeSelectOneAction *act, GObject * tbl ) +static void sp_spray_mode_changed( GObject * tbl, int mode ) { - int mode = ege_select_one_action_get_active( act ); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt("/tools/spray/mode", mode); sp_spray_init(tbl); @@ -352,56 +352,53 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj /* Mode */ { - GtkListStore* model = gtk_list_store_new( 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); - - GtkTreeIter iter; - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Spray with copies"), - 1, _("Spray copies of the initial selection"), - 2, INKSCAPE_ICON("spray-mode-copy"), - -1 ); - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Spray with clones"), - 1, _("Spray clones of the initial selection"), - 2, INKSCAPE_ICON("spray-mode-clone"), - -1 ); - + InkSelectOneActionColumns columns; + + Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns); + + Gtk::TreeModel::Row row; + + row = *(store->append()); + row[columns.col_label ] = _("Spray with copies"); + row[columns.col_tooltip ] = _("Spray copies of the initial selection"); + row[columns.col_icon ] = INKSCAPE_ICON("spray-mode-copy"); + row[columns.col_sensitive] = true; + + row = *(store->append()); + row[columns.col_label ] = _("Spray with clones"); + row[columns.col_tooltip ] = _("Spray clones of the initial selection"); + row[columns.col_icon ] = INKSCAPE_ICON("spray-mode-clone"); + row[columns.col_sensitive] = true; + #ifdef ENABLE_SPRAY_MODE_SINGLE_PATH - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Spray single path"), - 1, _("Spray objects in a single path"), - 2, INKSCAPE_ICON("spray-mode-union"), - -1 ); + row = *(store->append()); + row[columns.col_label ] = _("Spray single path"); + row[columns.col_tooltip ] = _("Spray objects in a single path"); + row[columns.col_icon ] = INKSCAPE_ICON("spray-mode-union"); + row[columns.col_sensitive] = true; #endif - - gtk_list_store_append( model, &iter ); - gtk_list_store_set( model, &iter, - 0, _("Delete sprayed items"), - 1, _("Delete sprayed items from selection"), - 2, INKSCAPE_ICON("draw-eraser"), - -1 ); - - EgeSelectOneAction* act = ege_select_one_action_new( "SprayModeAction", _("Mode"), (""), NULL, GTK_TREE_MODEL(model) ); - g_object_set( act, "short_label", _("Mode:"), NULL ); - gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); - g_object_set_data( holder, "mode_action", 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 ); + row = *(store->append()); + row[columns.col_label ] = _("Delete sprayed items"); + row[columns.col_tooltip ] = _("Delete sprayed items from selection"); + row[columns.col_icon ] = INKSCAPE_ICON("draw-eraser"); + row[columns.col_sensitive] = true; + + InkSelectOneAction* act = + InkSelectOneAction::create( "SprayModeAction", // Name + _("Mode"), // Label + _(""), // Tooltip + "Not Used", // Icon + store ); // Tree store + + act->use_radio( true ); + act->use_group_label( true ); gint mode = prefs->getInt("/tools/spray/mode", 1); - ege_select_one_action_set_active( act, mode ); - g_signal_connect_after( G_OBJECT(act), "changed", G_CALLBACK(sp_spray_mode_changed), holder ); + act->set_active( mode ); + + gtk_action_group_add_action( mainActions, GTK_ACTION( act->gobj() )); - g_object_set_data( G_OBJECT(holder), "spray_tool_mode", act); + act->signal_changed().connect(sigc::bind<0>(sigc::ptr_fun(&sp_spray_mode_changed), holder)); } { /* Population */ |
