Code

Adding use of GtkScaleButton when available
[inkscape.git] / src / splivarot.cpp
index 72f059bdcdbb314b4e90ec2e03e9f5e732bc5ba9..5868140a6d25b101fe677b514e1c2cd51b84da8b 100644 (file)
@@ -89,6 +89,12 @@ sp_selected_path_diff()
     sp_selected_path_boolop(bool_op_diff, SP_VERB_SELECTION_DIFF, _("Difference"));
 }
 
+void
+sp_selected_path_diff_skip_undo()
+{
+    sp_selected_path_boolop(bool_op_diff, SP_VERB_NONE, _("Difference"));
+}
+
 void
 sp_selected_path_symdiff()
 {
@@ -453,8 +459,8 @@ sp_selected_path_boolop(bool_op bop, const unsigned int verb, const Glib::ustrin
     // adjust style properties that depend on a possible transform in the source object in order
     // to get a correct style attribute for the new path
     SPItem* item_source = SP_ITEM(source);
-    NR::Matrix i2root = sp_item_i2root_affine(item_source);
-    sp_item_adjust_stroke(item_source, i2root.expansion());
+    NR::Matrix i2root = from_2geom(sp_item_i2root_affine(item_source));
+    sp_item_adjust_stroke(item_source, NR::expansion(i2root));
     sp_item_adjust_pattern(item_source, i2root);
     sp_item_adjust_gradient(item_source, i2root);
     sp_item_adjust_livepatheffect(item_source, i2root);
@@ -485,7 +491,7 @@ sp_selected_path_boolop(bool_op bop, const unsigned int verb, const Glib::ustrin
 
     // premultiply by the inverse of parent's repr
     SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent));
-    NR::Matrix local = sp_item_i2doc_affine(parent_item);
+    NR::Matrix local = from_2geom(sp_item_i2doc_affine(parent_item));
     gchar *transform = sp_svg_transform_write(local.inverse());
 
     // now that we have the result, add it on the canvas
@@ -633,7 +639,7 @@ sp_selected_path_outline()
             gchar const *val = sp_repr_css_property(css, "stroke", NULL);
 
             if (val == NULL || strcmp(val, "none") == 0) {
-                sp_curve_unref(curve);
+                curve->unref();
                 continue;
             }
         }
@@ -661,7 +667,7 @@ sp_selected_path_outline()
         }
 
         NR::Matrix const transform(item->transform);
-        float const scale = transform.expansion();
+        float const scale = NR::expansion(transform);
         gchar *style = g_strdup(SP_OBJECT_REPR(item)->attribute("style"));
         SPStyle *i_style = SP_OBJECT(item)->style;
         gchar const *mask = SP_OBJECT_REPR(item)->attribute("mask");
@@ -710,7 +716,7 @@ sp_selected_path_outline()
         Path *orig = Path_for_item(item, false);
         if (orig == NULL) {
             g_free(style);
-            sp_curve_unref(curve);
+            curve->unref();
             continue;
         }
 
@@ -820,7 +826,7 @@ sp_selected_path_outline()
 
                 SPShape *shape = SP_SHAPE(item);
 
-                for (NArtBpath* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) {
+                for (NArtBpath const* bp = SP_CURVE_BPATH(shape->curve); bp->code != NR_END; bp++) {
                     for (int m = SP_MARKER_LOC_START; m < SP_MARKER_LOC_QTY; m++) {
                         if (sp_shape_marker_required (shape, m, bp)) {
 
@@ -871,7 +877,7 @@ sp_selected_path_outline()
 
             Inkscape::GC::release(repr);
 
-            sp_curve_unref(curve);
+            curve->unref();
             selection->remove(item);
             SP_OBJECT(item)->deleteObject(false);
 
@@ -1046,7 +1052,7 @@ sp_selected_path_create_offset_object(int expand, bool updating)
     if (orig == NULL)
     {
         g_free(style);
-        sp_curve_unref(curve);
+        curve->unref();
         return;
     }
 
@@ -1083,7 +1089,7 @@ sp_selected_path_create_offset_object(int expand, bool updating)
         delete theRes;
     }
 
-    sp_curve_unref(curve);
+    curve->unref();
 
     if (res->descr_cmd.size() <= 1)
     {
@@ -1268,7 +1274,7 @@ sp_selected_path_do_offset(bool expand, double prefOffset)
         Path *orig = Path_for_item(item, false);
         if (orig == NULL) {
             g_free(style);
-            sp_curve_unref(curve);
+            curve->unref();
             continue;
         }
 
@@ -1356,7 +1362,7 @@ sp_selected_path_do_offset(bool expand, double prefOffset)
 
         did = true;
 
-        sp_curve_unref(curve);
+        curve->unref();
         // remember the position of the item
         gint pos = SP_OBJECT_REPR(item)->position();
         // remember parent
@@ -1476,11 +1482,11 @@ sp_selected_path_simplify_item(SPDesktop *desktop,
     Path *orig = Path_for_item(item, false);
     if (orig == NULL) {
         g_free(style);
-        sp_curve_unref(curve);
+        curve->unref();
         return false;
     }
 
-    sp_curve_unref(curve);
+    curve->unref();
     // remember the position of the item
     gint pos = SP_OBJECT_REPR(item)->position();
     // remember parent
@@ -1598,7 +1604,7 @@ sp_selected_path_simplify_items(SPDesktop *desktop,
           continue;
 
       if (simplifyIndividualPaths) {
-          NR::Maybe<NR::Rect> itemBbox = item->getBounds(sp_item_i2d_affine(item));        
+          NR::Maybe<NR::Rect> itemBbox = item->getBounds(from_2geom(sp_item_i2d_affine(item)));
           if (itemBbox) {
               simplifySize      = L2(itemBbox->dimensions());
           } else {
@@ -1723,37 +1729,39 @@ Path_for_item(SPItem *item, bool doTransformation, bool transformFull)
     
     Path *dest = bpath_to_Path(bpath);
 
-    if (doTransformation) {
-        g_free(bpath); // see comment in bpath_for_curve
-    }
-    
-    sp_curve_unref(curve);
+    g_free(bpath);
+
+    curve->unref();
     
     return dest;
 }
 
+/* 
+ * This function always returns a new NArtBpath, the caller must g_free the returned path!
+*/
 NArtBpath *
 bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull)
 {
     if (curve == NULL)
         return NULL;
 
-    NArtBpath *bpath = SP_CURVE_BPATH(curve);
+    NArtBpath const *bpath = SP_CURVE_BPATH(curve);
     if (bpath == NULL) {
         return NULL;
     }
-    
+
+    NArtBpath *new_bpath; // we will get a duplicate which has to be freed at some point!
     if (doTransformation) {
-        NArtBpath *new_bpath; // we will get a duplicate which has to be freed at some point!
         if (transformFull) {
-            new_bpath = nr_artpath_affine(bpath, sp_item_i2doc_affine(item));
+            new_bpath = nr_artpath_affine(bpath, from_2geom(sp_item_i2doc_affine(item)));
         } else {
             new_bpath = nr_artpath_affine(bpath, item->transform);
         }
-        bpath = new_bpath;
+    } else {
+        new_bpath = nr_artpath_affine(bpath, NR::identity());
     }
 
-    return bpath;
+    return new_bpath;
 }
 
 SPCurve* curve_for_item(SPItem *item)