[gimp] Bug 599573 - Remember dialog defaults between Gimp sessions



commit 905dec866e55da45c45090890716b7be41c17aa6
Author: Michael Natterer <mitch gimp org>
Date:   Sat Sep 24 12:33:42 2016 +0200

    Bug 599573 - Remember dialog defaults between Gimp sessions
    
    Remember the "Merge Visible Layers" dialog settings in GimpDialogConfig.

 app/actions/image-commands.c  |   35 +++++++++++++++++--------------
 app/config/gimpdialogconfig.c |   46 +++++++++++++++++++++++++++++++++++++++++
 app/config/gimpdialogconfig.h |    4 +++
 app/config/gimprc-blurbs.h    |    9 ++++++++
 4 files changed, 78 insertions(+), 16 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index 9b9a0f0..5294c4a 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -25,7 +25,7 @@
 
 #include "actions-types.h"
 
-#include "config/gimpcoreconfig.h"
+#include "config/gimpdialogconfig.h"
 
 #include "gegl/gimp-babl.h"
 
@@ -124,12 +124,9 @@ static void   image_merge_layers_callback  (GtkWidget              *dialog,
 
 /*  private variables  */
 
-static GimpMergeType         image_merge_layers_type               = GIMP_EXPAND_AS_NECESSARY;
-static gboolean              image_merge_layers_merge_active_group = TRUE;
-static gboolean              image_merge_layers_discard_invisible  = FALSE;
-static GimpUnit              image_resize_unit                     = GIMP_UNIT_PIXEL;
-static GimpUnit              image_scale_unit                      = GIMP_UNIT_PIXEL;
-static GimpInterpolationType image_scale_interp                    = -1;
+static GimpUnit              image_resize_unit  = GIMP_UNIT_PIXEL;
+static GimpUnit              image_scale_unit   = GIMP_UNIT_PIXEL;
+static GimpInterpolationType image_scale_interp = -1;
 
 
 /*  public functions  */
@@ -793,12 +790,14 @@ image_merge_layers_cmd_callback (GtkAction *action,
 
   if (! dialog)
     {
+      GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
       dialog = image_merge_layers_dialog_new (image,
                                               action_data_get_context (data),
                                               widget,
-                                              image_merge_layers_type,
-                                              image_merge_layers_merge_active_group,
-                                              image_merge_layers_discard_invisible,
+                                              config->layer_merge_type,
+                                              config->layer_merge_active_group_only,
+                                              config->layer_merge_discard_invisible,
                                               image_merge_layers_callback,
                                               NULL);
 
@@ -1045,15 +1044,19 @@ image_merge_layers_callback (GtkWidget     *dialog,
                              gboolean       merge_active_group,
                              gboolean       discard_invisible)
 {
-  image_merge_layers_type               = merge_type;
-  image_merge_layers_merge_active_group = merge_active_group;
-  image_merge_layers_discard_invisible  = discard_invisible;
+  GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
+  g_object_set (config,
+                "layer-merge-type",              merge_type,
+                "layer-merge-active-group-only", merge_active_group,
+                "layer-merge-discard-invisible", discard_invisible,
+                NULL);
 
   gimp_image_merge_visible_layers (image,
                                    context,
-                                   image_merge_layers_type,
-                                   image_merge_layers_merge_active_group,
-                                   image_merge_layers_discard_invisible);
+                                   config->layer_merge_type,
+                                   config->layer_merge_active_group_only,
+                                   config->layer_merge_discard_invisible);
 
   gimp_image_flush (image);
 
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index fcf2002..29b674b 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -54,6 +54,10 @@ enum
   PROP_LAYER_ADD_MASK_TYPE,
   PROP_LAYER_ADD_MASK_INVERT,
 
+  PROP_LAYER_MERGE_TYPE,
+  PROP_LAYER_MERGE_ACTIVE_GROUP_ONLY,
+  PROP_LAYER_MERGE_DISCARD_INVISIBLE,
+
   PROP_CHANNEL_NEW_NAME,
   PROP_CHANNEL_NEW_COLOR,
 
@@ -168,6 +172,28 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
                             FALSE,
                             GIMP_PARAM_STATIC_STRINGS);
 
+  GIMP_CONFIG_PROP_ENUM (object_class, PROP_LAYER_MERGE_TYPE,
+                         "layer-merge-type",
+                         "Default layer merge type",
+                         LAYER_MERGE_TYPE_BLURB,
+                         GIMP_TYPE_MERGE_TYPE,
+                         GIMP_EXPAND_AS_NECESSARY,
+                         GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_LAYER_MERGE_ACTIVE_GROUP_ONLY,
+                            "layer-merge-active-group-only",
+                            "Default layer merge active group only",
+                            LAYER_MERGE_ACTIVE_GROUP_ONLY_BLURB,
+                            TRUE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_LAYER_MERGE_DISCARD_INVISIBLE,
+                            "layer-merge-discard-invisible",
+                            "Default layer merge discard invisible",
+                            LAYER_MERGE_DISCARD_INVISIBLE_BLURB,
+                            FALSE,
+                            GIMP_PARAM_STATIC_STRINGS);
+
   GIMP_CONFIG_PROP_STRING (object_class, PROP_CHANNEL_NEW_NAME,
                            "channel-new-name",
                            "Default new channel name",
@@ -367,6 +393,16 @@ gimp_dialog_config_set_property (GObject      *object,
       config->layer_add_mask_invert = g_value_get_boolean (value);
       break;
 
+    case PROP_LAYER_MERGE_TYPE:
+      config->layer_merge_type = g_value_get_enum (value);
+      break;
+    case PROP_LAYER_MERGE_ACTIVE_GROUP_ONLY:
+      config->layer_merge_active_group_only = g_value_get_boolean (value);
+      break;
+    case PROP_LAYER_MERGE_DISCARD_INVISIBLE:
+      config->layer_merge_discard_invisible = g_value_get_boolean (value);
+      break;
+
     case PROP_CHANNEL_NEW_NAME:
       if (config->channel_new_name)
         g_free (config->channel_new_name);
@@ -457,6 +493,16 @@ gimp_dialog_config_get_property (GObject    *object,
       g_value_set_boolean (value, config->layer_add_mask_invert);
       break;
 
+    case PROP_LAYER_MERGE_TYPE:
+      g_value_set_enum (value, config->layer_merge_type);
+      break;
+    case PROP_LAYER_MERGE_ACTIVE_GROUP_ONLY:
+      g_value_set_boolean (value, config->layer_merge_active_group_only);
+      break;
+    case PROP_LAYER_MERGE_DISCARD_INVISIBLE:
+      g_value_set_boolean (value, config->layer_merge_discard_invisible);
+      break;
+
     case PROP_CHANNEL_NEW_NAME:
       g_value_set_string (value, config->channel_new_name);
       break;
diff --git a/app/config/gimpdialogconfig.h b/app/config/gimpdialogconfig.h
index 03a87e5..67829ab 100644
--- a/app/config/gimpdialogconfig.h
+++ b/app/config/gimpdialogconfig.h
@@ -52,6 +52,10 @@ struct _GimpDialogConfig
   GimpAddMaskType         layer_add_mask_type;
   gboolean                layer_add_mask_invert;
 
+  GimpMergeType           layer_merge_type;
+  gboolean                layer_merge_active_group_only;
+  gboolean                layer_merge_discard_invisible;
+
   gchar                  *channel_new_name;
   GimpRGB                 channel_new_color;
 
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 2cff829..7ca4020 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -432,6 +432,15 @@ _("Sets the default mask for the 'Add Layer Mask' dialog.")
 #define LAYER_ADD_MASK_INVERT_BLURB \
 _("Sets the default 'invert mask' state for the 'Add Layer Mask' dialog.")
 
+#define LAYER_MERGE_TYPE_BLURB \
+_("Sets the default merge type for the 'Merge Visible Layers' dialog.")
+
+#define LAYER_MERGE_ACTIVE_GROUP_ONLY_BLURB \
+_("Sets the default 'Active group only' for the 'Merge Visible Layers' dialog.")
+
+#define LAYER_MERGE_DISCARD_INVISIBLE_BLURB \
+_("Sets the default 'Discard invisible' for the 'Merge Visible Layers' dialog.")
+
 #define CHANNEL_NEW_NAME_BLURB \
 _("Sets the default channel name for the 'New Channel' dialog.")
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]