[gimp] app: Session manage empty- and single-image window separately



commit 0c4409c8971ffdc0dd01e39f363a95095d51d39d
Author: Martin Nordholts <martinn src gnome org>
Date:   Sat Mar 13 16:35:57 2010 +0100

    app: Session manage empty- and single-image window separately
    
    Session manage empty- and single-image window separately. So when
    starting up, the default 2.6 UI is the same. But when enabling
    single-window mode, the image window will become much larger then the
    empty-image window. These conceptually different windows will then
    from that point be session managed separately: switching mode switches
    size of the image window.

 app/dialogs/dialogs.c         |    4 +-
 app/display/gimpimagewindow.c |   84 +++++++++++++++++++++++++++++++++++-----
 etc/sessionrc                 |    8 ++++
 3 files changed, 84 insertions(+), 12 deletions(-)
---
diff --git a/app/dialogs/dialogs.c b/app/dialogs/dialogs.c
index d31a9b0..b9504df 100644
--- a/app/dialogs/dialogs.c
+++ b/app/dialogs/dialogs.c
@@ -364,8 +364,10 @@ static const GimpDialogFactoryEntry entries[] =
             GIMP_HELP_PALETTE_EDITOR_DIALOG,
             dialogs_palette_editor_get, 0, TRUE),
 
-  /*  emtpy image window  */
+  /*  image windows  */
   FOREIGN_NOT_HIDEABLE ("gimp-empty-image-window",
+                        TRUE, TRUE),
+  FOREIGN_NOT_HIDEABLE ("gimp-single-image-window",
                         TRUE, TRUE)
 };
 
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index dda9554..b915e00 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -58,6 +58,9 @@
 #include "gimp-log.h"
 #include "gimp-intl.h"
 
+#define GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID  "gimp-empty-image-window"
+#define GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID "gimp-single-image-window"
+
 
 enum
 {
@@ -89,6 +92,8 @@ struct _GimpImageWindowPrivate
   GtkWidget         *right_docks;
 
   GdkWindowState     window_state;
+
+  const gchar       *entry_id;
 };
 
 typedef struct
@@ -139,6 +144,10 @@ static void      gimp_image_window_session_apply       (GimpImageWindow     *win
                                                         const gchar         *entry_id);
 static void      gimp_image_window_session_update      (GimpImageWindow     *window,
                                                         GimpDisplay         *new_display);
+static const gchar *
+                 gimp_image_window_config_to_entry_id  (GimpGuiConfig       *config);
+static void      gimp_image_window_set_entry_id        (GimpImageWindow     *window,
+                                                        const gchar         *entry_id);
 static void      gimp_image_window_show_tooltip        (GimpUIManager       *manager,
                                                         const gchar         *tooltip,
                                                         GimpImageWindow     *window);
@@ -369,6 +378,9 @@ gimp_image_window_constructor (GType                  type,
   g_signal_connect_object (config, "notify::hide-docks",
                            G_CALLBACK (gimp_image_window_config_notify),
                            window, G_CONNECT_SWAPPED);
+
+  private->entry_id = gimp_image_window_config_to_entry_id (config);
+
   return object;
 }
 
@@ -1115,6 +1127,7 @@ gimp_image_window_config_notify (GimpImageWindow *window,
 {
   GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
 
+  /* Dock column visibility */
   if (strcmp (pspec->name, "single-window-mode") == 0 ||
       strcmp (pspec->name, "hide-docks")         == 0)
     {
@@ -1125,6 +1138,13 @@ gimp_image_window_config_notify (GimpImageWindow *window,
       gtk_widget_set_visible (private->left_docks, show_docks);
       gtk_widget_set_visible (private->right_docks, show_docks);
     }
+
+  /* Session management */
+  if (strcmp (pspec->name, "single-window-mode") == 0)
+    {
+      gimp_image_window_set_entry_id (window,
+                                      gimp_image_window_config_to_entry_id (config));
+    }
 }
 
 static void
@@ -1364,21 +1384,63 @@ gimp_image_window_session_update (GimpImageWindow *window,
 {
   GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
 
-  if (gimp_display_get_image (new_display))
+  if (private->entry_id == NULL)
+    return;
+
+  if (strcmp (private->entry_id, GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID) == 0)
     {
-      /* As soon as we have an image we should not affect the size of the
-       * empty image window
-       */
-      gimp_image_window_session_clear (window);
+      if (gimp_display_get_image (new_display))
+        {
+          /* As soon as we have an image we should not affect the size of the
+           * empty image window
+           */
+          gimp_image_window_session_clear (window);
+        }
+      else if (! gimp_display_get_image (new_display) &&
+               g_list_length (private->shells) <= 1)
+        {
+          /* As soon as we have no image (and no other shells that may
+           * contain images) we should become the empty image window
+           */
+          gimp_image_window_session_apply (window, private->entry_id);
+        }
     }
-  else if (! gimp_display_get_image (new_display) &&
-           g_list_length (private->shells) <= 1)
+  else if (strcmp (private->entry_id, GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID) == 0)
     {
-      /* As soon as we have no image (and no other shells that may
-       * contain images) we should become the empty image window
-       */
-      gimp_image_window_session_apply (window, "gimp-empty-image-window");
+      /* Always session manage the single image window */
+      gimp_image_window_session_apply (window, private->entry_id);
     }
+  else
+    {
+      g_assert_not_reached ();
+    }
+}
+
+static const gchar *
+gimp_image_window_config_to_entry_id (GimpGuiConfig *config)
+{
+  return (config->single_window_mode ?
+          GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID :
+          GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID);
+}
+
+static void
+gimp_image_window_set_entry_id (GimpImageWindow *window,
+                                const gchar     *entry_id)
+{
+  GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
+
+  g_return_if_fail (entry_id != NULL);
+
+  if ((private->entry_id && strcmp (private->entry_id, entry_id) == 0) ||
+      ! private->active_shell)
+    return;
+
+  gimp_image_window_session_clear (window);
+
+  private->entry_id = entry_id;
+
+  gimp_image_window_session_update (window, private->active_shell->display);
 }
 
 static void
diff --git a/etc/sessionrc b/etc/sessionrc
index e5bdd4a..aaf72bd 100644
--- a/etc/sessionrc
+++ b/etc/sessionrc
@@ -34,5 +34,13 @@
 	        (tab-style preview))
             (dockable "gimp-gradient-list"
 	        (tab-style preview)))))
+(session-info "toplevel"
+    (factory-entry "gimp-empty-image-window")
+    (position 410 370)
+    (size 620 200))
+(session-info "toplevel"
+    (factory-entry "gimp-single-image-window")
+    (position 160 70)
+    (size 1140 780))
 
 # end of sessionrc



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