[gimp] Enhance GimpProcedureDialog have int combo widget for G_PARAM_SPEC_ENUM
- From: Lloyd Konneker <lkonneker src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Enhance GimpProcedureDialog have int combo widget for G_PARAM_SPEC_ENUM
- Date: Sat, 13 Aug 2022 13:24:49 +0000 (UTC)
commit 0c1b00b04c772b2c653144f19f5b24df49b4cfe8
Author: lloyd konneker <konnekerl gmail com>
Date: Sat Aug 13 07:34:17 2022 -0400
Enhance GimpProcedureDialog have int combo widget for G_PARAM_SPEC_ENUM
Resolves #8488
libgimp/gimpproceduredialog.c | 20 ++++++++++++--
libgimpwidgets/gimppropwidgets.c | 58 +++++++++++++++++++++++++++++++++++++---
2 files changed, 72 insertions(+), 6 deletions(-)
---
diff --git a/libgimp/gimpproceduredialog.c b/libgimp/gimpproceduredialog.c
index f3e126da1d..bd63b42d50 100644
--- a/libgimp/gimpproceduredialog.c
+++ b/libgimp/gimpproceduredialog.c
@@ -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;
}
diff --git a/libgimpwidgets/gimppropwidgets.c b/libgimpwidgets/gimppropwidgets.c
index a6f23af92a..1d79fd8507 100644
--- a/libgimpwidgets/gimppropwidgets.c
+++ b/libgimpwidgets/gimppropwidgets.c
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]