[gimp] Bug 599573 - Remember dialog defaults between Gimp sessions
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 599573 - Remember dialog defaults between Gimp sessions
- Date: Wed, 19 Oct 2016 22:33:22 +0000 (UTC)
commit 34eff7322e6ec1b006dd2bee582d1299e0217959
Author: Michael Natterer <mitch gimp org>
Date: Thu Oct 20 00:30:10 2016 +0200
Bug 599573 - Remember dialog defaults between Gimp sessions
Add resize and fill options for the "Layer Boundary Size" and
"Canvas Size" dialogs to GimpDialogConfig.
app/actions/image-commands.c | 26 +++++++++++---
app/actions/layers-commands.c | 19 +++++++++--
app/config/gimpdialogconfig.c | 65 ++++++++++++++++++++++++++++++++++++++
app/config/gimpdialogconfig.h | 6 +++
app/config/gimprc-blurbs.h | 17 +++++++++-
app/dialogs/preferences-dialog.c | 24 ++++++++++++++
app/dialogs/resize-dialog.c | 50 ++++++++++++++++++++++------
app/dialogs/resize-dialog.h | 5 ++-
8 files changed, 188 insertions(+), 24 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index c39df9d..dff1c11 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -133,12 +133,12 @@ static void image_profile_convert_callback (GtkWidget *dialog
static void image_resize_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
- GimpFillType fill_type,
gint width,
gint height,
GimpUnit unit,
gint offset_x,
gint offset_y,
+ GimpFillType fill_type,
GimpItemSet layer_set,
gboolean resize_text_layers,
gpointer user_data);
@@ -629,15 +629,22 @@ image_resize_cmd_callback (GtkAction *action,
if (! dialog)
{
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
if (image_resize_unit != GIMP_UNIT_PERCENT)
image_resize_unit = gimp_display_get_shell (display)->unit;
dialog = resize_dialog_new (GIMP_VIEWABLE (image),
action_data_get_context (data),
- _("Set Image Canvas Size"), "gimp-image-resize",
+ _("Set Image Canvas Size"),
+ "gimp-image-resize",
widget,
- gimp_standard_help_func, GIMP_HELP_IMAGE_RESIZE,
+ gimp_standard_help_func,
+ GIMP_HELP_IMAGE_RESIZE,
image_resize_unit,
+ config->image_resize_fill_type,
+ config->image_resize_layer_set,
+ config->image_resize_resize_text_layers,
image_resize_callback,
display);
@@ -1277,12 +1284,12 @@ static void
image_resize_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
- GimpFillType fill_type,
gint width,
gint height,
GimpUnit unit,
gint offset_x,
gint offset_y,
+ GimpFillType fill_type,
GimpItemSet layer_set,
gboolean resize_text_layers,
gpointer user_data)
@@ -1293,8 +1300,15 @@ image_resize_callback (GtkWidget *dialog,
if (width > 0 && height > 0)
{
- GimpImage *image = GIMP_IMAGE (viewable);
- GimpProgress *progress;
+ GimpImage *image = GIMP_IMAGE (viewable);
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+ GimpProgress *progress;
+
+ g_object_set (config,
+ "image-resize-fill-type", fill_type,
+ "image-resize-layer-set", layer_set,
+ "image-resize-resize-text-layers", resize_text_layers,
+ NULL);
gtk_widget_destroy (dialog);
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index b04b3ce..8508e36 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -151,12 +151,12 @@ static void layers_scale_callback (GtkWidget *dialog,
static void layers_resize_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
- GimpFillType fill_type,
gint width,
gint height,
GimpUnit unit,
gint offset_x,
gint offset_y,
+ GimpFillType fill_type,
GimpItemSet unused,
gboolean unused2,
gpointer data);
@@ -645,7 +645,8 @@ layers_resize_cmd_callback (GtkAction *action,
if (! dialog)
{
- GimpDisplay *display = NULL;
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+ GimpDisplay *display = NULL;
if (GIMP_IS_IMAGE_WINDOW (data))
display = action_data_get_display (data);
@@ -661,6 +662,9 @@ layers_resize_cmd_callback (GtkAction *action,
gimp_standard_help_func,
GIMP_HELP_LAYER_RESIZE,
layer_resize_unit,
+ config->layer_resize_fill_type,
+ GIMP_ITEM_SET_NONE,
+ FALSE,
layers_resize_callback,
NULL);
@@ -1305,21 +1309,28 @@ static void
layers_resize_callback (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
- GimpFillType fill_type,
gint width,
gint height,
GimpUnit unit,
gint offset_x,
gint offset_y,
+ GimpFillType fill_type,
GimpItemSet unused,
gboolean unused2,
gpointer user_data)
{
+
layer_resize_unit = unit;
if (width > 0 && height > 0)
{
- GimpItem *item = GIMP_ITEM (viewable);
+ GimpItem *item = GIMP_ITEM (viewable);
+ GimpImage *image = gimp_item_get_image (item);
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
+ g_object_set (config,
+ "layer-resize-fill-type", fill_type,
+ NULL);
gtk_widget_destroy (dialog);
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index f8b1763..8456569 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -62,9 +62,15 @@ enum
PROP_IMAGE_CONVERT_INDEXED_DITHER_ALPHA,
PROP_IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS,
+ PROP_IMAGE_RESIZE_FILL_TYPE,
+ PROP_IMAGE_RESIZE_LAYER_SET,
+ PROP_IMAGE_RESIZE_RESIZE_TEXT_LAYERS,
+
PROP_LAYER_NEW_NAME,
PROP_LAYER_NEW_FILL_TYPE,
+ PROP_LAYER_RESIZE_FILL_TYPE,
+
PROP_LAYER_ADD_MASK_TYPE,
PROP_LAYER_ADD_MASK_INVERT,
@@ -256,6 +262,29 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_ENUM (object_class, PROP_IMAGE_RESIZE_FILL_TYPE,
+ "image-resize-fill-type",
+ "Default image resize fill type",
+ IMAGE_RESIZE_FILL_TYPE_BLURB,
+ GIMP_TYPE_FILL_TYPE,
+ GIMP_FILL_TRANSPARENT,
+ GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_ENUM (object_class, PROP_IMAGE_RESIZE_LAYER_SET,
+ "image-resize-layer-set",
+ "Default image resize layer set",
+ IMAGE_RESIZE_LAYER_SET_BLURB,
+ GIMP_TYPE_ITEM_SET,
+ GIMP_ITEM_SET_NONE,
+ GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_IMAGE_RESIZE_RESIZE_TEXT_LAYERS,
+ "image-resize-resize-text-layers",
+ "Default image resize text layers",
+ IMAGE_RESIZE_RESIZE_TEXT_LAYERS_BLURB,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_STRING (object_class, PROP_LAYER_NEW_NAME,
"layer-new-name",
"Default new layer name",
@@ -271,6 +300,14 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
GIMP_FILL_TRANSPARENT,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_ENUM (object_class, PROP_LAYER_RESIZE_FILL_TYPE,
+ "layer-resize-fill-type",
+ "Default layer resize fill type",
+ LAYER_RESIZE_FILL_TYPE_BLURB,
+ GIMP_TYPE_FILL_TYPE,
+ GIMP_FILL_TRANSPARENT,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_ENUM (object_class, PROP_LAYER_ADD_MASK_TYPE,
"layer-add-mask-type",
"Default layer mask type",
@@ -567,6 +604,16 @@ gimp_dialog_config_set_property (GObject *object,
config->image_convert_indexed_dither_text_layers = g_value_get_boolean (value);
break;
+ case PROP_IMAGE_RESIZE_FILL_TYPE:
+ config->image_resize_fill_type = g_value_get_enum (value);
+ break;
+ case PROP_IMAGE_RESIZE_LAYER_SET:
+ config->image_resize_layer_set = g_value_get_enum (value);
+ break;
+ case PROP_IMAGE_RESIZE_RESIZE_TEXT_LAYERS:
+ config->image_resize_resize_text_layers = g_value_get_boolean (value);
+ break;
+
case PROP_LAYER_NEW_NAME:
if (config->layer_new_name)
g_free (config->layer_new_name);
@@ -576,6 +623,10 @@ gimp_dialog_config_set_property (GObject *object,
config->layer_new_fill_type = g_value_get_enum (value);
break;
+ case PROP_LAYER_RESIZE_FILL_TYPE:
+ config->layer_resize_fill_type = g_value_get_enum (value);
+ break;
+
case PROP_LAYER_ADD_MASK_TYPE:
config->layer_add_mask_type = g_value_get_enum (value);
break;
@@ -729,6 +780,16 @@ gimp_dialog_config_get_property (GObject *object,
g_value_set_boolean (value, config->image_convert_indexed_dither_text_layers);
break;
+ case PROP_IMAGE_RESIZE_FILL_TYPE:
+ g_value_set_enum (value, config->image_resize_fill_type);
+ break;
+ case PROP_IMAGE_RESIZE_LAYER_SET:
+ g_value_set_enum (value, config->image_resize_layer_set);
+ break;
+ case PROP_IMAGE_RESIZE_RESIZE_TEXT_LAYERS:
+ g_value_set_boolean (value, config->image_resize_resize_text_layers);
+ break;
+
case PROP_LAYER_NEW_NAME:
g_value_set_string (value, config->layer_new_name);
break;
@@ -736,6 +797,10 @@ gimp_dialog_config_get_property (GObject *object,
g_value_set_enum (value, config->layer_new_fill_type);
break;
+ case PROP_LAYER_RESIZE_FILL_TYPE:
+ g_value_set_enum (value, config->layer_resize_fill_type);
+ break;
+
case PROP_LAYER_ADD_MASK_TYPE:
g_value_set_enum (value, config->layer_add_mask_type);
break;
diff --git a/app/config/gimpdialogconfig.h b/app/config/gimpdialogconfig.h
index 304fc2d..5a1dc33 100644
--- a/app/config/gimpdialogconfig.h
+++ b/app/config/gimpdialogconfig.h
@@ -60,9 +60,15 @@ struct _GimpDialogConfig
gboolean image_convert_indexed_dither_alpha;
gboolean image_convert_indexed_dither_text_layers;
+ GimpFillType image_resize_fill_type;
+ GimpItemSet image_resize_layer_set;
+ gboolean image_resize_resize_text_layers;
+
gchar *layer_new_name;
GimpFillType layer_new_fill_type;
+ GimpFillType layer_resize_fill_type;
+
GimpAddMaskType layer_add_mask_type;
gboolean layer_add_mask_invert;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 9808ca4..7f25b5b 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -450,7 +450,7 @@ _("Sets the default maximum number of colors for the 'Convert to Indexed' dialog
#define IMAGE_CONVERT_INDEXED_REMOVE_DUPLICATES_BLURB \
_("Sets the default 'Remove duplicate colors' state for the 'Convert to Indexed' dialog.")
-#define IMAGE_CONVERT_INDEXED_DITHER_TYPE_BLURB \
+#define IMAGE_CONVERT_INDEXED_DITHER_TYPE_BLURB \
_("Sets the default dithering type for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_ALPHA_BLURB \
@@ -459,12 +459,24 @@ _("Sets the default 'Dither alpha' state for the 'Convert to Indexed' dialog.")
#define IMAGE_CONVERT_INDEXED_DITHER_TEXT_LAYERS_BLURB \
_("Sets the default 'Dither text layers' state for the 'Convert to Indexed' dialog.")
-#define LAYER_NEW_NAME_BLURB \
+#define IMAGE_RESIZE_FILL_TYPE_BLURB \
+_("Sets the default fill type for the 'Canvas Size' dialog.")
+
+#define IMAGE_RESIZE_LAYER_SET_BLURB \
+_("Sets the default set of layers to resize for the 'Canvas Size' dialog.")
+
+#define IMAGE_RESIZE_RESIZE_TEXT_LAYERS_BLURB \
+_("Sets the default 'Resize text layers' state for the 'Canvas Size' dialog.")
+
+#define LAYER_NEW_NAME_BLURB \
_("Sets the default layer name for the 'New Layer' dialog.")
#define LAYER_NEW_FILL_TYPE_BLURB \
_("Sets the default fill type for the 'New Layer' dialog.")
+#define LAYER_RESIZE_FILL_TYPE_BLURB \
+_("Sets the default fill type for the 'Layer Boundary Size' dialog.")
+
#define LAYER_ADD_MASK_TYPE_BLURB \
_("Sets the default mask for the 'Add Layer Mask' dialog.")
@@ -607,4 +619,5 @@ _("When enabled, uses OpenCL for some operations.")
#define ACTION_HISTORY_SIZE_BLURB \
"The maximum number of actions saved in history."
+
#endif /* __GIMP_RC_BLURBS_H__ */
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 1f72d1d..04ad6bc 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1888,6 +1888,21 @@ prefs_dialog_new (Gimp *gimp,
_("Enable dithering of text layers"),
GTK_BOX (vbox2));
+ /* Canvas Size Dialog */
+ vbox2 = prefs_frame_new (_("Canvas Size Dialog"),
+ GTK_CONTAINER (vbox), FALSE);
+ table = prefs_table_new (2, GTK_CONTAINER (vbox2));
+
+ prefs_enum_combo_box_add (object, "image-resize-fill-type", 0, 0,
+ _("Fill with:"),
+ GTK_TABLE (table), 0, size_group);
+ prefs_enum_combo_box_add (object, "image-resize-layer-set", 0, 0,
+ _("Resize layers:"),
+ GTK_TABLE (table), 1, size_group);
+
+ prefs_check_button_add (object, "image-resize-resize-text-layers",
+ _("Resize text layers"),
+ GTK_BOX (vbox2));
/* New Layer Dialog */
vbox2 = prefs_frame_new (_("New Layer Dialog"),
@@ -1902,6 +1917,15 @@ prefs_dialog_new (Gimp *gimp,
_("Fill type:"),
GTK_TABLE (table), 1, size_group);
+ /* Layer Boundary Size Dialog */
+ vbox2 = prefs_frame_new (_("Layer Boundary Size Dialog"),
+ GTK_CONTAINER (vbox), FALSE);
+ table = prefs_table_new (1, GTK_CONTAINER (vbox2));
+
+ prefs_enum_combo_box_add (object, "layer-resize-fill-type", 0, 0,
+ _("Fill with:"),
+ GTK_TABLE (table), 0, size_group);
+
/* Add Layer Mask Dialog */
vbox2 = prefs_frame_new (_("Add Layer Mask Dialog"),
GTK_CONTAINER (vbox), FALSE);
diff --git a/app/dialogs/resize-dialog.c b/app/dialogs/resize-dialog.c
index 7e364da..6c5b6bc 100644
--- a/app/dialogs/resize-dialog.c
+++ b/app/dialogs/resize-dialog.c
@@ -48,7 +48,6 @@ typedef struct
GimpViewable *viewable;
GimpContext *context;
GimpFillType fill_type;
- GimpUnit old_unit;
GimpItemSet layer_set;
gboolean resize_text_layers;
GimpResizeCallback callback;
@@ -56,9 +55,17 @@ typedef struct
gint old_width;
gint old_height;
+ GimpUnit old_unit;
+ GimpFillType old_fill_type;
+ GimpItemSet old_layer_set;
+ gboolean old_resize_text_layers;
+
GtkWidget *box;
GtkWidget *offset;
GtkWidget *area;
+ GtkWidget *layer_set_combo;
+ GtkWidget *fill_type_combo;
+ GtkWidget *text_layers_button;
} ResizeDialog;
@@ -90,6 +97,9 @@ resize_dialog_new (GimpViewable *viewable,
GimpHelpFunc help_func,
const gchar *help_id,
GimpUnit unit,
+ GimpFillType fill_type,
+ GimpItemSet layer_set,
+ gboolean resize_text_layers,
GimpResizeCallback callback,
gpointer user_data)
{
@@ -148,14 +158,18 @@ resize_dialog_new (GimpViewable *viewable,
private->viewable = viewable;
private->context = context;
- private->fill_type = GIMP_FILL_TRANSPARENT;
- private->old_unit = unit;
- private->layer_set = GIMP_ITEM_SET_NONE;
- private->resize_text_layers = FALSE;
+ private->fill_type = fill_type;
+ private->layer_set = layer_set;
+ private->resize_text_layers = resize_text_layers;
private->callback = callback;
private->user_data = user_data;
- private->old_width = width;
- private->old_height = height;
+
+ private->old_width = width;
+ private->old_height = height;
+ private->old_unit = unit;
+ private->old_fill_type = private->fill_type;
+ private->old_layer_set = private->layer_set;
+ private->old_resize_text_layers = private->resize_text_layers;
dialog = gimp_viewable_dialog_new (viewable, context,
title, role, GIMP_STOCK_RESIZE, title,
@@ -315,7 +329,8 @@ resize_dialog_new (GimpViewable *viewable,
gtk_size_group_add_widget (size_group, label);
- combo = gimp_enum_combo_box_new (GIMP_TYPE_ITEM_SET);
+ private->layer_set_combo = combo =
+ gimp_enum_combo_box_new (GIMP_TYPE_ITEM_SET);
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
@@ -331,7 +346,8 @@ resize_dialog_new (GimpViewable *viewable,
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
- combo = gimp_enum_combo_box_new (GIMP_TYPE_FILL_TYPE);
+ private->fill_type_combo = combo =
+ gimp_enum_combo_box_new (GIMP_TYPE_FILL_TYPE);
gtk_box_pack_end (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_widget_show (combo);
@@ -353,7 +369,8 @@ resize_dialog_new (GimpViewable *viewable,
gtk_size_group_add_widget (size_group, label);
- button = gtk_check_button_new_with_mnemonic (_("Resize _text layers"));
+ private->text_layers_button = button =
+ gtk_check_button_new_with_mnemonic (_("Resize _text layers"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
private->resize_text_layers);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
@@ -399,12 +416,12 @@ resize_dialog_response (GtkWidget *dialog,
private->callback (dialog,
private->viewable,
private->context,
- private->fill_type,
width,
height,
unit,
gimp_size_entry_get_refval (entry, 0),
gimp_size_entry_get_refval (entry, 1),
+ private->fill_type,
private->layer_set,
private->resize_text_layers,
private->user_data);
@@ -428,6 +445,17 @@ resize_dialog_reset (ResizeDialog *private)
"height", private->old_height,
"unit", private->old_unit,
NULL);
+
+ if (private->layer_set_combo)
+ gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->layer_set_combo),
+ private->old_layer_set);
+
+ gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->fill_type_combo),
+ private->old_fill_type);
+
+ if (private->text_layers_button)
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (private->text_layers_button),
+ private->old_resize_text_layers);
}
static void
diff --git a/app/dialogs/resize-dialog.h b/app/dialogs/resize-dialog.h
index 1041ee8..7e8423c 100644
--- a/app/dialogs/resize-dialog.h
+++ b/app/dialogs/resize-dialog.h
@@ -22,12 +22,12 @@
typedef void (* GimpResizeCallback) (GtkWidget *dialog,
GimpViewable *viewable,
GimpContext *context,
- GimpFillType fill_type,
gint width,
gint height,
GimpUnit unit,
gint offset_x,
gint offset_y,
+ GimpFillType fill_type,
GimpItemSet layer_set,
gboolean resize_text_layers,
gpointer user_data);
@@ -41,6 +41,9 @@ GtkWidget * resize_dialog_new (GimpViewable *viewable,
GimpHelpFunc help_func,
const gchar *help_id,
GimpUnit unit,
+ GimpFillType fill_type,
+ GimpItemSet layer_set,
+ gboolean resize_text_layers,
GimpResizeCallback callback,
gpointer user_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]