[gimp] app: add gimp_gegl_config_register()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_gegl_config_register()
- Date: Fri, 22 Jan 2016 20:29:25 +0000 (UTC)
commit 1ef06fdbb2ea793e7ca7e60222c40e0a437d540c
Author: Michael Natterer <mitch gimp org>
Date: Wed Jan 20 21:26:43 2016 +0100
app: add gimp_gegl_config_register()
which registers config classes for operations that don't want their
config objects to be auto-generated. Register all color tools' config
objects. Change gimp_gegl_config_sync_node() to correctly handle ops
that have an object property of the right config object type.
app/gegl/gimp-gegl-config.c | 91 ++++++++++++++++++++++++++++++-------
app/gegl/gimp-gegl-config.h | 3 +
app/operations/gimp-operations.c | 27 +++++++++++-
3 files changed, 102 insertions(+), 19 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-config.c b/app/gegl/gimp-gegl-config.c
index e3eb094..3196a98 100644
--- a/app/gegl/gimp-gegl-config.c
+++ b/app/gegl/gimp-gegl-config.c
@@ -36,9 +36,33 @@
#include "gimp-gegl-utils.h"
-static GHashTable *config_types = NULL;
-static GHashTable *config_containers = NULL;
+static GHashTable *
+gimp_gegl_config_get_type_table (void)
+{
+ static GHashTable *config_types = NULL;
+
+ if (! config_types)
+ config_types = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ NULL);
+
+ return config_types;
+}
+
+static GHashTable *
+gimp_gegl_config_get_container_table (void)
+{
+ static GHashTable *config_containers = NULL;
+
+ if (! config_containers)
+ config_containers = g_hash_table_new_full (g_direct_hash,
+ g_direct_equal,
+ NULL,
+ (GDestroyNotify) g_object_unref);
+ return config_containers;
+}
static GValue *
gimp_gegl_config_value_new (GParamSpec *pspec)
@@ -191,21 +215,37 @@ gimp_gegl_config_config_iface_init (GimpConfigInterface *iface)
iface->equal = gimp_gegl_config_equal;
}
+
+/* public functions */
+
+void
+gimp_gegl_config_register (const gchar *operation,
+ GType config_type)
+{
+ GHashTable *config_types;
+
+ g_return_if_fail (operation != NULL);
+ g_return_if_fail (g_type_is_a (config_type, GIMP_TYPE_OBJECT));
+
+ config_types = gimp_gegl_config_get_type_table ();
+
+ g_hash_table_insert (config_types,
+ g_strdup (operation),
+ (gpointer) config_type);
+ }
+
GimpObject *
gimp_gegl_config_new (const gchar *operation,
const gchar *icon_name,
GType parent_type)
{
- GType config_type;
+ GHashTable *config_types;
+ GType config_type;
g_return_val_if_fail (operation != NULL, NULL);
g_return_val_if_fail (g_type_is_a (parent_type, GIMP_TYPE_OBJECT), NULL);
- if (! config_types)
- config_types = g_hash_table_new_full (g_str_hash,
- g_str_equal,
- (GDestroyNotify) g_free,
- NULL);
+ config_types = gimp_gegl_config_get_type_table ();
config_type = (GType) g_hash_table_lookup (config_types, operation);
@@ -271,15 +311,12 @@ gimp_gegl_config_new (const gchar *operation,
GimpContainer *
gimp_gegl_config_get_container (GType config_type)
{
+ GHashTable *config_containers;
GimpContainer *container;
g_return_val_if_fail (g_type_is_a (config_type, GIMP_TYPE_OBJECT), NULL);
- if (! config_containers)
- config_containers = g_hash_table_new_full (g_direct_hash,
- g_direct_equal,
- NULL,
- (GDestroyNotify) g_object_unref);
+ config_containers = gimp_gegl_config_get_container_table ();
container = g_hash_table_lookup (config_containers, (gpointer) config_type);
@@ -295,15 +332,15 @@ gimp_gegl_config_get_container (GType config_type)
}
void
-gimp_gegl_config_sync_node (GimpObject *proxy,
- GeglNode *node)
+gimp_gegl_config_sync_node (GimpObject *config,
+ GeglNode *node)
{
GParamSpec **pspecs;
gchar *operation;
guint n_pspecs;
gint i;
- g_return_if_fail (GIMP_IS_OBJECT (proxy));
+ g_return_if_fail (GIMP_IS_OBJECT (config));
g_return_if_fail (GEGL_IS_NODE (node));
gegl_node_get (node,
@@ -317,8 +354,26 @@ gimp_gegl_config_sync_node (GimpObject *proxy,
for (i = 0; i < n_pspecs; i++)
{
+ GParamSpec *pspec = pspecs[i];
+
+ /* if the operation has an object property of the config's
+ * type, set it and done
+ */
+ if (G_IS_PARAM_SPEC_OBJECT (pspec) &&
+ pspec->value_type == G_TYPE_FROM_INSTANCE (config))
+ {
+ gegl_node_set (node,
+ pspec->name, config,
+ NULL);
+ g_free (pspecs);
+ return;
+ }
+ }
+
+ for (i = 0; i < n_pspecs; i++)
+ {
GParamSpec *gegl_pspec = pspecs[i];
- GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (proxy),
+ GParamSpec *gimp_pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (config),
gegl_pspec->name);
if (gimp_pspec)
@@ -327,7 +382,7 @@ gimp_gegl_config_sync_node (GimpObject *proxy,
g_value_init (&value, gimp_pspec->value_type);
- g_object_get_property (G_OBJECT (proxy), gimp_pspec->name,
+ g_object_get_property (G_OBJECT (config), gimp_pspec->name,
&value);
if (GEGL_IS_PARAM_SPEC_COLOR (gegl_pspec))
diff --git a/app/gegl/gimp-gegl-config.h b/app/gegl/gimp-gegl-config.h
index 3f09ce5..09b44de 100644
--- a/app/gegl/gimp-gegl-config.h
+++ b/app/gegl/gimp-gegl-config.h
@@ -19,6 +19,9 @@
#define __GIMP_GEGL_CONFIG_H__
+void gimp_gegl_config_register (const gchar *operation,
+ GType config_type);
+
GimpObject * gimp_gegl_config_new (const gchar *operation,
const gchar *icon_name,
GType parent_type);
diff --git a/app/operations/gimp-operations.c b/app/operations/gimp-operations.c
index a1a7e89..41a89ed 100644
--- a/app/operations/gimp-operations.c
+++ b/app/operations/gimp-operations.c
@@ -19,13 +19,15 @@
#include "config.h"
-#include <gio/gio.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gegl.h>
#include "operations-types.h"
#include "core/gimp.h"
+#include "gegl/gimp-gegl-config.h"
+
#include "gimp-operations.h"
#include "gimpoperationblend.h"
@@ -53,6 +55,14 @@
#include "gimpoperationposterize.h"
#include "gimpoperationthreshold.h"
+#include "gimpbrightnesscontrastconfig.h"
+#include "gimpcolorbalanceconfig.h"
+#include "gimpcolorizeconfig.h"
+#include "gimpcurvesconfig.h"
+#include "gimphuesaturationconfig.h"
+#include "gimplevelsconfig.h"
+#include "gimpthresholdconfig.h"
+
#include "gimpoperationpointlayermode.h"
#include "gimpoperationnormalmode.h"
#include "gimpoperationdissolvemode.h"
@@ -145,4 +155,19 @@ gimp_operations_init (void)
g_type_class_ref (GIMP_TYPE_OPERATION_ERASE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_REPLACE_MODE);
g_type_class_ref (GIMP_TYPE_OPERATION_ANTI_ERASE_MODE);
+
+ gimp_gegl_config_register ("gimp:brightness-contrast",
+ GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG);
+ gimp_gegl_config_register ("gimp:color-balance",
+ GIMP_TYPE_COLOR_BALANCE_CONFIG);
+ gimp_gegl_config_register ("gimp:colorize",
+ GIMP_TYPE_COLORIZE_CONFIG);
+ gimp_gegl_config_register ("gimp:curves",
+ GIMP_TYPE_CURVES_CONFIG);
+ gimp_gegl_config_register ("gimp:hue-saturation",
+ GIMP_TYPE_HUE_SATURATION_CONFIG);
+ gimp_gegl_config_register ("gimp:levels",
+ GIMP_TYPE_LEVELS_CONFIG);
+ gimp_gegl_config_register ("gimp:threshold",
+ GIMP_TYPE_THRESHOLD_CONFIG);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]