From 635da347cd874d9c863f34de87729cfa6a9f11b9 Mon Sep 17 00:00:00 2001 From: Jehan Date: Fri, 6 Mar 2026 22:49:14 +0100 Subject: [PATCH] plug-ins: improve describing enum and choice arguments. * Also print the default value for both types of args. * Display choice values with quotes since they are technically strings. --- plug-ins/filter-browser/filter-browser.c | 28 +++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/plug-ins/filter-browser/filter-browser.c b/plug-ins/filter-browser/filter-browser.c index c730d0f2be..98bbfe0ffb 100644 --- a/plug-ins/filter-browser/filter-browser.c +++ b/plug-ins/filter-browser/filter-browser.c @@ -299,37 +299,49 @@ create_filter_param_details (GParamSpec *pspec, help = (help != NULL ? g_markup_escape_text (help, -1) : NULL); /* \xe2\x80\xa2 is the UTF-8 for the bullet point. */ if (help != NULL) - g_string_append_printf (desc, "\n\xe2\x80\xa2 %s: %s\n\t%s", nick, label, help); + g_string_append_printf (desc, "\n\xe2\x80\xa2 \"%s\": %s\n\t%s", nick, label, help); else - g_string_append_printf (desc, "\n\xe2\x80\xa2 %s: %s", nick, label); + g_string_append_printf (desc, "\n\xe2\x80\xa2 \"%s\": %s", nick, label); g_free (nick); g_free (label); g_free (help); } + g_string_append_printf (blurb, "\ndefault: \"%s\"", + gimp_param_spec_choice_get_default (pspec)); + g_string_append (blurb, desc->str); g_string_free (desc, TRUE); } if (g_type_is_a (gtype, G_TYPE_ENUM)) { - GEnumClass *eclass = NULL; - GType etype = 0; + const GValue *default_value; + GEnumClass *eclass = NULL; + GType etype = 0; + GString *desc = NULL; - etype = G_VALUE_TYPE (g_param_spec_get_default_value (pspec)); - eclass = g_type_class_ref (etype); + default_value = g_param_spec_get_default_value (pspec); + etype = G_VALUE_TYPE (default_value); + eclass = g_type_class_ref (etype); - g_string_append_printf (blurb, "\n%s", _("Allowed values:")); + desc = g_string_new ("\n"); + g_string_append_printf (desc, "%s", _("Allowed values:")); for (guint i = 0; i < eclass->n_values; i++ ) { GEnumValue value = eclass->values[i]; /* \xe2\x80\xa2 is the UTF-8 for the bullet point. */ - g_string_append_printf (blurb, "\n\xe2\x80\xa2 %s: %s", value.value_name, value.value_nick); + g_string_append_printf (desc, "\n\xe2\x80\xa2 %s: %s", value.value_name, value.value_nick); + if (value.value == g_value_get_enum (default_value)) + g_string_append_printf (blurb, "\ndefault: %s", value.value_name); } + g_string_append (blurb, desc->str); + + g_string_free (desc, TRUE); g_type_class_unref (eclass); }