[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, 24 Aug 2016 10:34:30 +0000 (UTC)
commit 981a1b9c2ec263eb84024389a54621d15ccbefa8
Author: Michael Natterer <mitch gimp org>
Date: Wed Aug 24 12:33:56 2016 +0200
Bug 599573 - Remember dialog defaults between Gimp sessions
Remeber the "New Layer" dialog settings in GimpDialogConfig.
app/actions/layers-commands.c | 52 ++++++++++++++++++-------------------
app/config/gimpdialogconfig.c | 51 +++++++++++++++++++++++++++++++++++++
app/config/gimpdialogconfig.h | 4 +++
app/config/gimprc-blurbs.h | 6 ++++
app/dialogs/preferences-dialog.c | 14 ++++++++++
5 files changed, 100 insertions(+), 27 deletions(-)
---
diff --git a/app/actions/layers-commands.c b/app/actions/layers-commands.c
index 10be12f..6deaad1 100644
--- a/app/actions/layers-commands.c
+++ b/app/actions/layers-commands.c
@@ -147,8 +147,6 @@ static gint layers_mode_index (GimpLayerModeEffects layer_mode);
/* private variables */
-static GimpFillType layer_fill_type = GIMP_FILL_TRANSPARENT;
-static gchar *layer_name = NULL;
static GimpUnit layer_resize_unit = GIMP_UNIT_PIXEL;
static GimpUnit layer_scale_unit = GIMP_UNIT_PIXEL;
static GimpInterpolationType layer_scale_interp = -1;
@@ -199,15 +197,18 @@ layers_edit_attributes_cmd_callback (GtkAction *action,
GimpImage *image;
GimpLayer *layer;
GtkWidget *widget;
+ GimpDialogConfig *config;
return_if_no_layer (image, layer, data);
return_if_no_widget (widget, data);
+ config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
dialog = layer_options_dialog_new (gimp_item_get_image (GIMP_ITEM (layer)),
layer,
action_data_get_context (data),
widget,
gimp_object_get_name (layer),
- layer_fill_type,
+ config->layer_new_fill_type,
_("Layer Attributes"),
"gimp-layer-edit",
"gtk-edit",
@@ -229,9 +230,12 @@ layers_new_cmd_callback (GtkAction *action,
GimpImage *image;
GtkWidget *widget;
GimpLayer *floating_sel;
+ GimpDialogConfig *config;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
+ config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
/* If there is a floating selection, the new command transforms
* the current fs into a new layer
*/
@@ -255,8 +259,8 @@ layers_new_cmd_callback (GtkAction *action,
dialog = layer_options_dialog_new (image, NULL,
action_data_get_context (data),
widget,
- layer_name ? layer_name : _("Layer"),
- layer_fill_type,
+ config->layer_new_name,
+ config->layer_new_fill_type,
_("New Layer"),
"gimp-layer-new",
GIMP_STOCK_LAYER,
@@ -282,25 +286,18 @@ layers_new_last_vals_cmd_callback (GtkAction *action,
gint off_x, off_y;
gdouble opacity;
GimpLayerModeEffects mode;
+ GimpDialogConfig *config;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
+ config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
/* If there is a floating selection, the new command transforms
* the current fs into a new layer
*/
if ((floating_sel = gimp_image_get_floating_selection (image)))
{
- GError *error = NULL;
-
- if (! floating_sel_to_layer (floating_sel, &error))
- {
- gimp_message_literal (image->gimp, G_OBJECT (widget),
- GIMP_MESSAGE_WARNING, error->message);
- g_clear_error (&error);
- return;
- }
-
- gimp_image_flush (image);
+ layers_new_cmd_callback (action, data);
return;
}
@@ -329,12 +326,12 @@ layers_new_last_vals_cmd_callback (GtkAction *action,
new_layer = gimp_layer_new (image, width, height,
gimp_image_get_layer_format (image, TRUE),
- layer_name,
+ config->layer_new_name,
opacity, mode);
gimp_drawable_fill (GIMP_DRAWABLE (new_layer),
action_data_get_context (data),
- layer_fill_type);
+ config->layer_new_fill_type);
gimp_item_translate (GIMP_ITEM (new_layer), off_x, off_y, FALSE);
gimp_image_add_layer (image, new_layer,
@@ -1074,15 +1071,16 @@ layers_new_layer_response (GtkWidget *widget,
{
if (response_id == GTK_RESPONSE_OK)
{
- GimpLayer *layer;
-
- if (layer_name)
- g_free (layer_name);
+ GimpDialogConfig *config;
+ GimpLayer *layer;
- layer_name =
- g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)));
+ config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
- layer_fill_type = dialog->fill_type;
+ g_object_set (config,
+ "layer-new-fill-type", dialog->fill_type,
+ "layer-new-name",
+ gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)),
+ NULL);
dialog->xsize =
RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (dialog->size_se),
@@ -1095,14 +1093,14 @@ layers_new_layer_response (GtkWidget *widget,
dialog->xsize,
dialog->ysize,
gimp_image_get_layer_format (dialog->image, TRUE),
- layer_name,
+ config->layer_new_name,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (layer)
{
gimp_drawable_fill (GIMP_DRAWABLE (layer),
dialog->context,
- layer_fill_type);
+ config->layer_new_fill_type);
gimp_image_add_layer (dialog->image, layer,
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index c6ffd59..5520433 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -37,11 +37,16 @@ enum
{
PROP_0,
PROP_COLOR_PROFILE_POLICY,
+
+ PROP_LAYER_NEW_NAME,
+ PROP_LAYER_NEW_FILL_TYPE,
+
PROP_LAYER_ADD_MASK_TYPE,
PROP_LAYER_ADD_MASK_INVERT
};
+static void gimp_dialog_config_finalize (GObject *object);
static void gimp_dialog_config_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -62,6 +67,7 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = gimp_dialog_config_finalize;
object_class->set_property = gimp_dialog_config_set_property;
object_class->get_property = gimp_dialog_config_get_property;
@@ -73,6 +79,21 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
GIMP_COLOR_PROFILE_POLICY_ASK,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_STRING (object_class, PROP_LAYER_NEW_NAME,
+ "layer-new-name",
+ "Default new layer name",
+ LAYER_NEW_NAME_BLURB,
+ _("Layer"),
+ GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_ENUM (object_class, PROP_LAYER_NEW_FILL_TYPE,
+ "layer-new-fill-type",
+ "Default new layer fill type",
+ LAYER_NEW_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",
@@ -95,6 +116,20 @@ gimp_dialog_config_init (GimpDialogConfig *config)
}
static void
+gimp_dialog_config_finalize (GObject *object)
+{
+ GimpDialogConfig *config = GIMP_DIALOG_CONFIG (object);
+
+ if (config->layer_new_name)
+ {
+ g_free (config->layer_new_name);
+ config->layer_new_name = NULL;
+ }
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
gimp_dialog_config_set_property (GObject *object,
guint property_id,
const GValue *value,
@@ -108,6 +143,15 @@ gimp_dialog_config_set_property (GObject *object,
config->color_profile_policy = g_value_get_enum (value);
break;
+ case PROP_LAYER_NEW_NAME:
+ if (config->layer_new_name)
+ g_free (config->layer_new_name);
+ config->layer_new_name = g_value_dup_string (value);
+ break;
+ case PROP_LAYER_NEW_FILL_TYPE:
+ config->layer_new_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;
@@ -135,6 +179,13 @@ gimp_dialog_config_get_property (GObject *object,
g_value_set_enum (value, config->color_profile_policy);
break;
+ case PROP_LAYER_NEW_NAME:
+ g_value_set_string (value, config->layer_new_name);
+ break;
+ case PROP_LAYER_NEW_FILL_TYPE:
+ g_value_set_enum (value, config->layer_new_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 14559aa..eb4d6cc 100644
--- a/app/config/gimpdialogconfig.h
+++ b/app/config/gimpdialogconfig.h
@@ -38,6 +38,10 @@ struct _GimpDialogConfig
GimpGuiConfig parent_instance;
GimpColorProfilePolicy color_profile_policy;
+
+ gchar *layer_new_name;
+ GimpFillType layer_new_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 e68f477..98dfdcc 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -420,6 +420,12 @@ _("Sets the folder for temporary storage. Files will appear here " \
#define ICON_THEME_PATH_BLURB \
"Sets the icon theme search path."
+#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_ADD_MASK_TYPE_BLURB \
_("Sets the default mask for the 'Add Layer Mask' dialog.")
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 8b87cd7..7f1a728 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -2029,6 +2029,20 @@ prefs_dialog_new (Gimp *gimp,
_("Color profile policy:"),
GTK_TABLE (table), 0, size_group);
+ /* New Layer Dialog */
+ vbox2 = prefs_frame_new (_("New Layer Dialog"),
+ GTK_CONTAINER (vbox), FALSE);
+ table = prefs_table_new (2, GTK_CONTAINER (vbox2));
+
+ entry = gimp_prop_entry_new (object, "layer-new-name", -1);
+ gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
+ _("Layer name:"), 0.0, 0.5,
+ entry, 1, FALSE);
+
+ prefs_enum_combo_box_add (object, "layer-new-fill-type", 0, 0,
+ _("Fill type:"),
+ GTK_TABLE (table), 1, size_group);
+
/* Add Layer Mask Dialog */
vbox2 = prefs_frame_new (_("Add Layer Mask Dialog"),
GTK_CONTAINER (vbox), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]