Code

ensure copy/paste of style between gradient stops works
authorbuliabyak <buliabyak@users.sourceforge.net>
Mon, 22 Oct 2007 18:12:35 +0000 (18:12 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Mon, 22 Oct 2007 18:12:35 +0000 (18:12 +0000)
src/selection-chemistry.cpp

index 2466b542eb8c697d0d3da9bf872414e38eda48ad..8d0aa4e79eb1c0aed1ee6218bcab239979f850f2 100644 (file)
@@ -75,6 +75,7 @@
 #include "unit-constants.h"
 #include "xml/simple-document.h"
 #include "sp-filter-reference.h"
+#include "gradient-drag.h"
 
 using NR::X;
 using NR::Y;
@@ -973,6 +974,20 @@ void sp_copy_stuff_used_by_item (GSList **defs_clip, SPItem *item, const GSList
     }
 }
 
+void
+sp_set_style_clipboard (SPCSSAttr *css)
+{
+    if (css != NULL) {
+        // clear style clipboard
+        if (style_clipboard) {
+            sp_repr_css_attr_unref (style_clipboard);
+            style_clipboard = NULL;
+        }
+        //sp_repr_css_print (css);
+        style_clipboard = css;
+    }
+}
+
 /**
  * \pre item != NULL
  */
@@ -1031,6 +1046,10 @@ void sp_selection_copy()
         return; // copied color under cursor, nothing else to do
     }
 
+    if (desktop->event_context->get_drag() && desktop->event_context->get_drag()->copy()) {
+        return; // copied selected stop(s), nothing else to do
+    }
+
     // check if something is selected
     if (selection->isEmpty()) {
         desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing was copied."));
@@ -1092,15 +1111,7 @@ void sp_selection_copy()
         SPStyle *const query = sp_style_new(SP_ACTIVE_DOCUMENT);
         if (sp_desktop_query_style_all (desktop, query)) {
             SPCSSAttr *css = sp_css_attr_from_style (query, SP_STYLE_FLAG_ALWAYS);
-            if (css != NULL) {
-                // clear style clipboard
-                if (style_clipboard) {
-                    sp_repr_css_attr_unref (style_clipboard);
-                    style_clipboard = NULL;
-                }
-                //sp_repr_css_print (css);
-                style_clipboard = css;
-            }
+            sp_set_style_clipboard (css);
         }
         sp_style_unref(query);
     }
@@ -1170,8 +1181,8 @@ void sp_selection_paste_style()
     Inkscape::Selection *selection = sp_desktop_selection(desktop);
 
     // check if something is in the clipboard
-    if (clipboard == NULL) {
-        desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
+    if (style_clipboard == NULL) {
+        desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the style clipboard."));
         return;
     }