mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-10-06 01:12:40 +02:00
libgimp, libgimpbase, libgimpconfig: GimpParamSpecChoise's parent should be GParamSpecString.
This commit is contained in:
@@ -376,15 +376,6 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
||||
|
||||
param_def->meta.m_enum.default_val = espec->default_value;
|
||||
}
|
||||
else if (pspec_type == GIMP_TYPE_PARAM_CHOICE)
|
||||
{
|
||||
GimpParamSpecChoice *cspec = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_CHOICE;
|
||||
|
||||
param_def->meta.m_choice.default_val = cspec->default_value;
|
||||
param_def->meta.m_choice.choice = cspec->choice;
|
||||
}
|
||||
else if (pspec_type == G_TYPE_PARAM_BOOLEAN)
|
||||
{
|
||||
GParamSpecBoolean *bspec = G_PARAM_SPEC_BOOLEAN (pspec);
|
||||
@@ -403,6 +394,17 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
||||
param_def->meta.m_float.max_val = dspec->maximum;
|
||||
param_def->meta.m_float.default_val = dspec->default_value;
|
||||
}
|
||||
/* Must be before G_IS_PARAM_SPEC_STRING() because it's a parent. */
|
||||
else if (pspec_type == GIMP_TYPE_PARAM_CHOICE)
|
||||
{
|
||||
GimpParamSpecChoice *cspec = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
GParamSpecString *sspec = G_PARAM_SPEC_STRING (pspec);
|
||||
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_CHOICE;
|
||||
|
||||
param_def->meta.m_choice.default_val = sspec->default_value;
|
||||
param_def->meta.m_choice.choice = cspec->choice;
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_STRING (pspec))
|
||||
{
|
||||
GParamSpecString *gsspec = G_PARAM_SPEC_STRING (pspec);
|
||||
|
@@ -703,9 +703,10 @@ gimp_procedure_config_get_choice_id (GimpProcedureConfig *config,
|
||||
|
||||
if (! g_type_is_a (G_TYPE_FROM_INSTANCE (param_spec), GIMP_TYPE_PARAM_CHOICE))
|
||||
{
|
||||
g_warning ("%s: property '%s' of %s is not a GimpParamSpecChoice.",
|
||||
g_warning ("%s: property '%s' of %s is a %s, not a GimpParamSpecChoice.",
|
||||
G_STRFUNC,
|
||||
param_spec->name,
|
||||
g_type_name (G_TYPE_FROM_INSTANCE (param_spec)),
|
||||
g_type_name (param_spec->owner_type));
|
||||
return 0;
|
||||
}
|
||||
|
@@ -402,8 +402,6 @@ gimp_choice_desc_free (GimpChoiceDesc *desc)
|
||||
|
||||
static void gimp_param_choice_class_init (GParamSpecClass *klass);
|
||||
static void gimp_param_choice_init (GParamSpec *pspec);
|
||||
static void gimp_param_choice_value_set_default (GParamSpec *pspec,
|
||||
GValue *value);
|
||||
static void gimp_param_choice_finalize (GParamSpec *pspec);
|
||||
static gboolean gimp_param_choice_validate (GParamSpec *pspec,
|
||||
GValue *value);
|
||||
@@ -429,7 +427,7 @@ gimp_param_choice_get_type (void)
|
||||
(GInstanceInitFunc) gimp_param_choice_init
|
||||
};
|
||||
|
||||
type = g_type_register_static (G_TYPE_PARAM_BOXED,
|
||||
type = g_type_register_static (G_TYPE_PARAM_STRING,
|
||||
"GimpParamChoice", &info, 0);
|
||||
}
|
||||
|
||||
@@ -440,7 +438,6 @@ static void
|
||||
gimp_param_choice_class_init (GParamSpecClass *klass)
|
||||
{
|
||||
klass->value_type = G_TYPE_STRING;
|
||||
klass->value_set_default = gimp_param_choice_value_set_default;
|
||||
klass->finalize = gimp_param_choice_finalize;
|
||||
klass->value_validate = gimp_param_choice_validate;
|
||||
klass->values_cmp = gimp_param_choice_values_cmp;
|
||||
@@ -451,17 +448,7 @@ gimp_param_choice_init (GParamSpec *pspec)
|
||||
{
|
||||
GimpParamSpecChoice *choice = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
|
||||
choice->choice = NULL;
|
||||
choice->default_value = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_choice_value_set_default (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GimpParamSpecChoice *cspec = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
|
||||
g_value_set_string (value, cspec->default_value);
|
||||
choice->choice = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -470,7 +457,6 @@ gimp_param_choice_finalize (GParamSpec *pspec)
|
||||
GimpParamSpecChoice *spec_choice = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
GParamSpecClass *parent_class = g_type_class_peek (g_type_parent (GIMP_TYPE_PARAM_CHOICE));
|
||||
|
||||
g_free (spec_choice->default_value);
|
||||
g_object_unref (spec_choice->choice);
|
||||
|
||||
parent_class->finalize (pspec);
|
||||
@@ -481,14 +467,15 @@ gimp_param_choice_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GimpParamSpecChoice *spec_choice = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
GParamSpecString *spec_string = G_PARAM_SPEC_STRING (pspec);
|
||||
GimpChoice *choice = spec_choice->choice;
|
||||
const gchar *strval = g_value_get_string (value);
|
||||
|
||||
if (! gimp_choice_is_valid (choice, strval))
|
||||
{
|
||||
if (gimp_choice_is_valid (choice, spec_choice->default_value))
|
||||
if (gimp_choice_is_valid (choice, spec_string->default_value))
|
||||
{
|
||||
g_value_set_string (value, spec_choice->default_value);
|
||||
g_value_set_string (value, spec_string->default_value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -549,14 +536,20 @@ gimp_param_spec_choice (const gchar *name,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GimpParamSpecChoice *choice_spec;
|
||||
GParamSpecString *string_spec;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_CHOICE (choice), NULL);
|
||||
g_return_val_if_fail (gimp_choice_is_valid (choice, default_value), NULL);
|
||||
|
||||
choice_spec = g_param_spec_internal (GIMP_TYPE_PARAM_CHOICE,
|
||||
name, nick, blurb, flags);
|
||||
|
||||
g_return_val_if_fail (choice_spec, NULL);
|
||||
|
||||
string_spec = G_PARAM_SPEC_STRING (choice_spec);
|
||||
|
||||
choice_spec->choice = choice;
|
||||
choice_spec->default_value = g_strdup (default_value);
|
||||
string_spec->default_value = g_strdup (default_value);
|
||||
|
||||
return G_PARAM_SPEC (choice_spec);
|
||||
}
|
||||
|
@@ -80,10 +80,9 @@ typedef struct _GimpParamSpecChoice GimpParamSpecChoice;
|
||||
|
||||
struct _GimpParamSpecChoice
|
||||
{
|
||||
GParamSpecBoxed parent_instance;
|
||||
GParamSpecString parent_instance;
|
||||
|
||||
gchar *default_value;
|
||||
GimpChoice *choice;
|
||||
GimpChoice *choice;
|
||||
};
|
||||
|
||||
GType gimp_param_choice_get_type (void) G_GNUC_CONST;
|
||||
|
@@ -94,7 +94,16 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
|
||||
{
|
||||
GParamSpecString *spec = G_PARAM_SPEC_STRING (pspec);
|
||||
|
||||
if (GEGL_IS_PARAM_SPEC_FILE_PATH (pspec))
|
||||
if (GIMP_IS_PARAM_SPEC_CHOICE (pspec))
|
||||
{
|
||||
GimpParamSpecChoice *cspec = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
|
||||
copy = gimp_param_spec_choice (name, nick, blurb,
|
||||
g_object_ref (cspec->choice),
|
||||
spec->default_value,
|
||||
flags);
|
||||
}
|
||||
else if (GEGL_IS_PARAM_SPEC_FILE_PATH (pspec))
|
||||
{
|
||||
copy = gimp_param_spec_config_path (name, nick, blurb,
|
||||
GIMP_CONFIG_PATH_FILE,
|
||||
@@ -229,15 +238,6 @@ gimp_config_param_spec_duplicate (GParamSpec *pspec)
|
||||
flags);
|
||||
}
|
||||
}
|
||||
else if (GIMP_IS_PARAM_SPEC_CHOICE (pspec))
|
||||
{
|
||||
GimpParamSpecChoice *spec = GIMP_PARAM_SPEC_CHOICE (pspec);
|
||||
|
||||
copy = gimp_param_spec_choice (name, nick, blurb,
|
||||
g_object_ref (spec->choice),
|
||||
spec->default_value,
|
||||
flags);
|
||||
}
|
||||
else if (GIMP_IS_PARAM_SPEC_OBJECT (pspec))
|
||||
{
|
||||
/* GimpParamSpecColor, GimpParamSpecUnit and all GimpParamSpecResource types. */
|
||||
|
Reference in New Issue
Block a user