[gimp/goat-invasion: 365/412] app: add a ton of parameters to GimpImageMapTool::get_settings_ui()



commit d1802d56cf0ebfce029cda257ad5d99f238ba629
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 31 22:33:43 2012 +0200

    app: add a ton of parameters to GimpImageMapTool::get_settings_ui()
    
    so they can be passed in instead of being looked up in the class
    struct, which enables freely configuring the settings stuff from
    subclasses, such as soon GimpOperationTool.

 app/tools/gimpimagemaptool-settings.c |   42 +++++++++++++-------------------
 app/tools/gimpimagemaptool-settings.h |    6 ++++
 app/tools/gimpimagemaptool.c          |   28 ++++++++++++++++++----
 app/tools/gimpimagemaptool.h          |    6 ++++
 4 files changed, 52 insertions(+), 30 deletions(-)
---
diff --git a/app/tools/gimpimagemaptool-settings.c b/app/tools/gimpimagemaptool-settings.c
index 1b59c62..b4c3320 100644
--- a/app/tools/gimpimagemaptool-settings.c
+++ b/app/tools/gimpimagemaptool-settings.c
@@ -60,21 +60,19 @@ static gboolean gimp_image_map_tool_settings_export (GimpSettingsBox  *box,
 
 GtkWidget *
 gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool  *image_map_tool,
+                                          GimpContainer     *settings,
+                                          const gchar       *settings_filename,
+                                          const gchar       *import_dialog_title,
+                                          const gchar       *export_dialog_title,
+                                          const gchar       *file_dialog_help_id,
+                                          const gchar       *default_folder,
                                           GtkWidget        **settings_box)
 {
-  GimpImageMapToolClass *klass;
-  GimpToolInfo          *tool_info;
-  GtkSizeGroup          *label_group;
-  GtkWidget             *hbox;
-  GtkWidget             *label;
-  GtkWidget             *settings_combo;
-  gchar                 *filename;
-  gchar                 *folder;
-
-  klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
-
-  if (! klass->settings_name)
-    return NULL;
+  GimpToolInfo *tool_info;
+  GtkSizeGroup *label_group;
+  GtkWidget    *hbox;
+  GtkWidget    *label;
+  GtkWidget    *settings_combo;
 
   tool_info = GIMP_TOOL (image_map_tool)->tool_info;
 
@@ -87,24 +85,18 @@ gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool  *image_map_tool,
   gtk_size_group_add_widget (label_group, label);
   gtk_widget_show (label);
 
-  filename = gimp_tool_info_build_options_filename (tool_info, ".settings");
-  folder   = g_build_filename (gimp_directory (), klass->settings_name, NULL);
-
   *settings_box = gimp_settings_box_new (tool_info->gimp,
                                          image_map_tool->config,
-                                         klass->recent_settings,
-                                         filename,
-                                         klass->import_dialog_title,
-                                         klass->export_dialog_title,
-                                         tool_info->help_id,
-                                         folder,
+                                         settings,
+                                         settings_filename,
+                                         import_dialog_title,
+                                         export_dialog_title,
+                                         file_dialog_help_id,
+                                         default_folder,
                                          NULL);
   gtk_box_pack_start (GTK_BOX (hbox), *settings_box, TRUE, TRUE, 0);
   gtk_widget_show (*settings_box);
 
-  g_free (filename);
-  g_free (folder);
-
   settings_combo = gimp_settings_box_get_combo (GIMP_SETTINGS_BOX (*settings_box));
   gtk_label_set_mnemonic_widget (GTK_LABEL (label), settings_combo);
 
diff --git a/app/tools/gimpimagemaptool-settings.h b/app/tools/gimpimagemaptool-settings.h
index 94cdccc..825c396 100644
--- a/app/tools/gimpimagemaptool-settings.h
+++ b/app/tools/gimpimagemaptool-settings.h
@@ -22,6 +22,12 @@
 
 
 GtkWidget * gimp_image_map_tool_real_get_settings_ui (GimpImageMapTool *tool,
+                                                      GimpContainer     *settings,
+                                                      const gchar       *settings_filename,
+                                                      const gchar       *import_dialog_title,
+                                                      const gchar       *export_dialog_title,
+                                                      const gchar       *file_dialog_help_id,
+                                                      const gchar       *default_folder,
                                                       GtkWidget       **settings_box);
 gboolean    gimp_image_map_tool_real_settings_import (GimpImageMapTool *tool,
                                                       const gchar      *filename,
diff --git a/app/tools/gimpimagemaptool.c b/app/tools/gimpimagemaptool.c
index 8ecce5d..8c38124 100644
--- a/app/tools/gimpimagemaptool.c
+++ b/app/tools/gimpimagemaptool.c
@@ -297,7 +297,6 @@ gimp_image_map_tool_initialize (GimpTool     *tool,
       GtkWidget             *dialog;
       GtkWidget             *vbox;
       GtkWidget             *toggle;
-      GtkWidget             *settings_ui;
 
       klass = GIMP_IMAGE_MAP_TOOL_GET_CLASS (image_map_tool);
 
@@ -355,11 +354,30 @@ gimp_image_map_tool_initialize (GimpTool     *tool,
                                G_CALLBACK (gimp_image_map_tool_response),
                                G_OBJECT (image_map_tool), 0);
 
-      settings_ui = klass->get_settings_ui (image_map_tool,
-                                            &image_map_tool->settings_box);
-
-      if (settings_ui)
+      if (klass->settings_name)
         {
+          GtkWidget *settings_ui;
+          gchar     *settings_filename;
+          gchar     *default_folder;
+
+          settings_filename =
+            gimp_tool_info_build_options_filename (tool_info, ".settings");
+
+          default_folder =
+            g_build_filename (gimp_directory (), klass->settings_name, NULL);
+
+          settings_ui = klass->get_settings_ui (image_map_tool,
+                                                klass->recent_settings,
+                                                settings_filename,
+                                                klass->import_dialog_title,
+                                                klass->export_dialog_title,
+                                                tool_info->help_id,
+                                                default_folder,
+                                                &image_map_tool->settings_box);
+
+          g_free (settings_filename);
+          g_free (default_folder);
+
           gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), settings_ui,
                               FALSE, FALSE, 0);
           gtk_widget_show (settings_ui);
diff --git a/app/tools/gimpimagemaptool.h b/app/tools/gimpimagemaptool.h
index 62d8752..6b9d540 100644
--- a/app/tools/gimpimagemaptool.h
+++ b/app/tools/gimpimagemaptool.h
@@ -73,6 +73,12 @@ struct _GimpImageMapToolClass
   void        (* reset)           (GimpImageMapTool  *image_map_tool);
 
   GtkWidget * (* get_settings_ui) (GimpImageMapTool  *image_map_tool,
+                                   GimpContainer     *settings,
+                                   const gchar       *settings_filename,
+                                   const gchar       *import_dialog_title,
+                                   const gchar       *export_dialog_title,
+                                   const gchar       *file_dialog_help_id,
+                                   const gchar       *default_folder,
                                    GtkWidget        **settings_box);
 
   gboolean    (* settings_import) (GimpImageMapTool  *image_map_tool,



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