GtkWidget * gimp_clone_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_paint_options_gui (tool_options); GtkWidget *frame; GtkWidget *combo; GtkWidget *source_vbox; GtkWidget *button; GtkWidget *hbox; /* the source frame */ frame = gimp_frame_new (NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the source type menu */ combo = gimp_prop_enum_combo_box_new (config, "clone-type", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Source")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_frame_set_label_widget (GTK_FRAME (frame), combo); gtk_widget_show (combo); source_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (frame), source_vbox); gtk_widget_show (source_vbox); button = gimp_prop_check_button_new (config, "sample-merged", NULL); gtk_box_pack_start (GTK_BOX (source_vbox), button, FALSE, FALSE, 0); g_object_bind_property_full (config, "clone-type", button, "visible", G_BINDING_SYNC_CREATE, gimp_clone_options_sync_source, NULL, GINT_TO_POINTER (GIMP_CLONE_IMAGE), NULL); hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), NULL, 2, "pattern-view-type", "pattern-view-size"); gtk_box_pack_start (GTK_BOX (source_vbox), hbox, FALSE, FALSE, 0); g_object_bind_property_full (config, "clone-type", hbox, "visible", G_BINDING_SYNC_CREATE, gimp_clone_options_sync_source, NULL, GINT_TO_POINTER (GIMP_CLONE_PATTERN), NULL); combo = gimp_prop_enum_combo_box_new (config, "align-mode", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Alignment")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); return vbox; }
GtkWidget * gimp_region_select_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_selection_options_gui (tool_options); GtkWidget *button; GtkWidget *scale; GtkWidget *combo; GType tool_type; tool_type = tool_options->tool_info->tool_type; /* the select transparent areas toggle */ button = gimp_prop_check_button_new (config, "select-transparent", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); /* the sample merged toggle */ button = gimp_prop_check_button_new (config, "sample-merged", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); /* the diagonal neighbors toggle */ if (tool_type == GIMP_TYPE_FUZZY_SELECT_TOOL) { button = gimp_prop_check_button_new (config, "diagonal-neighbors", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); } /* the threshold scale */ scale = gimp_prop_spin_scale_new (config, "threshold", NULL, 1.0, 16.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* the select criterion combo */ combo = gimp_prop_enum_combo_box_new (config, "select-criterion", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Select by")); gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); /* the show mask toggle */ button = gimp_prop_check_button_new (config, "draw-mask", NULL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); return vbox; }
GtkWidget * gimp_region_select_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_selection_options_gui (tool_options); GtkWidget *button; GtkWidget *scale; GtkWidget *combo; /* the select transparent areas toggle */ button = gimp_prop_check_button_new (config, "select-transparent", _("Select transparent areas")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); /* the sample merged toggle */ button = gimp_prop_check_button_new (config, "sample-merged", _("Sample merged")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); /* the threshold scale */ scale = gimp_prop_spin_scale_new (config, "threshold", _("Threshold"), 1.0, 16.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* the select criterion combo */ combo = gimp_prop_enum_combo_box_new (config, "select-criterion", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Select by")); gtk_box_pack_start (GTK_BOX (vbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); /* the show mask toggle */ button = gimp_prop_check_button_new (config, "draw-mask", _("Draw Mask")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); return vbox; }
GtkWidget * gimp_bucket_fill_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_paint_options_gui (tool_options); GtkWidget *vbox2; GtkWidget *frame; GtkWidget *hbox; GtkWidget *button; GtkWidget *scale; GtkWidget *combo; gchar *str; GdkModifierType toggle_mask; toggle_mask = gimp_get_toggle_behavior_mask (); /* fill type */ str = g_strdup_printf (_("Fill Type (%s)"), gimp_get_mod_string (toggle_mask)), frame = gimp_prop_enum_radio_frame_new (config, "fill-mode", str, 0, 0); g_free (str); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); hbox = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (tool_options), NULL, 2, "pattern-view-type", "pattern-view-size"); gimp_enum_radio_frame_add (GTK_FRAME (frame), hbox, GIMP_PATTERN_BUCKET_FILL, TRUE); /* fill selection */ str = g_strdup_printf (_("Affected Area (%s)"), gimp_get_mod_string (GDK_SHIFT_MASK)); frame = gimp_prop_boolean_radio_frame_new (config, "fill-selection", str, _("Fill whole selection"), _("Fill similar colors")); g_free (str); gtk_box_reorder_child (GTK_BOX (gtk_bin_get_child (GTK_BIN (frame))), g_object_get_data (G_OBJECT (frame), "radio-button"), 1); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); frame = gimp_frame_new (_("Finding Similar Colors")); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); g_object_bind_property (config, "fill-selection", frame, "sensitive", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (frame), vbox2); gtk_widget_show (vbox2); /* the fill transparent areas toggle */ button = gimp_prop_check_button_new (config, "fill-transparent", _("Fill transparent areas")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); /* the sample merged toggle */ button = gimp_prop_check_button_new (config, "sample-merged", _("Sample merged")); gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0); gtk_widget_show (button); /* the threshold scale */ scale = gimp_prop_spin_scale_new (config, "threshold", _("Threshold"), 1.0, 16.0, 1); gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* the fill criterion combo */ combo = gimp_prop_enum_combo_box_new (config, "fill-criterion", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Fill by")); gtk_box_pack_start (GTK_BOX (vbox2), combo, FALSE, FALSE, 0); gtk_widget_show (combo); return vbox; }
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; }
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_blend_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_paint_options_gui (tool_options); GtkWidget *vbox2; GtkWidget *frame; GtkWidget *scale; GtkWidget *combo; GtkWidget *button; /* the gradient */ button = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (tool_options), _("Gradient"), 2, "gradient-view-type", "gradient-view-size", "gradient-reverse", "gimp-gradient-editor"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); /* the gradient type menu */ combo = gimp_prop_enum_combo_box_new (config, "gradient-type", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Shape")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (combo), "gimp-gradient"); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); /* the repeat option */ combo = gimp_prop_enum_combo_box_new (config, "gradient-repeat", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Repeat")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); g_signal_connect (config, "notify::gradient-type", G_CALLBACK (blend_options_gradient_type_notify), combo); /* the offset scale */ scale = gimp_prop_spin_scale_new (config, "offset", _("Offset"), 1.0, 10.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* the dither toggle */ button = gimp_prop_check_button_new (config, "dither", _("Dithering")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); /* supersampling options */ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); frame = gimp_prop_expanding_frame_new (config, "supersample", _("Adaptive supersampling"), vbox2, NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* max depth scale */ scale = gimp_prop_spin_scale_new (config, "supersample-depth", _("Max depth"), 1.0, 1.0, 0); gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* threshold scale */ scale = gimp_prop_spin_scale_new (config, "supersample-threshold", _("Threshold"), 0.01, 0.1, 2); gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0); gtk_widget_show (scale); return vbox; }
/** * gimp_transform_options_gui: * @tool_options: a #GimpToolOptions * * Build the Transform Tool Options. * * Return value: a container holding the transform tool options **/ GtkWidget * gimp_transform_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GtkWidget *vbox = gimp_tool_options_gui (tool_options); GtkWidget *hbox; GtkWidget *box; GtkWidget *label; GtkWidget *frame; GtkWidget *combo; GtkWidget *scale; GtkWidget *grid_box; const gchar *constrain_name = NULL; const gchar *constrain_label = NULL; const gchar *constrain_tip = NULL; hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); label = gtk_label_new (_("Transform:")); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); gtk_widget_show (label); box = gimp_prop_enum_icon_box_new (config, "type", "gimp", 0, 0); gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0); gtk_widget_show (box); frame = gimp_prop_enum_radio_frame_new (config, "direction", _("Direction"), 0, 0); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the interpolation menu */ combo = gimp_prop_enum_combo_box_new (config, "interpolation", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Interpolation")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); /* the clipping menu */ combo = gimp_prop_enum_combo_box_new (config, "clip", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Clipping")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); gtk_widget_show (combo); /* the preview frame */ scale = gimp_prop_spin_scale_new (config, "preview-opacity", _("Image opacity"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1); frame = gimp_prop_expanding_frame_new (config, "show-preview", _("Show image preview"), scale, NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the guides frame */ frame = gimp_frame_new (NULL); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); /* the guides type menu */ combo = gimp_prop_enum_combo_box_new (config, "grid-type", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Guides")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_frame_set_label_widget (GTK_FRAME (frame), combo); gtk_widget_show (combo); /* the grid density scale */ scale = gimp_prop_spin_scale_new (config, "grid-size", NULL, 1.8, 8.0, 0); gimp_spin_scale_set_label (GIMP_SPIN_SCALE (scale), NULL); gtk_container_add (GTK_CONTAINER (frame), scale); g_object_bind_property_full (config, "grid-type", scale, "visible", G_BINDING_SYNC_CREATE, gimp_transform_options_sync_grid, NULL, NULL, NULL); if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL) { constrain_name = "constrain-rotate"; constrain_label = _("15 degrees (%s)"); constrain_tip = _("Limit rotation steps to 15 degrees"); } else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL) { constrain_name = "constrain-scale"; constrain_label = _("Keep aspect (%s)"); constrain_tip = _("Keep the original aspect ratio"); } //TODO: check that the selection tools use the gimp_get_*_mask() functions for constrain/etc or change to what they use else if (tool_options->tool_info->tool_type == GIMP_TYPE_UNIFIED_TRANSFORM_TOOL) { GdkModifierType shift = gimp_get_extend_selection_mask (); GdkModifierType ctrl = gimp_get_constrain_behavior_mask (); struct { GdkModifierType mod; gchar *name; gchar *desc; gchar *tip; } opt_list[] = { { shift, NULL, "Constrain (%s)" }, { shift, "constrain-move", "Move", "Constrain movement to 45 degree angles from center (%s)" }, { shift, "constrain-scale", "Scale", "Maintain aspect ratio when scaling (%s)" }, { shift, "constrain-rotate", "Rotate", "Constrain rotation to 15 degree increments (%s)" }, { shift, "constrain-shear", "Shear", "Shear along edge direction only (%s)" }, { shift, "constrain-perspective", "Perspective", "Constrain perspective handles to move along edges and diagonal (%s)" }, { ctrl, NULL, "From pivot (%s)" }, { ctrl, "frompivot-scale", "Scale", "Scale from pivot point (%s)" }, { ctrl, "frompivot-shear", "Shear", "Shear opposite edge by same amount (%s)" }, { ctrl, "frompivot-perspective", "Perspective", "Maintain position of pivot while changing perspective (%s)" }, { 0, NULL, "Pivot" }, { shift, "cornersnap", "Snap (%s)", "Snap pivot to corners and center (%s)" }, { 0, "fixedpivot", "Lock", "Lock pivot position to canvas" }, }; GtkWidget *button; gchar *label; gint i; frame = NULL; for (i = 0; i < G_N_ELEMENTS (opt_list); i++) { if (!opt_list[i].name && !opt_list[i].desc) { frame = NULL; continue; } label = g_strdup_printf (opt_list[i].desc, gimp_get_mod_string (opt_list[i].mod)); if (opt_list[i].name) { button = gimp_prop_check_button_new (config, opt_list[i].name, label); gtk_box_pack_start (GTK_BOX (frame ? grid_box : vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_free (label); label = g_strdup_printf (opt_list[i].tip, gimp_get_mod_string (opt_list[i].mod)); gimp_help_set_help_data (button, label, NULL); } else { frame = gimp_frame_new (label); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); grid_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (frame), grid_box); gtk_widget_show (grid_box); } g_free (label); } } if (constrain_label) { GtkWidget *button; gchar *label; GdkModifierType constrain_mask; constrain_mask = gimp_get_extend_selection_mask (); label = g_strdup_printf (constrain_label, gimp_get_mod_string (constrain_mask)); button = gimp_prop_check_button_new (config, constrain_name, label); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); gimp_help_set_help_data (button, constrain_tip, NULL); g_free (label); } return vbox; }
GtkWidget * gimp_paint_options_gui (GimpToolOptions *tool_options) { GObject *config = G_OBJECT (tool_options); GimpPaintOptions *options = GIMP_PAINT_OPTIONS (tool_options); GtkWidget *vbox = gimp_tool_options_gui (tool_options); GtkWidget *menu; GtkWidget *scale; GType tool_type; tool_type = tool_options->tool_info->tool_type; /* the paint mode menu */ menu = gimp_prop_paint_mode_menu_new (config, "paint-mode", TRUE, FALSE); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (menu), _("Mode")); g_object_set (menu, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (vbox), menu, FALSE, FALSE, 0); gtk_widget_show (menu); if (tool_type == GIMP_TYPE_ERASER_TOOL || tool_type == GIMP_TYPE_CONVOLVE_TOOL || tool_type == GIMP_TYPE_DODGE_BURN_TOOL || tool_type == GIMP_TYPE_HEAL_TOOL || tool_type == GIMP_TYPE_SMUDGE_TOOL) { gtk_widget_set_sensitive (menu, FALSE); } /* the opacity scale */ scale = gimp_prop_spin_scale_new (config, "opacity", _("Opacity"), 0.01, 0.1, 0); gimp_prop_widget_set_factor (scale, 100.0, 0.0, 0.0, 1); gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0); gtk_widget_show (scale); /* temp debug foo */ if (g_type_is_a (tool_type, GIMP_TYPE_PAINT_TOOL)) { GtkWidget *button; button = gimp_prop_check_button_new (config, "use-applicator", "Use GimpApplicator"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); } /* the brush */ if (g_type_is_a (tool_type, GIMP_TYPE_BRUSH_TOOL)) { GtkWidget *button; GtkWidget *hbox; GtkWidget *frame; button = gimp_prop_brush_box_new (NULL, GIMP_CONTEXT (tool_options), _("Brush"), 2, "brush-view-type", "brush-view-size", "gimp-brush-editor"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); scale = gimp_prop_spin_scale_new (config, "brush-size", _("Size"), 1.0, 10.0, 2); gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0); gimp_spin_scale_set_gamma (GIMP_SPIN_SCALE (scale), 1.7); gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gimp_icon_button_new (GIMP_STOCK_RESET, NULL); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_image_set_from_icon_name (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))), GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_paint_options_gui_reset_size), options); gimp_help_set_help_data (button, _("Reset size to brush's native size"), NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); scale = gimp_prop_spin_scale_new (config, "brush-aspect-ratio", _("Aspect Ratio"), 0.1, 1.0, 2); gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gimp_icon_button_new (GIMP_STOCK_RESET, NULL); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_image_set_from_icon_name (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))), GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_paint_options_gui_reset_aspect_ratio), options); gimp_help_set_help_data (button, _("Reset aspect ratio to brush's native"), NULL); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); scale = gimp_prop_spin_scale_new (config, "brush-angle", _("Angle"), 1.0, 5.0, 2); gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); gtk_widget_show (scale); button = gimp_icon_button_new (GIMP_STOCK_RESET, NULL); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); gtk_image_set_from_icon_name (GTK_IMAGE (gtk_bin_get_child (GTK_BIN (button))), GIMP_STOCK_RESET, GTK_ICON_SIZE_MENU); gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0); gtk_widget_show (button); g_signal_connect (button, "clicked", G_CALLBACK (gimp_paint_options_gui_reset_angle), options); gimp_help_set_help_data (button, _("Reset angle to zero"), NULL); button = gimp_prop_dynamics_box_new (NULL, GIMP_CONTEXT (tool_options), _("Dynamics"), 2, "dynamics-view-type", "dynamics-view-size", "gimp-dynamics-editor"); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); frame = dynamics_options_gui (options, tool_type); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); frame = jitter_options_gui (options, tool_type); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); } /* the "smooth stroke" options */ if (g_type_is_a (tool_type, GIMP_TYPE_PAINT_TOOL)) { GtkWidget *frame; frame = smoothing_options_gui (options, tool_type); gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0); gtk_widget_show (frame); } /* the "incremental" toggle */ if (tool_type == GIMP_TYPE_PENCIL_TOOL || tool_type == GIMP_TYPE_PAINTBRUSH_TOOL || tool_type == GIMP_TYPE_ERASER_TOOL) { GtkWidget *button; button = gimp_prop_enum_check_button_new (config, "application-mode", _("Incremental"), GIMP_PAINT_CONSTANT, GIMP_PAINT_INCREMENTAL); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); } /* the "hard edge" toggle */ if (tool_type == GIMP_TYPE_ERASER_TOOL || tool_type == GIMP_TYPE_CLONE_TOOL || tool_type == GIMP_TYPE_HEAL_TOOL || tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL || tool_type == GIMP_TYPE_CONVOLVE_TOOL || tool_type == GIMP_TYPE_DODGE_BURN_TOOL || tool_type == GIMP_TYPE_SMUDGE_TOOL) { GtkWidget *button; button = gimp_prop_check_button_new (config, "hard", _("Hard edge")); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show (button); } return vbox; }
static GtkWidget * dynamics_options_gui (GimpPaintOptions *paint_options, GType tool_type) { GObject *config = G_OBJECT (paint_options); GtkWidget *frame; GtkWidget *inner_frame; GtkWidget *scale; GtkWidget *menu; GtkWidget *combo; GtkWidget *checkbox; GtkWidget *vbox; GtkWidget *inner_vbox; GtkWidget *hbox; GtkWidget *box; frame = gimp_prop_expander_new (config, "dynamics-expanded", _("Dynamics Options")); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_widget_show (vbox); inner_frame = gimp_frame_new (_("Fade Options")); gtk_box_pack_start (GTK_BOX (vbox), inner_frame, FALSE, FALSE, 0); gtk_widget_show (inner_frame); inner_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_add (GTK_CONTAINER (inner_frame), inner_vbox); gtk_widget_show (inner_vbox); /* the fade-out scale & unitmenu */ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (GTK_BOX (inner_vbox), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); scale = gimp_prop_spin_scale_new (config, "fade-length", _("Fade length"), 1.0, 50.0, 0); gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), 1.0, 1000.0); gtk_box_pack_start (GTK_BOX (hbox), scale, TRUE, TRUE, 0); gtk_widget_show (scale); menu = gimp_prop_unit_combo_box_new (config, "fade-unit"); gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0); gtk_widget_show (menu); #if 0 /* FIXME pixel digits */ g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton); gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 0); #endif /* the repeat type */ combo = gimp_prop_enum_combo_box_new (config, "fade-repeat", 0, 0); gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Repeat")); g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL); gtk_box_pack_start (GTK_BOX (inner_vbox), combo, TRUE, TRUE, 0); gtk_widget_show (combo); checkbox = gimp_prop_check_button_new (config, "fade-reverse", _("Reverse")); gtk_box_pack_start (GTK_BOX (inner_vbox), checkbox, FALSE, FALSE, 0); gtk_widget_show (checkbox); /* Color UI */ if (g_type_is_a (tool_type, GIMP_TYPE_PAINTBRUSH_TOOL)) { inner_frame = gimp_frame_new (_("Color Options")); gtk_box_pack_start (GTK_BOX (vbox), inner_frame, FALSE, FALSE, 0); gtk_widget_show (inner_frame); box = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (config), _("Gradient"), 2, "gradient-view-type", "gradient-view-size", "gradient-reverse", "gimp-gradient-editor"); gtk_container_add (GTK_CONTAINER (inner_frame), box); gtk_widget_show (box); } return frame; }