mirror of https://github.com/GNOME/gimp.git
Enhance GimpProcedureDialog have int combo widget for G_PARAM_SPEC_ENUM
Resolves #8488
This commit is contained in:
parent
062b5290cd
commit
0c1b00b04c
|
@ -725,10 +725,26 @@ gimp_procedure_dialog_get_widget (GimpProcedureDialog *dialog,
|
|||
property, NULL,
|
||||
GTK_FILE_CHOOSER_ACTION_OPEN);
|
||||
}
|
||||
else if (G_PARAM_SPEC_TYPE (pspec) == G_TYPE_PARAM_ENUM)
|
||||
{
|
||||
GimpIntStore *store;
|
||||
|
||||
store = (GimpIntStore *) gimp_enum_store_new (G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
|
||||
widget = gimp_prop_int_combo_box_new (G_OBJECT (dialog->priv->config),
|
||||
property,
|
||||
store);
|
||||
gtk_widget_set_vexpand (widget, FALSE);
|
||||
gtk_widget_set_hexpand (widget, TRUE);
|
||||
widget = gimp_label_int_widget_new (g_param_spec_get_nick (pspec),
|
||||
widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: parameter %s has non supported type %s",
|
||||
G_STRFUNC, property, G_PARAM_SPEC_TYPE_NAME (pspec));
|
||||
g_warning ("%s: parameter %s has non supported type %s for value type %s",
|
||||
G_STRFUNC, property,
|
||||
G_PARAM_SPEC_TYPE_NAME (pspec),
|
||||
g_type_name (G_PARAM_SPEC_VALUE_TYPE (pspec)));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,11 @@ static GParamSpec * get_param_spec (GObject *object);
|
|||
static GParamSpec * find_param_spec (GObject *object,
|
||||
const gchar *property_name,
|
||||
const gchar *strloc);
|
||||
static GParamSpec * check_param_spec_quiet (
|
||||
GObject *object,
|
||||
const gchar *property_name,
|
||||
GType type,
|
||||
const gchar *strloc);
|
||||
static GParamSpec * check_param_spec (GObject *object,
|
||||
const gchar *property_name,
|
||||
GType type,
|
||||
|
@ -414,10 +419,36 @@ gimp_prop_int_combo_box_new (GObject *config,
|
|||
g_return_val_if_fail (G_IS_OBJECT (config), NULL);
|
||||
g_return_val_if_fail (property_name != NULL, NULL);
|
||||
|
||||
param_spec = check_param_spec_w (config, property_name,
|
||||
G_TYPE_PARAM_INT, G_STRFUNC);
|
||||
if (! param_spec)
|
||||
return NULL;
|
||||
/* Require property is integer valued type: INT or ENUM, and is writeable. */
|
||||
param_spec = check_param_spec_quiet (config, property_name,
|
||||
G_TYPE_PARAM_INT, G_STRFUNC);
|
||||
if (param_spec)
|
||||
{
|
||||
param_spec = check_param_spec_w (config, property_name,
|
||||
G_TYPE_PARAM_INT, G_STRFUNC);
|
||||
if (! param_spec)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
param_spec = check_param_spec_quiet (config, property_name,
|
||||
G_TYPE_PARAM_ENUM, G_STRFUNC);
|
||||
if (param_spec)
|
||||
{
|
||||
param_spec = check_param_spec_w (config, property_name,
|
||||
G_TYPE_PARAM_ENUM, G_STRFUNC);
|
||||
if (! param_spec)
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("%s: property '%s' of %s is not integer valued.",
|
||||
G_STRFUNC,
|
||||
param_spec->name,
|
||||
g_type_name (param_spec->owner_type));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
combo_box = g_object_new (GIMP_TYPE_INT_COMBO_BOX,
|
||||
"model", store,
|
||||
|
@ -4536,6 +4567,25 @@ find_param_spec (GObject *object,
|
|||
return param_spec;
|
||||
}
|
||||
|
||||
/* Compare GType of GParamSpec of object's property to GType.
|
||||
* Return GParamSpec when equal, else NULL.
|
||||
*/
|
||||
static GParamSpec *
|
||||
check_param_spec_quiet (GObject *object,
|
||||
const gchar *property_name,
|
||||
GType type,
|
||||
const gchar *strloc)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
|
||||
param_spec = find_param_spec (object, property_name, strloc);
|
||||
|
||||
if (param_spec && ! g_type_is_a (G_TYPE_FROM_INSTANCE (param_spec), type))
|
||||
return NULL;
|
||||
else
|
||||
return param_spec;
|
||||
}
|
||||
|
||||
static GParamSpec *
|
||||
check_param_spec (GObject *object,
|
||||
const gchar *property_name,
|
||||
|
|
Loading…
Reference in New Issue