diff --git a/app/operations/gimp-operation-config.c b/app/operations/gimp-operation-config.c index 13067dc354..cc5bf4a044 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 dfd84a4042..09d39974bd 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 175c9f467f..1444aca71e 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; }