Code

Separate spiro modes for pen and pencil tool
authorcilix42 <cilix42@users.sourceforge.net>
Tue, 22 Jul 2008 14:52:42 +0000 (14:52 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Tue, 22 Jul 2008 14:52:42 +0000 (14:52 +0000)
src/draw-context.cpp
src/widgets/toolbox.cpp

index 19551dd6a6dbe38a0683a919b62f09415742fea0..6a9e634360ad5ac878d80d29967dff976450cd2e 100644 (file)
@@ -247,6 +247,14 @@ sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event)
     return ret;
 }
 
+static char const *
+tool_name(SPDrawContext *dc)
+{
+    return ( SP_IS_PEN_CONTEXT(dc)
+             ? "tools.freehand.pen"
+             : "tools.freehand.pencil" );
+}
+
 static void
 spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *dc, SPItem *item)
 {
@@ -270,7 +278,7 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item)
     using namespace Inkscape::LivePathEffect;
 
     if (item && SP_IS_LPE_ITEM(item)) {
-        if (prefs_get_int_attribute("tools.freehand", "spiro-spline-mode", 0)) {
+        if (prefs_get_int_attribute(tool_name(dc), "spiro-spline-mode", 0)) {
             Effect::createAndApply(SPIRO, dc->desktop->doc(), item);
         }
 
@@ -572,14 +580,6 @@ spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
     c->unref();
 }
 
-static char const *
-tool_name(SPDrawContext *dc)
-{
-    return ( SP_IS_PEN_CONTEXT(dc)
-             ? "tools.freehand.pen"
-             : "tools.freehand.pencil" );
-}
-
 /*
  * Flushes white curve(s) and additional curve into object
  *
index 052a8f061a18f7f5a806861ad5002370334714e8..16e2f3f68bc5e172a366918eafefe589b3478406 100644 (file)
@@ -80,6 +80,7 @@
 #include "sp-clippath.h"
 #include "sp-mask.h"
 #include "style.h"
+#include "tools-switch.h"
 #include "selection.h"
 #include "selection-chemistry.h"
 #include "document-private.h"
@@ -3267,9 +3268,18 @@ static void sp_spiral_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActio
 //##     Pen/Pencil    ##
 //########################
 
-static void sp_pc_spiro_spline_mode_changed(EgeSelectOneAction* act, GObject* /*tbl*/)
+static char const *
+freehand_tool_name(GObject *dataKludge)
 {
-    prefs_set_int_attribute("tools.freehand", "spiro-spline-mode", ege_select_one_action_get_active(act));
+    SPDesktop *desktop = (SPDesktop *) g_object_get_data(dataKludge, "desktop");
+    return ( tools_isactive(desktop, TOOLS_FREEHAND_PENCIL)
+             ? "tools.freehand.pencil"
+             : "tools.freehand.pen" );
+}
+
+static void sp_pc_spiro_spline_mode_changed(EgeSelectOneAction* act, GObject* tbl)
+{
+    prefs_set_int_attribute(freehand_tool_name(tbl), "spiro-spline-mode", ege_select_one_action_get_active(act));
 }
 
 static void sp_add_spiro_toggle(GtkActionGroup* mainActions, GObject* holder, bool tool_is_pencil)
@@ -3278,7 +3288,7 @@ static void sp_add_spiro_toggle(GtkActionGroup* mainActions, GObject* holder, bo
     {
         //gchar const *flatsidedstr = prefs_get_string_attribute( "tools.shapes.star", "isflatsided" );
         //bool isSpiroMode = flatsidedstr ? (strcmp(flatsidedstr, "false") != 0) : true;
-        guint spiroMode = prefs_get_int_attribute("tools.freehand", "spiro-spline-mode", 0);
+        guint spiroMode = prefs_get_int_attribute(freehand_tool_name(holder), "spiro-spline-mode", 0);
         Inkscape::IconSize secondarySize = prefToSize("toolbox", "secondary", 1);
 
         {