diff options
| author | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-04 23:17:44 +0000 |
|---|---|---|
| committer | Alexander Valavanis <valavanisalex@gmail.com> | 2019-02-04 23:17:44 +0000 |
| commit | a04d9b7aa050920b7d98beac013e94e54fc2414a (patch) | |
| tree | 1f871112bc6ac0b179c0a0fa4447907b0da67414 | |
| parent | rm unused InkRadioAction (diff) | |
| download | inkscape-a04d9b7aa050920b7d98beac013e94e54fc2414a.tar.gz inkscape-a04d9b7aa050920b7d98beac013e94e54fc2414a.zip | |
NodeToolbar: GtkAction migration
| -rw-r--r-- | share/ui/select-toolbar.ui | 44 | ||||
| -rw-r--r-- | src/ui/tool/node.h | 12 | ||||
| -rw-r--r-- | src/ui/toolbar/node-toolbar.cpp | 732 | ||||
| -rw-r--r-- | src/ui/toolbar/node-toolbar.h | 49 | ||||
| -rw-r--r-- | src/widgets/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/widgets/ink-tool-menu-action.cpp | 58 | ||||
| -rw-r--r-- | src/widgets/ink-tool-menu-action.h | 61 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 2 |
8 files changed, 413 insertions, 547 deletions
diff --git a/share/ui/select-toolbar.ui b/share/ui/select-toolbar.ui index ebc5aec0b..eeb735d76 100644 --- a/share/ui/select-toolbar.ui +++ b/share/ui/select-toolbar.ui @@ -1,46 +1,4 @@ <ui> - <toolbar name='NodeToolbar'> - <separator /> - <toolitem action='NodeInsertAction'> - <menu action='NodeInsertActionMenu'> - <menuitem action='NodeInsertActionMinX' /> - <menuitem action='NodeInsertActionMaxX' /> - <menuitem action='NodeInsertActionMinY' /> - <menuitem action='NodeInsertActionMaxY' /> - </menu> - </toolitem> - <toolitem action='NodeDeleteAction' /> - <separator /> - <toolitem action='NodeJoinAction' /> - <toolitem action='NodeBreakAction' /> - <separator /> - <toolitem action='NodeJoinSegmentAction' /> - <toolitem action='NodeDeleteSegmentAction' /> - <separator /> - <toolitem action='NodeCuspAction' /> - <toolitem action='NodeSmoothAction' /> - <toolitem action='NodeSymmetricAction' /> - <toolitem action='NodeAutoAction' /> - <separator /> - <toolitem action='NodeLineAction' /> - <toolitem action='NodeCurveAction' /> - <separator /> - <toolitem action='ObjectToPath' /> - <toolitem action='StrokeToPath' /> - <separator /> - <toolitem action='NodeXAction' /> - <toolitem action='NodeYAction' /> - <toolitem action='NodeUnitsAction' /> - <separator /> - <toolitem action='ObjectEditClipPathAction' /> - <toolitem action='ObjectEditMaskPathAction' /> - <toolitem action='EditNextPathEffectParameter' /> - <separator /> - <toolitem action='NodesShowTransformHandlesAction' /> - <toolitem action='NodesShowHandlesAction' /> - <toolitem action='NodesShowHelperpath' /> - </toolbar> - <toolbar name='SprayToolbar'> <toolitem action='SprayModeAction' /> <separator /> @@ -193,6 +151,4 @@ <toolitem action='ConnectorDirectedAction' /> <toolitem action='ConnectorOverlapAction' /> </toolbar> - </ui> - diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 26678a304..5e5249455 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -143,6 +143,8 @@ public: */ Node(NodeSharedData const &data, Geom::Point const &pos); + Node(Node const &) = delete; + void move(Geom::Point const &p) override; void transform(Geom::Affine const &m) override; Geom::Rect bounds() const override; @@ -230,7 +232,6 @@ protected: private: - Node(Node const &) = delete; void _fixNeighbors(Geom::Point const &old_pos, Geom::Point const &new_pos); void _updateAutoHandles(); @@ -313,7 +314,7 @@ public: _node = (_node?_node->ln_prev:nullptr); return *this; } - bool operator==(self const &other) const { if(&other){return _node == other._node;} else{return false;} } + bool operator==(self const &other) const { return _node == other._node; } N &operator*() const { return *static_cast<N*>(_node); } inline operator bool() const; // define after NodeList /// Get a pointer to the underlying node. Equivalent to <code>&*i</code>. @@ -364,6 +365,10 @@ public: ~NodeList(); + // no copy or assign + NodeList(NodeList const &) = delete; + void operator=(NodeList const &) = delete; + // iterators iterator begin() { return iterator(ln_next); } iterator end() { return iterator(this); } @@ -432,9 +437,6 @@ public: static NodeList &get(Node *n); static NodeList &get(iterator const &i); private: - // no copy or assign - NodeList(NodeList const &) = delete; - void operator=(NodeList const &) = delete; SubpathList &_list; bool _closed; diff --git a/src/ui/toolbar/node-toolbar.cpp b/src/ui/toolbar/node-toolbar.cpp index 7fd28185e..9aa83286a 100644 --- a/src/ui/toolbar/node-toolbar.cpp +++ b/src/ui/toolbar/node-toolbar.cpp @@ -30,42 +30,38 @@ #include <glibmm/i18n.h> #include <gtkmm/adjustment.h> +#include <gtkmm/image.h> +#include <gtkmm/menutoolbutton.h> +#include <gtkmm/separatortoolitem.h> #include "desktop.h" #include "document-undo.h" -#include "widgets/ink-toggle-action.h" -#include "widgets/ink-tool-menu-action.h" -#include "widgets/toolbox.h" #include "inkscape.h" #include "selection-chemistry.h" #include "verbs.h" +#include "helper/action.h" + #include "object/sp-namedview.h" #include "ui/icon-names.h" -#include "ui/pref-pusher.h" +#include "ui/simple-pref-pusher.h" #include "ui/tool/control-point-selection.h" #include "ui/tool/multi-path-manipulator.h" #include "ui/tools/node-tool.h" -#include "ui/widget/ink-select-one-action.h" +#include "ui/widget/combo-tool-item.h" +#include "ui/widget/spin-button-tool-item.h" #include "ui/widget/unit-tracker.h" -#include "widgets/ege-adjustment-action.h" #include "widgets/widget-sizes.h" using Inkscape::UI::Widget::UnitTracker; using Inkscape::Util::Unit; using Inkscape::Util::Quantity; using Inkscape::DocumentUndo; -using Inkscape::UI::ToolboxFactory; -using Inkscape::UI::PrefPusher; using Inkscape::Util::unit_table; using Inkscape::UI::Tools::NodeTool; -//#################################### -//# node editing callbacks -//#################################### - /** Temporary hack: Returns the node tool in the active desktop. * Will go away during tool refactoring. */ static NodeTool *get_node_tool() @@ -80,136 +76,6 @@ static NodeTool *get_node_tool() return tool; } -static void sp_node_path_edit_add() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->insertNodes(); - } -} - -static void sp_node_path_edit_add_min_x() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_X); - } -} -static void sp_node_path_edit_add_max_x() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_X); - } -} -static void sp_node_path_edit_add_min_y() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_Y); - } -} -static void sp_node_path_edit_add_max_y() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_Y); - } -} - -static void sp_node_path_edit_delete() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - nt->_multipath->deleteNodes(prefs->getBool("/tools/nodes/delete_preserves_shape", true)); - } -} - -static void sp_node_path_edit_delete_segment() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->deleteSegments(); - } -} - -static void sp_node_path_edit_break() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->breakNodes(); - } -} - -static void sp_node_path_edit_join() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->joinNodes(); - } -} - -static void sp_node_path_edit_join_segment() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->joinSegments(); - } -} - -static void sp_node_path_edit_toline() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_STRAIGHT); - } -} - -static void sp_node_path_edit_tocurve() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_CUBIC_BEZIER); - } -} - -static void sp_node_path_edit_cusp() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->setNodeType(Inkscape::UI::NODE_CUSP); - } -} - -static void sp_node_path_edit_smooth() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->setNodeType(Inkscape::UI::NODE_SMOOTH); - } -} - -static void sp_node_path_edit_symmetrical() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->setNodeType(Inkscape::UI::NODE_SYMMETRIC); - } -} - -static void sp_node_path_edit_auto() -{ - NodeTool *nt = get_node_tool(); - if (nt) { - nt->_multipath->setNodeType(Inkscape::UI::NODE_AUTO); - } -} - -static void sp_node_path_edit_nextLPEparam(GtkAction * /*act*/, gpointer data) { - sp_selection_next_patheffect_param( reinterpret_cast<SPDesktop*>(data) ); -} - namespace Inkscape { namespace UI { namespace Toolbar { @@ -218,292 +84,281 @@ NodeToolbar::NodeToolbar(SPDesktop *desktop) : Toolbar(desktop), _tracker(new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR)), _freeze(false) -{} - -GtkWidget * -NodeToolbar::prep(SPDesktop *desktop, GtkActionGroup* mainActions) { - auto holder = new NodeToolbar(desktop); - Unit doc_units = *desktop->getNamedView()->display_units; - holder->_tracker->setActiveUnit(&doc_units); + auto prefs = Inkscape::Preferences::get(); - GtkIconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); + Unit doc_units = *desktop->getNamedView()->display_units; + _tracker->setActiveUnit(&doc_units); { - InkToolMenuAction* inky = ink_tool_menu_action_new( "NodeInsertAction", - _("Insert node"), - _("Insert new nodes into selected segments"), - INKSCAPE_ICON("node-add"), - secondarySize ); - gtk_action_set_short_label(GTK_ACTION(inky), _("Insert")); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); - GtkToolItem *menu_tool_button = gtk_menu_tool_button_new (nullptr, nullptr); - gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_tool_button), GTK_ACTION(inky)); - // also create dummy menu action: - gtk_action_group_add_action( mainActions, gtk_action_new("NodeInsertActionMenu", nullptr, nullptr, nullptr) ); - } + auto insert_node_item = Gtk::manage(new Gtk::MenuToolButton()); + insert_node_item->set_icon_name(INKSCAPE_ICON("node-add")); + insert_node_item->set_label(_("Insert node")); + insert_node_item->set_tooltip_text(_("Insert new nodes into selected segments")); + insert_node_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_add)); + + auto insert_node_menu = Gtk::manage(new Gtk::Menu()); + + { + // TODO: Consider moving back to icons in menu? + //auto insert_min_x_icon = Gtk::manage(new Gtk::Image()); + //insert_min_x_icon->set_from_icon_name(INKSCAPE_ICON("node_insert_min_x"), Gtk::ICON_SIZE_MENU); + //auto insert_min_x_item = Gtk::manage(new Gtk::MenuItem(*insert_min_x_icon)); + auto insert_min_x_item = Gtk::manage(new Gtk::MenuItem(_("Insert node at min X"))); + insert_min_x_item->set_tooltip_text(_("Insert new nodes at min X into selected segments")); + insert_min_x_item->signal_activate().connect(sigc::mem_fun(*this, &NodeToolbar::edit_add_min_x)); + insert_node_menu->append(*insert_min_x_item); + } + { + //auto insert_max_x_icon = Gtk::manage(new Gtk::Image()); + //insert_max_x_icon->set_from_icon_name(INKSCAPE_ICON("node_insert_max_x"), Gtk::ICON_SIZE_MENU); + //auto insert_max_x_item = Gtk::manage(new Gtk::MenuItem(*insert_max_x_icon)); + auto insert_max_x_item = Gtk::manage(new Gtk::MenuItem(_("Insert node at max X"))); + insert_max_x_item->set_tooltip_text(_("Insert new nodes at max X into selected segments")); + insert_max_x_item->signal_activate().connect(sigc::mem_fun(*this, &NodeToolbar::edit_add_max_x)); + insert_node_menu->append(*insert_max_x_item); + } + { + //auto insert_min_y_icon = Gtk::manage(new Gtk::Image()); + //insert_min_y_icon->set_from_icon_name(INKSCAPE_ICON("node_insert_min_y"), Gtk::ICON_SIZE_MENU); + //auto insert_min_y_item = Gtk::manage(new Gtk::MenuItem(*insert_min_y_icon)); + auto insert_min_y_item = Gtk::manage(new Gtk::MenuItem(_("Insert node at min Y"))); + insert_min_y_item->set_tooltip_text(_("Insert new nodes at min Y into selected segments")); + insert_min_y_item->signal_activate().connect(sigc::mem_fun(*this, &NodeToolbar::edit_add_min_y)); + insert_node_menu->append(*insert_min_y_item); + } + { + //auto insert_max_y_icon = Gtk::manage(new Gtk::Image()); + //insert_max_y_icon->set_from_icon_name(INKSCAPE_ICON("node_insert_max_y"), Gtk::ICON_SIZE_MENU); + //auto insert_max_y_item = Gtk::manage(new Gtk::MenuItem(*insert_max_y_icon)); + auto insert_max_y_item = Gtk::manage(new Gtk::MenuItem(_("Insert node at max Y"))); + insert_max_y_item->set_tooltip_text(_("Insert new nodes at max Y into selected segments")); + insert_max_y_item->signal_activate().connect(sigc::mem_fun(*this, &NodeToolbar::edit_add_max_y)); + insert_node_menu->append(*insert_max_y_item); + } - { - InkAction* inky = ink_action_new( "NodeInsertActionMinX", - _("Insert node at min X"), - _("Insert new nodes at min X into selected segments"), - INKSCAPE_ICON("node_insert_min_x"), - secondarySize ); - gtk_action_set_short_label( GTK_ACTION(inky), _("Insert min X")); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_min_x), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); - } - { - InkAction* inky = ink_action_new( "NodeInsertActionMaxX", - _("Insert node at max X"), - _("Insert new nodes at max X into selected segments"), - INKSCAPE_ICON("node_insert_max_x"), - secondarySize ); - g_object_set( inky, "short_label", _("Insert max X"), NULL ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_max_x), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + insert_node_menu->show_all(); + insert_node_item->set_menu(*insert_node_menu); + add(*insert_node_item); } + { - InkAction* inky = ink_action_new( "NodeInsertActionMinY", - _("Insert node at min Y"), - _("Insert new nodes at min Y into selected segments"), - INKSCAPE_ICON("node_insert_min_y"), - secondarySize ); - g_object_set( inky, "short_label", _("Insert min Y"), NULL ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_min_y), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto delete_item = Gtk::manage(new Gtk::ToolButton(_("Delete node"))); + delete_item->set_tooltip_text(_("Delete selected nodes")); + delete_item->set_icon_name(INKSCAPE_ICON("node-delete")); + delete_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_delete)); + add(*delete_item); } + + add(* Gtk::manage(new Gtk::SeparatorToolItem())); + { - InkAction* inky = ink_action_new( "NodeInsertActionMaxY", - _("Insert node at max Y"), - _("Insert new nodes at max Y into selected segments"), - INKSCAPE_ICON("node_insert_max_y"), - secondarySize ); - g_object_set( inky, "short_label", _("Insert max Y"), NULL ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_max_y), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto join_item = Gtk::manage(new Gtk::ToolButton(_("Join nodes"))); + join_item->set_tooltip_text(_("Join selected nodes")); + join_item->set_icon_name(INKSCAPE_ICON("node-join")); + join_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_join)); + add(*join_item); } { - InkAction* inky = ink_action_new( "NodeDeleteAction", - _("Delete node"), - _("Delete selected nodes"), - INKSCAPE_ICON("node-delete"), - secondarySize ); - g_object_set( inky, "short_label", _("Delete"), NULL ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto break_item = Gtk::manage(new Gtk::ToolButton(_("Break nodes"))); + break_item->set_tooltip_text(_("Break path at selected nodes")); + break_item->set_icon_name(INKSCAPE_ICON("node-break")); + break_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_break)); + add(*break_item); } + add(* Gtk::manage(new Gtk::SeparatorToolItem())); + { - InkAction* inky = ink_action_new( "NodeJoinAction", - _("Join nodes"), - _("Join selected nodes"), - INKSCAPE_ICON("node-join"), - secondarySize ); - g_object_set( inky, "short_label", _("Join"), NULL ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto join_segment_item = Gtk::manage(new Gtk::ToolButton(_("Join with segment"))); + join_segment_item->set_tooltip_text(_("Join selected endnodes with a new segment")); + join_segment_item->set_icon_name(INKSCAPE_ICON("node-join-segment")); + join_segment_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_join_segment)); + add(*join_segment_item); } { - InkAction* inky = ink_action_new( "NodeBreakAction", - _("Break nodes"), - _("Break path at selected nodes"), - INKSCAPE_ICON("node-break"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_break), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto delete_segment_item = Gtk::manage(new Gtk::ToolButton(_("Delete segment"))); + delete_segment_item->set_tooltip_text(_("Delete segment between two non-endpoint nodes")); + delete_segment_item->set_icon_name(INKSCAPE_ICON("node-delete-segment")); + delete_segment_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_delete_segment)); + add(*delete_segment_item); } + add(* Gtk::manage(new Gtk::SeparatorToolItem())); { - InkAction* inky = ink_action_new( "NodeJoinSegmentAction", - _("Join with segment"), - _("Join selected endnodes with a new segment"), - INKSCAPE_ICON("node-join-segment"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join_segment), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto cusp_item = Gtk::manage(new Gtk::ToolButton(_("Node Cusp"))); + cusp_item->set_tooltip_text(_("Make selected nodes corner")); + cusp_item->set_icon_name(INKSCAPE_ICON("node-type-cusp")); + cusp_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_cusp)); + add(*cusp_item); } { - InkAction* inky = ink_action_new( "NodeDeleteSegmentAction", - _("Delete segment"), - _("Delete segment between two non-endpoint nodes"), - INKSCAPE_ICON("node-delete-segment"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete_segment), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto smooth_item = Gtk::manage(new Gtk::ToolButton(_("Node Smooth"))); + smooth_item->set_tooltip_text(_("Make selected nodes smooth")); + smooth_item->set_icon_name(INKSCAPE_ICON("node-type-smooth")); + smooth_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_smooth)); + add(*smooth_item); } { - InkAction* inky = ink_action_new( "NodeCuspAction", - _("Node Cusp"), - _("Make selected nodes corner"), - INKSCAPE_ICON("node-type-cusp"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_cusp), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto symmetric_item = Gtk::manage(new Gtk::ToolButton(_("Node Symmetric"))); + symmetric_item->set_tooltip_text(_("Make selected nodes symmetric")); + symmetric_item->set_icon_name(INKSCAPE_ICON("node-type-symmetric")); + symmetric_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_symmetrical)); + add(*symmetric_item); } { - InkAction* inky = ink_action_new( "NodeSmoothAction", - _("Node Smooth"), - _("Make selected nodes smooth"), - INKSCAPE_ICON("node-type-smooth"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_smooth), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto auto_item = Gtk::manage(new Gtk::ToolButton(_("Node Auto"))); + auto_item->set_tooltip_text(_("Make selected nodes auto-smooth")); + auto_item->set_icon_name(INKSCAPE_ICON("node-type-auto-smooth")); + auto_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_auto)); + add(*auto_item); } + add(* Gtk::manage(new Gtk::SeparatorToolItem())); + { - InkAction* inky = ink_action_new( "NodeSymmetricAction", - _("Node Symmetric"), - _("Make selected nodes symmetric"), - INKSCAPE_ICON("node-type-symmetric"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_symmetrical), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto line_item = Gtk::manage(new Gtk::ToolButton(_("Node Line"))); + line_item->set_tooltip_text(_("Make selected segments lines")); + line_item->set_icon_name(INKSCAPE_ICON("node-segment-line")); + line_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_toline)); + add(*line_item); } { - InkAction* inky = ink_action_new( "NodeAutoAction", - _("Node Auto"), - _("Make selected nodes auto-smooth"), - INKSCAPE_ICON("node-type-auto-smooth"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_auto), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto curve_item = Gtk::manage(new Gtk::ToolButton(_("Node Curve"))); + curve_item->set_tooltip_text(_("Make selected segments curves")); + curve_item->set_icon_name(INKSCAPE_ICON("node-segment-curve")); + curve_item->signal_clicked().connect(sigc::mem_fun(*this, &NodeToolbar::edit_tocurve)); + add(*curve_item); } + add(* Gtk::manage(new Gtk::SeparatorToolItem())); + + auto context = Inkscape::ActionContext(_desktop); + { - InkAction* inky = ink_action_new( "NodeLineAction", - _("Node Line"), - _("Make selected segments lines"), - INKSCAPE_ICON("node-segment-line"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_toline), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto object_to_path_item = SPAction::create_toolbutton_for_verb(SP_VERB_OBJECT_TO_CURVE, context); + add(*object_to_path_item); } { - InkAction* inky = ink_action_new( "NodeCurveAction", - _("Node Curve"), - _("Make selected segments curves"), - INKSCAPE_ICON("node-segment-curve"), - secondarySize ); - g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_tocurve), 0 ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + auto stroke_to_path_item = SPAction::create_toolbutton_for_verb(SP_VERB_SELECTION_OUTLINE, context); + add(*stroke_to_path_item); } + add(* Gtk::manage(new Gtk::SeparatorToolItem())); + + /* X coord of selected node(s) */ { - InkToggleAction* act = ink_toggle_action_new( "NodesShowTransformHandlesAction", - _("Show Transform Handles"), - _("Show transformation handles for selected nodes"), - "node-transform", - secondarySize ); - gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); - holder->_pusher_show_transform_handles.reset(new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_transform_handles")); + std::vector<double> values = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; + auto nodes_x_val = prefs->getDouble("/tools/nodes/Xcoord", 0); + _nodes_x_adj = Gtk::Adjustment::create(nodes_x_val, -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP); + _nodes_x_item = Gtk::manage(new UI::Widget::SpinButtonToolItem("node-x", _("X:"), _nodes_x_adj)); + _nodes_x_item->set_tooltip_text(_("X coordinate of selected node(s)")); + _nodes_x_item->set_custom_numeric_menu_data(values); + _tracker->addAdjustment(_nodes_x_adj->gobj()); + _nodes_x_item->set_focus_widget(Glib::wrap(GTK_WIDGET(desktop->canvas))); + _nodes_x_adj->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &NodeToolbar::value_changed), Geom::X)); + _nodes_x_item->set_sensitive(false); + add(*_nodes_x_item); } + /* Y coord of selected node(s) */ { - InkToggleAction* act = ink_toggle_action_new( "NodesShowHandlesAction", - _("Show Handles"), - _("Show Bezier handles of selected nodes"), - INKSCAPE_ICON("show-node-handles"), - secondarySize ); - gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); - holder->_pusher_show_handles.reset(new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_handles")); + std::vector<double> values = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; + auto nodes_y_val = prefs->getDouble("/tools/nodes/Ycoord", 0); + _nodes_y_adj = Gtk::Adjustment::create(nodes_y_val, -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP); + _nodes_y_item = Gtk::manage(new UI::Widget::SpinButtonToolItem("node-y", _("Y:"), _nodes_y_adj)); + _nodes_y_item->set_tooltip_text(_("Y coordinate of selected node(s)")); + _nodes_y_item->set_custom_numeric_menu_data(values); + _tracker->addAdjustment(_nodes_y_adj->gobj()); + _nodes_y_item->set_focus_widget(Glib::wrap(GTK_WIDGET(desktop->canvas))); + _nodes_y_adj->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*this, &NodeToolbar::value_changed), Geom::Y)); + _nodes_y_item->set_sensitive(false); + add(*_nodes_y_item); } + // add the units menu { - InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath", - _("Show Outline"), - _("Show path outline (without path effects)"), - INKSCAPE_ICON("show-path-outline"), - secondarySize ); - gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); - holder->_pusher_show_outline.reset(new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_outline")); + auto unit_menu = _tracker->create_tool_item(_("Units"), ("")); + add(*unit_menu); } + add(* Gtk::manage(new Gtk::SeparatorToolItem())); + { - Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER); - holder->_nodes_lpeedit = ink_action_new( verb->get_id(), - verb->get_name(), - verb->get_tip(), - INKSCAPE_ICON("path-effect-parameter-next"), - secondarySize ); - g_signal_connect_after( G_OBJECT(holder->_nodes_lpeedit), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop ); - gtk_action_group_add_action( mainActions, GTK_ACTION(holder->_nodes_lpeedit) ); + _object_edit_clip_path_item = add_toggle_button(_("Edit clipping paths"), + _("Show clipping path(s) of selected object(s)")); + _object_edit_clip_path_item->set_icon_name(INKSCAPE_ICON("path-clip-edit")); + _pusher_edit_clipping_paths.reset(new SimplePrefPusher(_object_edit_clip_path_item, "/tools/nodes/edit_clipping_paths")); + _object_edit_clip_path_item->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &NodeToolbar::on_pref_toggled), + _object_edit_clip_path_item, + "/tools/nodes/edit_clipping_paths")); } { - InkToggleAction* inky = ink_toggle_action_new( "ObjectEditClipPathAction", - _("Edit clipping paths"), - _("Show clipping path(s) of selected object(s)"), - INKSCAPE_ICON("path-clip-edit"), - secondarySize ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); - holder->_pusher_edit_clipping_paths.reset(new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_clipping_paths")); + _object_edit_mask_path_item = add_toggle_button(_("Edit masks"), + _("Show mask(s) of selected object(s)")); + _object_edit_mask_path_item->set_icon_name(INKSCAPE_ICON("path-mask-edit")); + _pusher_edit_masks.reset(new SimplePrefPusher(_object_edit_mask_path_item, "/tools/nodes/edit_masks")); + _object_edit_mask_path_item->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &NodeToolbar::on_pref_toggled), + _object_edit_mask_path_item, + "/tools/nodes/edit_masks")); } { - InkToggleAction* inky = ink_toggle_action_new( "ObjectEditMaskPathAction", - _("Edit masks"), - _("Show mask(s) of selected object(s)"), - INKSCAPE_ICON("path-mask-edit"), - secondarySize ); - gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); - holder->_pusher_edit_masks.reset(new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_masks")); + _nodes_lpeedit_item = SPAction::create_toolbutton_for_verb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, context); + add(*_nodes_lpeedit_item); } - /* X coord of selected node(s) */ + add(* Gtk::manage(new Gtk::SeparatorToolItem())); + { - gchar const* labels[] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; - gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; - holder->_nodes_x_action = create_adjustment_action( "NodeXAction", - _("X coordinate:"), _("X:"), _("X coordinate of selected node(s)"), - "/tools/nodes/Xcoord", 0, - TRUE, "altx-nodes", - -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, - labels, values, G_N_ELEMENTS(labels), - holder->_tracker.get() ); - ege_adjustment_action_set_focuswidget(holder->_nodes_x_action, GTK_WIDGET(desktop->canvas)); - holder->_nodes_x_adj = Glib::wrap(ege_adjustment_action_get_adjustment(holder->_nodes_x_action)); - holder->_nodes_x_adj->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*holder, &NodeToolbar::value_changed), Geom::X)); - gtk_action_set_sensitive( GTK_ACTION(holder->_nodes_x_action), FALSE ); - gtk_action_group_add_action( mainActions, GTK_ACTION(holder->_nodes_x_action) ); + _show_transform_handles_item = add_toggle_button(_("Show Transform Handles"), + _("Show transformation handles for selected nodes")); + _show_transform_handles_item->set_icon_name(INKSCAPE_ICON("node-transform")); + _pusher_show_transform_handles.reset(new UI::SimplePrefPusher(_show_transform_handles_item, "/tools/nodes/show_transform_handles")); + _show_transform_handles_item->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &NodeToolbar::on_pref_toggled), + _show_transform_handles_item, + "/tools/nodes/show_transform_handles")); } - /* Y coord of selected node(s) */ { - gchar const* labels[] = {nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr}; - gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; - holder->_nodes_y_action = create_adjustment_action( "NodeYAction", - _("Y coordinate:"), _("Y:"), _("Y coordinate of selected node(s)"), - "/tools/nodes/Ycoord", 0, - FALSE, nullptr, - -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, - labels, values, G_N_ELEMENTS(labels), - holder->_tracker.get() ); - ege_adjustment_action_set_focuswidget(holder->_nodes_y_action, GTK_WIDGET(desktop->canvas)); - holder->_nodes_y_adj = Glib::wrap(ege_adjustment_action_get_adjustment(holder->_nodes_y_action)); - holder->_nodes_y_adj->signal_value_changed().connect(sigc::bind(sigc::mem_fun(*holder, &NodeToolbar::value_changed), Geom::Y)); - gtk_action_set_sensitive( GTK_ACTION(holder->_nodes_y_action), FALSE ); - gtk_action_group_add_action( mainActions, GTK_ACTION(holder->_nodes_y_action) ); + _show_handles_item = add_toggle_button(_("Show Handles"), + _("Show Bezier handles of selected nodes")); + _show_handles_item->set_icon_name(INKSCAPE_ICON("show-node-handles")); + _pusher_show_handles.reset(new UI::SimplePrefPusher(_show_handles_item, "/tools/nodes/show_handles")); + _show_handles_item->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &NodeToolbar::on_pref_toggled), + _show_handles_item, + "/tools/nodes/show_handles")); } - // add the units menu { - InkSelectOneAction* act = holder->_tracker->createAction( "NodeUnitsAction", _("Units"), ("") ); - gtk_action_group_add_action( mainActions, act->gobj() ); + _show_helper_path_item = add_toggle_button(_("Show Outline"), + _("Show path outline (without path effects)")); + _show_helper_path_item->set_icon_name(INKSCAPE_ICON("show-path-outline")); + _pusher_show_outline.reset(new UI::SimplePrefPusher(_show_helper_path_item, "/tools/nodes/show_outline")); + _show_helper_path_item->signal_toggled().connect(sigc::bind(sigc::mem_fun(*this, &NodeToolbar::on_pref_toggled), + _show_helper_path_item, + "/tools/nodes/show_outline")); } - holder->sel_changed(desktop->getSelection()); - desktop->connectEventContextChanged(sigc::mem_fun(*holder, &NodeToolbar::watch_ec)); + sel_changed(desktop->getSelection()); + desktop->connectEventContextChanged(sigc::mem_fun(*this, &NodeToolbar::watch_ec)); + show_all(); +} + +GtkWidget * +NodeToolbar::create(SPDesktop *desktop) +{ + auto holder = new NodeToolbar(desktop); return GTK_WIDGET(holder->gobj()); } // NodeToolbar::prep() @@ -551,12 +406,12 @@ NodeToolbar::sel_changed(Inkscape::Selection *selection) SPItem *item = selection->singleItem(); if (item && SP_IS_LPE_ITEM(item)) { if (SP_LPE_ITEM(item)->hasPathEffect()) { - gtk_action_set_sensitive(GTK_ACTION(_nodes_lpeedit), TRUE); + _nodes_lpeedit_item->set_sensitive(true); } else { - gtk_action_set_sensitive(GTK_ACTION(_nodes_lpeedit), FALSE); + _nodes_lpeedit_item->set_sensitive(false); } } else { - gtk_action_set_sensitive(GTK_ACTION(_nodes_lpeedit), FALSE); + _nodes_lpeedit_item->set_sensitive(false); } } @@ -607,11 +462,11 @@ NodeToolbar::coord_changed(gpointer /*shape_editor*/) NodeTool *nt = get_node_tool(); if (!nt || !(nt->_selected_nodes) ||nt->_selected_nodes->empty()) { // no path selected - gtk_action_set_sensitive(GTK_ACTION(_nodes_x_action), FALSE); - gtk_action_set_sensitive(GTK_ACTION(_nodes_y_action), FALSE); + _nodes_x_item->set_sensitive(false); + _nodes_y_item->set_sensitive(false); } else { - gtk_action_set_sensitive(GTK_ACTION(_nodes_x_action), TRUE); - gtk_action_set_sensitive(GTK_ACTION(_nodes_y_action), TRUE); + _nodes_x_item->set_sensitive(true); + _nodes_y_item->set_sensitive(true); Geom::Coord oldx = Quantity::convert(_nodes_x_adj->get_value(), unit, "px"); Geom::Coord oldy = Quantity::convert(_nodes_y_adj->get_value(), unit, "px"); Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint(); @@ -627,6 +482,159 @@ NodeToolbar::coord_changed(gpointer /*shape_editor*/) _freeze = false; } +void +NodeToolbar::edit_add() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodes(); + } +} + +void +NodeToolbar::edit_add_min_x() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_X); + } +} + +void +NodeToolbar::edit_add_max_x() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_X); + } +} + +void +NodeToolbar::edit_add_min_y() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_Y); + } +} + +void +NodeToolbar::edit_add_max_y() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_Y); + } +} + +void +NodeToolbar::edit_delete() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + nt->_multipath->deleteNodes(prefs->getBool("/tools/nodes/delete_preserves_shape", true)); + } +} + +void +NodeToolbar::edit_join() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->joinNodes(); + } +} + +void +NodeToolbar::edit_break() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->breakNodes(); + } +} + +void +NodeToolbar::edit_delete_segment() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->deleteSegments(); + } +} + +void +NodeToolbar::edit_join_segment() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->joinSegments(); + } +} + +void +NodeToolbar::edit_cusp() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_CUSP); + } +} + +void +NodeToolbar::edit_smooth() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_SMOOTH); + } +} + +void +NodeToolbar::edit_symmetrical() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_SYMMETRIC); + } +} + +void +NodeToolbar::edit_auto() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_AUTO); + } +} + +void +NodeToolbar::edit_toline() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_STRAIGHT); + } +} + +void +NodeToolbar::edit_tocurve() +{ + NodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_CUBIC_BEZIER); + } +} + +void +NodeToolbar::on_pref_toggled(Gtk::ToggleToolButton *item, + const Glib::ustring& path) +{ + auto prefs = Inkscape::Preferences::get(); + prefs->setBool(path, item->get_active()); +} + } } } diff --git a/src/ui/toolbar/node-toolbar.h b/src/ui/toolbar/node-toolbar.h index f688173b6..fc603cbf5 100644 --- a/src/ui/toolbar/node-toolbar.h +++ b/src/ui/toolbar/node-toolbar.h @@ -33,21 +33,18 @@ class SPDesktop; -typedef struct _EgeAdjustmentAction EgeAdjustmentAction; -typedef struct _GtkActionGroup GtkActionGroup; -typedef struct _InkAction InkAction; - namespace Inkscape { class Selection; namespace UI { -class PrefPusher; +class SimplePrefPusher; namespace Tools { class ToolBase; } namespace Widget { +class SpinButtonToolItem; class UnitTracker; } @@ -56,16 +53,22 @@ class NodeToolbar : public Toolbar { private: std::unique_ptr<UI::Widget::UnitTracker> _tracker; - std::unique_ptr<PrefPusher> _pusher_show_transform_handles; - std::unique_ptr<PrefPusher> _pusher_show_handles; - std::unique_ptr<PrefPusher> _pusher_show_outline; - std::unique_ptr<PrefPusher> _pusher_edit_clipping_paths; - std::unique_ptr<PrefPusher> _pusher_edit_masks; + std::unique_ptr<UI::SimplePrefPusher> _pusher_show_transform_handles; + std::unique_ptr<UI::SimplePrefPusher> _pusher_show_handles; + std::unique_ptr<UI::SimplePrefPusher> _pusher_show_outline; + std::unique_ptr<UI::SimplePrefPusher> _pusher_edit_clipping_paths; + std::unique_ptr<UI::SimplePrefPusher> _pusher_edit_masks; + + Gtk::ToggleToolButton *_object_edit_clip_path_item; + Gtk::ToggleToolButton *_object_edit_mask_path_item; + Gtk::ToggleToolButton *_show_transform_handles_item; + Gtk::ToggleToolButton *_show_handles_item; + Gtk::ToggleToolButton *_show_helper_path_item; - InkAction *_nodes_lpeedit; + Gtk::ToolButton *_nodes_lpeedit_item; - EgeAdjustmentAction *_nodes_x_action; - EgeAdjustmentAction *_nodes_y_action; + UI::Widget::SpinButtonToolItem *_nodes_x_item; + UI::Widget::SpinButtonToolItem *_nodes_y_item; Glib::RefPtr<Gtk::Adjustment> _nodes_x_adj; Glib::RefPtr<Gtk::Adjustment> _nodes_y_adj; @@ -81,12 +84,30 @@ private: void sel_modified(Inkscape::Selection *selection, guint /*flags*/); void coord_changed(gpointer shape_editor); void watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec); + void edit_add(); + void edit_add_min_x(); + void edit_add_max_x(); + void edit_add_min_y(); + void edit_add_max_y(); + void edit_delete(); + void edit_join(); + void edit_break(); + void edit_join_segment(); + void edit_delete_segment(); + void edit_cusp(); + void edit_smooth(); + void edit_symmetrical(); + void edit_auto(); + void edit_toline(); + void edit_tocurve(); + void on_pref_toggled(Gtk::ToggleToolButton *item, + const Glib::ustring& path); protected: NodeToolbar(SPDesktop *desktop); public: - static GtkWidget * prep(SPDesktop *desktop, GtkActionGroup* mainActions); + static GtkWidget * create(SPDesktop *desktop); }; } } diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 2bdc67485..c6dad3f1a 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -12,7 +12,6 @@ set(widgets_SRC ink-action.cpp ink-comboboxentry-action.cpp ink-toggle-action.cpp - ink-tool-menu-action.cpp paint-selector.cpp sp-attribute-widget.cpp sp-color-selector.cpp @@ -37,7 +36,6 @@ set(widgets_SRC ink-action.h ink-comboboxentry-action.h ink-toggle-action.h - ink-tool-menu-action.h paint-selector.h sp-attribute-widget.h sp-color-selector.h diff --git a/src/widgets/ink-tool-menu-action.cpp b/src/widgets/ink-tool-menu-action.cpp deleted file mode 100644 index 667f074cc..000000000 --- a/src/widgets/ink-tool-menu-action.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** @file - * TODO: insert short description here - *//* - * Authors: see git history - * - * Copyright (C) 2018 Authors - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ -#include "ink-tool-menu-action.h" - -// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 - -G_DEFINE_TYPE(InkToolMenuAction, ink_tool_menu_action, INK_ACTION_TYPE); - -static void -ink_tool_menu_action_class_init (InkToolMenuActionClass *klass) -{ - GtkActionClass *action_class = GTK_ACTION_CLASS (klass); - action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON; -} - -static void -ink_tool_menu_action_init (InkToolMenuAction* /*tma*/) -{ -} - -InkToolMenuAction * -ink_tool_menu_action_new (const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - GtkIconSize size ) -{ - g_return_val_if_fail (name != nullptr, NULL); - - GObject* obj = (GObject*)g_object_new( INK_TOOL_MENU_ACTION_TYPE, - "name", name, - "label", label, - "tooltip", tooltip, - "iconId", inkId, - "iconSize", size, - NULL ); - - InkToolMenuAction* action = INK_TOOL_MENU_ACTION( obj ); - - return 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/ink-tool-menu-action.h b/src/widgets/ink-tool-menu-action.h deleted file mode 100644 index 58e1974d1..000000000 --- a/src/widgets/ink-tool-menu-action.h +++ /dev/null @@ -1,61 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/** @file - * TODO: insert short description here - *//* - * Authors: see git history - * - * Copyright (C) 2017 Authors - * Released under GNU GPL v2+, read the file 'COPYING' for more information. - */ -#ifndef INK_TOOL_MENU_ACTION_H -#define INK_TOOL_MENU_ACTION_H - -#include "ink-action.h" - -// ToolMenu Action is happily derived from http://www.gtkforums.com/viewtopic.php?t=4215 - -G_BEGIN_DECLS - -#define INK_TOOL_MENU_ACTION_TYPE ( ink_tool_menu_action_get_type() ) -#define INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_CAST( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuAction) ) -#define INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_CAST( (klass), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) -#define IS_INK_TOOL_MENU_ACTION( obj ) ( G_TYPE_CHECK_INSTANCE_TYPE( (obj), INK_TOOL_MENU_ACTION_TYPE) ) -#define IS_INK_TOOL_MENU_ACTION_CLASS( klass ) ( G_TYPE_CHECK_CLASS_TYPE( (klass), INK_TOOL_MENU_ACTION_TYPE) ) -#define INK_TOOL_MENU_ACTION_GET_CLASS( obj ) ( G_TYPE_INSTANCE_GET_CLASS( (obj), INK_TOOL_MENU_ACTION_TYPE, InkToolMenuActionClass) ) - -typedef struct _InkToolMenuAction InkToolMenuAction; -typedef struct _InkToolMenuActionClass InkToolMenuActionClass; -typedef struct _InkToolMenuActionPrivate InkToolMenuActionPrivate; - -struct _InkToolMenuAction -{ - InkAction action; -}; - -struct _InkToolMenuActionClass -{ - InkActionClass parent_class; -}; - -GType ink_tool_menu_action_get_type( void ); - -InkToolMenuAction* ink_tool_menu_action_new( const gchar *name, - const gchar *label, - const gchar *tooltip, - const gchar *inkId, - GtkIconSize size ); - -G_END_DECLS - -#endif // INK_TOOL_MENU_ACTION_H - -/* - 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/toolbox.cpp b/src/widgets/toolbox.cpp index f4ffbbaf0..2de668561 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -191,7 +191,7 @@ static struct { } const aux_toolboxes[] = { { "/tools/select", "select_toolbox", Inkscape::UI::Toolbar::SelectToolbar::create, nullptr, "SelectToolbar", SP_VERB_INVALID, nullptr, nullptr}, - { "/tools/nodes", "node_toolbox", nullptr, Inkscape::UI::Toolbar::NodeToolbar::prep, "NodeToolbar", + { "/tools/nodes", "node_toolbox", Inkscape::UI::Toolbar::NodeToolbar::create, nullptr, "NodeToolbar", SP_VERB_INVALID, nullptr, nullptr}, { "/tools/tweak", "tweak_toolbox", Inkscape::UI::Toolbar::TweakToolbar::create, nullptr, "TweakToolbar", SP_VERB_CONTEXT_TWEAK_PREFS, "/tools/tweak", N_("Color/opacity used for color tweaking")}, |
