summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2019-01-29 18:16:27 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2019-01-29 18:16:27 +0000
commitc73847235afd19be7aa5deefd7ce02276b9bb969 (patch)
tree8d1b0c6bf108d1d2d132a75a6430575c0762efea /src
parentRemove unneeded and incomplete file (diff)
downloadinkscape-c73847235afd19be7aa5deefd7ce02276b9bb969.tar.gz
inkscape-c73847235afd19be7aa5deefd7ce02276b9bb969.zip
PaintbucketToolbar: GtkAction migration
Diffstat (limited to 'src')
-rw-r--r--src/ui/toolbar/paintbucket-toolbar.cpp190
-rw-r--r--src/ui/toolbar/paintbucket-toolbar.h17
-rw-r--r--src/widgets/toolbox.cpp2
3 files changed, 84 insertions, 125 deletions
diff --git a/src/ui/toolbar/paintbucket-toolbar.cpp b/src/ui/toolbar/paintbucket-toolbar.cpp
index 4efe27835..4e7232b80 100644
--- a/src/ui/toolbar/paintbucket-toolbar.cpp
+++ b/src/ui/toolbar/paintbucket-toolbar.cpp
@@ -25,9 +25,13 @@
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
+#include "paintbucket-toolbar.h"
+
#include <glibmm/i18n.h>
-#include "paintbucket-toolbar.h"
+#include <gtkmm/comboboxtext.h>
+#include <gtkmm/separatortoolitem.h>
+
#include "desktop.h"
#include "document-undo.h"
@@ -35,171 +39,126 @@
#include "ui/tools/flood-tool.h"
#include "ui/uxmanager.h"
#include "ui/widget/ink-select-one-action.h"
+#include "ui/widget/spin-button-tool-item.h"
#include "ui/widget/unit-tracker.h"
-#include "widgets/ink-action.h"
-#include "widgets/ege-adjustment-action.h"
-#include "widgets/toolbox.h"
-
using Inkscape::UI::Widget::UnitTracker;
-using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
-using Inkscape::UI::ToolboxFactory;
using Inkscape::Util::unit_table;
-
namespace Inkscape {
namespace UI {
namespace Toolbar {
PaintbucketToolbar::PaintbucketToolbar(SPDesktop *desktop)
: Toolbar(desktop),
_tracker(new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR))
-{}
-
-GtkWidget *
-PaintbucketToolbar::prep(SPDesktop *desktop, GtkActionGroup* mainActions)
{
- auto toolbar = new PaintbucketToolbar(desktop);
- EgeAdjustmentAction* eact = nullptr;
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ auto prefs = Inkscape::Preferences::get();
// Channel
{
- InkSelectOneActionColumns columns;
-
- Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns);
-
- Gtk::TreeModel::Row row;
+ add_label(_("Fill by:"));
+ _channels_cbt = Gtk::manage(new Gtk::ComboBoxText());
+
for (auto item: Inkscape::UI::Tools::FloodTool::channel_list) {
- row = *(store->append());
- row[columns.col_label ] = item;
- row[columns.col_tooltip ] = ("");
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_sensitive] = true;
+ _channels_cbt->append(item);
}
- toolbar->_channels_action =
- InkSelectOneAction::create( "ChannelsAction", // Name
- _("Fill by"), // Label
- (""), // Tooltip
- "Not Used", // Icon
- store ); // Tree store
-
- toolbar->_channels_action->use_radio( false );
- toolbar->_channels_action->use_icon( false );
- toolbar->_channels_action->use_label( true );
- toolbar->_channels_action->use_group_label( true );
int channels = prefs->getInt("/tools/paintbucket/channels", 0);
- toolbar->_channels_action->set_active( channels );
-
- gtk_action_group_add_action( mainActions, GTK_ACTION( toolbar->_channels_action->gobj() ));
+ _channels_cbt->set_active( channels );
+ _channels_cbt->signal_changed().connect(sigc::mem_fun(*this, &PaintbucketToolbar::channels_changed));
- toolbar->_channels_action->signal_changed().connect(sigc::mem_fun(*toolbar, &PaintbucketToolbar::channels_changed));
+ auto channels_item = Gtk::manage(new Gtk::ToolItem());
+ channels_item->add(*_channels_cbt);
+ add(*channels_item);
}
// Spacing spinbox
{
- eact = create_adjustment_action(
- "ThresholdAction",
- _("Fill Threshold"), _("Threshold:"),
- _("The maximum allowed difference between the clicked pixel and the neighboring pixels to be counted in the fill"),
- "/tools/paintbucket/threshold", 5,
- TRUE,
- "inkscape:paintbucket-threshold", 0, 100.0, 1.0, 10.0,
- nullptr, nullptr, 0,
- nullptr /*unit tracker*/, 1, 0 );
- ege_adjustment_action_set_focuswidget(eact, GTK_WIDGET(desktop->canvas));
-
- toolbar->_threshold_adj = Glib::wrap(ege_adjustment_action_get_adjustment(eact));
- toolbar->_threshold_adj->signal_value_changed().connect(sigc::mem_fun(*toolbar, &PaintbucketToolbar::threshold_changed));
- ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
- gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ auto threshold_val = prefs->getDouble("/tools/paintbucket/threshold", 5);
+ _threshold_adj = Gtk::Adjustment::create(threshold_val, 0, 100.0, 1.0, 10.0);
+ auto threshold_item = Gtk::manage(new UI::Widget::SpinButtonToolItem("inkscape:paintbucket-threshold", _("Threshold:"), _threshold_adj, 1, 0));
+ threshold_item->set_tooltip_text(_("The maximum allowed difference between the clicked pixel and the neighboring pixels to be counted in the fill"));
+ threshold_item->set_focus_widget(Glib::wrap(GTK_WIDGET(desktop->canvas)));
+ _threshold_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PaintbucketToolbar::threshold_changed));
+ // ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT );
+ add(*threshold_item);
}
+ add(* Gtk::manage(new Gtk::SeparatorToolItem()));
+
// Create the units menu.
Glib::ustring stored_unit = prefs->getString("/tools/paintbucket/offsetunits");
if (!stored_unit.empty()) {
Unit const *u = unit_table.getUnit(stored_unit);
- toolbar->_tracker->setActiveUnit(u);
+ _tracker->setActiveUnit(u);
}
+ // Offset spinbox
{
- InkSelectOneAction* act = toolbar->_tracker->createAction( "PaintbucketUnitsAction", _("Units"), ("") );
- gtk_action_group_add_action( mainActions, act->gobj() );
+ auto offset_val = prefs->getDouble("/tools/paintbucket/offset", 0);
+ _offset_adj = Gtk::Adjustment::create(offset_val, -1e4, 1e4, 0.1, 0.5);
+ auto offset_item = Gtk::manage(new UI::Widget::SpinButtonToolItem("inkscape:paintbucket-offset", _("Grow/shrink by:"), _offset_adj, 1, 2));
+ offset_item->set_tooltip_text(_("The amount to grow (positive) or shrink (negative) the created fill path"));
+ _tracker->addAdjustment(_offset_adj->gobj());
+ offset_item->set_focus_widget(Glib::wrap(GTK_WIDGET(desktop->canvas)));
+ _offset_adj->signal_value_changed().connect(sigc::mem_fun(*this, &PaintbucketToolbar::offset_changed));
+ add(*offset_item);
}
- // Offset spinbox
{
- eact = create_adjustment_action(
- "OffsetAction",
- _("Grow/shrink by"), _("Grow/shrink by:"),
- _("The amount to grow (positive) or shrink (negative) the created fill path"),
- "/tools/paintbucket/offset", 0,
- TRUE,
- "inkscape:paintbucket-offset", -1e4, 1e4, 0.1, 0.5,
- nullptr, nullptr, 0,
- toolbar->_tracker,
- 1, 2);
- ege_adjustment_action_set_focuswidget(eact, GTK_WIDGET(desktop->canvas));
- toolbar->_offset_adj = Glib::wrap(ege_adjustment_action_get_adjustment(eact));
- toolbar->_offset_adj->signal_value_changed().connect(sigc::mem_fun(*toolbar, &PaintbucketToolbar::offset_changed));
- gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
+ auto act = _tracker->createAction( "PaintbucketUnitsAction", _("Units"), ("") );
+ auto unit_menu = act->create_tool_item();
+ add(*unit_menu);
}
+ add(* Gtk::manage(new Gtk::SeparatorToolItem()));
+
/* Auto Gap */
{
- InkSelectOneActionColumns columns;
-
- Glib::RefPtr<Gtk::ListStore> store = Gtk::ListStore::create(columns);
+ add_label(_("Close gaps:"));
- Gtk::TreeModel::Row row;
+ _autogap_cbt = Gtk::manage(new Gtk::ComboBoxText());
for (auto item: Inkscape::UI::Tools::FloodTool::gap_list) {
- row = *(store->append());
- row[columns.col_label ] = item;
- row[columns.col_tooltip ] = ("");
- row[columns.col_icon ] = "NotUsed";
- row[columns.col_sensitive] = true;
+ _autogap_cbt->append(item);
}
- toolbar->_autogap_action =
- InkSelectOneAction::create( "AutoGapAction", // Name
- _("Close gaps"), // Label
- (""), // Tooltip
- "Not Used", // Icon
- store ); // Tree store
-
- toolbar->_autogap_action->use_radio( false );
- toolbar->_autogap_action->use_icon( false );
- toolbar->_autogap_action->use_label( true );
- toolbar->_autogap_action->use_group_label( true );
int autogap = prefs->getInt("/tools/paintbucket/autogap");
- toolbar->_autogap_action->set_active( autogap );
-
- gtk_action_group_add_action( mainActions, GTK_ACTION( toolbar->_autogap_action->gobj() ));
-
- toolbar->_autogap_action->signal_changed().connect(sigc::mem_fun(*toolbar, &PaintbucketToolbar::autogap_changed));
+ _autogap_cbt->set_active( autogap );
+ auto autogap_item = Gtk::manage(new Gtk::ToolItem());
+ autogap_item->add(*_autogap_cbt);
+ add(*autogap_item);
+ _autogap_cbt->signal_changed().connect(sigc::mem_fun(*this, &PaintbucketToolbar::autogap_changed));
}
+ add(* Gtk::manage(new Gtk::SeparatorToolItem()));
+
/* Reset */
{
- InkAction* inky = ink_action_new( "PaintbucketResetAction",
- _("Defaults"),
- _("Reset paint bucket parameters to defaults (use Inkscape Preferences > Tools to change defaults)"),
- INKSCAPE_ICON("edit-clear"),
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(defaults), (gpointer)toolbar );
- gtk_action_group_add_action( mainActions, GTK_ACTION(inky) );
- gtk_action_set_sensitive( GTK_ACTION(inky), TRUE );
+ auto reset_button = Gtk::manage(new Gtk::ToolButton(_("Defaults")));
+ reset_button->set_tooltip_text(_("Reset paint bucket parameters to defaults (use Inkscape Preferences > Tools to change defaults)"));
+ reset_button->set_icon_name(INKSCAPE_ICON("edit-clear"));
+ reset_button->signal_clicked().connect(sigc::mem_fun(*this, &PaintbucketToolbar::defaults));
+ add(*reset_button);
+ reset_button->set_sensitive(true);
}
+ show_all();
+}
+
+GtkWidget *
+PaintbucketToolbar::create(SPDesktop *desktop)
+{
+ auto toolbar = new PaintbucketToolbar(desktop);
return GTK_WIDGET(toolbar->gobj());
}
void
-PaintbucketToolbar::channels_changed(int channels)
+PaintbucketToolbar::channels_changed()
{
+ auto channels = _channels_cbt->get_active_row_number();
Inkscape::UI::Tools::FloodTool::set_channels(channels);
}
@@ -225,23 +184,22 @@ PaintbucketToolbar::offset_changed()
}
void
-PaintbucketToolbar::autogap_changed(int autogap)
+PaintbucketToolbar::autogap_changed()
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ int autogap = _autogap_cbt->get_active_row_number();
+ auto prefs = Inkscape::Preferences::get();
prefs->setInt("/tools/paintbucket/autogap", autogap);
}
void
-PaintbucketToolbar::defaults(GtkWidget * /* widget */, gpointer data)
+PaintbucketToolbar::defaults()
{
- auto toolbar = reinterpret_cast<PaintbucketToolbar *>(data);
-
// FIXME: make defaults settable via Inkscape Options
- toolbar->_threshold_adj->set_value(15);
- toolbar->_offset_adj->set_value(0.0);
+ _threshold_adj->set_value(15);
+ _offset_adj->set_value(0.0);
- toolbar->_channels_action->set_active( Inkscape::UI::Tools::FLOOD_CHANNELS_RGB );
- toolbar->_autogap_action->set_active( 0 );
+ _channels_cbt->set_active( Inkscape::UI::Tools::FLOOD_CHANNELS_RGB );
+ _autogap_cbt->set_active( 0 );
}
}
diff --git a/src/ui/toolbar/paintbucket-toolbar.h b/src/ui/toolbar/paintbucket-toolbar.h
index e8a92fbcf..ca5ba1933 100644
--- a/src/ui/toolbar/paintbucket-toolbar.h
+++ b/src/ui/toolbar/paintbucket-toolbar.h
@@ -32,10 +32,11 @@
#include <gtkmm/adjustment.h>
-class InkSelectOneAction;
class SPDesktop;
-typedef struct _GtkActionGroup GtkActionGroup;
+namespace Gtk {
+class ComboBoxText;
+}
namespace Inkscape {
namespace UI {
@@ -46,25 +47,25 @@ class UnitTracker;
namespace Toolbar {
class PaintbucketToolbar : public Toolbar {
private:
- InkSelectOneAction *_channels_action;
- InkSelectOneAction *_autogap_action;
+ Gtk::ComboBoxText *_channels_cbt;
+ Gtk::ComboBoxText *_autogap_cbt;
Glib::RefPtr<Gtk::Adjustment> _threshold_adj;
Glib::RefPtr<Gtk::Adjustment> _offset_adj;
UI::Widget::UnitTracker *_tracker;
- void channels_changed(int channels);
+ void channels_changed();
void threshold_changed();
void offset_changed();
- void autogap_changed(int autogap);
- static void defaults(GtkWidget *widget, gpointer data);
+ void autogap_changed();
+ void defaults();
protected:
PaintbucketToolbar(SPDesktop *desktop);
public:
- static GtkWidget * prep(SPDesktop *desktop, GtkActionGroup* mainActions);
+ static GtkWidget * create(SPDesktop *desktop);
};
}
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 171d6f3c9..0add85c6b 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -233,7 +233,7 @@ static struct {
{ "/tools/mesh", "mesh_toolbox", nullptr, Inkscape::UI::Toolbar::MeshToolbar::prep, "MeshToolbar",
SP_VERB_INVALID, nullptr, nullptr},
#if HAVE_POTRACE
- { "/tools/paintbucket", "paintbucket_toolbox", nullptr, Inkscape::UI::Toolbar::PaintbucketToolbar::prep, "PaintbucketToolbar",
+ { "/tools/paintbucket", "paintbucket_toolbox", Inkscape::UI::Toolbar::PaintbucketToolbar::create, nullptr, "PaintbucketToolbar",
SP_VERB_CONTEXT_PAINTBUCKET_PREFS, "/tools/paintbucket", N_("Style of Paint Bucket fill objects")},
#else
{ "/tools/paintbucket", "paintbucket_toolbox", 0, NULL, "PaintbucketToolbar", SP_VERB_NONE, "/tools/paintbucket", N_("Disabled")},