[gimp] app: register the "settings folder" (e.g. GIMPDIR/curves) with the settings type



commit 4f4d6b27cfd219e6d79877fa434aa71d6d8082db
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 5 22:00:17 2017 +0200

    app: register the "settings folder" (e.g. GIMPDIR/curves) with the settings type
    
    and remove all settings_folder API and values from GimpFilterTool and
    its subclasses.

 app/operations/gimp-operations.c       |   22 ++++++++++++++++++++++
 app/tools/gimpbrightnesscontrasttool.c |    3 ---
 app/tools/gimpcurvestool.c             |    3 ---
 app/tools/gimpfiltertool-settings.c    |    7 ++++++-
 app/tools/gimpfiltertool.c             |   29 +++++++----------------------
 app/tools/gimpfiltertool.h             |    2 --
 app/tools/gimplevelstool.c             |    3 ---
 app/tools/gimpoperationtool.c          |    2 --
 app/tools/gimpthresholdtool.c          |    3 ---
 9 files changed, 35 insertions(+), 39 deletions(-)
---
diff --git a/app/operations/gimp-operations.c b/app/operations/gimp-operations.c
index 26136a7..513794a 100644
--- a/app/operations/gimp-operations.c
+++ b/app/operations/gimp-operations.c
@@ -106,6 +106,16 @@ set_compat_file (GType        type,
   g_type_set_qdata (type, quark, file);
 }
 
+static void
+set_settings_folder (GType        type,
+                     const gchar *basename)
+{
+  GFile *file  = gimp_directory_file (basename, NULL);
+  GQuark quark = g_quark_from_static_string ("settings-folder");
+
+  g_type_set_qdata (type, quark, file);
+}
+
 void
 gimp_operations_init (Gimp *gimp)
 {
@@ -173,34 +183,46 @@ gimp_operations_init (Gimp *gimp)
                                   GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG);
   set_compat_file (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG,
                    "gimp-brightness-contrast-tool.settings");
+  set_settings_folder (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG,
+                       "brightness-contrast");
 
   gimp_operation_config_register (gimp,
                                   "gimp:color-balance",
                                   GIMP_TYPE_COLOR_BALANCE_CONFIG);
   set_compat_file (GIMP_TYPE_COLOR_BALANCE_CONFIG,
                    "gimp-color-balance-tool.settings");
+  set_settings_folder (GIMP_TYPE_COLOR_BALANCE_CONFIG,
+                       "color-balance");
 
   gimp_operation_config_register (gimp,
                                   "gimp:colorize",
                                   GIMP_TYPE_COLORIZE_CONFIG);
   set_compat_file (GIMP_TYPE_COLORIZE_CONFIG,
                    "gimp-colorize-tool.settings");
+  set_settings_folder (GIMP_TYPE_COLORIZE_CONFIG,
+                       "colorize");
 
   gimp_operation_config_register (gimp,
                                   "gimp:curves",
                                   GIMP_TYPE_CURVES_CONFIG);
   set_compat_file (GIMP_TYPE_CURVES_CONFIG,
                    "gimp-curves-tool.settings");
+  set_settings_folder (GIMP_TYPE_CURVES_CONFIG,
+                       "curves");
 
   gimp_operation_config_register (gimp,
                                   "gimp:hue-saturation",
                                   GIMP_TYPE_HUE_SATURATION_CONFIG);
   set_compat_file (GIMP_TYPE_HUE_SATURATION_CONFIG,
                    "gimp-hue-saturation-tool.settings");
+  set_settings_folder (GIMP_TYPE_HUE_SATURATION_CONFIG,
+                       "hue-saturation");
 
   gimp_operation_config_register (gimp,
                                   "gimp:levels",
                                   GIMP_TYPE_LEVELS_CONFIG);
   set_compat_file (GIMP_TYPE_LEVELS_CONFIG,
                    "gimp-levels-tool.settings");
+  set_settings_folder (GIMP_TYPE_LEVELS_CONFIG,
+                       "levels");
 }
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index cd78dd2..63176b5 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -79,7 +79,6 @@ static gchar *
                                                             gchar                **icon_name,
                                                             gchar                **help_id,
                                                             gboolean              *has_settings,
-                                                            gchar                **settings_folder,
                                                             gchar                **import_dialog_title,
                                                             gchar                **export_dialog_title);
 static void   gimp_brightness_contrast_tool_dialog         (GimpFilterTool        *filter_tool);
@@ -170,13 +169,11 @@ gimp_brightness_contrast_tool_get_operation (GimpFilterTool  *filter_tool,
                                              gchar          **icon_name,
                                              gchar          **help_id,
                                              gboolean        *has_settings,
-                                             gchar          **settings_folder,
                                              gchar          **import_dialog_title,
                                              gchar          **export_dialog_title)
 {
   *description         = g_strdup (_("Adjust Brightness and Contrast"));
   *has_settings        = TRUE;
-  *settings_folder     = g_strdup ("brightness-contrast");
   *import_dialog_title = g_strdup (_("Import Brightness-Contrast settings"));
   *export_dialog_title = g_strdup (_("Export Brightness-Contrast settings"));
 
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index ef5e57d..808b01c 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -89,7 +89,6 @@ static gchar    * gimp_curves_tool_get_operation   (GimpFilterTool       *filter
                                                     gchar               **icon_name,
                                                     gchar               **help_id,
                                                     gboolean             *has_settings,
-                                                    gchar               **settings_folder,
                                                     gchar               **import_dialog_title,
                                                     gchar               **export_dialog_title);
 static void       gimp_curves_tool_dialog          (GimpFilterTool       *filter_tool);
@@ -370,13 +369,11 @@ gimp_curves_tool_get_operation (GimpFilterTool  *filter_tool,
                                 gchar          **icon_name,
                                 gchar          **help_id,
                                 gboolean        *has_settings,
-                                gchar          **settings_folder,
                                 gchar          **import_dialog_title,
                                 gchar          **export_dialog_title)
 {
   *description         = g_strdup (_("Adjust Color Curves"));
   *has_settings        = TRUE;
-  *settings_folder     = g_strdup ("curves");
   *import_dialog_title = g_strdup (_("Import Curves"));
   *export_dialog_title = g_strdup (_("Export Curves"));
 
diff --git a/app/tools/gimpfiltertool-settings.c b/app/tools/gimpfiltertool-settings.c
index d6eb91a..364da11 100644
--- a/app/tools/gimpfiltertool-settings.c
+++ b/app/tools/gimpfiltertool-settings.c
@@ -66,17 +66,22 @@ GtkWidget *
 gimp_filter_tool_get_settings_box (GimpFilterTool *filter_tool)
 {
   GimpToolInfo *tool_info = GIMP_TOOL (filter_tool)->tool_info;
+  GQuark        quark     = g_quark_from_static_string ("settings-folder");
+  GType         type      = G_TYPE_FROM_INSTANCE (filter_tool->config);
+  GFile        *settings_folder;
   GtkWidget    *box;
   GtkWidget    *label;
   GtkWidget    *combo;
 
+  settings_folder = g_type_get_qdata (type, quark);
+
   box = gimp_settings_box_new (tool_info->gimp,
                                filter_tool->config,
                                filter_tool->settings,
                                filter_tool->import_dialog_title,
                                filter_tool->export_dialog_title,
                                filter_tool->help_id,
-                               filter_tool->settings_folder,
+                               settings_folder,
                                NULL);
 
   g_signal_connect (box, "import",
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index f008023..6d9a415 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -277,12 +277,6 @@ gimp_filter_tool_finalize (GObject *object)
       filter_tool->help_id = NULL;
     }
 
-  if (filter_tool->settings_folder)
-    {
-      g_object_unref (filter_tool->settings_folder);
-      filter_tool->settings_folder = NULL;
-    }
-
   if (filter_tool->import_dialog_title)
     {
       g_free (filter_tool->import_dialog_title);
@@ -1226,7 +1220,6 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
   GimpFilterToolClass *klass;
   GimpToolInfo        *tool_info;
   gchar               *operation_name;
-  gchar               *settings_folder = NULL;
 
   g_return_if_fail (GIMP_IS_FILTER_TOOL (filter_tool));
 
@@ -1299,12 +1292,6 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
       filter_tool->help_id = NULL;
     }
 
-  if (filter_tool->settings_folder)
-    {
-      g_object_unref (filter_tool->settings_folder);
-      filter_tool->settings_folder = NULL;
-    }
-
   if (filter_tool->import_dialog_title)
     {
       g_free (filter_tool->import_dialog_title);
@@ -1324,7 +1311,6 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
                                          &filter_tool->icon_name,
                                          &filter_tool->help_id,
                                          &filter_tool->has_settings,
-                                         &settings_folder,
                                          &filter_tool->import_dialog_title,
                                          &filter_tool->export_dialog_title);
 
@@ -1347,13 +1333,6 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
   if (! filter_tool->help_id)
     filter_tool->help_id = g_strdup (tool_info->help_id);
 
-  if (settings_folder)
-    {
-      filter_tool->settings_folder = gimp_directory_file (settings_folder,
-                                                          NULL);
-      g_free (settings_folder);
-    }
-
   filter_tool->operation = gegl_node_new_child (NULL,
                                                 "operation", operation_name,
                                                 NULL);
@@ -1433,6 +1412,12 @@ gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
     {
       if (filter_tool->has_settings)
         {
+          GQuark  quark = g_quark_from_static_string ("settings-folder");
+          GType   type  = G_TYPE_FROM_INSTANCE (filter_tool->config);
+          GFile  *settings_folder;
+
+          settings_folder = g_type_get_qdata (type, quark);
+
           g_object_set (filter_tool->settings_box,
                         "visible",        TRUE,
                         "config",         filter_tool->config,
@@ -1440,7 +1425,7 @@ gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
                         "help-id",        filter_tool->help_id,
                         "import-title",   filter_tool->import_dialog_title,
                         "export-title",   filter_tool->export_dialog_title,
-                        "default-folder", filter_tool->settings_folder,
+                        "default-folder", settings_folder,
                         "last-file",      NULL,
                         NULL);
         }
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index f86ba44..5149c1d 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -52,7 +52,6 @@ struct _GimpFilterTool
   gchar                 *help_id;
 
   gboolean               has_settings;
-  GFile                 *settings_folder;
   gchar                 *import_dialog_title;
   gchar                 *export_dialog_title;
 
@@ -83,7 +82,6 @@ struct _GimpFilterToolClass
                                    gchar            **icon_name,
                                    gchar            **help_id,
                                    gboolean          *has_settings,
-                                   gchar            **settings_folder,
                                    gchar            **import_dialog_title,
                                    gchar            **export_dialog_title);
   void        (* dialog)          (GimpFilterTool    *filter_tool);
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index 79d2807..6994465 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -79,7 +79,6 @@ static gchar    * gimp_levels_tool_get_operation  (GimpFilterTool   *filter_tool
                                                    gchar           **icon_name,
                                                    gchar           **help_id,
                                                    gboolean         *has_settings,
-                                                   gchar           **settings_folder,
                                                    gchar           **import_dialog_title,
                                                    gchar           **export_dialog_title);
 static void       gimp_levels_tool_dialog         (GimpFilterTool   *filter_tool);
@@ -261,13 +260,11 @@ gimp_levels_tool_get_operation (GimpFilterTool  *filter_tool,
                                 gchar          **icon_name,
                                 gchar          **help_id,
                                 gboolean        *has_settings,
-                                gchar          **settings_folder,
                                 gchar          **import_dialog_title,
                                 gchar          **export_dialog_title)
 {
   *description         = g_strdup (_("Adjust Color Levels"));
   *has_settings        = TRUE;
-  *settings_folder     = g_strdup ("levels");
   *import_dialog_title = g_strdup (_("Import Levels"));
   *export_dialog_title = g_strdup (_("Export Levels"));
 
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 3ed8100..f436646 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -85,7 +85,6 @@ static gchar     * gimp_operation_tool_get_operation   (GimpFilterTool    *filte
                                                         gchar            **icon_name,
                                                         gchar            **help_id,
                                                         gboolean          *has_settings,
-                                                        gchar            **settings_folder,
                                                         gchar            **import_dialog_title,
                                                         gchar            **export_dialog_title);
 static void        gimp_operation_tool_dialog          (GimpFilterTool    *filter_tool);
@@ -261,7 +260,6 @@ gimp_operation_tool_get_operation (GimpFilterTool  *filter_tool,
                                    gchar          **icon_name,
                                    gchar          **help_id,
                                    gboolean        *has_settings,
-                                   gchar          **settings_folder,
                                    gchar          **import_dialog_title,
                                    gchar          **export_dialog_title)
 {
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index 853251e..e96460e 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -59,7 +59,6 @@ static gchar    * gimp_threshold_tool_get_operation   (GimpFilterTool    *filter
                                                        gchar            **icon_name,
                                                        gchar            **help_id,
                                                        gboolean          *has_settings,
-                                                       gchar            **settings_folder,
                                                        gchar            **import_dialog_title,
                                                        gchar            **export_dialog_title);
 static void       gimp_threshold_tool_dialog          (GimpFilterTool    *filter_tool);
@@ -177,13 +176,11 @@ gimp_threshold_tool_get_operation (GimpFilterTool  *filter_tool,
                                    gchar          **icon_name,
                                    gchar          **help_id,
                                    gboolean        *has_settings,
-                                   gchar          **settings_folder,
                                    gchar          **import_dialog_title,
                                    gchar          **export_dialog_title)
 {
   *description         = g_strdup (_("Apply Threshold"));
   *has_settings        = TRUE;
-  *settings_folder     = g_strdup ("threshold");
   *import_dialog_title = g_strdup (_("Import Threshold Settings"));
   *export_dialog_title = g_strdup (_("Export Threshold Settings"));
 


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