gboolean stetic_param_spec_get_default (GParamSpec *pspec, GValue *value) { g_value_init (value, pspec->value_type); if (G_IS_PARAM_SPEC_CHAR (pspec)) g_value_set_char (value, G_PARAM_SPEC_CHAR (pspec)->default_value); else if (G_IS_PARAM_SPEC_UCHAR (pspec)) g_value_set_uchar (value, G_PARAM_SPEC_UCHAR (pspec)->default_value); else if (G_IS_PARAM_SPEC_INT (pspec)) g_value_set_int (value, G_PARAM_SPEC_INT (pspec)->default_value); else if (G_IS_PARAM_SPEC_UINT (pspec)) g_value_set_uint (value, G_PARAM_SPEC_UINT (pspec)->default_value); else if (G_IS_PARAM_SPEC_LONG (pspec)) g_value_set_long (value, G_PARAM_SPEC_LONG (pspec)->default_value); else if (G_IS_PARAM_SPEC_ULONG (pspec)) g_value_set_ulong (value, G_PARAM_SPEC_ULONG (pspec)->default_value); else if (G_IS_PARAM_SPEC_INT64 (pspec)) g_value_set_int64 (value, G_PARAM_SPEC_INT64 (pspec)->default_value); else if (G_IS_PARAM_SPEC_UINT64 (pspec)) g_value_set_uint64 (value, G_PARAM_SPEC_UINT64 (pspec)->default_value); else if (G_IS_PARAM_SPEC_FLOAT (pspec)) g_value_set_float (value, G_PARAM_SPEC_FLOAT (pspec)->default_value); else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) g_value_set_double (value, G_PARAM_SPEC_DOUBLE (pspec)->default_value); else if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) g_value_set_boolean (value, G_PARAM_SPEC_BOOLEAN (pspec)->default_value); else if (G_IS_PARAM_SPEC_UNICHAR (pspec)) g_value_set_uint (value, G_PARAM_SPEC_UNICHAR (pspec)->default_value); else if (G_IS_PARAM_SPEC_STRING (pspec)) g_value_set_static_string (value, G_PARAM_SPEC_STRING (pspec)->default_value); else return FALSE; return TRUE; }
static void gimp_magnify_options_reset (GimpToolOptions *tool_options) { GParamSpec *pspec; pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (tool_options), "auto-resize"); if (pspec) G_PARAM_SPEC_BOOLEAN (pspec)->default_value = GIMP_DISPLAY_CONFIG (tool_options->tool_info->gimp->config)->resize_windows_on_zoom; GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (tool_options); }
static void json_list_properties (GType type, const gchar *opname) { GParamSpec **self; GParamSpec **parent; guint n_self; guint n_parent; gint prop_no; gboolean first_prop = TRUE; g_print (",'properties':[\n"); if (!type) return; self = g_object_class_list_properties ( G_OBJECT_CLASS (g_type_class_ref (type)), &n_self); parent = g_object_class_list_properties ( /*G_OBJECT_CLASS (g_type_class_peek_parent (g_type_class_ref (type))),*/ G_OBJECT_CLASS (g_type_class_ref (GEGL_TYPE_OPERATION)), &n_parent); for (prop_no=0;prop_no<n_self;prop_no++) { gint parent_no; gboolean found=FALSE; for (parent_no=0;parent_no<n_parent;parent_no++) if (self[prop_no]==parent[parent_no]) found=TRUE; /* only print properties if we are an addition compared to * GeglOperation */ if (!found) { const gchar *type_name = g_type_name (G_OBJECT_TYPE (self[prop_no])); if (first_prop) { first_prop = FALSE; g_print(" { 'name':'%s'\n", g_param_spec_get_name (self[prop_no])); } else g_print(",{'name':'%s'\n", g_param_spec_get_name (self[prop_no])); g_print(" ,'label':\""); json_escape_string (g_param_spec_get_nick (self[prop_no])); g_print ("\"\n"); if(strstr (type_name, "Param")) { type_name = strstr (type_name, "Param"); type_name+=5; } g_print(" ,'type':'"); { for (const char *p = type_name; *p; p++) g_print("%c", g_ascii_tolower (*p)); } g_print("'\n"); if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_DOUBLE)) { gdouble default_value = G_PARAM_SPEC_DOUBLE (self[prop_no])->default_value; gdouble min = G_PARAM_SPEC_DOUBLE (self[prop_no])->minimum; gdouble max = G_PARAM_SPEC_DOUBLE (self[prop_no])->maximum; if (default_value<-10000000) g_print (" ,'default':'-inf'\n"); else if (default_value>10000000) g_print (" ,'default':'+inf'\n"); else g_print (" ,'default':'%2.2f'\n", default_value); if (min<-10000000) g_print (" ,'minimum':'-inf'\n"); else g_print (" ,'minimum':'%2.2f'\n", min); if (max>10000000) g_print (" ,'maximum':'+inf'\n"); else g_print (" ,'maximum':'%2.2f'\n", max); if (GEGL_IS_PARAM_SPEC_DOUBLE (self[prop_no])) { GeglParamSpecDouble *pspec = GEGL_PARAM_SPEC_DOUBLE (self[prop_no]); if (pspec->ui_minimum < -10000000) g_print (" ,'ui-minimum':'-inf'\n"); else g_print (" ,'ui-minimum':'%2.2f'\n", pspec->ui_minimum); if (pspec->ui_maximum > 10000000) g_print (" ,'ui-maximum':'+inf'\n"); else g_print (" ,'ui-maximum':'%2.2f'\n", pspec->ui_maximum); g_print (" ,'ui-gamma':'%2.2f'\n", pspec->ui_gamma); g_print (" ,'ui-step-small':'%2.2f'\n", pspec->ui_step_small); g_print (" ,'ui-step-big':'%2.2f'\n", pspec->ui_step_big); g_print (" ,'ui-digits':'%i'\n", pspec->ui_digits); } } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_INT)) { gint default_value = G_PARAM_SPEC_INT (self[prop_no])->default_value; gint min = G_PARAM_SPEC_INT (self[prop_no])->minimum; gint max = G_PARAM_SPEC_INT (self[prop_no])->maximum; if (default_value<-10000000) g_print (" ,'default':'-inf'\n"); else if (default_value>10000000) g_print (" ,'default':'+inf'\n"); else g_print (" ,'default':'%i'\n", default_value); if (min<-10000000) g_print (" ,'minimum':'-inf'\n"); else g_print (" ,'minimum':'%i'\n", min); if (max>10000000) g_print (" ,'maximum':'+inf'\n"); else g_print (" ,'maximum':'%i'\n", max); if (GEGL_IS_PARAM_SPEC_INT (self[prop_no])) { GeglParamSpecInt *pspec = GEGL_PARAM_SPEC_INT (self[prop_no]); if (pspec->ui_minimum < -10000000) g_print (" ,'ui-minimum':'-inf'\n"); else g_print (" ,'ui-minimum':'%i'\n", pspec->ui_minimum); if (pspec->ui_maximum > 10000000) g_print (" ,'ui-maximum':'+inf'\n"); else g_print (" ,'ui-maximum':'%i'\n", pspec->ui_maximum); g_print (" ,'ui-gamma':'%2.2f'\n", pspec->ui_gamma); g_print (" ,'ui-step-small':'%i'\n", pspec->ui_step_small); g_print (" ,'ui-step-big':'%i'\n", pspec->ui_step_big); } } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_BOOLEAN)) { g_print (" ,'default':'%s'\n", G_PARAM_SPEC_BOOLEAN (self[prop_no])->default_value?"True":"False"); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_STRING)) { const gchar *string = G_PARAM_SPEC_STRING (self[prop_no])->default_value; g_print (" ,'default':\""); json_escape_string (string); g_print ("\"\n"); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), GEGL_TYPE_COLOR)) { GeglColor *color = gegl_param_spec_color_get_default (self[prop_no]); if (color) { gchar *string; g_object_get (color, "string", &string, NULL); g_print (" ,'default':\""); json_escape_string (string); g_print ("\"\n"); g_free (string); } } else { } if (g_param_spec_get_blurb (self[prop_no]) && g_param_spec_get_blurb (self[prop_no])[0]!='\0') { g_print (" ,'description':\""); json_escape_string (g_param_spec_get_blurb (self[prop_no])); g_print ("\"\n"); } { guint count; gchar **property_keys = gegl_operation_list_property_keys ( opname, g_param_spec_get_name (self[prop_no]), &count); if (property_keys) { int i; if (property_keys[0]) { /* XXX: list is in reverse order */ for (i = 0; property_keys[i]; i++) { g_print (" ,'%s':'%s'\n", property_keys[i], gegl_operation_get_property_key (opname, g_param_spec_get_name (self[prop_no]), property_keys[i])); } } g_free (property_keys); } } g_print(" }"); } } if (self) g_free (self); if (parent) g_free (parent); g_print ("]"); }
/* XXX Historical note, originally I tried (ab)using override properties * in ESourceCamel, which redirected to the equivalent CamelSettings * property. Seemed to work at first, and I was proud of my clever * hack, but it turns out g_object_class_list_properties() excludes * override properties. So the ESourceCamel properties were being * skipped in source_load_from_key_file() (e-source.c). */ static GParamSpec * param_spec_clone (GParamSpec *pspec) { GParamSpec *clone; GParamFlags flags; const gchar *name, *nick, *blurb; name = g_param_spec_get_name (pspec); nick = g_param_spec_get_nick (pspec); blurb = g_param_spec_get_blurb (pspec); flags = (pspec->flags & ~(G_PARAM_STATIC_STRINGS)); if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) { GParamSpecBoolean *pspec_boolean = G_PARAM_SPEC_BOOLEAN (pspec); clone = g_param_spec_boolean (name, nick, blurb, pspec_boolean->default_value, flags); } else if (G_IS_PARAM_SPEC_CHAR (pspec)) { GParamSpecChar *pspec_char = G_PARAM_SPEC_CHAR (pspec); clone = g_param_spec_char (name, nick, blurb, pspec_char->minimum, pspec_char->maximum, pspec_char->default_value, flags); } else if (G_IS_PARAM_SPEC_UCHAR (pspec)) { GParamSpecUChar *pspec_uchar = G_PARAM_SPEC_UCHAR (pspec); clone = g_param_spec_uchar (name, nick, blurb, pspec_uchar->minimum, pspec_uchar->maximum, pspec_uchar->default_value, flags); } else if (G_IS_PARAM_SPEC_INT (pspec)) { GParamSpecInt *pspec_int = G_PARAM_SPEC_INT (pspec); clone = g_param_spec_int (name, nick, blurb, pspec_int->minimum, pspec_int->maximum, pspec_int->default_value, flags); } else if (G_IS_PARAM_SPEC_UINT (pspec)) { GParamSpecUInt *pspec_uint = G_PARAM_SPEC_UINT (pspec); clone = g_param_spec_uint (name, nick, blurb, pspec_uint->minimum, pspec_uint->maximum, pspec_uint->default_value, flags); } else if (G_IS_PARAM_SPEC_LONG (pspec)) { GParamSpecLong *pspec_long = G_PARAM_SPEC_LONG (pspec); clone = g_param_spec_long (name, nick, blurb, pspec_long->minimum, pspec_long->maximum, pspec_long->default_value, flags); } else if (G_IS_PARAM_SPEC_ULONG (pspec)) { GParamSpecULong *pspec_ulong = G_PARAM_SPEC_ULONG (pspec); clone = g_param_spec_ulong (name, nick, blurb, pspec_ulong->minimum, pspec_ulong->maximum, pspec_ulong->default_value, flags); } else if (G_IS_PARAM_SPEC_INT64 (pspec)) { GParamSpecInt64 *pspec_int64 = G_PARAM_SPEC_INT64 (pspec); clone = g_param_spec_int64 (name, nick, blurb, pspec_int64->minimum, pspec_int64->maximum, pspec_int64->default_value, flags); } else if (G_IS_PARAM_SPEC_UINT64 (pspec)) { GParamSpecUInt64 *pspec_uint64 = G_PARAM_SPEC_UINT64 (pspec); clone = g_param_spec_uint64 (name, nick, blurb, pspec_uint64->minimum, pspec_uint64->maximum, pspec_uint64->default_value, flags); } else if (G_IS_PARAM_SPEC_FLOAT (pspec)) { GParamSpecFloat *pspec_float = G_PARAM_SPEC_FLOAT (pspec); clone = g_param_spec_float (name, nick, blurb, pspec_float->minimum, pspec_float->maximum, pspec_float->default_value, flags); } else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) { GParamSpecDouble *pspec_double = G_PARAM_SPEC_DOUBLE (pspec); clone = g_param_spec_double (name, nick, blurb, pspec_double->minimum, pspec_double->maximum, pspec_double->default_value, flags); } else if (G_IS_PARAM_SPEC_ENUM (pspec)) { GParamSpecEnum *pspec_enum = G_PARAM_SPEC_ENUM (pspec); clone = g_param_spec_enum (name, nick, blurb, pspec->value_type, pspec_enum->default_value, flags); } else if (G_IS_PARAM_SPEC_FLAGS (pspec)) { GParamSpecFlags *pspec_flags = G_PARAM_SPEC_FLAGS (pspec); clone = g_param_spec_flags (name, nick, blurb, pspec->value_type, pspec_flags->default_value, flags); } else if (G_IS_PARAM_SPEC_STRING (pspec)) { GParamSpecString *pspec_string = G_PARAM_SPEC_STRING (pspec); clone = g_param_spec_string (name, nick, blurb, pspec_string->default_value, flags); } else if (G_IS_PARAM_SPEC_PARAM (pspec)) { clone = g_param_spec_param (name, nick, blurb, pspec->value_type, flags); } else if (G_IS_PARAM_SPEC_BOXED (pspec)) { clone = g_param_spec_boxed (name, nick, blurb, pspec->value_type, flags); } else if (G_IS_PARAM_SPEC_POINTER (pspec)) { clone = g_param_spec_pointer (name, nick, blurb, flags); } else if (G_IS_PARAM_SPEC_OBJECT (pspec)) { clone = g_param_spec_object (name, nick, blurb, pspec->value_type, flags); } else if (G_IS_PARAM_SPEC_UNICHAR (pspec)) { GParamSpecUnichar *pspec_unichar = G_PARAM_SPEC_UNICHAR (pspec); clone = g_param_spec_unichar (name, nick, blurb, pspec_unichar->default_value, flags); } else if (G_IS_PARAM_SPEC_GTYPE (pspec)) { GParamSpecGType *pspec_gtype = G_PARAM_SPEC_GTYPE (pspec); clone = g_param_spec_gtype (name, nick, blurb, pspec_gtype->is_a_type, flags); } else if (G_IS_PARAM_SPEC_VARIANT (pspec)) { GParamSpecVariant *pspec_variant = G_PARAM_SPEC_VARIANT (pspec); clone = g_param_spec_variant (name, nick, blurb, pspec_variant->type, pspec_variant->default_value, flags); } else { g_warn_if_reached (); } return clone; }
static void list_properties (GType type, gint indent, gboolean html) { GParamSpec **self; GParamSpec **parent; guint n_self; guint n_parent; gint prop_no; if (!type) return; self = g_object_class_list_properties ( G_OBJECT_CLASS (g_type_class_ref (type)), &n_self); parent = g_object_class_list_properties ( /*G_OBJECT_CLASS (g_type_class_peek_parent (g_type_class_ref (type))),*/ G_OBJECT_CLASS (g_type_class_ref (GEGL_TYPE_OPERATION)), &n_parent); for (prop_no=0;prop_no<n_self;prop_no++) { gint parent_no; gboolean found=FALSE; for (parent_no=0;parent_no<n_parent;parent_no++) if (self[prop_no]==parent[parent_no]) found=TRUE; /* only print properties if we are an addition compared to * GeglOperation */ if (!found) { const gchar *type_name = g_type_name (G_OBJECT_TYPE (self[prop_no])); type_name = strstr (type_name, "Param"); type_name+=5; g_print("<tr><td colspan='1'> </td><td colspan='1' class='prop_type' valign='top'>%s<br/><span style='font-style:normal;text-align:right;float:right;padding-right:1em;'>", type_name); if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_DOUBLE)) { g_print ("%2.2f", G_PARAM_SPEC_DOUBLE (self[prop_no])->default_value); { gdouble min = G_PARAM_SPEC_DOUBLE (self[prop_no])->minimum; gdouble max = G_PARAM_SPEC_DOUBLE (self[prop_no])->maximum; g_print ("<br/>"); if (min<-10000000) g_print ("-inf "); else g_print ("%2.2f", min); g_print ("-"); if (max>10000000) g_print (" +inf"); else g_print ("%2.2f", max); } } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_INT)) { g_print ("%i", G_PARAM_SPEC_INT (self[prop_no])->default_value); { gint min = G_PARAM_SPEC_INT (self[prop_no])->minimum; gint max = G_PARAM_SPEC_INT (self[prop_no])->maximum; g_print ("<br/>"); if (min<-10000000) g_print ("-inf "); else g_print ("%i", min); g_print ("-"); if (max>10000000) g_print (" +inf"); else g_print ("%i", max); } } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_FLOAT)) { g_print ("%2.2f", G_PARAM_SPEC_FLOAT (self[prop_no])->default_value); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_BOOLEAN)) { g_print ("%s", G_PARAM_SPEC_BOOLEAN (self[prop_no])->default_value?"True":"False"); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), G_TYPE_STRING)) { const gchar *string = G_PARAM_SPEC_STRING (self[prop_no])->default_value; if (strlen (string) > 8) { gchar copy[16]; g_snprintf (copy, 12, "%s..", string); g_print ("%s", copy); } else g_print ("%s", string); } else if (g_type_is_a (G_PARAM_SPEC_VALUE_TYPE (self[prop_no]), GEGL_TYPE_COLOR)) { GeglColor *color = gegl_param_spec_color_get_default (self[prop_no]); if (color) { gchar *string; g_object_get (color, "string", &string, NULL); g_print ("%s", string); g_free (string); g_object_unref (color); } } else { g_print ("\n"); } g_print ("</span></td>"); g_print("<td class='prop_name' valign='top'>%s</td>\n", g_param_spec_get_name (self[prop_no])); if (g_param_spec_get_blurb (self[prop_no])[0]!='\0') g_print ("<td colspan='1' valign='top' class='prop_blurb'>%s</td>\n", g_param_spec_get_blurb (self[prop_no])); else g_print ("<td><em>not documented</em></td>\n\n"); g_print ("</tr>\n"); } } if (self) g_free (self); if (parent) g_free (parent); }
GParamSpec * gimp_param_spec_duplicate (GParamSpec *pspec) { GParamSpec *copy = NULL; GParamFlags flags; g_return_val_if_fail (pspec != NULL, NULL); flags = pspec->flags | GIMP_CONFIG_PARAM_SERIALIZE; if (G_IS_PARAM_SPEC_STRING (pspec)) { GParamSpecString *spec = G_PARAM_SPEC_STRING (pspec); if (GEGL_IS_PARAM_SPEC_FILE_PATH (pspec)) { copy = gimp_param_spec_config_path (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), GIMP_CONFIG_PATH_FILE, spec->default_value, flags); } else { static GQuark multiline_quark = 0; if (! multiline_quark) multiline_quark = g_quark_from_static_string ("multiline"); copy = g_param_spec_string (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->default_value, flags); if (GEGL_IS_PARAM_SPEC_MULTILINE (pspec)) { g_param_spec_set_qdata (copy, multiline_quark, GINT_TO_POINTER (TRUE)); } } } else if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) { GParamSpecBoolean *spec = G_PARAM_SPEC_BOOLEAN (pspec); copy = g_param_spec_boolean (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->default_value, flags); } else if (G_IS_PARAM_SPEC_ENUM (pspec)) { GParamSpecEnum *spec = G_PARAM_SPEC_ENUM (pspec); copy = g_param_spec_enum (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), G_TYPE_FROM_CLASS (spec->enum_class), spec->default_value, flags); } else if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec)) { GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec); GParamSpecDouble *spec = G_PARAM_SPEC_DOUBLE (pspec); copy = gegl_param_spec_double (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->minimum, spec->maximum, spec->default_value, gspec->ui_minimum, gspec->ui_maximum, gspec->ui_gamma, flags); } else if (G_IS_PARAM_SPEC_DOUBLE (pspec)) { GParamSpecDouble *spec = G_PARAM_SPEC_DOUBLE (pspec); copy = g_param_spec_double (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->minimum, spec->maximum, spec->default_value, flags); } else if (G_IS_PARAM_SPEC_FLOAT (pspec)) { GParamSpecFloat *spec = G_PARAM_SPEC_FLOAT (pspec); copy = g_param_spec_float (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->minimum, spec->maximum, spec->default_value, flags); } else if (GEGL_IS_PARAM_SPEC_INT (pspec)) { GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec); GParamSpecInt *spec = G_PARAM_SPEC_INT (pspec); copy = gegl_param_spec_int (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->minimum, spec->maximum, spec->default_value, gspec->ui_minimum, gspec->ui_maximum, gspec->ui_gamma, flags); } else if (GEGL_IS_PARAM_SPEC_SEED (pspec)) { copy = gegl_param_spec_seed (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), pspec->flags | GIMP_CONFIG_PARAM_SERIALIZE); } else if (G_IS_PARAM_SPEC_INT (pspec)) { GParamSpecInt *spec = G_PARAM_SPEC_INT (pspec); copy = g_param_spec_int (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->minimum, spec->maximum, spec->default_value, flags); } else if (G_IS_PARAM_SPEC_UINT (pspec)) { GParamSpecUInt *spec = G_PARAM_SPEC_UINT (pspec); copy = g_param_spec_uint (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), spec->minimum, spec->maximum, spec->default_value, flags); } else if (GIMP_IS_PARAM_SPEC_RGB (pspec)) { GValue value = G_VALUE_INIT; GimpRGB color; g_value_init (&value, GIMP_TYPE_RGB); g_param_value_set_default (pspec, &value); gimp_value_get_rgb (&value, &color); g_value_unset (&value); copy = gimp_param_spec_rgb (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), gimp_param_spec_rgb_has_alpha (pspec), &color, flags); } else if (GEGL_IS_PARAM_SPEC_COLOR (pspec)) { GeglColor *gegl_color; GimpRGB gimp_color; gdouble r = 0.0; gdouble g = 0.0; gdouble b = 0.0; gdouble a = 1.0; GValue value = { 0, }; g_value_init (&value, GEGL_TYPE_COLOR); g_param_value_set_default (pspec, &value); gegl_color = g_value_get_object (&value); if (gegl_color) gegl_color_get_rgba (gegl_color, &r, &g, &b, &a); gimp_rgba_set (&gimp_color, r, g, b, a); g_value_unset (&value); copy = gimp_param_spec_rgb (pspec->name, g_param_spec_get_nick (pspec), g_param_spec_get_blurb (pspec), TRUE, &gimp_color, flags); } else if (G_IS_PARAM_SPEC_OBJECT (pspec) || G_IS_PARAM_SPEC_POINTER (pspec)) { /* silently ignore object properties */ } else { g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name); } if (copy) { GQuark quark = g_quark_from_static_string ("gegl-property-keys"); GHashTable *keys = g_param_spec_get_qdata (pspec, quark); if (keys) g_param_spec_set_qdata (copy, quark, g_hash_table_ref (keys)); } return copy; }
static void print_element_properties_info (GstElement * element) { GParamSpec **property_specs; guint num_properties, i; gboolean readable; gboolean first_flag; property_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element), &num_properties); n_print ("\n"); n_print ("Element Properties:\n"); for (i = 0; i < num_properties; i++) { GValue value = { 0, }; GParamSpec *param = property_specs[i]; readable = FALSE; g_value_init (&value, param->value_type); n_print (" %-20s: %s\n", g_param_spec_get_name (param), g_param_spec_get_blurb (param)); first_flag = TRUE; n_print ("%-23.23s flags: ", ""); if (param->flags & G_PARAM_READABLE) { g_object_get_property (G_OBJECT (element), param->name, &value); readable = TRUE; if (!first_flag) g_print (", "); else first_flag = FALSE; g_print (_("readable")); } if (param->flags & G_PARAM_WRITABLE) { if (!first_flag) g_print (", "); else first_flag = FALSE; g_print (_("writable")); } if (param->flags & GST_PARAM_CONTROLLABLE) { if (!first_flag) g_print (", "); else first_flag = FALSE; g_print (_("controllable")); } n_print ("\n"); switch (G_VALUE_TYPE (&value)) { case G_TYPE_STRING: { GParamSpecString *pstring = G_PARAM_SPEC_STRING (param); n_print ("%-23.23s String. ", ""); if (pstring->default_value == NULL) g_print ("Default: null "); else g_print ("Default: \"%s\" ", pstring->default_value); if (readable) { const char *string_val = g_value_get_string (&value); if (string_val == NULL) g_print ("Current: null"); else g_print ("Current: \"%s\"", string_val); } break; } case G_TYPE_BOOLEAN: { GParamSpecBoolean *pboolean = G_PARAM_SPEC_BOOLEAN (param); n_print ("%-23.23s Boolean. ", ""); g_print ("Default: %s ", (pboolean->default_value ? "true" : "false")); if (readable) g_print ("Current: %s", (g_value_get_boolean (&value) ? "true" : "false")); break; } case G_TYPE_ULONG: { GParamSpecULong *pulong = G_PARAM_SPEC_ULONG (param); n_print ("%-23.23s Unsigned Long. ", ""); g_print ("Range: %lu - %lu Default: %lu ", pulong->minimum, pulong->maximum, pulong->default_value); if (readable) g_print ("Current: %lu", g_value_get_ulong (&value)); break; } case G_TYPE_LONG: { GParamSpecLong *plong = G_PARAM_SPEC_LONG (param); n_print ("%-23.23s Long. ", ""); g_print ("Range: %ld - %ld Default: %ld ", plong->minimum, plong->maximum, plong->default_value); if (readable) g_print ("Current: %ld", g_value_get_long (&value)); break; } case G_TYPE_UINT: { GParamSpecUInt *puint = G_PARAM_SPEC_UINT (param); n_print ("%-23.23s Unsigned Integer. ", ""); g_print ("Range: %u - %u Default: %u ", puint->minimum, puint->maximum, puint->default_value); if (readable) g_print ("Current: %u", g_value_get_uint (&value)); break; } case G_TYPE_INT: { GParamSpecInt *pint = G_PARAM_SPEC_INT (param); n_print ("%-23.23s Integer. ", ""); g_print ("Range: %d - %d Default: %d ", pint->minimum, pint->maximum, pint->default_value); if (readable) g_print ("Current: %d", g_value_get_int (&value)); break; } case G_TYPE_UINT64: { GParamSpecUInt64 *puint64 = G_PARAM_SPEC_UINT64 (param); n_print ("%-23.23s Unsigned Integer64. ", ""); g_print ("Range: %" G_GUINT64_FORMAT " - %" G_GUINT64_FORMAT " Default: %" G_GUINT64_FORMAT " ", puint64->minimum, puint64->maximum, puint64->default_value); if (readable) g_print ("Current: %" G_GUINT64_FORMAT, g_value_get_uint64 (&value)); break; } case G_TYPE_INT64: { GParamSpecInt64 *pint64 = G_PARAM_SPEC_INT64 (param); n_print ("%-23.23s Integer64. ", ""); g_print ("Range: %" G_GINT64_FORMAT " - %" G_GINT64_FORMAT " Default: %" G_GINT64_FORMAT " ", pint64->minimum, pint64->maximum, pint64->default_value); if (readable) g_print ("Current: %" G_GINT64_FORMAT, g_value_get_int64 (&value)); break; } case G_TYPE_FLOAT: { GParamSpecFloat *pfloat = G_PARAM_SPEC_FLOAT (param); n_print ("%-23.23s Float. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", pfloat->minimum, pfloat->maximum, pfloat->default_value); if (readable) g_print ("Current: %15.7g", g_value_get_float (&value)); break; } case G_TYPE_DOUBLE: { GParamSpecDouble *pdouble = G_PARAM_SPEC_DOUBLE (param); n_print ("%-23.23s Double. ", ""); g_print ("Range: %15.7g - %15.7g Default: %15.7g ", pdouble->minimum, pdouble->maximum, pdouble->default_value); if (readable) g_print ("Current: %15.7g", g_value_get_double (&value)); break; } default: if (param->value_type == GST_TYPE_CAPS) { const GstCaps *caps = gst_value_get_caps (&value); if (!caps) n_print ("%-23.23s Caps (NULL)", ""); else { print_caps (caps, " "); } } else if (G_IS_PARAM_SPEC_ENUM (param)) { GParamSpecEnum *penum = G_PARAM_SPEC_ENUM (param); GEnumValue *values; guint j = 0; gint enum_value; const gchar *def_val_nick = "", *cur_val_nick = ""; values = G_ENUM_CLASS (g_type_class_ref (param->value_type))->values; enum_value = g_value_get_enum (&value); while (values[j].value_name) { if (values[j].value == enum_value) cur_val_nick = values[j].value_nick; if (values[j].value == penum->default_value) def_val_nick = values[j].value_nick; j++; } n_print ("%-23.23s Enum \"%s\" Default: %d, \"%s\" Current: %d, \"%s\"", "", g_type_name (G_VALUE_TYPE (&value)), penum->default_value, def_val_nick, enum_value, cur_val_nick); j = 0; while (values[j].value_name) { g_print ("\n"); if (_name) g_print ("%s", _name); g_print ("%-23.23s (%d): %-16s - %s", "", values[j].value, values[j].value_nick, values[j].value_name); j++; } /* g_type_class_unref (ec); */ } else if (G_IS_PARAM_SPEC_FLAGS (param)) { GParamSpecFlags *pflags = G_PARAM_SPEC_FLAGS (param); GFlagsValue *values; guint j = 0; gint flags_value; GString *cur_flags = NULL, *def_flags = NULL; values = G_FLAGS_CLASS (g_type_class_ref (param->value_type))->values; flags_value = g_value_get_flags (&value); while (values[j].value_name) { if (values[j].value & flags_value) { if (cur_flags) { g_string_append_printf (cur_flags, " | %s", values[j].value_nick); } else { cur_flags = g_string_new (values[j].value_nick); } } if (values[j].value & pflags->default_value) { if (def_flags) { g_string_append_printf (def_flags, " | %s", values[j].value_nick); } else { def_flags = g_string_new (values[j].value_nick); } } j++; } n_print ("%-23.23s Flags \"%s\" Default: 0x%08x, \"%s\" Current: 0x%08x, \"%s\"", "", g_type_name (G_VALUE_TYPE (&value)), pflags->default_value, (def_flags ? def_flags->str : "(none)"), flags_value, (cur_flags ? cur_flags->str : "(none)")); j = 0; while (values[j].value_name) { g_print ("\n"); if (_name) g_print ("%s", _name); g_print ("%-23.23s (0x%08x): %-16s - %s", "", values[j].value, values[j].value_nick, values[j].value_name); j++; } if (cur_flags) g_string_free (cur_flags, TRUE); if (def_flags) g_string_free (def_flags, TRUE); } else if (G_IS_PARAM_SPEC_OBJECT (param)) { n_print ("%-23.23s Object of type \"%s\"", "", g_type_name (param->value_type)); } else if (G_IS_PARAM_SPEC_BOXED (param)) { n_print ("%-23.23s Boxed pointer of type \"%s\"", "", g_type_name (param->value_type)); } else if (G_IS_PARAM_SPEC_POINTER (param)) { if (param->value_type != G_TYPE_POINTER) { n_print ("%-23.23s Pointer of type \"%s\".", "", g_type_name (param->value_type)); } else { n_print ("%-23.23s Pointer.", ""); } } else if (param->value_type == G_TYPE_VALUE_ARRAY) { GParamSpecValueArray *pvarray = G_PARAM_SPEC_VALUE_ARRAY (param); if (pvarray->element_spec) { n_print ("%-23.23s Array of GValues of type \"%s\"", "", g_type_name (pvarray->element_spec->value_type)); } else { n_print ("%-23.23s Array of GValues", ""); } } else if (GST_IS_PARAM_SPEC_FRACTION (param)) { GstParamSpecFraction *pfraction = GST_PARAM_SPEC_FRACTION (param); n_print ("%-23.23s Fraction. ", ""); g_print ("Range: %d/%d - %d/%d Default: %d/%d ", pfraction->min_num, pfraction->min_den, pfraction->max_num, pfraction->max_den, pfraction->def_num, pfraction->def_den); if (readable) g_print ("Current: %d/%d", gst_value_get_fraction_numerator (&value), gst_value_get_fraction_denominator (&value)); } else if (GST_IS_PARAM_SPEC_MINI_OBJECT (param)) { n_print ("%-23.23s MiniObject of type \"%s\"", "", g_type_name (param->value_type)); } else { n_print ("%-23.23s Unknown type %ld \"%s\"", "", param->value_type, g_type_name (param->value_type)); } break; } if (!readable) g_print (" Write only\n"); else g_print ("\n"); g_value_reset (&value); } if (num_properties == 0) n_print (" none\n"); g_free (property_specs); }
static void param_boolean_set_default (GParamSpec *pspec, GValue *value) { value->data[0].v_int = G_PARAM_SPEC_BOOLEAN (pspec)->default_value; }
static gboolean gst_interpolation_control_source_bind (GstControlSource * source, GParamSpec * pspec) { GType type, base; GstInterpolationControlSource *self = GST_INTERPOLATION_CONTROL_SOURCE (source); gboolean ret = TRUE; /* get the fundamental base type */ self->priv->type = base = type = G_PARAM_SPEC_VALUE_TYPE (pspec); while ((type = g_type_parent (type))) base = type; self->priv->base = base; /* restore type */ type = self->priv->type; if (!gst_interpolation_control_source_set_interpolation_mode (self, self->priv->interpolation_mode)) return FALSE; switch (base) { case G_TYPE_INT:{ GParamSpecInt *tpspec = G_PARAM_SPEC_INT (pspec); g_value_init (&self->priv->default_value, type); g_value_set_int (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_int (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_int (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_UINT:{ GParamSpecUInt *tpspec = G_PARAM_SPEC_UINT (pspec); g_value_init (&self->priv->default_value, type); g_value_set_uint (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_uint (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_uint (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_LONG:{ GParamSpecLong *tpspec = G_PARAM_SPEC_LONG (pspec); g_value_init (&self->priv->default_value, type); g_value_set_long (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_long (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_long (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_ULONG:{ GParamSpecULong *tpspec = G_PARAM_SPEC_ULONG (pspec); g_value_init (&self->priv->default_value, type); g_value_set_ulong (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_ulong (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_ulong (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_INT64:{ GParamSpecInt64 *tpspec = G_PARAM_SPEC_INT64 (pspec); g_value_init (&self->priv->default_value, type); g_value_set_int64 (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_int64 (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_int64 (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_UINT64:{ GParamSpecUInt64 *tpspec = G_PARAM_SPEC_UINT64 (pspec); g_value_init (&self->priv->default_value, type); g_value_set_uint64 (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_uint64 (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_uint64 (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_FLOAT:{ GParamSpecFloat *tpspec = G_PARAM_SPEC_FLOAT (pspec); g_value_init (&self->priv->default_value, type); g_value_set_float (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_float (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_float (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_DOUBLE:{ GParamSpecDouble *tpspec = G_PARAM_SPEC_DOUBLE (pspec); g_value_init (&self->priv->default_value, type); g_value_set_double (&self->priv->default_value, tpspec->default_value); g_value_init (&self->priv->minimum_value, type); g_value_set_double (&self->priv->minimum_value, tpspec->minimum); g_value_init (&self->priv->maximum_value, type); g_value_set_double (&self->priv->maximum_value, tpspec->maximum); break; } case G_TYPE_BOOLEAN:{ GParamSpecBoolean *tpspec = G_PARAM_SPEC_BOOLEAN (pspec); g_value_init (&self->priv->default_value, type); g_value_set_boolean (&self->priv->default_value, tpspec->default_value); break; } case G_TYPE_ENUM:{ GParamSpecEnum *tpspec = G_PARAM_SPEC_ENUM (pspec); g_value_init (&self->priv->default_value, type); g_value_set_enum (&self->priv->default_value, tpspec->default_value); break; } case G_TYPE_STRING:{ GParamSpecString *tpspec = G_PARAM_SPEC_STRING (pspec); g_value_init (&self->priv->default_value, type); g_value_set_string (&self->priv->default_value, tpspec->default_value); break; } default: GST_WARNING ("incomplete implementation for paramspec type '%s'", G_PARAM_SPEC_TYPE_NAME (pspec)); ret = FALSE; break; } if (ret) { self->priv->valid_cache = FALSE; self->priv->nvalues = 0; } else { gst_interpolation_control_source_reset (self); } return ret; }