mirror of https://github.com/GNOME/gimp.git
app: add gimp_fill_options_get_undo_desc()
which returns an undo string to be used when filling with the option's settings.
This commit is contained in:
parent
137379ea66
commit
9ef2428fcb
|
@ -53,11 +53,12 @@ typedef struct _GimpFillOptionsPrivate GimpFillOptionsPrivate;
|
|||
struct _GimpFillOptionsPrivate
|
||||
{
|
||||
GimpFillStyle style;
|
||||
|
||||
gboolean antialias;
|
||||
|
||||
GimpViewType pattern_view_type;
|
||||
GimpViewSize pattern_view_size;
|
||||
|
||||
const gchar *undo_desc;
|
||||
};
|
||||
|
||||
#define GET_PRIVATE(options) \
|
||||
|
@ -139,6 +140,7 @@ gimp_fill_options_set_property (GObject *object,
|
|||
{
|
||||
case PROP_STYLE:
|
||||
private->style = g_value_get_enum (value);
|
||||
private->undo_desc = NULL;
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
private->antialias = g_value_get_boolean (value);
|
||||
|
@ -240,29 +242,39 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
GimpFillType fill_type,
|
||||
GError **error)
|
||||
{
|
||||
GimpRGB color;
|
||||
GimpFillOptionsPrivate *private;
|
||||
GimpRGB color;
|
||||
const gchar *undo_desc;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
private = GET_PRIVATE (options);
|
||||
|
||||
private->undo_desc = NULL;
|
||||
|
||||
switch (fill_type)
|
||||
{
|
||||
case GIMP_FILL_FOREGROUND:
|
||||
gimp_context_get_foreground (context, &color);
|
||||
undo_desc = C_("undo-type", "Fill with Foreground Color");
|
||||
break;
|
||||
|
||||
case GIMP_FILL_BACKGROUND:
|
||||
gimp_context_get_background (context, &color);
|
||||
undo_desc = C_("undo-type", "Fill with Background Color");
|
||||
break;
|
||||
|
||||
case GIMP_FILL_WHITE:
|
||||
gimp_rgba_set (&color, 1.0, 1.0, 1.0, GIMP_OPACITY_OPAQUE);
|
||||
undo_desc = C_("undo-type", "Fill with White");
|
||||
break;
|
||||
|
||||
case GIMP_FILL_TRANSPARENT:
|
||||
gimp_context_get_background (context, &color);
|
||||
gimp_context_set_paint_mode (GIMP_CONTEXT (options), GIMP_ERASE_MODE);
|
||||
undo_desc = C_("undo-type", "Fill with Transparency");
|
||||
break;
|
||||
|
||||
case GIMP_FILL_PATTERN:
|
||||
|
@ -278,6 +290,7 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
|
||||
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_PATTERN);
|
||||
gimp_context_set_pattern (GIMP_CONTEXT (options), pattern);
|
||||
private->undo_desc = C_("undo-type", "Fill with Pattern");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -290,6 +303,31 @@ gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
|
||||
gimp_fill_options_set_style (options, GIMP_FILL_STYLE_SOLID);
|
||||
gimp_context_set_foreground (GIMP_CONTEXT (options), &color);
|
||||
private->undo_desc = undo_desc;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_fill_options_get_undo_desc (GimpFillOptions *options)
|
||||
{
|
||||
GimpFillOptionsPrivate *private;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), NULL);
|
||||
|
||||
private = GET_PRIVATE (options);
|
||||
|
||||
if (private->undo_desc)
|
||||
return private->undo_desc;
|
||||
|
||||
switch (private->style)
|
||||
{
|
||||
case GIMP_FILL_STYLE_SOLID:
|
||||
return C_("undo-type", "Fill with Solid Color");
|
||||
|
||||
case GIMP_FILL_STYLE_PATTERN:
|
||||
return C_("undo-type", "Fill with Pattern");
|
||||
}
|
||||
|
||||
g_return_val_if_reached (NULL);
|
||||
}
|
||||
|
|
|
@ -63,5 +63,7 @@ gboolean gimp_fill_options_set_by_fill_type (GimpFillOptions *options,
|
|||
GimpFillType fill_type,
|
||||
GError **error);
|
||||
|
||||
const gchar * gimp_fill_options_get_undo_desc (GimpFillOptions *options);
|
||||
|
||||
|
||||
#endif /* __GIMP_FILL_OPTIONS_H__ */
|
||||
|
|
Loading…
Reference in New Issue