[gimp/blend-tool-fun] foo



commit 1974c2cfe7e3686b13e8d852437d88ea567ad208
Author: Michael Henning <drawoc darkrefraction com>
Date:   Mon Jun 23 23:15:52 2014 -0400

    foo

 app/tools/gimpblendtool.c |   54 ++++++++++++++++++++++++++------------------
 app/tools/gimpblendtool.h |    2 +
 2 files changed, 34 insertions(+), 22 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index fec49bc..c4fe7c2 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -123,9 +123,9 @@ static void   gimp_blend_tool_create_graph        (GimpBlendTool         *blend_
 static void   gimp_blend_tool_update_preview_coords (GimpBlendTool       *blend_tool);
 
 static void   gimp_blend_tool_start_op_sync       (GimpBlendTool         *blend_tool);
-static void   gimp_blend_tool_options_notify      (GimpBlendOptions      *options,
-                                                   GParamSpec            *pspec,
-                                                   GimpBlendTool         *blend_tool);
+static void   gimp_blend_tool_options_notify      (GimpTool              *tool,
+                                                   GimpToolOptions       *options,
+                                                   const GParamSpec      *pspec);
 static void   gimp_blend_tool_stop_op_sync        (GimpBlendTool         *blend_tool);
 
 static void   gimp_blend_tool_create_image_map    (GimpBlendTool         *blend_tool,
@@ -176,6 +176,7 @@ gimp_blend_tool_class_init (GimpBlendToolClass *klass)
   tool_class->key_press           = gimp_blend_tool_key_press;
   tool_class->active_modifier_key = gimp_blend_tool_active_modifier_key;
   tool_class->cursor_update       = gimp_blend_tool_cursor_update;
+  tool_class->options_notify      = gimp_blend_tool_options_notify;
 
   draw_tool_class->draw           = gimp_blend_tool_draw;
 }
@@ -312,6 +313,9 @@ gimp_blend_tool_button_press (GimpTool            *tool,
       blend_tool->end_y = coords->y;
 
       blend_tool->grabbed_point = POINT_END;
+
+/*      gimp_blend_tool_point_motion (GimpBlendTool *blend_tool,
+                                    gboolean constrain_angle);*/
       break;
 
     case POINT_START:
@@ -806,18 +810,16 @@ gimp_blend_tool_start_op_sync (GimpBlendTool *blend_tool)
   gint              i;
 
   /* Listen for any property changes on the config object that match the op */
+
+  blend_tool->op_properties = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                                     NULL, g_free);
+
   pspecs = gegl_operation_list_properties ("gimp:blend", &n_pspecs);
 
   for (i = 0; i < n_pspecs; i++)
     {
-      GParamSpec *pspec = pspecs[i];
-      gchar *signal_name = g_strdup_printf ("notify::%s", pspec->name);
-
-      g_signal_connect (options, signal_name,
-                        G_CALLBACK (gimp_blend_tool_options_notify),
-                        blend_tool);
-
-      g_free (signal_name);
+      gchar *name = g_strdup (pspecs[i]->name);
+      g_hash_table_add (blend_tool->op_properties, name);
     }
 
   g_free (pspecs);
@@ -827,28 +829,36 @@ gimp_blend_tool_start_op_sync (GimpBlendTool *blend_tool)
 }
 
 static void
-gimp_blend_tool_options_notify (GimpBlendOptions *options,
-                                GParamSpec       *pspec,
-                                GimpBlendTool    *blend_tool)
+gimp_blend_tool_options_notify (GimpTool         *tool,
+                                GimpToolOptions  *options,
+                                const GParamSpec *pspec)
 {
-  GValue value = G_VALUE_INIT;
-  g_value_init (&value, pspec->value_type);
+  GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
 
-  g_object_get_property (G_OBJECT (options), pspec->name, &value);
-  gegl_node_set_property (blend_tool->render_node, pspec->name, &value);
+  if (blend_tool->render_node &&
+      g_hash_table_contains (blend_tool->op_properties, pspec->name))
+    {
+      GValue value = G_VALUE_INIT;
+      g_value_init (&value, pspec->value_type);
 
-  g_value_unset (&value);
+      g_object_get_property (G_OBJECT (options), pspec->name, &value);
+      gegl_node_set_property (blend_tool->render_node, pspec->name, &value);
 
-  gimp_image_map_apply (blend_tool->image_map, NULL);
+      g_value_unset (&value);
+
+      gimp_image_map_apply (blend_tool->image_map, NULL);
+    }
 }
 
 static void
 gimp_blend_tool_stop_op_sync (GimpBlendTool *blend_tool)
 {
-  GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
+  /*GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
   g_signal_handlers_disconnect_by_func (options,
                                         G_CALLBACK (gimp_blend_tool_options_notify),
-                                        blend_tool);
+                                        blend_tool);*/
+g_hash_table_unref (blend_tool->op_properties);
+blend_tool->op_properties = NULL;
 }
 
 /* Image map stuff */
diff --git a/app/tools/gimpblendtool.h b/app/tools/gimpblendtool.h
index 6f35d04..426a35b 100644
--- a/app/tools/gimpblendtool.h
+++ b/app/tools/gimpblendtool.h
@@ -63,6 +63,8 @@ struct _GimpBlendTool
   GeglNode       *graph;
   GeglNode       *render_node;
   GimpImageMap   *image_map;
+
+  GHashTable     *op_properties;
 };
 
 struct _GimpBlendToolClass


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]