[gimp/blend-tool-fun: 7/7] app: In GimpBlendTool, sync the operation properties with GimpBlendOptions
- From: Michael Henning <mhenning src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/blend-tool-fun: 7/7] app: In GimpBlendTool, sync the operation properties with GimpBlendOptions
- Date: Tue, 24 Jun 2014 15:34:00 +0000 (UTC)
commit 5a122078e53a4f052d748274535b751c356567bf
Author: Michael Henning <drawoc darkrefraction com>
Date: Sun Jun 22 21:53:38 2014 -0400
app: In GimpBlendTool, sync the operation properties with GimpBlendOptions
app/tools/gimpblendtool.c | 89 ++++++++++++++++++++++++++++++++++++++++++---
app/tools/gimpblendtool.h | 2 +
2 files changed, 86 insertions(+), 5 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index f0bcac8..a6c68db 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -41,6 +41,8 @@
#include "core/gimpprogress.h"
#include "core/gimpprojection.h"
+#include "gegl/gimp-gegl-config-proxy.h"
+
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
@@ -59,6 +61,9 @@
/* local function prototypes */
+static void gimp_blend_tool_constructed (GObject *object);
+static void gimp_blend_tool_dispose (GObject *object);
+
static gboolean gimp_blend_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
@@ -87,8 +92,8 @@ static void gimp_blend_tool_motion (GimpTool *tool,
guint32 time,
GdkModifierType state,
GimpDisplay *display);
-static void gimp_blend_tool_point_motion (GimpBlendTool *blend_tool,
- gboolean constrain_angle);
+static void gimp_blend_tool_point_motion (GimpBlendTool *blend_tool,
+ gboolean constrain_angle);
static gboolean gimp_blend_tool_key_press (GimpTool *tool,
GdkEventKey *kevent,
GimpDisplay *display);
@@ -119,6 +124,9 @@ static void gimp_blend_tool_push_status (GimpBlendTool *blend_
static void gimp_blend_tool_create_graph (GimpBlendTool *blend_tool);
static void gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool);
+static void gimp_blend_tool_options_notify (GimpTool *tool,
+ GimpToolOptions *options,
+ const GParamSpec *pspec);
static void gimp_blend_tool_create_image_map (GimpBlendTool *blend_tool,
GimpDrawable *drawable);
@@ -156,9 +164,13 @@ gimp_blend_tool_register (GimpToolRegisterCallback callback,
static void
gimp_blend_tool_class_init (GimpBlendToolClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
+ object_class->constructed = gimp_blend_tool_constructed;
+ object_class->dispose = gimp_blend_tool_dispose;
+
tool_class->initialize = gimp_blend_tool_initialize;
tool_class->control = gimp_blend_tool_control;
tool_class->oper_update = gimp_blend_tool_oper_update;
@@ -168,11 +180,51 @@ 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;
}
static void
+gimp_blend_tool_constructed (GObject *object)
+{
+ GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (object);
+ GParamSpec **pspecs;
+ guint n_pspecs;
+ gint i;
+
+ /* Generate a hash table as the set of properties available on 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++)
+ {
+ gchar *name = g_strdup (pspecs[i]->name);
+ g_hash_table_add (blend_tool->op_properties, name);
+ }
+
+ g_free (pspecs);
+
+ /* Chain up */
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+}
+
+static void
+gimp_blend_tool_dispose (GObject *object)
+{
+ GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (object);
+
+ if (blend_tool->op_properties)
+ {
+ g_hash_table_unref (blend_tool->op_properties);
+ blend_tool->op_properties = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
gimp_blend_tool_init (GimpBlendTool *blend_tool)
{
GimpTool *tool = GIMP_TOOL (blend_tool);
@@ -632,15 +684,19 @@ static void
gimp_blend_tool_start (GimpBlendTool *blend_tool,
GimpDisplay *display)
{
- GimpTool *tool = GIMP_TOOL (blend_tool);
- GimpImage *image = gimp_display_get_image (display);
- GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpTool *tool = GIMP_TOOL (blend_tool);
+ GimpImage *image = gimp_display_get_image (display);
+ GimpDrawable *drawable = gimp_image_get_active_drawable (image);
+ GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (blend_tool);
tool->display = display;
tool->drawable = drawable;
gimp_blend_tool_create_image_map (blend_tool, drawable);
+ /* Initially sync all of the properties */
+ gimp_gegl_config_proxy_sync (GIMP_OBJECT (options), blend_tool->render_node);
+
if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (blend_tool)))
gimp_draw_tool_start (GIMP_DRAW_TOOL (blend_tool), display);
}
@@ -785,6 +841,29 @@ gimp_blend_tool_update_preview_coords (GimpBlendTool *blend_tool)
NULL);
}
+static void
+gimp_blend_tool_options_notify (GimpTool *tool,
+ GimpToolOptions *options,
+ const GParamSpec *pspec)
+{
+ GimpBlendTool *blend_tool = GIMP_BLEND_TOOL (tool);
+
+ /* Sync any property changes on the config object that match the op */
+ 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_object_get_property (G_OBJECT (options), pspec->name, &value);
+ gegl_node_set_property (blend_tool->render_node, pspec->name, &value);
+
+ g_value_unset (&value);
+
+ gimp_image_map_apply (blend_tool->image_map, NULL);
+ }
+}
+
/* Image map stuff */
static void
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]