[gimp] app: add gimp_operation_config_list_properties()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_operation_config_list_properties()
- Date: Sun, 9 Jul 2017 16:01:35 +0000 (UTC)
commit 51cc6893ab8f35f24fb4800cb2b787116bedd4de
Author: Michael Natterer <mitch gimp org>
Date: Sun Jul 9 17:59:29 2017 +0200
app: add gimp_operation_config_list_properties()
which is the same as g_object_class_list_properties() but filters
out the properties for which we don't want to create a GUI.
Use it in gimp_prop_gui_new().
app/operations/gimp-operation-config.c | 45 ++++++++++++++++++++++++++++++++
app/operations/gimp-operation-config.h | 5 +++
app/propgui/gimppropgui.c | 35 ++++++------------------
3 files changed, 59 insertions(+), 26 deletions(-)
---
diff --git a/app/operations/gimp-operation-config.c b/app/operations/gimp-operation-config.c
index 13067dc..cc5bf4a 100644
--- a/app/operations/gimp-operation-config.c
+++ b/app/operations/gimp-operation-config.c
@@ -618,6 +618,51 @@ gimp_operation_config_connect_node (GimpObject *config,
g_free (pspecs);
}
+GParamSpec **
+gimp_operation_config_list_properties (GimpObject *config,
+ GType owner_type,
+ GParamFlags flags,
+ guint *n_pspecs)
+{
+ GParamSpec **param_specs;
+ guint n_param_specs;
+ gint i, j;
+
+ g_return_val_if_fail (GIMP_IS_OBJECT (config), NULL);
+
+ param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config),
+ &n_param_specs);
+
+ for (i = 0, j = 0; i < n_param_specs; i++)
+ {
+ GParamSpec *pspec = param_specs[i];
+
+ /* ignore properties of parent classes of owner_type */
+ if (! g_type_is_a (pspec->owner_type, owner_type))
+ continue;
+
+ if (flags && ((pspec->flags & flags) != flags))
+ continue;
+
+ if (gimp_gegl_param_spec_has_key (pspec, "role", "output-extent"))
+ continue;
+
+ param_specs[j] = param_specs[i];
+ j++;
+ }
+
+ if (n_pspecs)
+ *n_pspecs = j;
+
+ if (j == 0)
+ {
+ g_free (param_specs);
+ param_specs = NULL;
+ }
+
+ return param_specs;
+}
+
/* private functions */
diff --git a/app/operations/gimp-operation-config.h b/app/operations/gimp-operation-config.h
index dfd84a4..09d3997 100644
--- a/app/operations/gimp-operation-config.h
+++ b/app/operations/gimp-operation-config.h
@@ -44,5 +44,10 @@ void gimp_operation_config_sync_node (GimpObject *config,
void gimp_operation_config_connect_node (GimpObject *config,
GeglNode *node);
+GParamSpec ** gimp_operation_config_list_properties (GimpObject *config,
+ GType owner_type,
+ GParamFlags flags,
+ guint *n_pspecs);
+
#endif /* __GIMP_OPERATION_CONFIG_H__ */
diff --git a/app/propgui/gimppropgui.c b/app/propgui/gimppropgui.c
index 175c9f4..1444aca 100644
--- a/app/propgui/gimppropgui.c
+++ b/app/propgui/gimppropgui.c
@@ -37,6 +37,8 @@
#include "gegl/gimp-gegl-utils.h"
+#include "operations/gimp-operation-config.h"
+
#include "core/gimpcontext.h"
#include "widgets/gimpcolorpanel.h"
@@ -488,37 +490,18 @@ gimp_prop_gui_new (GObject *config,
GtkWidget *gui = NULL;
GParamSpec **param_specs;
guint n_param_specs;
- gint i, j;
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
- param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config),
- &n_param_specs);
+ param_specs = gimp_operation_config_list_properties (GIMP_OBJECT (config),
+ owner_type, flags,
+ &n_param_specs);
- for (i = 0, j = 0; i < n_param_specs; i++)
- {
- GParamSpec *pspec = param_specs[i];
-
- /* ignore properties of parent classes of owner_type */
- if (! g_type_is_a (pspec->owner_type, owner_type))
- continue;
-
- if (flags && ((pspec->flags & flags) != flags))
- continue;
-
- if (HAS_KEY (pspec, "role", "output-extent"))
- continue;
-
- param_specs[j] = param_specs[i];
- j++;
- }
-
- n_param_specs = j;
-
- if (n_param_specs > 0)
+ if (param_specs)
{
const gchar *config_type_name = G_OBJECT_TYPE_NAME (config);
+ gint i;
for (i = 0; i < G_N_ELEMENTS (gui_new_funcs); i++)
{
@@ -539,6 +522,8 @@ gimp_prop_gui_new (GObject *config,
break;
}
}
+
+ g_free (param_specs);
}
else
{
@@ -549,8 +534,6 @@ gimp_prop_gui_new (GObject *config,
gtk_misc_set_padding (GTK_MISC (gui), 0, 4);
}
- g_free (param_specs);
-
return gui;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]