[gimp] app: add gimp_fill_options_get_undo_desc()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_fill_options_get_undo_desc()
- Date: Fri, 11 Mar 2016 17:48:05 +0000 (UTC)
commit 9ef2428fcb6350ea7de61488bf1b10a800468fd5
Author: Michael Natterer <mitch gimp org>
Date: Fri Mar 11 18:47:03 2016 +0100
app: add gimp_fill_options_get_undo_desc()
which returns an undo string to be used when filling with the option's
settings.
app/core/gimpfilloptions.c | 42 ++++++++++++++++++++++++++++++++++++++++--
app/core/gimpfilloptions.h | 2 ++
2 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimpfilloptions.c b/app/core/gimpfilloptions.c
index df07681..173d72c 100644
--- a/app/core/gimpfilloptions.c
+++ b/app/core/gimpfilloptions.c
@@ -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);
+}
diff --git a/app/core/gimpfilloptions.h b/app/core/gimpfilloptions.h
index 5948a95..995e7c9 100644
--- a/app/core/gimpfilloptions.h
+++ b/app/core/gimpfilloptions.h
@@ -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__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]