void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { EgeAdjustmentAction* eact = 0; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); { GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT ); GList* items = 0; gint count = 0; for ( items = Inkscape::UI::Tools::flood_channels_dropdown_items_list(); items ; items = g_list_next(items) ) { GtkTreeIter iter; gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, reinterpret_cast<gchar*>(items->data), 1, count, -1 ); count++; } g_list_free( items ); items = 0; EgeSelectOneAction* act1 = ege_select_one_action_new( "ChannelsAction", _("Fill by"), (""), NULL, GTK_TREE_MODEL(model) ); g_object_set( act1, "short_label", _("Fill by:"), NULL ); ege_select_one_action_set_appearance( act1, "compact" ); ege_select_one_action_set_active( act1, prefs->getInt("/tools/paintbucket/channels", 0) ); g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK(paintbucket_channels_changed), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(act1) ); g_object_set_data( holder, "channels_action", act1 ); } // 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, GTK_WIDGET(desktop->canvas), holder, TRUE, "inkscape:paintbucket-threshold", 0, 100.0, 1.0, 10.0, 0, 0, 0, paintbucket_threshold_changed, NULL /*unit tracker*/, 1, 0 ); ege_adjustment_action_set_appearance( eact, TOOLBAR_SLIDER_HINT ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } // Create the units menu. UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); Glib::ustring stored_unit = prefs->getString("/tools/paintbucket/offsetunits"); if (!stored_unit.empty()) { Unit const *u = unit_table.getUnit(stored_unit); tracker->setActiveUnit(u); } g_object_set_data( holder, "tracker", tracker ); { GtkAction* act = tracker->createAction( "PaintbucketUnitsAction", _("Units"), ("") ); gtk_action_group_add_action( mainActions, act ); } // 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, GTK_WIDGET(desktop->canvas), holder, TRUE, "inkscape:paintbucket-offset", -1e4, 1e4, 0.1, 0.5, 0, 0, 0, paintbucket_offset_changed, tracker, 1, 2); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } /* Auto Gap */ { GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT ); GList* items = 0; gint count = 0; for ( items = Inkscape::UI::Tools::flood_autogap_dropdown_items_list(); items ; items = g_list_next(items) ) { GtkTreeIter iter; gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, reinterpret_cast<gchar*>(items->data), 1, count, -1 ); count++; } g_list_free( items ); items = 0; EgeSelectOneAction* act2 = ege_select_one_action_new( "AutoGapAction", _("Close gaps"), (""), NULL, GTK_TREE_MODEL(model) ); g_object_set( act2, "short_label", _("Close gaps:"), NULL ); ege_select_one_action_set_appearance( act2, "compact" ); ege_select_one_action_set_active( act2, prefs->getBool("/tools/paintbucket/autogap") ); g_signal_connect( G_OBJECT(act2), "changed", G_CALLBACK(paintbucket_autogap_changed), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(act2) ); g_object_set_data( holder, "autogap_action", act2 ); } /* Reset */ { GtkAction* act = gtk_action_new( "PaintbucketResetAction", _("Defaults"), _("Reset paint bucket parameters to defaults (use Inkscape Preferences > Tools to change defaults)"), GTK_STOCK_CLEAR ); g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(paintbucket_defaults), holder ); gtk_action_group_add_action( mainActions, act ); gtk_action_set_sensitive( act, TRUE ); } }
void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); Unit doc_units = *sp_desktop_namedview(desktop)->doc_units; tracker->setActiveUnit(&doc_units); g_object_set_data( holder, "tracker", tracker ); Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); { InkToolMenuAction* inky = ink_tool_menu_action_new( "NodeInsertAction", _("Insert node"), _("Insert new nodes into selected segments"), INKSCAPE_ICON("node-add"), secondarySize ); g_object_set( INK_ACTION(inky), "short_label", _("Insert"), NULL ); 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 (NULL, NULL); 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", NULL, NULL, NULL) ); } { 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 ); g_object_set( inky, "short_label", _("Insert min X"), NULL ); 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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) ); } { 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 ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_transform_handles"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); } { 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 ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_handles"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); } { 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 ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_outline"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); } { Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER); InkAction* inky = 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(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); g_object_set_data( holder, "nodes_lpeedit", inky); } { 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) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_clipping_paths"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); } { 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) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_masks"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); } /* X coord of selected node(s) */ { EgeAdjustmentAction* eact = 0; gchar const* labels[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; eact = create_adjustment_action( "NodeXAction", _("X coordinate:"), _("X:"), _("X coordinate of selected node(s)"), "/tools/nodes/Xcoord", 0, GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-nodes", -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_node_path_x_value_changed, tracker ); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "nodes_x_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } /* Y coord of selected node(s) */ { EgeAdjustmentAction* eact = 0; gchar const* labels[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; eact = create_adjustment_action( "NodeYAction", _("Y coordinate:"), _("Y:"), _("Y coordinate of selected node(s)"), "/tools/nodes/Ycoord", 0, GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_node_path_y_value_changed, tracker ); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "nodes_y_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } // add the units menu { GtkAction* act = tracker->createAction( "NodeUnitsAction", _("Units"), ("") ); gtk_action_group_add_action( mainActions, act ); } sp_node_toolbox_sel_changed(sp_desktop_selection(desktop), holder); //watch selection Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISNodeToolbox"); sigc::connection *c_selection_changed = new sigc::connection (sp_desktop_selection (desktop)->connectChanged (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), holder))); pool->add_connection ("selection-changed", c_selection_changed); sigc::connection *c_selection_modified = new sigc::connection (sp_desktop_selection (desktop)->connectModified (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), holder))); pool->add_connection ("selection-modified", c_selection_modified); sigc::connection *c_subselection_changed = new sigc::connection (desktop->connectToolSubselectionChanged (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), holder))); pool->add_connection ("tool-subselection-changed", c_subselection_changed); Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); } // end of sp_node_toolbox_prep()
void sp_rect_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { EgeAdjustmentAction* eact = 0; Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); { EgeOutputAction* act = ege_output_action_new( "RectStateAction", _("<b>New:</b>"), "", 0 ); ege_output_action_set_use_markup( act, TRUE ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); g_object_set_data( holder, "mode_action", act ); } // rx/ry units menu: create UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); //tracker->addUnit( SP_UNIT_PERCENT, 0 ); // fixme: add % meaning per cent of the width/height tracker->setActiveUnit(unit_table.getUnit("px")); g_object_set_data( holder, "tracker", tracker ); /* W */ { gchar const* labels[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; eact = create_adjustment_action( "RectWidthAction", _("Width"), _("W:"), _("Width of rectangle"), "/tools/shapes/rect/width", 0, GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-rect", 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_width_value_changed, tracker); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "width_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } /* H */ { gchar const* labels[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; eact = create_adjustment_action( "RectHeightAction", _("Height"), _("H:"), _("Height of rectangle"), "/tools/shapes/rect/height", 0, GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_height_value_changed, tracker); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "height_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } /* rx */ { gchar const* labels[] = {_("not rounded"), 0, 0, 0, 0, 0, 0, 0, 0}; gdouble values[] = {0.5, 1, 2, 3, 5, 10, 20, 50, 100}; eact = create_adjustment_action( "RadiusXAction", _("Horizontal radius"), _("Rx:"), _("Horizontal radius of rounded corners"), "/tools/shapes/rect/rx", 0, GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_rx_value_changed, tracker); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } /* ry */ { gchar const* labels[] = {_("not rounded"), 0, 0, 0, 0, 0, 0, 0, 0}; gdouble values[] = {0.5, 1, 2, 3, 5, 10, 20, 50, 100}; eact = create_adjustment_action( "RadiusYAction", _("Vertical radius"), _("Ry:"), _("Vertical radius of rounded corners"), "/tools/shapes/rect/ry", 0, GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, 0, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_rtb_ry_value_changed, tracker); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } // add the units menu { GtkAction* act = tracker->createAction( "RectUnitsAction", _("Units"), ("") ); gtk_action_group_add_action( mainActions, act ); } /* Reset */ { InkAction* inky = ink_action_new( "RectResetAction", _("Not rounded"), _("Make corners sharp"), INKSCAPE_ICON("rectangle-make-corners-sharp"), secondarySize ); g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_rtb_defaults), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); gtk_action_set_sensitive( GTK_ACTION(inky), TRUE ); g_object_set_data( holder, "not_rounded", inky ); } g_object_set_data( holder, "single", GINT_TO_POINTER(TRUE) ); sp_rtb_sensitivize( holder ); desktop->connectEventContextChanged(sigc::bind(sigc::ptr_fun(rect_toolbox_watch_ec), holder)); g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); }