mirror of https://github.com/GNOME/gimp.git
app, libgimp, libgimpbase: use GimpParamSpecObject infrastructure for…
… GimpParamSpecUnit's default value.
When I reparented GimpParamSpecUnit to GimpParamSpecObject in commit
ba3da3d338
, I clearly forgot to get rid of the redundant default value.
This commit is contained in:
parent
af53dfab75
commit
23c9503bfa
|
@ -49,9 +49,12 @@ static gchar *
|
|||
gimp_param_spec_unit_desc (GParamSpec *pspec)
|
||||
{
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
GObject *default_value;
|
||||
|
||||
default_value = gimp_param_spec_object_get_default (pspec);
|
||||
|
||||
return g_strdup_printf ("<i>(default %s%s%s)</i>",
|
||||
gimp_unit_get_abbreviation (uspec->default_value),
|
||||
gimp_unit_get_abbreviation (GIMP_UNIT (default_value)),
|
||||
uspec->allow_pixel ? ", pixel allowed": "",
|
||||
uspec->allow_percent ? ", percent allowed": "");
|
||||
}
|
||||
|
|
|
@ -430,12 +430,15 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|||
else if (pspec_type == GIMP_TYPE_PARAM_UNIT)
|
||||
{
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
GObject *default_value;
|
||||
|
||||
default_value = gimp_param_spec_object_get_default (pspec);
|
||||
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_UNIT;
|
||||
|
||||
param_def->meta.m_unit.allow_pixels = uspec->allow_pixel;
|
||||
param_def->meta.m_unit.allow_percent = uspec->allow_percent;
|
||||
param_def->meta.m_unit.default_val = gimp_unit_get_id (uspec->default_value);
|
||||
param_def->meta.m_unit.default_val = gimp_unit_get_id (GIMP_UNIT (default_value));
|
||||
}
|
||||
#ifndef LIBGIMP_COMPILATION
|
||||
/* This trick is only for core side when it needs to send the param
|
||||
|
|
|
@ -45,9 +45,12 @@ static gchar *
|
|||
gimp_param_spec_unit_desc (GParamSpec *pspec)
|
||||
{
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
GObject *default_value;
|
||||
|
||||
default_value = gimp_param_spec_object_get_default (pspec);
|
||||
|
||||
return g_strdup_printf ("<i>(default %s%s%s)</i>",
|
||||
gimp_unit_get_abbreviation (uspec->default_value),
|
||||
gimp_unit_get_abbreviation (GIMP_UNIT (default_value)),
|
||||
uspec->allow_pixel ? ", pixel allowed": "",
|
||||
uspec->allow_percent ? ", percent allowed": "");
|
||||
}
|
||||
|
|
|
@ -933,8 +933,6 @@ gimp_units_to_points (gdouble value,
|
|||
static void gimp_param_unit_class_init (GimpParamSpecObjectClass *klass);
|
||||
static void gimp_param_unit_init (GParamSpec *pspec);
|
||||
static GParamSpec * gimp_param_unit_duplicate (GParamSpec *pspec);
|
||||
static void gimp_param_unit_set_default (GParamSpec *pspec,
|
||||
GValue *value);
|
||||
static gboolean gimp_param_unit_validate (GParamSpec *pspec,
|
||||
GValue *value);
|
||||
|
||||
|
@ -980,18 +978,19 @@ gimp_param_unit_class_init (GimpParamSpecObjectClass *klass)
|
|||
klass->duplicate = gimp_param_unit_duplicate;
|
||||
|
||||
pclass->value_type = GIMP_TYPE_UNIT;
|
||||
pclass->value_set_default = gimp_param_unit_set_default;
|
||||
pclass->value_validate = gimp_param_unit_validate;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_unit_init (GParamSpec *pspec)
|
||||
{
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
GimpParamSpecObject *ospec = GIMP_PARAM_SPEC_OBJECT (pspec);
|
||||
|
||||
uspec->allow_pixel = TRUE;
|
||||
uspec->allow_percent = TRUE;
|
||||
uspec->default_value = gimp_unit_inch ();
|
||||
uspec->allow_pixel = TRUE;
|
||||
uspec->allow_percent = TRUE;
|
||||
ospec->_default_value = g_object_ref (G_OBJECT (gimp_unit_inch ()));
|
||||
ospec->_has_default = TRUE;
|
||||
}
|
||||
|
||||
static GParamSpec *
|
||||
|
@ -1008,24 +1007,15 @@ gimp_param_unit_duplicate (GParamSpec *pspec)
|
|||
g_param_spec_get_blurb (pspec),
|
||||
uspec->allow_pixel,
|
||||
uspec->allow_percent,
|
||||
uspec->default_value,
|
||||
GIMP_UNIT (gimp_param_spec_object_get_default (pspec)),
|
||||
pspec->flags);
|
||||
|
||||
return duplicate;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_param_unit_set_default (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
{
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
|
||||
g_value_set_object (value, uspec->default_value);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_param_unit_validate (GParamSpec *pspec,
|
||||
GValue *value)
|
||||
GValue *value)
|
||||
{
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
GObject *unit = value->data[0].v_pointer;
|
||||
|
@ -1035,7 +1025,7 @@ gimp_param_unit_validate (GParamSpec *pspec,
|
|||
(! uspec->allow_pixel && value->data[0].v_pointer == gimp_unit_pixel ()))
|
||||
{
|
||||
g_clear_object (&unit);
|
||||
value->data[0].v_pointer = g_object_ref (uspec->default_value);
|
||||
value->data[0].v_pointer = g_object_ref (gimp_param_spec_object_get_default (pspec));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -1065,7 +1055,7 @@ gimp_param_spec_unit (const gchar *name,
|
|||
const gchar *blurb,
|
||||
gboolean allow_pixel,
|
||||
gboolean allow_percent,
|
||||
GimpUnit *default_value,
|
||||
GimpUnit *default_value,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GimpParamSpecUnit *uspec;
|
||||
|
@ -1079,7 +1069,7 @@ gimp_param_spec_unit (const gchar *name,
|
|||
|
||||
uspec->allow_pixel = allow_pixel;
|
||||
uspec->allow_percent = allow_percent;
|
||||
uspec->default_value = default_value;
|
||||
gimp_param_spec_object_set_default (G_PARAM_SPEC (uspec), G_OBJECT (default_value));
|
||||
|
||||
return G_PARAM_SPEC (uspec);
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ struct _GimpParamSpecUnit
|
|||
|
||||
gboolean allow_pixel;
|
||||
gboolean allow_percent;
|
||||
GimpUnit *default_value;
|
||||
};
|
||||
|
||||
GType gimp_param_unit_get_type (void) G_GNUC_CONST;
|
||||
|
|
Loading…
Reference in New Issue