[gimp] app: follow GEGL propertiy keys convention change
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: follow GEGL propertiy keys convention change
- Date: Fri, 16 May 2014 01:12:27 +0000 (UTC)
commit dac7201eadf8d9f3aee745fb6fcc484b5135d2c6
Author: Michael Natterer <mitch gimp org>
Date: Fri May 16 03:10:01 2014 +0200
app: follow GEGL propertiy keys convention change
and clean up the magic a bit.
app/gegl/gimp-gegl-utils.c | 14 +++++++++++
app/gegl/gimp-gegl-utils.h | 4 +++
app/tools/gimpoperationtool.c | 41 +++++++++++++++++++-------------
app/widgets/gimpproptable.c | 51 +++++++++++++----------------------------
4 files changed, 58 insertions(+), 52 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-utils.c b/app/gegl/gimp-gegl-utils.c
index 7f88d15..9344300 100644
--- a/app/gegl/gimp-gegl-utils.c
+++ b/app/gegl/gimp-gegl-utils.c
@@ -21,6 +21,7 @@
#include "config.h"
#include <gegl.h>
+#include <gegl-plugin.h>
#include "gimp-gegl-types.h"
@@ -124,3 +125,16 @@ gimp_gegl_progress_connect (GeglNode *node,
g_object_unref (operation);
}
+
+gboolean
+gimp_gegl_param_spec_has_key (GParamSpec *pspec,
+ const gchar *key,
+ const gchar *value)
+{
+ const gchar *v = gegl_param_spec_get_property_key (pspec, key);
+
+ if (v && ! strcmp (v, value))
+ return TRUE;
+
+ return FALSE;
+}
diff --git a/app/gegl/gimp-gegl-utils.h b/app/gegl/gimp-gegl-utils.h
index 3ce22c8..74c8981 100644
--- a/app/gegl/gimp-gegl-utils.h
+++ b/app/gegl/gimp-gegl-utils.h
@@ -31,5 +31,9 @@ void gimp_gegl_progress_connect (GeglNode *node,
GimpProgress *progress,
const gchar *text);
+gboolean gimp_gegl_param_spec_has_key (GParamSpec *pspec,
+ const gchar *key,
+ const gchar *value);
+
#endif /* __GIMP_GEGL_UTILS_H__ */
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 5bb3f1c..f58d568 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -488,39 +488,46 @@ gimp_operation_tool_sync_op (GimpOperationTool *op_tool,
for (i = 0; i < n_pspecs; i++)
{
- GParamSpec *pspec = pspecs[i];
- const gchar *role = gegl_param_spec_get_property_key (pspec, "role");
+ GParamSpec *pspec = pspecs[i];
- if (role)
+#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)
+
+ if (HAS_KEY (pspec, "role", "output-extent"))
{
- if (! strcmp (role, "source-x"))
+ if (HAS_KEY (pspec, "unit", "pixel-coordinate") &&
+ HAS_KEY (pspec, "axis", "x"))
{
g_object_set (op_tool->config, pspec->name, 0, NULL);
}
- else if (! strcmp (role, "source-y"))
+ else if (HAS_KEY (pspec, "unit", "pixel-coordinate") &&
+ HAS_KEY (pspec, "axis", "y"))
{
g_object_set (op_tool->config, pspec->name, 0, NULL);
}
- else if (! strcmp (role, "source-width"))
+ else if (HAS_KEY (pspec, "unit", "pixel-distance") &&
+ HAS_KEY (pspec, "axis", "x"))
{
g_object_set (op_tool->config, pspec->name, bounds_width, NULL);
}
- else if (! strcmp (role, "source-height"))
+ else if (HAS_KEY (pspec, "unit", "pixel-distance") &&
+ HAS_KEY (pspec, "axis", "x"))
{
g_object_set (op_tool->config, pspec->name, bounds_height, NULL);
}
- else if (! strcmp (role, "foreground") ||
- ! strcmp (role, "background"))
- {
- GimpRGB color;
+ }
+ else if (HAS_KEY (pspec, "role", "foreground"))
+ {
+ GimpRGB color;
- if (! strcmp (role, "foreground"))
- gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
- else
- gimp_context_get_background (GIMP_CONTEXT (options), &color);
+ gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
+ g_object_set (op_tool->config, pspec->name, &color, NULL);
+ }
+ else if (HAS_KEY (pspec, "role", "background"))
+ {
+ GimpRGB color;
- g_object_set (op_tool->config, pspec->name, &color, NULL);
- }
+ gimp_context_get_background (GIMP_CONTEXT (options), &color);
+ g_object_set (op_tool->config, pspec->name, &color, NULL);
}
}
diff --git a/app/widgets/gimpproptable.c b/app/widgets/gimpproptable.c
index 07e9e15..e87c13a 100644
--- a/app/widgets/gimpproptable.c
+++ b/app/widgets/gimpproptable.c
@@ -26,7 +26,6 @@
#include <gegl.h>
#include <gegl-paramspecs.h>
-#include <gegl-plugin.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
@@ -36,6 +35,8 @@
#include "widgets-types.h"
+#include "gegl/gimp-gegl-utils.h"
+
#include "core/gimpcontext.h"
#include "gimpcolorpanel.h"
@@ -85,19 +86,6 @@ gimp_prop_table_new_seed_clicked (GtkButton *button,
gtk_adjustment_set_value (adj, value);
}
-static gboolean
-param_spec_has_key (GParamSpec *pspec,
- const gchar *key,
- const gchar *value)
-{
- const gchar *v = gegl_param_spec_get_property_key (pspec, key);
-
- if (v && ! strcmp (v, value))
- return TRUE;
-
- return FALSE;
-}
-
GtkWidget *
gimp_prop_table_new (GObject *config,
GType owner_type,
@@ -130,7 +118,6 @@ gimp_prop_table_new (GObject *config,
for (i = 0; i < n_param_specs; i++)
{
GParamSpec *pspec = param_specs[i];
- const gchar *role = gegl_param_spec_get_property_key (pspec, "role");
GtkWidget *widget = NULL;
const gchar *label = NULL;
@@ -138,16 +125,10 @@ gimp_prop_table_new (GObject *config,
if (! g_type_is_a (pspec->owner_type, owner_type))
continue;
- if (role)
- {
- if (! strcmp (role, "source-x") ||
- ! strcmp (role, "source-y") ||
- ! strcmp (role, "source-width") ||
- ! strcmp (role, "source-height"))
- {
- continue;
- }
- }
+#define HAS_KEY(p,k,v) gimp_gegl_param_spec_has_key (p, k, v)
+
+ if (HAS_KEY (pspec, "role", "output-extent"))
+ continue;
if (G_IS_PARAM_SPEC_STRING (pspec))
{
@@ -269,15 +250,15 @@ gimp_prop_table_new (GObject *config,
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
- if (param_spec_has_key (pspec, "unit", "pixel-coordinate") &&
- param_spec_has_key (pspec, "axis", "x"))
+ if (HAS_KEY (pspec, "unit", "pixel-coordinate") &&
+ HAS_KEY (pspec, "axis", "x"))
{
last_pspec = pspec;
last_x_adj = adj;
last_x_row = row;
}
- else if (param_spec_has_key (pspec, "unit", "pixel-distance") &&
- param_spec_has_key (pspec, "axis", "x"))
+ else if (HAS_KEY (pspec, "unit", "pixel-distance") &&
+ HAS_KEY (pspec, "axis", "x"))
{
last_pspec = pspec;
last_x_adj = adj;
@@ -286,13 +267,13 @@ gimp_prop_table_new (GObject *config,
else if (last_pspec != NULL &&
last_x_adj != NULL &&
last_x_row == row - 1 &&
- param_spec_has_key (pspec, "axis", "y") &&
+ HAS_KEY (pspec, "axis", "y") &&
- ((param_spec_has_key (pspec, "unit", "pixel-coordinate") &&
- param_spec_has_key (last_pspec, "unit", "pixel-coordinate"))
+ ((HAS_KEY (pspec, "unit", "pixel-coordinate") &&
+ HAS_KEY (last_pspec, "unit", "pixel-coordinate"))
||
- (param_spec_has_key (pspec, "unit", "pixel-distance") &&
- param_spec_has_key (last_pspec, "unit", "pixel-distance"))))
+ (HAS_KEY (pspec, "unit", "pixel-distance") &&
+ HAS_KEY (last_pspec, "unit", "pixel-distance"))))
{
GtkWidget *chain = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
@@ -323,7 +304,7 @@ gimp_prop_table_new (GObject *config,
g_object_set_data (G_OBJECT (last_x_adj), "y-adjustment", adj);
if (create_picker_func &&
- param_spec_has_key (pspec, "unit", "pixel-coordinate"))
+ HAS_KEY (pspec, "unit", "pixel-coordinate"))
{
GtkWidget *button;
gchar *pspec_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]