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



commit 20a32d970d80d7d7c0e3afb1119c1053a510eb1e
Author: Michael Natterer <mitch gimp org>
Date:   Wed Sep 14 01:27:42 2016 +0200

    Bug 599573 - Remember dialog defaults between Gimp sessions
    
    Add GimpFillOptions and GimpStrokeOptions to GimpDialogConfig and use
    them in the Fill/Stroke Selection/Path dialogs and for the "with last
    values" commands. Add GUI for them to Preferences -> Dialog Defaults.
    
    This requires most of the stuff in my last few commits, and some
    more changes:
    
    GimpFillOptions is a GimpContext which has all sorts of connections to
    everything, including a Gimp pointer. Hack around in GimpDialogConfig
    to add a Gimp property, and add "gimp" parameters to quite some GimpRC
    functions. Treat the Gimp* as a GObject* in all public API because
    core/ stuff is not known in config/.

 app/actions/select-commands.c    |   45 ++++-------
 app/actions/vectors-commands.c   |   49 ++++-------
 app/app.c                        |    3 +-
 app/config/gimpconfig-dump.c     |    9 ++-
 app/config/gimpconfig-dump.h     |    3 +-
 app/config/gimpdialogconfig.c    |  167 +++++++++++++++++++++++++++++++++++---
 app/config/gimpdialogconfig.h    |   10 +++
 app/config/gimprc-blurbs.h       |    6 ++
 app/config/gimprc.c              |   34 +++++++--
 app/config/gimprc.h              |    3 +-
 app/core/gimp-user-install.c     |    8 ++-
 app/core/gimp-user-install.h     |    3 +-
 app/core/gimp.c                  |    3 +-
 app/dialogs/fill-dialog.c        |   42 ++++------
 app/dialogs/preferences-dialog.c |   19 +++++
 app/dialogs/stroke-dialog.c      |   34 +++-----
 app/main.c                       |    2 +-
 17 files changed, 302 insertions(+), 138 deletions(-)
---
diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c
index 1cb7409..0312d74 100644
--- a/app/actions/select-commands.c
+++ b/app/actions/select-commands.c
@@ -424,11 +424,11 @@ void
 select_fill_last_vals_cmd_callback (GtkAction *action,
                                     gpointer   data)
 {
-  GimpImage       *image;
-  GimpDrawable    *drawable;
-  GtkWidget       *widget;
-  GimpFillOptions *options;
-  GError          *error = NULL;
+  GimpImage        *image;
+  GimpDrawable     *drawable;
+  GtkWidget        *widget;
+  GimpDialogConfig *config;
+  GError           *error = NULL;
   return_if_no_image (image, data);
   return_if_no_widget (widget, data);
 
@@ -442,16 +442,10 @@ select_fill_last_vals_cmd_callback (GtkAction *action,
       return;
     }
 
-  options = g_object_get_data (G_OBJECT (image->gimp), "saved-fill-options");
-
-  if (options)
-    g_object_ref (options);
-  else
-    options = gimp_fill_options_new (image->gimp,
-                                     action_data_get_context (data), TRUE);
+  config = GIMP_DIALOG_CONFIG (image->gimp->config);
 
   if (! gimp_item_fill (GIMP_ITEM (gimp_image_get_mask (image)),
-                        drawable, options, TRUE, NULL, &error))
+                        drawable, config->fill_options, TRUE, NULL, &error))
     {
       gimp_message_literal (image->gimp,
                             G_OBJECT (widget), GIMP_MESSAGE_WARNING,
@@ -462,8 +456,6 @@ select_fill_last_vals_cmd_callback (GtkAction *action,
     {
       gimp_image_flush (image);
     }
-
-  g_object_unref (options);
 }
 
 void
@@ -510,12 +502,12 @@ void
 select_stroke_last_vals_cmd_callback (GtkAction *action,
                                       gpointer   data)
 {
-  GimpImage         *image;
-  GimpDrawable      *drawable;
-  GimpContext       *context;
-  GtkWidget         *widget;
-  GimpStrokeOptions *options;
-  GError            *error = NULL;
+  GimpImage        *image;
+  GimpDrawable     *drawable;
+  GimpContext      *context;
+  GtkWidget        *widget;
+  GimpDialogConfig *config;
+  GError           *error = NULL;
   return_if_no_image (image, data);
   return_if_no_context (context, data);
   return_if_no_widget (widget, data);
@@ -530,15 +522,10 @@ select_stroke_last_vals_cmd_callback (GtkAction *action,
       return;
     }
 
-  options = g_object_get_data (G_OBJECT (image->gimp), "saved-stroke-options");
-
-  if (options)
-    g_object_ref (options);
-  else
-    options = gimp_stroke_options_new (image->gimp, context, TRUE);
+  config = GIMP_DIALOG_CONFIG (image->gimp->config);
 
   if (! gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
-                          drawable, context, options, NULL,
+                          drawable, context, config->stroke_options, NULL,
                           TRUE, NULL, &error))
     {
       gimp_message_literal (image->gimp,
@@ -550,8 +537,6 @@ select_stroke_last_vals_cmd_callback (GtkAction *action,
     {
       gimp_image_flush (image);
     }
-
-  g_object_unref (options);
 }
 
 
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index e728794..3e05a42 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -422,12 +422,12 @@ void
 vectors_fill_last_vals_cmd_callback (GtkAction *action,
                                      gpointer   data)
 {
-  GimpImage       *image;
-  GimpVectors     *vectors;
-  GimpDrawable    *drawable;
-  GtkWidget       *widget;
-  GimpFillOptions *options;
-  GError          *error = NULL;
+  GimpImage        *image;
+  GimpVectors      *vectors;
+  GimpDrawable     *drawable;
+  GtkWidget        *widget;
+  GimpDialogConfig *config;
+  GError           *error = NULL;
   return_if_no_vectors (image, vectors, data);
   return_if_no_widget (widget, data);
 
@@ -441,16 +441,10 @@ vectors_fill_last_vals_cmd_callback (GtkAction *action,
       return;
     }
 
-  options = g_object_get_data (G_OBJECT (image->gimp), "saved-fill-options");
-
-  if (options)
-    g_object_ref (options);
-  else
-    options = gimp_fill_options_new (image->gimp,
-                                     action_data_get_context (data), TRUE);
+  config = GIMP_DIALOG_CONFIG (image->gimp->config);
 
   if (! gimp_item_fill (GIMP_ITEM (vectors),
-                        drawable, options, TRUE, NULL, &error))
+                        drawable, config->fill_options, TRUE, NULL, &error))
     {
       gimp_message_literal (image->gimp, G_OBJECT (widget),
                             GIMP_MESSAGE_WARNING, error->message);
@@ -460,8 +454,6 @@ vectors_fill_last_vals_cmd_callback (GtkAction *action,
     {
       gimp_image_flush (image);
     }
-
-  g_object_unref (options);
 }
 
 void
@@ -509,13 +501,13 @@ void
 vectors_stroke_last_vals_cmd_callback (GtkAction *action,
                                        gpointer   data)
 {
-  GimpImage         *image;
-  GimpVectors       *vectors;
-  GimpDrawable      *drawable;
-  GimpContext       *context;
-  GtkWidget         *widget;
-  GimpStrokeOptions *options;
-  GError            *error = NULL;
+  GimpImage        *image;
+  GimpVectors      *vectors;
+  GimpDrawable     *drawable;
+  GimpContext      *context;
+  GtkWidget        *widget;
+  GimpDialogConfig *config;
+  GError           *error = NULL;
   return_if_no_vectors (image, vectors, data);
   return_if_no_context (context, data);
   return_if_no_widget (widget, data);
@@ -530,15 +522,10 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action,
       return;
     }
 
-  options = g_object_get_data (G_OBJECT (image->gimp), "saved-stroke-options");
-
-  if (options)
-    g_object_ref (options);
-  else
-    options = gimp_stroke_options_new (image->gimp, context, TRUE);
+  config = GIMP_DIALOG_CONFIG (image->gimp->config);
 
   if (! gimp_item_stroke (GIMP_ITEM (vectors),
-                          drawable, context, options, NULL,
+                          drawable, context, config->stroke_options, NULL,
                           TRUE, NULL, &error))
     {
       gimp_message_literal (image->gimp, G_OBJECT (widget),
@@ -549,8 +536,6 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action,
     {
       gimp_image_flush (image);
     }
-
-  g_object_unref (options);
 }
 
 void
diff --git a/app/app.c b/app/app.c
index dbbf471..cec51e0 100644
--- a/app/app.c
+++ b/app/app.c
@@ -216,7 +216,8 @@ app_run (const gchar         *full_prog_name,
   if (g_file_query_file_type (gimpdir, G_FILE_QUERY_INFO_NONE, NULL) !=
       G_FILE_TYPE_DIRECTORY)
     {
-      GimpUserInstall *install = gimp_user_install_new (be_verbose);
+      GimpUserInstall *install = gimp_user_install_new (G_OBJECT (gimp),
+                                                        be_verbose);
 
 #ifdef GIMP_CONSOLE_COMPILATION
       gimp_user_install_run (install);
diff --git a/app/config/gimpconfig-dump.c b/app/config/gimpconfig-dump.c
index 059fdc1..f64c31e 100644
--- a/app/config/gimpconfig-dump.c
+++ b/app/config/gimpconfig-dump.c
@@ -56,13 +56,18 @@ static void    dump_with_linebreaks (GOutputStream    *output,
 
 
 gboolean
-gimp_config_dump (GimpConfigDumpFormat  format)
+gimp_config_dump (GObject              *gimp,
+                  GimpConfigDumpFormat  format)
 {
   GOutputStream    *output;
   GimpConfigWriter *writer;
   GimpConfig       *rc;
 
-  rc = g_object_new (GIMP_TYPE_RC, NULL);
+  g_return_val_if_fail (G_IS_OBJECT (gimp), FALSE);
+
+  rc = g_object_new (GIMP_TYPE_RC,
+                     "gimp", gimp,
+                     NULL);
 
 #ifdef G_OS_WIN32
   output = g_win32_output_stream_new ((gpointer) 1, FALSE);
diff --git a/app/config/gimpconfig-dump.h b/app/config/gimpconfig-dump.h
index a9d21db..f574ff4 100644
--- a/app/config/gimpconfig-dump.h
+++ b/app/config/gimpconfig-dump.h
@@ -30,7 +30,8 @@ typedef enum
 } GimpConfigDumpFormat;
 
 
-gboolean  gimp_config_dump (GimpConfigDumpFormat  format);
+gboolean  gimp_config_dump (GObject              *gimp,
+                            GimpConfigDumpFormat  format);
 
 
 #endif  /* __GIMP_CONFIG_DUMP_H__ */
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index b65c636..fcf2002 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -28,6 +28,10 @@
 #include "libgimpcolor/gimpcolor.h"
 #include "libgimpconfig/gimpconfig.h"
 
+#include "core/core-types.h" /* fill and stroke options */
+#include "core/gimp.h"
+#include "core/gimpstrokeoptions.h"
+
 #include "config-types.h"
 
 #include "gimprc-blurbs.h"
@@ -39,6 +43,9 @@
 enum
 {
   PROP_0,
+
+  PROP_GIMP,
+
   PROP_COLOR_PROFILE_POLICY,
 
   PROP_LAYER_NEW_NAME,
@@ -61,19 +68,43 @@ enum
 
   PROP_SELECTION_BORDER_RADIUS,
   PROP_SELECTION_BORDER_STYLE,
-  PROP_SELECTION_BORDER_EDGE_LOCK
+  PROP_SELECTION_BORDER_EDGE_LOCK,
+
+  PROP_FILL_OPTIONS,
+  PROP_STROKE_OPTIONS
 };
 
 
-static void  gimp_dialog_config_finalize     (GObject      *object);
-static void  gimp_dialog_config_set_property (GObject      *object,
-                                              guint         property_id,
-                                              const GValue *value,
-                                              GParamSpec   *pspec);
-static void  gimp_dialog_config_get_property (GObject      *object,
-                                              guint         property_id,
-                                              GValue       *value,
-                                              GParamSpec   *pspec);
+typedef struct _GimpDialogConfigPrivate GimpDialogConfigPrivate;
+
+struct _GimpDialogConfigPrivate
+{
+  Gimp *gimp;
+};
+
+#define GET_PRIVATE(config) \
+        G_TYPE_INSTANCE_GET_PRIVATE (config, \
+                                     GIMP_TYPE_DIALOG_CONFIG, \
+                                     GimpDialogConfigPrivate)
+
+
+static void  gimp_dialog_config_constructed           (GObject      *object);
+static void  gimp_dialog_config_finalize              (GObject      *object);
+static void  gimp_dialog_config_set_property          (GObject      *object,
+                                                       guint         property_id,
+                                                       const GValue *value,
+                                                       GParamSpec   *pspec);
+static void  gimp_dialog_config_get_property          (GObject      *object,
+                                                       guint         property_id,
+                                                       GValue       *value,
+                                                       GParamSpec   *pspec);
+
+static void  gimp_dialog_config_fill_options_notify   (GObject      *object,
+                                                       GParamSpec   *pspec,
+                                                       gpointer      data);
+static void  gimp_dialog_config_stroke_options_notify (GObject      *object,
+                                                       GParamSpec   *pspec,
+                                                       gpointer      data);
 
 
 G_DEFINE_TYPE (GimpDialogConfig, gimp_dialog_config, GIMP_TYPE_GUI_CONFIG)
@@ -87,10 +118,18 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
   GObjectClass *object_class     = G_OBJECT_CLASS (klass);
   GimpRGB       half_transparent = { 0.0, 0.0, 0.0, 0.5 };
 
+  object_class->constructed  = gimp_dialog_config_constructed;
   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;
 
+  g_object_class_install_property (object_class, PROP_GIMP,
+                                   g_param_spec_object ("gimp",
+                                                        NULL, NULL,
+                                                        GIMP_TYPE_GIMP,
+                                                        GIMP_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+
   GIMP_CONFIG_PROP_ENUM (object_class, PROP_COLOR_PROFILE_POLICY,
                          "color-profile-policy",
                          "Color profile policy",
@@ -200,6 +239,24 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
                          GIMP_TYPE_CHANNEL_BORDER_STYLE,
                          GIMP_CHANNEL_BORDER_STYLE_SMOOTH,
                          GIMP_PARAM_STATIC_STRINGS);
+
+  GIMP_CONFIG_PROP_OBJECT (object_class, PROP_FILL_OPTIONS,
+                           "fill-options",
+                           "Fill Options",
+                           FILL_OPTIONS_BLURB,
+                           GIMP_TYPE_FILL_OPTIONS,
+                           GIMP_PARAM_STATIC_STRINGS |
+                           GIMP_CONFIG_PARAM_AGGREGATE);
+
+  GIMP_CONFIG_PROP_OBJECT (object_class, PROP_STROKE_OPTIONS,
+                           "stroke-options",
+                           "Stroke Options",
+                           STROKE_OPTIONS_BLURB,
+                           GIMP_TYPE_STROKE_OPTIONS,
+                           GIMP_PARAM_STATIC_STRINGS |
+                           GIMP_CONFIG_PARAM_AGGREGATE);
+
+  g_type_class_add_private (klass, sizeof (GimpDialogConfigPrivate));
 }
 
 static void
@@ -208,6 +265,36 @@ gimp_dialog_config_init (GimpDialogConfig *config)
 }
 
 static void
+gimp_dialog_config_constructed (GObject *object)
+{
+  GimpDialogConfig        *config = GIMP_DIALOG_CONFIG (object);
+  GimpDialogConfigPrivate *priv   = GET_PRIVATE (object);
+  GimpContext             *context;
+
+  G_OBJECT_CLASS (parent_class)->constructed (object);
+
+  g_assert (GIMP_IS_GIMP (priv->gimp));
+
+  context = gimp_get_user_context (priv->gimp);
+
+  config->fill_options = gimp_fill_options_new (priv->gimp, context, TRUE);
+  gimp_context_set_serialize_properties (GIMP_CONTEXT (config->fill_options),
+                                         0);
+
+  g_signal_connect (config->fill_options, "notify",
+                    G_CALLBACK (gimp_dialog_config_fill_options_notify),
+                    config);
+
+  config->stroke_options = gimp_stroke_options_new (priv->gimp, context, TRUE);
+  gimp_context_set_serialize_properties (GIMP_CONTEXT (config->stroke_options),
+                                         0);
+
+  g_signal_connect (config->stroke_options, "notify",
+                    G_CALLBACK (gimp_dialog_config_stroke_options_notify),
+                    config);
+}
+
+static void
 gimp_dialog_config_finalize (GObject *object)
 {
   GimpDialogConfig *config = GIMP_DIALOG_CONFIG (object);
@@ -230,6 +317,18 @@ gimp_dialog_config_finalize (GObject *object)
       config->vectors_new_name = NULL;
     }
 
+  if (config->fill_options)
+    {
+      g_object_unref (config->fill_options);
+      config->fill_options = NULL;
+    }
+
+  if (config->stroke_options)
+    {
+      g_object_unref (config->stroke_options);
+      config->stroke_options = NULL;
+    }
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -239,10 +338,15 @@ gimp_dialog_config_set_property (GObject      *object,
                                  const GValue *value,
                                  GParamSpec   *pspec)
 {
-  GimpDialogConfig *config = GIMP_DIALOG_CONFIG (object);
+  GimpDialogConfig        *config = GIMP_DIALOG_CONFIG (object);
+  GimpDialogConfigPrivate *priv   = GET_PRIVATE (object);
 
   switch (property_id)
     {
+    case PROP_GIMP:
+      priv->gimp = g_value_get_object (value); /* don't ref */
+      break;
+
     case PROP_COLOR_PROFILE_POLICY:
       config->color_profile_policy = g_value_get_enum (value);
       break;
@@ -303,6 +407,17 @@ gimp_dialog_config_set_property (GObject      *object,
       config->selection_border_style = g_value_get_enum (value);
       break;
 
+    case PROP_FILL_OPTIONS:
+      if (g_value_get_object (value))
+        gimp_config_sync (g_value_get_object (value) ,
+                          G_OBJECT (config->fill_options), 0);
+      break;
+    case PROP_STROKE_OPTIONS:
+      if (g_value_get_object (value))
+        gimp_config_sync (g_value_get_object (value) ,
+                          G_OBJECT (config->stroke_options), 0);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -315,10 +430,15 @@ gimp_dialog_config_get_property (GObject    *object,
                                  GValue     *value,
                                  GParamSpec *pspec)
 {
-  GimpDialogConfig *config = GIMP_DIALOG_CONFIG (object);
+  GimpDialogConfig        *config = GIMP_DIALOG_CONFIG (object);
+  GimpDialogConfigPrivate *priv   = GET_PRIVATE (object);
 
   switch (property_id)
     {
+    case PROP_GIMP:
+      g_value_set_object (value, priv->gimp);
+      break;
+
     case PROP_COLOR_PROFILE_POLICY:
       g_value_set_enum (value, config->color_profile_policy);
       break;
@@ -373,8 +493,31 @@ gimp_dialog_config_get_property (GObject    *object,
       g_value_set_enum (value, config->selection_border_style);
       break;
 
+    case PROP_FILL_OPTIONS:
+      g_value_set_object (value, config->fill_options);
+      break;
+    case PROP_STROKE_OPTIONS:
+      g_value_set_object (value, config->stroke_options);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
     }
 }
+
+static void
+gimp_dialog_config_fill_options_notify (GObject    *object,
+                                        GParamSpec *pspec,
+                                        gpointer    data)
+{
+  g_object_notify (G_OBJECT (data), "fill-options");
+}
+
+static void
+gimp_dialog_config_stroke_options_notify (GObject    *object,
+                                          GParamSpec *pspec,
+                                          gpointer    data)
+{
+  g_object_notify (G_OBJECT (data), "stroke-options");
+}
diff --git a/app/config/gimpdialogconfig.h b/app/config/gimpdialogconfig.h
index 33b43b4..03a87e5 100644
--- a/app/config/gimpdialogconfig.h
+++ b/app/config/gimpdialogconfig.h
@@ -24,6 +24,13 @@
 #include "config/gimpguiconfig.h"
 
 
+/* We don't want to include stuff from core/ here, instead do the next
+ * less ugly hack...
+ */
+typedef struct _GimpFillOptions   GimpFillOptions;
+typedef struct _GimpStrokeOptions GimpStrokeOptions;
+
+
 #define GIMP_TYPE_DIALOG_CONFIG            (gimp_dialog_config_get_type ())
 #define GIMP_DIALOG_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DIALOG_CONFIG, 
GimpDialogConfig))
 #define GIMP_DIALOG_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DIALOG_CONFIG, 
GimpDialogConfigClass))
@@ -60,6 +67,9 @@ struct _GimpDialogConfig
   gdouble                 selection_border_radius;
   gboolean                selection_border_edge_lock;
   GimpChannelBorderStyle  selection_border_style;
+
+  GimpFillOptions        *fill_options;
+  GimpStrokeOptions      *stroke_options;
 };
 
 struct _GimpDialogConfigClass
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index 99c9c89..2cff829 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -464,6 +464,12 @@ _("Sets the default 'Selected areas continue outside the image' setting " \
 #define SELECTION_BORDER_STYLE_BLURB \
 _("Sets the default border style for the 'Border Selection' dialog.")
 
+#define FILL_OPTIONS_BLURB \
+"The default fill options for the fill dialogs."
+
+#define STROKE_OPTIONS_BLURB \
+"The default stroke options for the stroke dialogs."
+
 #define THUMBNAIL_SIZE_BLURB \
 _("Sets the size of the thumbnail shown in the Open dialog.")
 
diff --git a/app/config/gimprc.c b/app/config/gimprc.c
index 0e23714..ce6fdd0 100644
--- a/app/config/gimprc.c
+++ b/app/config/gimprc.c
@@ -230,7 +230,17 @@ gimp_rc_duplicate_unknown_token (const gchar *key,
 static GimpConfig *
 gimp_rc_duplicate (GimpConfig *config)
 {
-  GimpConfig *dup = g_object_new (GIMP_TYPE_RC, NULL);
+  GObject    *gimp;
+  GimpConfig *dup;
+
+  g_object_get (config, "gimp", &gimp, NULL);
+
+  dup = g_object_new (GIMP_TYPE_RC,
+                      "gimp", gimp,
+                      NULL);
+
+  if (gimp)
+    g_object_unref (gimp);
 
   gimp_config_sync (G_OBJECT (config), G_OBJECT (dup), 0);
 
@@ -302,6 +312,7 @@ gimp_rc_notify (GimpRc     *rc,
 
 /**
  * gimp_rc_new:
+ * @gimp:          a #Gimp
  * @system_gimprc: the name of the system-wide gimprc file or %NULL to
  *                 use the standard location
  * @user_gimprc:   the name of the user gimprc file or %NULL to use the
@@ -314,18 +325,21 @@ gimp_rc_notify (GimpRc     *rc,
  * Returns: the new #GimpRc.
  */
 GimpRc *
-gimp_rc_new (GFile    *system_gimprc,
+gimp_rc_new (GObject  *gimp,
+             GFile    *system_gimprc,
              GFile    *user_gimprc,
              gboolean  verbose)
 {
   GimpRc *rc;
 
+  g_return_val_if_fail (G_IS_OBJECT (gimp), NULL);
   g_return_val_if_fail (system_gimprc == NULL || G_IS_FILE (system_gimprc),
                         NULL);
   g_return_val_if_fail (user_gimprc == NULL || G_IS_FILE (user_gimprc),
                         NULL);
 
   rc = g_object_new (GIMP_TYPE_RC,
+                     "gimp",          gimp,
                      "verbose",       verbose,
                      "system-gimprc", system_gimprc,
                      "user-gimprc",   user_gimprc,
@@ -488,9 +502,10 @@ gimp_rc_set_unknown_token (GimpRc      *rc,
 void
 gimp_rc_save (GimpRc *rc)
 {
-  GimpRc *global;
-  gchar  *header;
-  GError *error = NULL;
+  GObject *gimp;
+  GimpRc  *global;
+  gchar   *header;
+  GError  *error = NULL;
 
   const gchar *top =
     "GIMP gimprc\n"
@@ -506,7 +521,14 @@ gimp_rc_save (GimpRc *rc)
 
   g_return_if_fail (GIMP_IS_RC (rc));
 
-  global = g_object_new (GIMP_TYPE_RC, NULL);
+  g_object_get (rc, "gimp", &gimp, NULL);
+
+  global = g_object_new (GIMP_TYPE_RC,
+                         "gimp", gimp,
+                         NULL);
+
+  if (gimp)
+    g_object_unref (gimp);
 
   gimp_config_deserialize_gfile (GIMP_CONFIG (global),
                                  rc->system_gimprc, NULL, NULL);
diff --git a/app/config/gimprc.h b/app/config/gimprc.h
index d75cc30..5cbb557 100644
--- a/app/config/gimprc.h
+++ b/app/config/gimprc.h
@@ -51,7 +51,8 @@ struct _GimpRcClass
 
 
 GType     gimp_rc_get_type          (void) G_GNUC_CONST;
-GimpRc  * gimp_rc_new               (GFile       *system_gimprc,
+GimpRc  * gimp_rc_new               (GObject     *gimp,
+                                     GFile       *system_gimprc,
                                      GFile       *user_gimprc,
                                      gboolean     verbose);
 
diff --git a/app/core/gimp-user-install.c b/app/core/gimp-user-install.c
index bd368a3..aab8e8e 100644
--- a/app/core/gimp-user-install.c
+++ b/app/core/gimp-user-install.c
@@ -61,6 +61,8 @@
 
 struct _GimpUserInstall
 {
+  GObject                 *gimp;
+
   gboolean                verbose;
 
   gchar                  *old_dir;
@@ -145,10 +147,12 @@ static gboolean  user_install_migrate_files      (GimpUserInstall    *install);
 /*  public functions  */
 
 GimpUserInstall *
-gimp_user_install_new (gboolean verbose)
+gimp_user_install_new (GObject  *gimp,
+                       gboolean  verbose)
 {
   GimpUserInstall *install = g_slice_new0 (GimpUserInstall);
 
+  install->gimp    = gimp;
   install->verbose = verbose;
 
   user_install_detect_old (install, gimp_directory ());
@@ -782,7 +786,7 @@ user_install_migrate_files (GimpUserInstall *install)
 
   gimp_templates_migrate (install->old_dir);
 
-  gimprc = gimp_rc_new (NULL, NULL, FALSE);
+  gimprc = gimp_rc_new (install->gimp, NULL, NULL, FALSE);
   gimp_rc_migrate (gimprc);
   gimp_rc_save (gimprc);
   g_object_unref (gimprc);
diff --git a/app/core/gimp-user-install.h b/app/core/gimp-user-install.h
index 8354a63..bede4cb 100644
--- a/app/core/gimp-user-install.h
+++ b/app/core/gimp-user-install.h
@@ -26,7 +26,8 @@ typedef void  (* GimpUserInstallLogFunc) (const gchar *message,
                                           gpointer     user_data);
 
 
-GimpUserInstall * gimp_user_install_new  (gboolean          verbose);
+GimpUserInstall * gimp_user_install_new  (GObject          *gimp,
+                                          gboolean          verbose);
 gboolean          gimp_user_install_run  (GimpUserInstall  *install);
 void              gimp_user_install_free (GimpUserInstall  *install);
 
diff --git a/app/core/gimp.c b/app/core/gimp.c
index 61fb1d5..bcf8109 100644
--- a/app/core/gimp.c
+++ b/app/core/gimp.c
@@ -799,7 +799,8 @@ gimp_load_config (Gimp  *gimp,
    */
   gimp_unitrc_load (gimp);
 
-  gimprc = gimp_rc_new (alternate_system_gimprc,
+  gimprc = gimp_rc_new (G_OBJECT (gimp),
+                        alternate_system_gimprc,
                         alternate_gimprc,
                         gimp->be_verbose);
 
diff --git a/app/dialogs/fill-dialog.c b/app/dialogs/fill-dialog.c
index 1eb0f02..d750da8 100644
--- a/app/dialogs/fill-dialog.c
+++ b/app/dialogs/fill-dialog.c
@@ -28,6 +28,8 @@
 
 #include "dialogs-types.h"
 
+#include "config/gimpdialogconfig.h"
+
 #include "core/gimp.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpimage.h"
@@ -61,11 +63,11 @@ fill_dialog_new (GimpItem    *item,
                  const gchar *help_id,
                  GtkWidget   *parent)
 {
-  GimpFillOptions *options;
-  GimpFillOptions *saved_options;
-  GtkWidget       *dialog;
-  GtkWidget       *main_vbox;
-  GtkWidget       *fill_editor;
+  GimpDialogConfig *config;
+  GimpFillOptions  *options;
+  GtkWidget        *dialog;
+  GtkWidget        *main_vbox;
+  GtkWidget        *fill_editor;
 
   g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
@@ -73,13 +75,12 @@ fill_dialog_new (GimpItem    *item,
   g_return_val_if_fail (help_id != NULL, NULL);
   g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
 
-  options = gimp_fill_options_new (context->gimp, context, TRUE);
+  config = GIMP_DIALOG_CONFIG (context->gimp->config);
 
-  saved_options = g_object_get_data (G_OBJECT (context->gimp),
-                                     "saved-fill-options");
+  options = gimp_fill_options_new (context->gimp, context, TRUE);
 
-  if (saved_options)
-    gimp_config_sync (G_OBJECT (saved_options), G_OBJECT (options), 0);
+  gimp_config_sync (G_OBJECT (config->fill_options),
+                    G_OBJECT (options), 0);
 
   dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (item), context,
                                      title, "gimp-fill-options",
@@ -151,9 +152,9 @@ fill_dialog_response (GtkWidget  *widget,
 
     case GTK_RESPONSE_OK:
       {
-        GimpDrawable    *drawable = gimp_image_get_active_drawable (image);
-        GimpFillOptions *saved_options;
-        GError          *error    = NULL;
+        GimpDialogConfig *config   = GIMP_DIALOG_CONFIG (context->gimp->config);
+        GimpDrawable     *drawable = gimp_image_get_active_drawable (image);
+        GError           *error    = NULL;
 
         if (! drawable)
           {
@@ -164,19 +165,8 @@ fill_dialog_response (GtkWidget  *widget,
             return;
           }
 
-        saved_options = g_object_get_data (G_OBJECT (context->gimp),
-                                           "saved-fill-options");
-
-        if (saved_options)
-          g_object_ref (saved_options);
-        else
-          saved_options = gimp_fill_options_new (context->gimp, context, TRUE);
-
-        gimp_config_sync (G_OBJECT (options), G_OBJECT (saved_options), 0);
-
-        g_object_set_data_full (G_OBJECT (context->gimp), "saved-fill-options",
-                                saved_options,
-                                (GDestroyNotify) g_object_unref);
+        gimp_config_sync (G_OBJECT (options),
+                          G_OBJECT (config->fill_options), 0);
 
         if (! gimp_item_fill (item, drawable, options, TRUE, NULL, &error))
           {
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 3d0e1f6..a152ac6 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -50,6 +50,7 @@
 #include "widgets/gimpmessagedialog.h"
 #include "widgets/gimpprefsbox.h"
 #include "widgets/gimppropwidgets.h"
+#include "widgets/gimpstrokeeditor.h"
 #include "widgets/gimptemplateeditor.h"
 #include "widgets/gimptooleditor.h"
 #include "widgets/gimpwidgets-constructors.h"
@@ -2202,6 +2203,24 @@ prefs_dialog_new (Gimp       *gimp,
                           _("Selected areas continue outside the image"),
                           GTK_BOX (vbox2));
 
+  /*  Fill Options Dialog  */
+  vbox2 = prefs_frame_new (_("Fill Selection Outline & Fill Path Dialogs"),
+                           GTK_CONTAINER (vbox), FALSE);
+
+  table = gimp_fill_editor_new (GIMP_DIALOG_CONFIG (object)->fill_options,
+                                FALSE);
+  gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
+  gtk_widget_show (table);
+
+  /*  Stroke Options Dialog  */
+  vbox2 = prefs_frame_new (_("Stroke Selection & Stroke Path Dialogs"),
+                           GTK_CONTAINER (vbox), FALSE);
+
+  table = gimp_stroke_editor_new (GIMP_DIALOG_CONFIG (object)->stroke_options,
+                                  96.0 /* FIXME */, FALSE);
+  gtk_box_pack_start (GTK_BOX (vbox2), table, FALSE, FALSE, 0);
+  gtk_widget_show (table);
+
   g_object_unref (size_group);
 
 
diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c
index a71e484..5d33f43 100644
--- a/app/dialogs/stroke-dialog.c
+++ b/app/dialogs/stroke-dialog.c
@@ -27,6 +27,8 @@
 
 #include "dialogs-types.h"
 
+#include "config/gimpdialogconfig.h"
+
 #include "core/gimp.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpimage.h"
@@ -64,8 +66,8 @@ stroke_dialog_new (GimpItem    *item,
                    const gchar *help_id,
                    GtkWidget   *parent)
 {
+  GimpDialogConfig  *config;
   GimpStrokeOptions *options;
-  GimpStrokeOptions *saved_options;
   GimpImage         *image;
   GtkWidget         *dialog;
   GtkWidget         *main_vbox;
@@ -83,13 +85,12 @@ stroke_dialog_new (GimpItem    *item,
 
   image = gimp_item_get_image (item);
 
-  options = gimp_stroke_options_new (context->gimp, context, TRUE);
+  config = GIMP_DIALOG_CONFIG (context->gimp->config);
 
-  saved_options = g_object_get_data (G_OBJECT (context->gimp),
-                                     "saved-stroke-options");
+  options = gimp_stroke_options_new (context->gimp, context, TRUE);
 
-  if (saved_options)
-    gimp_config_sync (G_OBJECT (saved_options), G_OBJECT (options), 0);
+  gimp_config_sync (G_OBJECT (config->stroke_options),
+                    G_OBJECT (options), 0);
 
   dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (item), context,
                                      title, "gimp-stroke-options",
@@ -270,9 +271,9 @@ stroke_dialog_response (GtkWidget  *widget,
 
     case GTK_RESPONSE_OK:
       {
-        GimpDrawable      *drawable = gimp_image_get_active_drawable (image);
-        GimpStrokeOptions *saved_options;
-        GError            *error    = NULL;
+        GimpDialogConfig *config   = GIMP_DIALOG_CONFIG (context->gimp->config);
+        GimpDrawable     *drawable = gimp_image_get_active_drawable (image);
+        GError           *error    = NULL;
 
         if (! drawable)
           {
@@ -283,19 +284,8 @@ stroke_dialog_response (GtkWidget  *widget,
             return;
           }
 
-        saved_options = g_object_get_data (G_OBJECT (context->gimp),
-                                           "saved-stroke-options");
-
-        if (saved_options)
-          g_object_ref (saved_options);
-        else
-          saved_options = gimp_stroke_options_new (context->gimp, context, TRUE);
-
-        gimp_config_sync (G_OBJECT (options), G_OBJECT (saved_options), 0);
-
-        g_object_set_data_full (G_OBJECT (context->gimp), "saved-stroke-options",
-                                saved_options,
-                                (GDestroyNotify) g_object_unref);
+        gimp_config_sync (G_OBJECT (options),
+                          G_OBJECT (config->stroke_options), 0);
 
         if (! gimp_item_stroke (item, drawable, context, options, NULL,
                                 TRUE, NULL, &error))
diff --git a/app/main.c b/app/main.c
index bdc9d69..ee63cd6 100644
--- a/app/main.c
+++ b/app/main.c
@@ -719,7 +719,7 @@ gimp_option_dump_gimprc (const gchar  *option_name,
       gimp = g_object_new (GIMP_TYPE_GIMP, NULL);
       gimp_load_config (gimp, NULL, NULL);
 
-      success = gimp_config_dump (format);
+      success = gimp_config_dump (G_OBJECT (gimp), format);
 
       g_object_unref (gimp);
 


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