[gimp] app: make "Color Management" and "Dialog Defaults" resettable individually



commit 9645f9039fff018497ff9c34035d5f17f7048f3e
Author: Michael Natterer <mitch gimp org>
Date:   Thu Sep 22 18:53:18 2016 +0200

    app: make "Color Management" and "Dialog Defaults" resettable individually

 app/dialogs/preferences-dialog.c |   57 +++++++++++++++++++++++++++++++++++--
 1 files changed, 53 insertions(+), 4 deletions(-)
---
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index a152ac6..044fee3 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -94,6 +94,11 @@ static void        prefs_message                  (GtkMessageType  type,
                                                    gboolean        destroy,
                                                    const gchar    *message);
 
+static void   prefs_color_management_reset        (GtkWidget  *widget,
+                                                   GObject    *config);
+static void   prefs_dialog_defaults_reset         (GtkWidget  *widget,
+                                                   GObject    *config);
+
 static void   prefs_resolution_source_callback    (GtkWidget  *widget,
                                                    GObject    *config);
 static void   prefs_resolution_calibrate_callback (GtkWidget  *widget,
@@ -433,6 +438,39 @@ prefs_response (GtkWidget *widget,
 }
 
 static void
+prefs_color_management_reset (GtkWidget *widget,
+                              GObject   *config)
+{
+  gimp_config_reset (GIMP_CONFIG (config));
+}
+
+static void
+prefs_dialog_defaults_reset (GtkWidget *widget,
+                             GObject   *config)
+{
+  GParamSpec **pspecs;
+  guint        n_pspecs;
+  guint        i;
+
+  pspecs = g_object_class_list_properties (G_OBJECT_GET_CLASS (config),
+                                           &n_pspecs);
+
+  g_object_freeze_notify (config);
+
+  for (i = 0; i < n_pspecs; i++)
+    {
+      GParamSpec *pspec = pspecs[i];
+
+      if (pspec->owner_type == GIMP_TYPE_DIALOG_CONFIG)
+        gimp_config_reset_property (config, pspec->name);
+    }
+
+  g_object_thaw_notify (config);
+
+  g_free (pspecs);
+}
+
+static void
 prefs_template_select_callback (GimpContainerView *view,
                                 GimpTemplate      *template,
                                 gpointer           insert_data,
@@ -1397,15 +1435,19 @@ prefs_dialog_new (Gimp       *gimp,
 
   gimp_prefs_box_set_page_scrollable (GIMP_PREFS_BOX (prefs_box), vbox, TRUE);
 
+  button = gimp_prefs_box_set_page_resettable (GIMP_PREFS_BOX (prefs_box),
+                                               vbox,
+                                               _("Reset Color Management"));
+  g_signal_connect (button, "clicked",
+                    G_CALLBACK (prefs_color_management_reset),
+                    core_config->color_management);
+
   {
-    GObject      *color_config;
+    GObject      *color_config = G_OBJECT (core_config->color_management);
     GtkListStore *store;
     gchar        *filename;
     gint          row = 0;
 
-    g_object_get (object, "color-management", &color_config, NULL);
-    g_object_unref (color_config);
-
     filename = gimp_personal_rc_file ("profilerc");
     store = gimp_color_profile_store_new (filename);
     g_free (filename);
@@ -2094,6 +2136,13 @@ prefs_dialog_new (Gimp       *gimp,
 
   gimp_prefs_box_set_page_scrollable (GIMP_PREFS_BOX (prefs_box), vbox, TRUE);
 
+  button = gimp_prefs_box_set_page_resettable (GIMP_PREFS_BOX (prefs_box),
+                                               vbox,
+                                               _("Reset Dialog Defaults"));
+  g_signal_connect (button, "clicked",
+                    G_CALLBACK (prefs_dialog_defaults_reset),
+                    config);
+
   size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
   /*  Color profile import dialog  */


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