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 ("]"); }
GtkWidget * gimp_prop_widget_new_from_pspec (GObject *config, GParamSpec *pspec, GimpContext *context, GimpCreatePickerFunc create_picker_func, gpointer picker_creator, const gchar **label) { GtkWidget *widget = NULL; g_return_val_if_fail (G_IS_OBJECT (config), NULL); g_return_val_if_fail (pspec != NULL, NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (label != NULL, NULL); *label = NULL; if (GEGL_IS_PARAM_SPEC_SEED (pspec)) { GtkAdjustment *adj; GtkWidget *spin; GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); spin = gimp_prop_spin_button_new (config, pspec->name, 1.0, 10.0, 0); gtk_box_pack_start (GTK_BOX (widget), spin, TRUE, TRUE, 0); gtk_widget_show (spin); button = gtk_button_new_with_label (_("New Seed")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin)); g_signal_connect (button, "clicked", G_CALLBACK (gimp_prop_widget_new_seed_clicked), adj); *label = g_param_spec_get_nick (pspec); } else if (G_IS_PARAM_SPEC_INT (pspec) || G_IS_PARAM_SPEC_UINT (pspec) || G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) { gdouble lower; gdouble upper; gdouble step; gdouble page; gint digits; if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec)) { GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; step = gspec->ui_step_small; page = gspec->ui_step_big; digits = gspec->ui_digits; } else if (GEGL_IS_PARAM_SPEC_INT (pspec)) { GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; step = gspec->ui_step_small; page = gspec->ui_step_big; digits = 0; } else { gdouble value; _gimp_prop_widgets_get_numeric_values (config, pspec, &value, &lower, &upper, G_STRFUNC); if ((upper - lower <= 1.0) && (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec))) { step = 0.01; page = 0.1; digits = 4; } else if ((upper - lower <= 10.0) && (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec))) { step = 0.1; page = 1.0; digits = 3; } else { step = 1.0; page = 10.0; digits = (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0; } } widget = gimp_prop_spin_scale_new (config, pspec->name, NULL, step, page, digits); if (HAS_KEY (pspec, "unit", "degree") && (upper - lower) == 360.0) { GtkWidget *hbox; GtkWidget *dial; gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_widget_show (widget); dial = gimp_prop_angle_dial_new (config, pspec->name); gtk_box_pack_start (GTK_BOX (hbox), dial, FALSE, FALSE, 0); gtk_widget_show (dial); widget = hbox; } else if (HAS_KEY (pspec, "unit", "kelvin")) { GtkWidget *hbox; GtkWidget *button; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0); gtk_widget_show (widget); button = gimp_prop_kelvin_presets_new (config, pspec->name); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); widget = hbox; } } else if (G_IS_PARAM_SPEC_STRING (pspec)) { static GQuark multiline_quark = 0; if (! multiline_quark) multiline_quark = g_quark_from_static_string ("multiline"); if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec)) { widget = gimp_prop_file_chooser_button_new (config, pspec->name, g_param_spec_get_nick (pspec), GTK_FILE_CHOOSER_ACTION_OPEN); } else if (g_param_spec_get_qdata (pspec, multiline_quark)) { GtkTextBuffer *buffer; GtkWidget *view; buffer = gimp_prop_text_buffer_new (config, pspec->name, -1); view = gtk_text_view_new_with_buffer (buffer); g_object_unref (buffer); widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (widget), view); gtk_widget_show (view); } else { widget = gimp_prop_entry_new (config, pspec->name, -1); } *label = g_param_spec_get_nick (pspec); } else if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) { widget = gimp_prop_check_button_new (config, pspec->name, g_param_spec_get_nick (pspec)); } else if (G_IS_PARAM_SPEC_ENUM (pspec)) { widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (widget), g_param_spec_get_nick (pspec)); } else if (GIMP_IS_PARAM_SPEC_RGB (pspec)) { GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); button = gimp_prop_color_button_new (config, pspec->name, g_param_spec_get_nick (pspec), 128, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context); gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0); gtk_widget_show (button); if (create_picker_func) { button = create_picker_func (picker_creator, pspec->name, GIMP_STOCK_COLOR_PICKER_GRAY, _("Pick color from the image")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); } *label = g_param_spec_get_nick (pspec); } else { g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name); } return widget; }
GtkWidget * gimp_prop_table_new (GObject *config, GType owner_type, GimpContext *context, GimpCreatePickerFunc create_picker_func, gpointer picker_creator) { GtkWidget *table; GtkSizeGroup *size_group; GParamSpec **param_specs; guint n_param_specs; gint i; gint row = 0; GParamSpec *last_pspec = NULL; GtkAdjustment *last_x_adj = NULL; gint last_x_row = 0; g_return_val_if_fail (G_IS_OBJECT (config), NULL); g_return_val_if_fail (context == NULL || GIMP_IS_CONTEXT (context), NULL); param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config), &n_param_specs); size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); table = gtk_table_new (3, 1, FALSE); gtk_table_set_col_spacings (GTK_TABLE (table), 4); gtk_table_set_row_spacings (GTK_TABLE (table), 2); for (i = 0; i < n_param_specs; i++) { GParamSpec *pspec = param_specs[i]; GtkWidget *widget = NULL; const gchar *label = NULL; /* ignore properties of parent classes of owner_type */ if (! g_type_is_a (pspec->owner_type, owner_type)) continue; if (G_IS_PARAM_SPEC_STRING (pspec)) { static GQuark multiline_quark = 0; if (! multiline_quark) multiline_quark = g_quark_from_static_string ("multiline"); if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (pspec)) { widget = gimp_prop_file_chooser_button_new (config, pspec->name, g_param_spec_get_nick (pspec), GTK_FILE_CHOOSER_ACTION_OPEN); } else if (g_param_spec_get_qdata (pspec, multiline_quark)) { GtkTextBuffer *buffer; GtkWidget *view; buffer = gimp_prop_text_buffer_new (config, pspec->name, -1); view = gtk_text_view_new_with_buffer (buffer); widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (widget), view); gtk_widget_show (view); } else { widget = gimp_prop_entry_new (config, pspec->name, -1); } label = g_param_spec_get_nick (pspec); } else if (G_IS_PARAM_SPEC_BOOLEAN (pspec)) { widget = gimp_prop_check_button_new (config, pspec->name, g_param_spec_get_nick (pspec)); } else if (G_IS_PARAM_SPEC_ENUM (pspec)) { widget = gimp_prop_enum_combo_box_new (config, pspec->name, 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (widget), g_param_spec_get_nick (pspec)); } else if (GEGL_IS_PARAM_SPEC_SEED (pspec)) { GtkAdjustment *adj; GtkWidget *scale; GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); scale = gimp_prop_spin_scale_new (config, pspec->name, g_param_spec_get_nick (pspec), 1.0, 10.0, 0); gtk_box_pack_start (GTK_BOX (widget), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gtk_button_new_with_label (_("New Seed")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (scale)); g_signal_connect (button, "clicked", G_CALLBACK (gimp_prop_table_new_seed_clicked), adj); } else if (G_IS_PARAM_SPEC_INT (pspec) || G_IS_PARAM_SPEC_UINT (pspec) || G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) { GtkAdjustment *adj; gdouble value; gdouble lower; gdouble upper; gdouble step = 1.0; gdouble page = 10.0; gint digits = (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec)) ? 2 : 0; if (GEGL_IS_PARAM_SPEC_DOUBLE (pspec)) { GeglParamSpecDouble *gspec = GEGL_PARAM_SPEC_DOUBLE (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; } else if (GEGL_IS_PARAM_SPEC_INT (pspec)) { GeglParamSpecInt *gspec = GEGL_PARAM_SPEC_INT (pspec); lower = gspec->ui_minimum; upper = gspec->ui_maximum; } else { _gimp_prop_widgets_get_numeric_values (config, pspec, &value, &lower, &upper, G_STRFUNC); } if ((upper - lower < 10.0) && (G_IS_PARAM_SPEC_FLOAT (pspec) || G_IS_PARAM_SPEC_DOUBLE (pspec))) { step = 0.1; page = 1.0; digits = 3; } widget = gimp_prop_spin_scale_new (config, pspec->name, g_param_spec_get_nick (pspec), step, page, digits); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)); if (g_str_has_suffix (pspec->name, "x") || g_str_has_suffix (pspec->name, "width")) { last_pspec = pspec; last_x_adj = adj; last_x_row = row; } else if ((g_str_has_suffix (pspec->name, "y") || g_str_has_suffix (pspec->name, "height")) && last_pspec != NULL && last_x_adj != NULL && last_x_row == row - 1) { GtkWidget *chain = gimp_chain_button_new (GIMP_CHAIN_RIGHT); gtk_table_attach (GTK_TABLE (table), chain, 3, 4, last_x_row, row + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (chain); if (gtk_adjustment_get_value (last_x_adj) == gtk_adjustment_get_value (adj)) { GBinding *binding; gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chain), TRUE); binding = g_object_bind_property (last_x_adj, "value", adj, "value", G_BINDING_BIDIRECTIONAL); g_object_set_data (G_OBJECT (chain), "binding", binding); } g_signal_connect (chain, "toggled", G_CALLBACK (gimp_prop_table_chain_toggled), last_x_adj); g_object_set_data (G_OBJECT (last_x_adj), "y-adjustment", adj); if (create_picker_func) { GtkWidget *button; gchar *pspec_name; pspec_name = g_strconcat (last_pspec->name, ":", pspec->name, NULL); button = create_picker_func (picker_creator, pspec_name, GIMP_STOCK_CURSOR, _("Pick coordinates from the image")); gtk_table_attach (GTK_TABLE (table), button, 4, 5, last_x_row, row + 1, GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0); gtk_widget_show (button); g_object_weak_ref (G_OBJECT (button), (GWeakNotify) g_free, pspec_name); } } } else if (GIMP_IS_PARAM_SPEC_RGB (pspec)) { GtkWidget *button; widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4); button = gimp_prop_color_button_new (config, pspec->name, g_param_spec_get_nick (pspec), 128, 24, GIMP_COLOR_AREA_SMALL_CHECKS); gimp_color_button_set_update (GIMP_COLOR_BUTTON (button), TRUE); gimp_color_panel_set_context (GIMP_COLOR_PANEL (button), context); gtk_box_pack_start (GTK_BOX (widget), button, TRUE, TRUE, 0); gtk_widget_show (button); if (create_picker_func) { button = create_picker_func (picker_creator, pspec->name, GIMP_STOCK_COLOR_PICKER_GRAY, _("Pick color from the image")); gtk_box_pack_start (GTK_BOX (widget), button, FALSE, FALSE, 0); gtk_widget_show (button); } label = g_param_spec_get_nick (pspec); } else { g_warning ("%s: not supported: %s (%s)\n", G_STRFUNC, g_type_name (G_TYPE_FROM_INSTANCE (pspec)), pspec->name); } if (widget) { if (label) { gimp_table_attach_aligned (GTK_TABLE (table), 0, row, label, 0.0, 0.5, widget, 2, FALSE); } else { gtk_table_attach_defaults (GTK_TABLE (table), widget, 0, 3, row, row + 1); gtk_widget_show (widget); } row++; } } g_object_unref (size_group); g_free (param_specs); return table; }
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; }