diff --git a/app/core/core-enums.c b/app/core/core-enums.c index da26d61ae7..eabe6ef5eb 100644 --- a/app/core/core-enums.c +++ b/app/core/core-enums.c @@ -587,6 +587,35 @@ gimp_dynamics_output_type_get_type (void) return type; } +GType +gimp_custom_style_get_type (void) +{ + static const GEnumValue values[] = + { + { GIMP_CUSTOM_STYLE_SOLID_COLOR, "GIMP_CUSTOM_STYLE_SOLID_COLOR", "solid-color" }, + { GIMP_CUSTOM_STYLE_PATTERN, "GIMP_CUSTOM_STYLE_PATTERN", "pattern" }, + { 0, NULL, NULL } + }; + + static const GimpEnumDesc descs[] = + { + { GIMP_CUSTOM_STYLE_SOLID_COLOR, NC_("custom-style", "Solid color"), NULL }, + { GIMP_CUSTOM_STYLE_PATTERN, NC_("custom-style", "Pattern"), NULL }, + { 0, NULL, NULL } + }; + + static GType type = 0; + + if (G_UNLIKELY (! type)) + { + type = g_enum_register_static ("GimpCustomStyle", values); + gimp_type_set_translation_context (type, "custom-style"); + gimp_enum_set_value_descriptions (type, descs); + } + + return type; +} + GType gimp_fill_style_get_type (void) { diff --git a/app/core/core-enums.h b/app/core/core-enums.h index 20912a349e..92f9a8b3da 100644 --- a/app/core/core-enums.h +++ b/app/core/core-enums.h @@ -290,6 +290,16 @@ typedef enum /*< pdb-skip >*/ } GimpDynamicsOutputType; +#define GIMP_TYPE_CUSTOM_STYLE (gimp_custom_style_get_type ()) + +GType gimp_custom_style_get_type (void) G_GNUC_CONST; + +typedef enum /*< pdb-skip >*/ +{ + GIMP_CUSTOM_STYLE_SOLID_COLOR, /*< desc="Solid color" >*/ + GIMP_CUSTOM_STYLE_PATTERN /*< desc="Pattern" >*/ +} GimpCustomStyle; + #define GIMP_TYPE_FILL_STYLE (gimp_fill_style_get_type ()) GType gimp_fill_style_get_type (void) G_GNUC_CONST; diff --git a/app/core/gimpfilloptions.c b/app/core/gimpfilloptions.c index b8814fc7f2..51a5b07bad 100644 --- a/app/core/gimpfilloptions.c +++ b/app/core/gimpfilloptions.c @@ -48,6 +48,7 @@ enum { PROP_0, PROP_STYLE, + PROP_CUSTOM_STYLE, PROP_ANTIALIAS, PROP_FEATHER, PROP_FEATHER_RADIUS, @@ -60,10 +61,11 @@ typedef struct _GimpFillOptionsPrivate GimpFillOptionsPrivate; struct _GimpFillOptionsPrivate { - GimpFillStyle style; - gboolean antialias; - gboolean feather; - gdouble feather_radius; + GimpFillStyle style; + GimpCustomStyle custom_style; + gboolean antialias; + gboolean feather; + gdouble feather_radius; GimpViewType pattern_view_type; GimpViewSize pattern_view_size; @@ -113,6 +115,14 @@ gimp_fill_options_class_init (GimpFillOptionsClass *klass) GIMP_FILL_STYLE_FG_COLOR, GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_ENUM (object_class, PROP_CUSTOM_STYLE, + "custom-style", + _("Custom style"), + NULL, + GIMP_TYPE_CUSTOM_STYLE, + GIMP_CUSTOM_STYLE_SOLID_COLOR, + GIMP_PARAM_STATIC_STRINGS); + GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ANTIALIAS, "antialias", _("Antialiasing"), @@ -177,6 +187,10 @@ gimp_fill_options_set_property (GObject *object, private->style = g_value_get_enum (value); private->undo_desc = NULL; break; + case PROP_CUSTOM_STYLE: + private->custom_style = g_value_get_enum (value); + private->undo_desc = NULL; + break; case PROP_ANTIALIAS: private->antialias = g_value_get_boolean (value); break; @@ -213,6 +227,9 @@ gimp_fill_options_get_property (GObject *object, case PROP_STYLE: g_value_set_enum (value, private->style); break; + case PROP_CUSTOM_STYLE: + g_value_set_enum (value, private->custom_style); + break; case PROP_ANTIALIAS: g_value_set_boolean (value, private->antialias); break; @@ -293,6 +310,24 @@ gimp_fill_options_set_style (GimpFillOptions *options, g_object_set (options, "style", style, NULL); } +GimpCustomStyle +gimp_fill_options_get_custom_style (GimpFillOptions *options) +{ + g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), + GIMP_CUSTOM_STYLE_SOLID_COLOR); + + return GET_PRIVATE (options)->custom_style; +} + +void +gimp_fill_options_set_custom_style (GimpFillOptions *options, + GimpCustomStyle custom_style) +{ + g_return_if_fail (GIMP_IS_FILL_OPTIONS (options)); + + g_object_set (options, "custom-style", custom_style, NULL); +} + gboolean gimp_fill_options_get_antialias (GimpFillOptions *options) { diff --git a/app/core/gimpfilloptions.h b/app/core/gimpfilloptions.h index 434530be0e..8b4790e00d 100644 --- a/app/core/gimpfilloptions.h +++ b/app/core/gimpfilloptions.h @@ -56,6 +56,11 @@ GimpFillStyle gimp_fill_options_get_style (GimpFillOptions *optio void gimp_fill_options_set_style (GimpFillOptions *options, GimpFillStyle style); +GimpCustomStyle gimp_fill_options_get_custom_style + (GimpFillOptions *options); +void gimp_fill_options_set_custom_style (GimpFillOptions *options, + GimpCustomStyle custom_style); + gboolean gimp_fill_options_get_antialias (GimpFillOptions *options); void gimp_fill_options_set_antialias (GimpFillOptions *options, gboolean antialias); diff --git a/app/dialogs/fill-dialog.c b/app/dialogs/fill-dialog.c index c9f45255a8..bf6fac807b 100644 --- a/app/dialogs/fill-dialog.c +++ b/app/dialogs/fill-dialog.c @@ -138,7 +138,7 @@ fill_dialog_new (GList *items, main_vbox, TRUE, TRUE, 0); gtk_widget_show (main_vbox); - fill_editor = gimp_fill_editor_new (private->options, FALSE); + fill_editor = gimp_fill_editor_new (private->options, FALSE, FALSE); gtk_box_pack_start (GTK_BOX (main_vbox), fill_editor, FALSE, FALSE, 0); gtk_widget_show (fill_editor); diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index 18710f82d6..50458bfbb9 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -2601,7 +2601,7 @@ prefs_dialog_new (Gimp *gimp, GTK_CONTAINER (vbox), FALSE); editor = gimp_fill_editor_new (GIMP_DIALOG_CONFIG (object)->fill_options, - FALSE); + FALSE, FALSE); gtk_box_pack_start (GTK_BOX (vbox2), editor, FALSE, FALSE, 0); gtk_widget_show (editor); @@ -2617,7 +2617,7 @@ prefs_dialog_new (Gimp *gimp, */ editor = gimp_stroke_editor_new (GIMP_DIALOG_CONFIG (object)->stroke_options, gimp_template_get_resolution_y (core_config->default_image), - FALSE); + FALSE, FALSE); gtk_box_pack_start (GTK_BOX (vbox2), editor, FALSE, FALSE, 0); gtk_widget_show (editor); diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c index d0fd91774e..585b1ef164 100644 --- a/app/dialogs/stroke-dialog.c +++ b/app/dialogs/stroke-dialog.c @@ -180,7 +180,8 @@ stroke_dialog_new (GList *items, gimp_image_get_resolution (image, &xres, &yres); - stroke_editor = gimp_stroke_editor_new (private->options, yres, FALSE); + stroke_editor = gimp_stroke_editor_new (private->options, yres, FALSE, + FALSE); gtk_container_add (GTK_CONTAINER (frame), stroke_editor); gtk_widget_show (stroke_editor); diff --git a/app/text/gimptext.c b/app/text/gimptext.c index d8033b0f2d..87456fec06 100644 --- a/app/text/gimptext.c +++ b/app/text/gimptext.c @@ -333,9 +333,9 @@ gimp_text_class_init (GimpTextClass *klass) GIMP_PARAM_WRITABLE)); GIMP_CONFIG_PROP_ENUM (object_class, PROP_OUTLINE_STYLE, - "outline-style", NULL, NULL, - GIMP_TYPE_FILL_STYLE, - GIMP_FILL_STYLE_FG_COLOR, + "outline-custom-style", NULL, NULL, + GIMP_TYPE_CUSTOM_STYLE, + GIMP_CUSTOM_STYLE_SOLID_COLOR, GIMP_PARAM_STATIC_STRINGS); GIMP_CONFIG_PROP_OBJECT (object_class, PROP_OUTLINE_PATTERN, "outline-pattern", NULL, NULL, diff --git a/app/text/gimptext.h b/app/text/gimptext.h index 4ca3b333be..d06b4494a9 100644 --- a/app/text/gimptext.h +++ b/app/text/gimptext.h @@ -50,7 +50,7 @@ struct _GimpText gchar *language; GimpTextDirection base_dir; GimpRGB color; - GimpFillStyle outline_style; + GimpCustomStyle outline_style; GimpPattern *outline_pattern; GimpRGB outline_foreground; gdouble outline_width; diff --git a/app/text/gimptextlayer.c b/app/text/gimptextlayer.c index c3ddb29ec9..1147b1e324 100644 --- a/app/text/gimptextlayer.c +++ b/app/text/gimptextlayer.c @@ -981,7 +981,7 @@ gimp_text_layer_render_layout (GimpTextLayer *layer, if (text->outline_dash_info) gimp_text_layer_set_dash_info (cr, text->outline_width, text->outline_dash_offset, text->outline_dash_info); - if (text->outline_style == GIMP_FILL_STYLE_PATTERN && text->outline_pattern) + if (text->outline_style == GIMP_CUSTOM_STYLE_PATTERN && text->outline_pattern) { GimpTempBuf *tempbuf = gimp_pattern_get_mask (text->outline_pattern); cairo_surface_t *surface = gimp_temp_buf_create_cairo_surface (tempbuf); diff --git a/app/tools/gimptextoptions.c b/app/tools/gimptextoptions.c index 902f19cc20..fc5450f890 100644 --- a/app/tools/gimptextoptions.c +++ b/app/tools/gimptextoptions.c @@ -279,10 +279,10 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass) GIMP_PARAM_STATIC_STRINGS | GIMP_CONFIG_PARAM_DEFAULTS); GIMP_CONFIG_PROP_ENUM (object_class, PROP_OUTLINE_STYLE, - "outline-style", + "outline-custom-style", NULL, NULL, - GIMP_TYPE_FILL_STYLE, - GIMP_FILL_STYLE_FG_COLOR, + GIMP_TYPE_CUSTOM_STYLE, + GIMP_CUSTOM_STYLE_SOLID_COLOR, GIMP_PARAM_STATIC_STRINGS); GIMP_CONFIG_PROP_RGB (object_class, PROP_OUTLINE_FOREGROUND, "outline-foreground", @@ -627,7 +627,7 @@ gimp_text_options_reset (GimpConfig *config) gimp_config_reset_property (object, "box-mode"); gimp_config_reset_property (object, "outline"); - gimp_config_reset_property (object, "outline-style"); + gimp_config_reset_property (object, "outline-custom-style"); gimp_config_reset_property (object, "outline-foreground"); gimp_config_reset_property (object, "outline-pattern"); gimp_config_reset_property (object, "outline-width"); @@ -917,7 +917,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options) g_object_bind_property (options, "outline-" #a, \ stroke_options, #a, \ G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE) - BIND (style); + BIND (custom-style); BIND (foreground); BIND (pattern); BIND (width); @@ -929,7 +929,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options) BIND (dash-offset); BIND (dash-info); - editor = gimp_stroke_editor_new (stroke_options, 72.0, TRUE); + editor = gimp_stroke_editor_new (stroke_options, 72.0, TRUE, TRUE); gtk_container_add (GTK_CONTAINER (outline_frame), editor); gtk_widget_show (editor); diff --git a/app/tools/gimptextoptions.h b/app/tools/gimptextoptions.h index 0a85bb8f7e..d004fcd35e 100644 --- a/app/tools/gimptextoptions.h +++ b/app/tools/gimptextoptions.h @@ -50,7 +50,7 @@ struct _GimpTextOptions GimpTextBoxMode box_mode; GimpTextOutline outline; - GimpFillStyle outline_style; + GimpCustomStyle outline_style; GimpRGB outline_foreground; GimpPattern *outline_pattern; gdouble outline_width; diff --git a/app/widgets/gimpfilleditor.c b/app/widgets/gimpfilleditor.c index b5d9ad7ac8..6601003fe6 100644 --- a/app/widgets/gimpfilleditor.c +++ b/app/widgets/gimpfilleditor.c @@ -43,7 +43,8 @@ enum { PROP_0, PROP_OPTIONS, - PROP_EDIT_CONTEXT + PROP_EDIT_CONTEXT, + PROP_USE_CUSTOM_STYLE }; @@ -87,6 +88,13 @@ gimp_fill_editor_class_init (GimpFillEditorClass *klass) FALSE, GIMP_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); + + g_object_class_install_property (object_class, PROP_EDIT_CONTEXT, + g_param_spec_boolean ("use-custom-style", + NULL, NULL, + FALSE, + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY)); } static void @@ -109,8 +117,17 @@ gimp_fill_editor_constructed (GObject *object) gimp_assert (GIMP_IS_FILL_OPTIONS (editor->options)); - box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style", - 0, 0); + g_object_get (object, + "use-custom-style", &editor->use_custom_style, + NULL); + + if (editor->use_custom_style) + box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), + "custom-style", 0, 0); + else + box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style", + 0, 0); + gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0); if (editor->edit_context) @@ -118,25 +135,40 @@ gimp_fill_editor_constructed (GObject *object) GtkWidget *color_button; GtkWidget *pattern_box; - color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), - "foreground", - _("Fill Color"), - 1, 24, - GIMP_COLOR_AREA_SMALL_CHECKS); - gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), - GIMP_CONTEXT (editor->options)); - gimp_enum_radio_box_add (GTK_BOX (box), color_button, - GIMP_FILL_STYLE_FG_COLOR, FALSE); + if (editor->use_custom_style) + { + color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), + "foreground", + _("Fill Color"), + 1, 24, + GIMP_COLOR_AREA_SMALL_CHECKS); + gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), + GIMP_CONTEXT (editor->options)); + gimp_enum_radio_box_add (GTK_BOX (box), color_button, + GIMP_CUSTOM_STYLE_SOLID_COLOR, FALSE); + } + else + { + color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), + "foreground", + _("Fill Color"), + 1, 24, + GIMP_COLOR_AREA_SMALL_CHECKS); + gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), + GIMP_CONTEXT (editor->options)); + gimp_enum_radio_box_add (GTK_BOX (box), color_button, + GIMP_FILL_STYLE_FG_COLOR, FALSE); - color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), - "background", - _("Fill BG Color"), - 1, 24, - GIMP_COLOR_AREA_SMALL_CHECKS); - gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), - GIMP_CONTEXT (editor->options)); - gimp_enum_radio_box_add (GTK_BOX (box), color_button, - GIMP_FILL_STYLE_BG_COLOR, FALSE); + color_button = gimp_prop_color_button_new (G_OBJECT (editor->options), + "background", + _("Fill BG Color"), + 1, 24, + GIMP_COLOR_AREA_SMALL_CHECKS); + gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button), + GIMP_CONTEXT (editor->options)); + gimp_enum_radio_box_add (GTK_BOX (box), color_button, + GIMP_FILL_STYLE_BG_COLOR, FALSE); + } pattern_box = gimp_prop_pattern_box_new (NULL, GIMP_CONTEXT (editor->options), @@ -144,7 +176,10 @@ gimp_fill_editor_constructed (GObject *object) "pattern-view-type", "pattern-view-size"); gimp_enum_radio_box_add (GTK_BOX (box), pattern_box, - GIMP_FILL_STYLE_PATTERN, FALSE); + (editor->use_custom_style ? + GIMP_CUSTOM_STYLE_PATTERN : + GIMP_FILL_STYLE_PATTERN), + FALSE); } button = gimp_prop_check_button_new (G_OBJECT (editor->options), @@ -183,6 +218,10 @@ gimp_fill_editor_set_property (GObject *object, editor->edit_context = g_value_get_boolean (value); break; + case PROP_USE_CUSTOM_STYLE: + editor->use_custom_style = g_value_get_boolean (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -207,6 +246,10 @@ gimp_fill_editor_get_property (GObject *object, g_value_set_boolean (value, editor->edit_context); break; + case PROP_USE_CUSTOM_STYLE: + g_value_set_boolean (value, editor->use_custom_style); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -215,12 +258,14 @@ gimp_fill_editor_get_property (GObject *object, GtkWidget * gimp_fill_editor_new (GimpFillOptions *options, - gboolean edit_context) + gboolean edit_context, + gboolean use_custom_style) { g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), NULL); return g_object_new (GIMP_TYPE_FILL_EDITOR, - "options", options, - "edit-context", edit_context ? TRUE : FALSE, + "options", options, + "edit-context", edit_context ? TRUE : FALSE, + "use_custom_style", use_custom_style ? TRUE : FALSE, NULL); } diff --git a/app/widgets/gimpfilleditor.h b/app/widgets/gimpfilleditor.h index 00c47c1668..8ac90c5987 100644 --- a/app/widgets/gimpfilleditor.h +++ b/app/widgets/gimpfilleditor.h @@ -38,6 +38,7 @@ struct _GimpFillEditor GimpFillOptions *options; gboolean edit_context; + gboolean use_custom_style; /* For solid color and pattern only */ }; struct _GimpFillEditorClass @@ -49,7 +50,8 @@ struct _GimpFillEditorClass GType gimp_fill_editor_get_type (void) G_GNUC_CONST; GtkWidget * gimp_fill_editor_new (GimpFillOptions *options, - gboolean edit_context); + gboolean edit_context, + gboolean use_custom_style); #endif /* __GIMP_FILL_EDITOR_H__ */ diff --git a/app/widgets/gimpstrokeeditor.c b/app/widgets/gimpstrokeeditor.c index 139f6a6830..ade9b2de7f 100644 --- a/app/widgets/gimpstrokeeditor.c +++ b/app/widgets/gimpstrokeeditor.c @@ -308,14 +308,16 @@ gimp_stroke_editor_get_property (GObject *object, GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options, gdouble resolution, - gboolean edit_context) + gboolean edit_context, + gboolean use_custom_style) { g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), NULL); return g_object_new (GIMP_TYPE_STROKE_EDITOR, - "options", options, - "resolution", resolution, - "edit-context", edit_context ? TRUE : FALSE, + "options", options, + "resolution", resolution, + "edit-context", edit_context ? TRUE : FALSE, + "use-custom-style", use_custom_style ? TRUE: FALSE, NULL); } diff --git a/app/widgets/gimpstrokeeditor.h b/app/widgets/gimpstrokeeditor.h index 9435cec7a6..b6a37087fd 100644 --- a/app/widgets/gimpstrokeeditor.h +++ b/app/widgets/gimpstrokeeditor.h @@ -52,7 +52,8 @@ GType gimp_stroke_editor_get_type (void) G_GNUC_CONST; GtkWidget * gimp_stroke_editor_new (GimpStrokeOptions *options, gdouble resolution, - gboolean edit_context); + gboolean edit_context, + gboolean use_custom_style); #endif /* __GIMP_STROKE_EDITOR_H__ */