Code

r11516@tres: ted | 2006-04-26 21:30:18 -0700
[inkscape.git] / src / node-context.cpp
index 72117c462a295f8607f0fd5d6f53d1fefcea884c..67511ea30e83c3e0a4f4445e3c9da1fdc5084608 100644 (file)
@@ -159,9 +159,9 @@ sp_node_context_setup(SPEventContext *ec)
         ((SPEventContextClass *) parent_class)->setup(ec);
 
     nc->sel_changed_connection.disconnect();
-    nc->sel_changed_connection = SP_DT_SELECTION(ec->desktop)->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc));
+    nc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc));
 
-    Inkscape::Selection *selection = SP_DT_SELECTION(ec->desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
     SPItem *item = selection->singleItem();
 
     nc->nodepath = NULL;
@@ -288,7 +288,7 @@ sp_nodepath_update_from_item(SPNodeContext *nc, SPItem *item)
         ec->shape_knot_holder = NULL;
     }
 
-    Inkscape::Selection *selection = SP_DT_SELECTION(desktop);
+    Inkscape::Selection *selection = sp_desktop_selection(desktop);
     item = selection->singleItem();
 
     if (item) {
@@ -310,7 +310,6 @@ nodepath_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name,
                             bool is_interactive, gpointer data)
 {
     SPItem *item = NULL;
-    char const *newd = NULL, *newtypestr = NULL;
     gboolean changed = FALSE;
 
     g_assert(data);
@@ -322,21 +321,18 @@ nodepath_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name,
 
     if (np) {
         item = SP_ITEM(np->path);
-        if (!strcmp(name, "d")) {
-            newd = new_value;
-            changed = nodepath_repr_d_changed(np, new_value);
-        } else if (!strcmp(name, "sodipodi:nodetypes")) {
-            newtypestr = new_value;
-            changed = nodepath_repr_typestr_changed(np, new_value);
-        } else {
-            return;
-            // With paths, we only need to act if one of the path-affecting attributes has changed.
+        if (!strcmp(name, "d") || !strcmp(name, "sodipodi:nodetypes")) { // With paths, we only need to act if one of the path-affecting attributes has changed.
+            changed = (np->local_change == 0);
+            if (np->local_change > 0)
+                np->local_change--;
         }
+
     } else if (kh) {
         item = SP_ITEM(kh->item);
         changed = !(kh->local_change);
         kh->local_change = FALSE;
     }
+
     if (np && changed) {
         GList *saved = NULL;
         SPDesktop *desktop = np->desktop;
@@ -409,7 +405,7 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
     gint ret = FALSE;
 
     SPDesktop *desktop = event_context->desktop;
-    Inkscape::Selection *selection = SP_DT_SELECTION (desktop);
+    Inkscape::Selection *selection = sp_desktop_selection (desktop);
 
     SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
 
@@ -427,10 +423,6 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
                     SPItem *item_over = sp_event_context_over_item (desktop, selection->singleItem(),
                                                                     NR::Point(event->button.x, event->button.y));
 
-                    // check if this is indeed our nodepathed item
-                    if (item_over != nc->nodepath->path)
-                        break;
-
                     bool over_stroke = false;
                     if (item_over && nc->nodepath) {
                         over_stroke = sp_node_context_is_over_stroke (nc, item_over, NR::Point(event->button.x, event->button.y), false);
@@ -523,7 +515,7 @@ static gint
 sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
 {
     SPDesktop *desktop = event_context->desktop;
-    Inkscape::Selection *selection = SP_DT_SELECTION (desktop);
+    Inkscape::Selection *selection = sp_desktop_selection (desktop);
 
     SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
     double const nudge = prefs_get_double_attribute_limited("options.nudgedistance", "value", 2, 0, 1000); // in px
@@ -622,7 +614,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         if (nc->nodepath && nc->nodepath->selected)
                             sp_nodepath_deselect(nc->nodepath);
                         else
-                            SP_DT_SELECTION(desktop)->clear();
+                            sp_desktop_selection(desktop)->clear();
                     }
                 }
                 ret = TRUE;
@@ -644,8 +636,13 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                 case GDK_Delete:
                 case GDK_KP_Delete:
                 case GDK_BackSpace:
-                    // with any modifiers
-                    sp_node_selected_delete();
+                    if (MOD__CTRL_ONLY) {
+                        sp_node_selected_delete();
+                    } else {
+                        if (nc->nodepath && nc->nodepath->selected) {
+                            sp_node_delete_preserve(g_list_copy(nc->nodepath->selected));
+                        }
+                    }
                     ret = TRUE;
                     break;
                 case GDK_C:
@@ -794,7 +791,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event)
                         if (nc->nodepath && nc->nodepath->selected) {
                             sp_nodepath_deselect(nc->nodepath);
                         } else {
-                            SP_DT_SELECTION(desktop)->clear();
+                            sp_desktop_selection(desktop)->clear();
                         }
                     }
                     ret = TRUE;