Code

Implement a preference that determines whether deleting nodes
authorKrzysztof Kosiński <tweenk.pl@gmail.com>
Tue, 2 Mar 2010 23:22:31 +0000 (00:22 +0100)
committerKrzysztof Kosiński <tweenk.pl@gmail.com>
Tue, 2 Mar 2010 23:22:31 +0000 (00:22 +0100)
preserves the shape

src/ui/dialog/inkscape-preferences.cpp
src/ui/dialog/inkscape-preferences.h
src/ui/tool/multi-path-manipulator.cpp
src/widgets/toolbox.cpp

index 82bca9da0dcecb064841f5bbcaff8398d915fe6e..40efc82827befebeead7b5cc58cca8da85c9afb3 100644 (file)
@@ -433,7 +433,7 @@ void InkscapePreferences::initPageTools()
     this->AddPage(_page_node, _("Node"), iter_tools, PREFS_PAGE_TOOLS_NODE);
     AddSelcueCheckbox(_page_node, "/tools/nodes", true);
     AddGradientCheckbox(_page_node, "/tools/nodes", true);
-    _page_node.add_group_header( _("Path outline:"));
+    _page_node.add_group_header( _("Path outline"));
     _t_node_pathoutline_color.init(_("Path outline color"), "/tools/nodes/highlight_color", 0xff0000ff);
     _page_node.add_line( false, "", _t_node_pathoutline_color, "", _("Selects the color used for showing the path outline."), false);
     _t_node_show_outline.init(_("Always show outline"), "/tools/nodes/show_outline", false);
@@ -450,9 +450,11 @@ void InkscapePreferences::initPageTools()
     _page_node.add_line( true, "", _t_node_pathflash_selected, "", _("Show temporary outline even when a path is selected for editing"));
     _t_node_pathflash_timeout.init("/tools/nodes/pathflash_timeout", 0, 10000.0, 100.0, 100.0, 1000.0, true, false);
     _page_node.add_line( false, _("Flash time"), _t_node_pathflash_timeout, "ms", _("Specifies how long the path outline will be visible after a mouse-over (in milliseconds). Specify 0 to have the outline shown until mouse leaves the path."), false);
-    _page_node.add_group_header(_("Transform Handles:"));
+    _page_node.add_group_header(_("Editing preferences"));
     _t_node_single_node_transform_handles.init(_("Show transform handles for single nodes"), "/tools/nodes/single_node_transform_handles", false);
     _page_node.add_line( true, "", _t_node_single_node_transform_handles, "", _("Show transform handles even when only a single node is selected."));
+    _t_node_delete_preserves_shape.init(_("Deleting nodes preserves shape"), "/tools/nodes/delete_preserves_shape", true);
+    _page_node.add_line( true, "", _t_node_delete_preserves_shape, "", _("Move handles next to deleted nodes to resemble original shape. Hold Ctrl to get the other behavior."));
 
     //Tweak
     this->AddPage(_page_tweak, _("Tweak"), iter_tools, PREFS_PAGE_TOOLS_TWEAK);
index e3f76b753492d48b145ea6632a0b86da80fb6000..0ba8c965d4ebfa26bed947cbc3d431c2d393944f 100644 (file)
@@ -149,6 +149,7 @@ protected:
     PrefSpinButton  _t_node_pathflash_timeout;
     PrefCheckButton _t_node_show_path_direction;
     PrefCheckButton _t_node_single_node_transform_handles;
+    PrefCheckButton _t_node_delete_preserves_shape;
     PrefColorPicker _t_node_pathoutline_color;
 
     PrefRadioButton _win_dockable, _win_floating;
index f5646ac36c81f6b1777fb9c3b22beba44c88df96..3b0852e6e6842e4f9f7befcf429ba0a04dc95c85 100644 (file)
@@ -466,9 +466,13 @@ bool MultiPathManipulator::event(GdkEvent *event)
                 // Alt+Delete - delete segments
                 deleteSegments();
             } else {
-                // Control+Delete - delete nodes
-                // Delete - delete nodes preserving shape
-                deleteNodes(!held_control(event->key));
+                Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+                bool del_preserves_shape = prefs->getBool("/tools/nodes/delete_preserves_shape", true);
+                // pass keep_shape = true when:
+                // a) del preserves shape, and control is not pressed
+                // b) ctrl+del preserves shape (del_preserves_shape is false), and control is pressed
+                // Hence xor
+                deleteNodes(del_preserves_shape ^ held_control(event->key));
             }
             return true;
         case GDK_c:
index f81702f4f9c04841276767e1dbee2cac4a3265e9..8b12a7a5ee8ed70c2e72ea784a3fc08835f71f98 100644 (file)
@@ -1043,7 +1043,8 @@ sp_node_path_edit_delete(void)
 {
     InkNodeTool *nt = get_node_tool();
     if (nt) {
-        nt->_multipath->deleteNodes();
+        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+        nt->_multipath->deleteNodes(prefs->getBool("/tools/nodes/delete_preserves_shape", true));
     }
 }
 
@@ -7645,8 +7646,7 @@ static void sp_connector_toolbox_prep( SPDesktop *desktop, GtkActionGroup* mainA
         gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act), ( tbuttonstate ? TRUE : FALSE ));
 
         g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_directed_graph_layout_toggled), holder );
-        sigc::connection *connection = new sigc::connection(sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_connector_toolbox_selection_changed), (GObject *)holder))
-        );
+        sp_desktop_selection(desktop)->connectChanged(sigc::bind(sigc::ptr_fun(sp_connector_toolbox_selection_changed), (GObject *)holder));
     }
 
     // Avoid overlaps toggle button