[gimp/metadata-browser] app: port dockable showing to using GimpWindowStrategy API



commit c6ec21f00f2caa86c023fd2a0a1028af63020cd9
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jan 30 23:24:44 2012 +0100

    app: port dockable showing to using GimpWindowStrategy API
    
    so it works right in SWM. Fixed actions/, tools/, and app/ for now.

 app/actions/data-commands.c         |   10 ++++++++--
 app/actions/edit-commands.c         |   11 ++++++++---
 app/actions/file-commands.c         |    1 +
 app/actions/select-commands.c       |    9 ++++++---
 app/actions/tool-options-commands.c |   34 ++++++++++++++++++++++------------
 app/actions/view-commands.c         |   23 ++++++++++++++---------
 app/gui/gui-message.c               |   17 ++++++++++++-----
 app/tools/gimpcolortool.c           |   15 +++++++++------
 8 files changed, 80 insertions(+), 40 deletions(-)
---
diff --git a/app/actions/data-commands.c b/app/actions/data-commands.c
index c8ae9ee..1821117 100644
--- a/app/actions/data-commands.c
+++ b/app/actions/data-commands.c
@@ -40,6 +40,8 @@
 #include "widgets/gimpmessagebox.h"
 #include "widgets/gimpmessagedialog.h"
 
+#include "display/gimpwindowstrategy.h"
+
 #include "dialogs/data-delete-dialog.h"
 
 #include "actions.h"
@@ -256,8 +258,12 @@ data_edit_cmd_callback (GtkAction   *action,
       GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (view));
       GtkWidget *dockable;
 
-      dockable = gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (), screen,
-                                                   value, -1);
+      dockable =
+        gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (context->gimp)),
+                                                   context->gimp,
+                                                   gimp_dialog_factory_get_singleton (),
+                                                   screen,
+                                                   value);
 
       gimp_data_editor_set_data (GIMP_DATA_EDITOR (gtk_bin_get_child (GTK_BIN (dockable))),
                                  data);
diff --git a/app/actions/edit-commands.c b/app/actions/edit-commands.c
index c34d728..4d44157 100644
--- a/app/actions/edit-commands.c
+++ b/app/actions/edit-commands.c
@@ -48,6 +48,7 @@
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplayshell.h"
 #include "display/gimpdisplayshell-transform.h"
+#include "display/gimpwindowstrategy.h"
 
 #include "dialogs/fade-dialog.h"
 
@@ -445,12 +446,16 @@ void
 edit_named_paste_cmd_callback (GtkAction *action,
                                gpointer   data)
 {
+  Gimp      *gimp;
   GtkWidget *widget;
+  return_if_no_gimp (gimp, data);
   return_if_no_widget (widget, data);
 
-  gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
-                                    gtk_widget_get_screen (widget),
-                                    "gimp-buffer-list|gimp-buffer-grid", -1);
+  gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
+                                             gimp,
+                                             gimp_dialog_factory_get_singleton (),
+                                             gtk_widget_get_screen (widget),
+                                             "gimp-buffer-list|gimp-buffer-grid");
 }
 
 void
diff --git a/app/actions/file-commands.c b/app/actions/file-commands.c
index 93ee58c..d8be013 100644
--- a/app/actions/file-commands.c
+++ b/app/actions/file-commands.c
@@ -51,6 +51,7 @@
 
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplay-foreach.h"
+#include "display/gimpwindowstrategy.h"
 
 #include "dialogs/file-save-dialog.h"
 
diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c
index 04529b3..9aa609b 100644
--- a/app/actions/select-commands.c
+++ b/app/actions/select-commands.c
@@ -36,6 +36,7 @@
 
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplayshell.h"
+#include "display/gimpwindowstrategy.h"
 
 #include "dialogs/stroke-dialog.h"
 
@@ -317,9 +318,11 @@ select_save_cmd_callback (GtkAction *action,
   gimp_selection_save (GIMP_SELECTION (gimp_image_get_mask (image)));
   gimp_image_flush (image);
 
-  gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
-                                    gtk_widget_get_screen (widget),
-                                    "gimp-channel-list", -1);
+  gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (image->gimp)),
+                                             image->gimp,
+                                             gimp_dialog_factory_get_singleton (),
+                                             gtk_widget_get_screen (widget),
+                                             "gimp-channel-list");
 }
 
 void
diff --git a/app/actions/tool-options-commands.c b/app/actions/tool-options-commands.c
index a4746cc..12466b7 100644
--- a/app/actions/tool-options-commands.c
+++ b/app/actions/tool-options-commands.c
@@ -42,6 +42,8 @@
 #include "widgets/gimptooloptionseditor.h"
 #include "widgets/gimpuimanager.h"
 
+#include "display/gimpwindowstrategy.h"
+
 #include "dialogs/data-delete-dialog.h"
 
 #include "tool-options-commands.h"
@@ -51,7 +53,8 @@
 
 /*  local function prototypes  */
 
-static void   tool_options_show_preset_editor (GimpEditor     *editor,
+static void   tool_options_show_preset_editor (Gimp           *gimp,
+                                               GimpEditor     *editor,
                                                GimpToolPreset *preset);
 
 
@@ -62,13 +65,14 @@ tool_options_save_new_preset_cmd_callback (GtkAction *action,
                                            gpointer   user_data)
 {
   GimpEditor  *editor  = GIMP_EDITOR (user_data);
-  GimpContext *context = gimp_get_user_context (gimp_editor_get_ui_manager (editor)->gimp);
+  Gimp        *gimp    = gimp_editor_get_ui_manager (editor)->gimp;
+  GimpContext *context = gimp_get_user_context (gimp);
   GimpData    *data;
 
   data = gimp_data_factory_data_new (context->gimp->tool_preset_factory,
                                      context, _("Untitled"));
 
-  tool_options_show_preset_editor (editor, GIMP_TOOL_PRESET (data));
+  tool_options_show_preset_editor (gimp, editor, GIMP_TOOL_PRESET (data));
 }
 
 void
@@ -77,7 +81,8 @@ tool_options_save_preset_cmd_callback (GtkAction *action,
                                        gpointer   data)
 {
   GimpEditor     *editor    = GIMP_EDITOR (data);
-  GimpContext    *context   = gimp_get_user_context (gimp_editor_get_ui_manager (editor)->gimp);
+  Gimp           *gimp      = gimp_editor_get_ui_manager (editor)->gimp;
+  GimpContext    *context   = gimp_get_user_context (gimp);
   GimpToolInfo   *tool_info = gimp_context_get_tool (context);
   GimpToolPreset *preset;
 
@@ -89,7 +94,7 @@ tool_options_save_preset_cmd_callback (GtkAction *action,
       gimp_config_sync (G_OBJECT (tool_info->tool_options),
                         G_OBJECT (preset->tool_options), 0);
 
-      tool_options_show_preset_editor (editor, preset);
+      tool_options_show_preset_editor (gimp, editor, preset);
     }
 }
 
@@ -99,7 +104,8 @@ tool_options_restore_preset_cmd_callback (GtkAction *action,
                                           gpointer   data)
 {
   GimpEditor     *editor    = GIMP_EDITOR (data);
-  GimpContext    *context   = gimp_get_user_context (gimp_editor_get_ui_manager (editor)->gimp);
+  Gimp           *gimp      = gimp_editor_get_ui_manager (editor)->gimp;
+  GimpContext    *context   = gimp_get_user_context (gimp);
   GimpToolInfo   *tool_info = gimp_context_get_tool (context);
   GimpToolPreset *preset;
 
@@ -121,7 +127,8 @@ tool_options_edit_preset_cmd_callback (GtkAction *action,
                                        gpointer   data)
 {
   GimpEditor     *editor    = GIMP_EDITOR (data);
-  GimpContext    *context   = gimp_get_user_context (gimp_editor_get_ui_manager (editor)->gimp);
+  Gimp           *gimp      = gimp_editor_get_ui_manager (editor)->gimp;
+  GimpContext    *context   = gimp_get_user_context (gimp);
   GimpToolInfo   *tool_info = gimp_context_get_tool (context);
   GimpToolPreset *preset;
 
@@ -130,7 +137,7 @@ tool_options_edit_preset_cmd_callback (GtkAction *action,
 
   if (preset)
     {
-      tool_options_show_preset_editor (editor, preset);
+      tool_options_show_preset_editor (gimp, editor, preset);
     }
 }
 
@@ -225,15 +232,18 @@ tool_options_reset_all_cmd_callback (GtkAction *action,
 /*  private functions  */
 
 static void
-tool_options_show_preset_editor (GimpEditor     *editor,
+tool_options_show_preset_editor (Gimp           *gimp,
+                                 GimpEditor     *editor,
                                  GimpToolPreset *preset)
 {
   GtkWidget *dockable;
 
   dockable =
-    gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
-                                      gtk_widget_get_screen (GTK_WIDGET (editor)),
-                                      "gimp-tool-preset-editor", -1);
+    gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
+                                               gimp,
+                                               gimp_dialog_factory_get_singleton (),
+                                               gtk_widget_get_screen (GTK_WIDGET (editor)),
+                                               "gimp-tool-preset-editor");
 
   gimp_data_editor_set_data (GIMP_DATA_EDITOR (gtk_bin_get_child (GTK_BIN (dockable))),
                              GIMP_DATA (preset));
diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c
index 8dfeecb..47292c8 100644
--- a/app/actions/view-commands.c
+++ b/app/actions/view-commands.c
@@ -34,6 +34,12 @@
 #include "core/gimpgrouplayer.h"
 #include "core/gimpprojection.h"
 
+#include "widgets/gimpactiongroup.h"
+#include "widgets/gimpcolordialog.h"
+#include "widgets/gimpdock.h"
+#include "widgets/gimpdialogfactory.h"
+#include "widgets/gimpuimanager.h"
+
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplay-foreach.h"
 #include "display/gimpdisplayshell.h"
@@ -43,12 +49,7 @@
 #include "display/gimpdisplayshell-scale-dialog.h"
 #include "display/gimpdisplayshell-scroll.h"
 #include "display/gimpimagewindow.h"
-
-#include "widgets/gimpactiongroup.h"
-#include "widgets/gimpcolordialog.h"
-#include "widgets/gimpdock.h"
-#include "widgets/gimpdialogfactory.h"
-#include "widgets/gimpuimanager.h"
+#include "display/gimpwindowstrategy.h"
 
 #include "actions.h"
 #include "view-commands.h"
@@ -315,12 +316,16 @@ void
 view_navigation_window_cmd_callback (GtkAction *action,
                                      gpointer   data)
 {
+  Gimp             *gimp;
   GimpDisplayShell *shell;
+  return_if_no_gimp (gimp, data);
   return_if_no_shell (shell, data);
 
-  gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
-                                    gtk_widget_get_screen (GTK_WIDGET (shell)),
-                                    "gimp-navigation-view", -1);
+  gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
+                                             gimp,
+                                             gimp_dialog_factory_get_singleton (),
+                                             gtk_widget_get_screen (GTK_WIDGET (shell)),
+                                             "gimp-navigation-view");
 }
 
 void
diff --git a/app/gui/gui-message.c b/app/gui/gui-message.c
index 69c86d5..522bfc8 100644
--- a/app/gui/gui-message.c
+++ b/app/gui/gui-message.c
@@ -41,12 +41,15 @@
 #include "widgets/gimpsessioninfo.h"
 #include "widgets/gimpwidgets-utils.h"
 
+#include "display/gimpwindowstrategy.h"
+
 #include "gui-message.h"
 
 #include "gimp-intl.h"
 
 
-static gboolean  gui_message_error_console (GimpMessageSeverity  severity,
+static gboolean  gui_message_error_console (Gimp                *gimp,
+                                            GimpMessageSeverity  severity,
                                             const gchar         *domain,
                                             const gchar         *message);
 static gboolean  gui_message_error_dialog  (Gimp                *gimp,
@@ -69,7 +72,7 @@ gui_message (Gimp                *gimp,
   switch (gimp->message_handler)
     {
     case GIMP_ERROR_CONSOLE:
-      if (gui_message_error_console (severity, domain, message))
+      if (gui_message_error_console (gimp, severity, domain, message))
         return;
 
       gimp->message_handler = GIMP_MESSAGE_BOX;
@@ -89,7 +92,8 @@ gui_message (Gimp                *gimp,
 }
 
 static gboolean
-gui_message_error_console (GimpMessageSeverity  severity,
+gui_message_error_console (Gimp                *gimp,
+                           GimpMessageSeverity  severity,
                            const gchar         *domain,
                            const gchar         *message)
 {
@@ -106,9 +110,12 @@ gui_message_error_console (GimpMessageSeverity  severity,
     }
 
   if (! dockable)
-    dockable = gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
+    dockable =
+      gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (gimp)),
+                                                 gimp,
+                                                 gimp_dialog_factory_get_singleton (),
                                                  gdk_screen_get_default (),
-                                                 "gimp-error-console", -1);
+                                                 "gimp-error-console");
 
   if (dockable)
     {
diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c
index 0cc7e29..6b5a32d 100644
--- a/app/tools/gimpcolortool.c
+++ b/app/tools/gimpcolortool.c
@@ -49,6 +49,7 @@
 #include "display/gimpdisplayshell-appearance.h"
 #include "display/gimpdisplayshell-selection.h"
 #include "display/gimpdisplayshell-transform.h"
+#include "display/gimpwindowstrategy.h"
 
 #include "gimpcoloroptions.h"
 #include "gimpcolortool.h"
@@ -656,15 +657,17 @@ gimp_color_tool_real_picked (GimpColorTool      *color_tool,
 
     case GIMP_COLOR_PICK_MODE_PALETTE:
       {
-        GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
-        GdkScreen        *screen;
+        GimpDisplayShell *shell  = gimp_display_get_shell (tool->display);
+        GdkScreen        *screen = gtk_widget_get_screen (GTK_WIDGET (shell));
         GtkWidget        *dockable;
 
-        screen = gtk_widget_get_screen (GTK_WIDGET (shell));
-        dockable = gimp_dialog_factory_dialog_raise (gimp_dialog_factory_get_singleton (),
+        dockable =
+          gimp_window_strategy_show_dockable_dialog (GIMP_WINDOW_STRATEGY (gimp_get_window_strategy (tool->display->gimp)),
+                                                     tool->display->gimp,
+                                                     gimp_dialog_factory_get_singleton (),
                                                      screen,
-                                                     "gimp-palette-editor",
-                                                     -1);
+                                                     "gimp-palette-editor");
+
         if (dockable)
           {
             GtkWidget *palette_editor;



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