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().
This commit is contained in:
Michael Natterer 2017-07-09 17:59:29 +02:00
parent 2a75df030e
commit 51cc6893ab
3 changed files with 59 additions and 26 deletions

View File

@ -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 */

View File

@ -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__ */

View File

@ -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;
}