gimp r25113 - in trunk: . app/actions app/core app/display app/gui



Author: mitch
Date: Tue Mar 18 21:22:21 2008
New Revision: 25113
URL: http://svn.gnome.org/viewvc/gimp?rev=25113&view=rev

Log:
2008-03-18  Michael Natterer  <mitch gimp org>

	First draft of the "no image open" window, which is implemented as
	a display without image (a view with NULL model). Didn't change
	the display's appearance yet so I can first make sure the display
	without image works properly in all details before hiding these
	details.

	* app/core/gimp-gui.[ch]: add "gimp" parameter to display_create()
	and allow "image" to be NULL.

	* app/core/gimpcontext.c (gimp_context_real_set_display): a
	display's image can be NULL now.

	* app/display/gimpdisplay.[ch]: add Gimp and GimpDisplayConfig
	members.  Add Gimp parameter to gimp_display_shell_new(). Changed
	gimp_display_reconnect() to gimp_display_set_image() and allow to
	set a NULL image.

	* app/gui/gui-vtable.c (gui_display_create): if there is a single
	display without an image, call gimp_display_set_image() on that
	display instead of creating a new one.

	* app/display/gimpdisplayshell-close.c: if the last display is
	closed, don't close it but make it empty. Factored out that code
	to gimp_display_shell_really_close().

	* app/display/gimpdisplayshell-dnd.c: when dropping uris on an
	empty display, open the first one into that display and the other
	ones as layers of the newly opened image. This is consistent with
	dropping on an existing image but maybe needs some discussion.

	* app/display/gimpdisplayshell-callbacks.c: bail out early in the
	tool event callback so tools never have to deal with empty
	displays. In expose(), draw the drop zone on the empty display.

	* app/display/gimpdisplayshell-title.c: set the empty display's
	title to "Gimp - Drop Files".

	* app/display/gimpdisplay-foreach.c
	* app/display/gimpdisplay-handlers.c
	* app/display/gimpdisplayshell-appearance.c
	* app/display/gimpdisplayshell-autoscroll.c
	* app/display/gimpdisplayshell-callbacks.c
	* app/display/gimpdisplayshell-cursor.c
	* app/display/gimpdisplayshell-dnd.c
	* app/display/gimpdisplayshell-draw.c
	* app/display/gimpdisplayshell-filter-dialog.c
	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell-layer-select.c
	* app/display/gimpdisplayshell-preview.c
	* app/display/gimpdisplayshell-render.c
	* app/display/gimpdisplayshell-scale.c
	* app/display/gimpdisplayshell-scroll.c
	* app/display/gimpdisplayshell-selection.c
	* app/display/gimpdisplayshell-title.c
	* app/display/gimpdisplayshell.c
	* app/display/gimpnavigationeditor.c
	* app/display/gimpstatusbar.c: use display->gimp and
	display->config instead of going via the image. Guard against
	empty displays in some few places (most places can't be
	called). Where needed, use the canvas' dimensions instead of the
	image's dimensions so scroll offsets and scrollbars still have
	sane values instead of the last image's ones.

	* app/actions/actions.c (action_data_get_gimp)
	(action_data_get_context): use display->gimp instead of
	display->image->gimp.

	* app/actions/edit-commands.c (edit_paste_cmd_callback): redirect
	to "paste as new" if there is an empty display.

	* app/actions/tools-commands.c (tools_select_cmd_callback): don't
	initialize the new tool on an empty display.

	* app/actions/view-actions.c (view_actions_update): changed lots
	of sensitivity settings to be insensitive when there is no image
	(instead of no display).

	* app/actions/view-commands.c: use the display's config object
	instead of gimp's.



Modified:
   trunk/ChangeLog
   trunk/app/actions/actions.c
   trunk/app/actions/edit-commands.c
   trunk/app/actions/tools-commands.c
   trunk/app/actions/view-actions.c
   trunk/app/actions/view-commands.c
   trunk/app/core/gimp-gui.c
   trunk/app/core/gimp-gui.h
   trunk/app/core/gimpcontext.c
   trunk/app/display/gimpdisplay-foreach.c
   trunk/app/display/gimpdisplay-handlers.c
   trunk/app/display/gimpdisplay.c
   trunk/app/display/gimpdisplay.h
   trunk/app/display/gimpdisplayshell-appearance.c
   trunk/app/display/gimpdisplayshell-autoscroll.c
   trunk/app/display/gimpdisplayshell-callbacks.c
   trunk/app/display/gimpdisplayshell-close.c
   trunk/app/display/gimpdisplayshell-cursor.c
   trunk/app/display/gimpdisplayshell-dnd.c
   trunk/app/display/gimpdisplayshell-draw.c
   trunk/app/display/gimpdisplayshell-filter-dialog.c
   trunk/app/display/gimpdisplayshell-handlers.c
   trunk/app/display/gimpdisplayshell-layer-select.c
   trunk/app/display/gimpdisplayshell-preview.c
   trunk/app/display/gimpdisplayshell-render.c
   trunk/app/display/gimpdisplayshell-scale.c
   trunk/app/display/gimpdisplayshell-scroll.c
   trunk/app/display/gimpdisplayshell-selection.c
   trunk/app/display/gimpdisplayshell-title.c
   trunk/app/display/gimpdisplayshell.c
   trunk/app/display/gimpnavigationeditor.c
   trunk/app/display/gimpstatusbar.c
   trunk/app/gui/gui-vtable.c

Modified: trunk/app/actions/actions.c
==============================================================================
--- trunk/app/actions/actions.c	(original)
+++ trunk/app/actions/actions.c	Tue Mar 18 21:22:21 2008
@@ -252,7 +252,7 @@
     return NULL;
 
   if (GIMP_IS_DISPLAY (data))
-    return ((GimpDisplay *) data)->image->gimp;
+    return ((GimpDisplay *) data)->gimp;
   else if (GIMP_IS_GIMP (data))
     return data;
   else if (GIMP_IS_DOCK (data))
@@ -279,7 +279,7 @@
     return NULL;
 
   if (GIMP_IS_DISPLAY (data))
-    return gimp_get_user_context (((GimpDisplay *) data)->image->gimp);
+    return gimp_get_user_context (((GimpDisplay *) data)->gimp);
   else if (GIMP_IS_GIMP (data))
     return gimp_get_user_context (data);
   else if (GIMP_IS_DOCK (data))

Modified: trunk/app/actions/edit-commands.c
==============================================================================
--- trunk/app/actions/edit-commands.c	(original)
+++ trunk/app/actions/edit-commands.c	Tue Mar 18 21:22:21 2008
@@ -268,7 +268,7 @@
 {
   GimpDisplay *display = action_data_get_display (data);
 
-  if (display)
+  if (display && display->image)
     edit_paste (display, FALSE);
   else
     edit_paste_as_new_cmd_callback (action, data);

Modified: trunk/app/actions/tools-commands.c
==============================================================================
--- trunk/app/actions/tools-commands.c	(original)
+++ trunk/app/actions/tools-commands.c	Tue Mar 18 21:22:21 2008
@@ -35,6 +35,8 @@
 #include "widgets/gimpenumaction.h"
 #include "widgets/gimpuimanager.h"
 
+#include "display/gimpdisplay.h"
+
 #include "tools/gimp-tools.h"
 #include "tools/gimpcoloroptions.h"
 #include "tools/gimpforegroundselectoptions.h"
@@ -97,7 +99,7 @@
 
   display = gimp_context_get_display (context);
 
-  if (display)
+  if (display && display->image)
     tool_manager_initialize_active (gimp, display);
 }
 

Modified: trunk/app/actions/view-actions.c
==============================================================================
--- trunk/app/actions/view-actions.c	(original)
+++ trunk/app/actions/view-actions.c	Tue Mar 18 21:22:21 2008
@@ -531,6 +531,7 @@
                      gpointer         data)
 {
   GimpDisplay        *display        = action_data_get_display (data);
+  GimpImage          *image          = NULL;
   GimpDisplayShell   *shell          = NULL;
   GimpDisplayOptions *options        = NULL;
   gchar              *label          = NULL;
@@ -539,6 +540,7 @@
 
   if (display)
     {
+      image = display->image;
       shell = GIMP_DISPLAY_SHELL (display->shell);
 
       fullscreen = gimp_display_shell_get_fullscreen (shell);
@@ -555,10 +557,10 @@
 #define SET_COLOR(action,color) \
         gimp_action_group_set_action_color (group, action, color, FALSE)
 
-  SET_SENSITIVE ("view-new",   display);
+  SET_SENSITIVE ("view-new",   image);
   SET_SENSITIVE ("view-close", display);
 
-  SET_SENSITIVE ("view-dot-for-dot", display);
+  SET_SENSITIVE ("view-dot-for-dot", image);
   SET_ACTIVE    ("view-dot-for-dot", display && shell->dot_for_dot);
 
   SET_SENSITIVE ("view-zoom-revert", revert_enabled);
@@ -575,46 +577,46 @@
                                           _("Re_vert Zoom"));
     }
 
-  SET_SENSITIVE ("view-zoom-out",    display);
-  SET_SENSITIVE ("view-zoom-in",     display);
-  SET_SENSITIVE ("view-zoom-fit-in", display);
-  SET_SENSITIVE ("view-zoom-fill", display);
-
-  SET_SENSITIVE ("view-zoom-16-1",  display);
-  SET_SENSITIVE ("view-zoom-8-1",   display);
-  SET_SENSITIVE ("view-zoom-4-1",   display);
-  SET_SENSITIVE ("view-zoom-2-1",   display);
-  SET_SENSITIVE ("view-zoom-1-1",   display);
-  SET_SENSITIVE ("view-zoom-1-2",   display);
-  SET_SENSITIVE ("view-zoom-1-4",   display);
-  SET_SENSITIVE ("view-zoom-1-8",   display);
-  SET_SENSITIVE ("view-zoom-1-16",  display);
-  SET_SENSITIVE ("view-zoom-other", display);
+  SET_SENSITIVE ("view-zoom-out",    image);
+  SET_SENSITIVE ("view-zoom-in",     image);
+  SET_SENSITIVE ("view-zoom-fit-in", image);
+  SET_SENSITIVE ("view-zoom-fill",   image);
+
+  SET_SENSITIVE ("view-zoom-16-1",  image);
+  SET_SENSITIVE ("view-zoom-8-1",   image);
+  SET_SENSITIVE ("view-zoom-4-1",   image);
+  SET_SENSITIVE ("view-zoom-2-1",   image);
+  SET_SENSITIVE ("view-zoom-1-1",   image);
+  SET_SENSITIVE ("view-zoom-1-2",   image);
+  SET_SENSITIVE ("view-zoom-1-4",   image);
+  SET_SENSITIVE ("view-zoom-1-8",   image);
+  SET_SENSITIVE ("view-zoom-1-16",  image);
+  SET_SENSITIVE ("view-zoom-other", image);
 
-  if (display)
+  if (image)
     view_actions_set_zoom (group, shell);
 
-  SET_SENSITIVE ("view-navigation-window", display);
-  SET_SENSITIVE ("view-display-filters",   display);
+  SET_SENSITIVE ("view-navigation-window", image);
+  SET_SENSITIVE ("view-display-filters",   image);
 
-  SET_SENSITIVE ("view-show-selection",      display);
+  SET_SENSITIVE ("view-show-selection",      image);
   SET_ACTIVE    ("view-show-selection",      display && options->show_selection);
-  SET_SENSITIVE ("view-show-layer-boundary", display);
+  SET_SENSITIVE ("view-show-layer-boundary", image);
   SET_ACTIVE    ("view-show-layer-boundary", display && options->show_layer_boundary);
-  SET_SENSITIVE ("view-show-guides",         display);
+  SET_SENSITIVE ("view-show-guides",         image);
   SET_ACTIVE    ("view-show-guides",         display && options->show_guides);
-  SET_SENSITIVE ("view-show-grid",           display);
+  SET_SENSITIVE ("view-show-grid",           image);
   SET_ACTIVE    ("view-show-grid",           display && options->show_grid);
-  SET_SENSITIVE ("view-show-sample-points",  display);
+  SET_SENSITIVE ("view-show-sample-points",  image);
   SET_ACTIVE    ("view-show-sample-points",  display && options->show_sample_points);
 
-  SET_SENSITIVE ("view-snap-to-guides",      display);
+  SET_SENSITIVE ("view-snap-to-guides",      image);
   SET_ACTIVE    ("view-snap-to-guides",      display && shell->snap_to_guides);
-  SET_SENSITIVE ("view-snap-to-grid",        display);
+  SET_SENSITIVE ("view-snap-to-grid",        image);
   SET_ACTIVE    ("view-snap-to-grid",        display && shell->snap_to_grid);
-  SET_SENSITIVE ("view-snap-to-canvas",      display);
+  SET_SENSITIVE ("view-snap-to-canvas",      image);
   SET_ACTIVE    ("view-snap-to-canvas",      display && shell->snap_to_canvas);
-  SET_SENSITIVE ("view-snap-to-vectors",     display);
+  SET_SENSITIVE ("view-snap-to-vectors",     image);
   SET_ACTIVE    ("view-snap-to-vectors",     display && shell->snap_to_vectors);
 
   SET_SENSITIVE ("view-padding-color-theme",       display);
@@ -649,8 +651,8 @@
   SET_SENSITIVE ("view-show-statusbar",  display);
   SET_ACTIVE    ("view-show-statusbar",  display && options->show_statusbar);
 
-  SET_SENSITIVE ("view-shrink-wrap", display);
-  SET_SENSITIVE ("view-fullscreen",  display);
+  SET_SENSITIVE ("view-shrink-wrap", image);
+  SET_SENSITIVE ("view-fullscreen",  image);
   SET_ACTIVE    ("view-fullscreen",  display && fullscreen);
 
   if (GIMP_IS_DISPLAY (group->user_data) ||

Modified: trunk/app/actions/view-commands.c
==============================================================================
--- trunk/app/actions/view-commands.c	(original)
+++ trunk/app/actions/view-commands.c	Tue Mar 18 21:22:21 2008
@@ -608,17 +608,14 @@
       g_object_set_data (G_OBJECT (shell), "padding-color-dialog", NULL);
 
       {
-        GimpDisplayConfig  *config;
         GimpDisplayOptions *default_options;
 
-        config = GIMP_DISPLAY_CONFIG (display->image->gimp->config);
-
         options->padding_mode_set = FALSE;
 
         if (fullscreen)
-          default_options = config->default_fullscreen_view;
+          default_options = display->config->default_fullscreen_view;
         else
-          default_options = config->default_view;
+          default_options = display->config->default_view;
 
         gimp_display_shell_set_padding (shell,
                                         default_options->padding_mode,

Modified: trunk/app/core/gimp-gui.c
==============================================================================
--- trunk/app/core/gimp-gui.c	(original)
+++ trunk/app/core/gimp-gui.c	Tue Mar 18 21:22:21 2008
@@ -281,10 +281,10 @@
                      gdouble    scale)
 {
   g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+  g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
 
   if (gimp->gui.display_create)
-    return gimp->gui.display_create (image, unit, scale);
+    return gimp->gui.display_create (gimp, image, unit, scale);
 
   return NULL;
 }

Modified: trunk/app/core/gimp-gui.h
==============================================================================
--- trunk/app/core/gimp-gui.h	(original)
+++ trunk/app/core/gimp-gui.h	Tue Mar 18 21:22:21 2008
@@ -51,7 +51,8 @@
                                           gint                 ID);
   gint           (* display_get_id)      (GimpObject          *display);
   guint32        (* display_get_window)  (GimpObject          *display);
-  GimpObject   * (* display_create)      (GimpImage           *image,
+  GimpObject   * (* display_create)      (Gimp                *gimp,
+                                          GimpImage           *image,
                                           GimpUnit             unit,
                                           gdouble              scale);
   void           (* display_delete)      (GimpObject          *display);

Modified: trunk/app/core/gimpcontext.c
==============================================================================
--- trunk/app/core/gimpcontext.c	(original)
+++ trunk/app/core/gimpcontext.c	Tue Mar 18 21:22:21 2008
@@ -1777,9 +1777,12 @@
 
       g_object_get (display, "image", &image, NULL);
 
-      gimp_context_real_set_image (context, image);
+      if (image)
+        {
+          gimp_context_real_set_image (context, image);
 
-      g_object_unref (image);
+          g_object_unref (image);
+        }
     }
 
   g_object_notify (G_OBJECT (context), "display");

Modified: trunk/app/display/gimpdisplay-foreach.c
==============================================================================
--- trunk/app/display/gimpdisplay-foreach.c	(original)
+++ trunk/app/display/gimpdisplay-foreach.c	Tue Mar 18 21:22:21 2008
@@ -46,7 +46,7 @@
     {
       GimpDisplay *display = list->data;
 
-      if (display->image->dirty)
+      if (display->image && display->image->dirty)
         return TRUE;
     }
 
@@ -183,7 +183,7 @@
       GimpDisplay *display = list->data;
 
       if (display->image == old)
-        gimp_display_reconnect (display, new);
+        gimp_display_set_image (display, new);
     }
 
   /*  set the new_image on the remembered contexts (in reverse

Modified: trunk/app/display/gimpdisplay-handlers.c
==============================================================================
--- trunk/app/display/gimpdisplay-handlers.c	(original)
+++ trunk/app/display/gimpdisplay-handlers.c	Tue Mar 18 21:22:21 2008
@@ -151,7 +151,7 @@
 {
   gchar *filename = file_utils_uri_display_name (uri);
 
-  gimp_message (image->gimp, G_OBJECT (display), GIMP_MESSAGE_INFO,
+  gimp_message (display->gimp, G_OBJECT (display), GIMP_MESSAGE_INFO,
                 _("Image saved to '%s'"), filename);
 
   g_free (filename);

Modified: trunk/app/display/gimpdisplay.c
==============================================================================
--- trunk/app/display/gimpdisplay.c	(original)
+++ trunk/app/display/gimpdisplay.c	Tue Mar 18 21:22:21 2008
@@ -25,6 +25,8 @@
 #include "display-types.h"
 #include "tools/tools-types.h"
 
+#include "config/gimpdisplayconfig.h"
+
 #include "core/gimp.h"
 #include "core/gimparea.h"
 #include "core/gimpimage.h"
@@ -47,6 +49,7 @@
 {
   PROP_0,
   PROP_ID,
+  PROP_GIMP,
   PROP_IMAGE,
   PROP_SHELL
 };
@@ -117,6 +120,13 @@
                                                      GIMP_PARAM_READWRITE |
                                                      G_PARAM_CONSTRUCT_ONLY));
 
+  g_object_class_install_property (object_class, PROP_GIMP,
+                                   g_param_spec_object ("gimp",
+                                                        NULL, NULL,
+                                                        GIMP_TYPE_GIMP,
+                                                        GIMP_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+
   g_object_class_install_property (object_class, PROP_IMAGE,
                                    g_param_spec_object ("image",
                                                         NULL, NULL,
@@ -135,6 +145,8 @@
 {
   display->ID           = 0;
 
+  display->gimp         = NULL;
+
   display->image        = NULL;
   display->instance     = 0;
 
@@ -170,10 +182,17 @@
     case PROP_ID:
       display->ID = g_value_get_int (value);
       break;
+
+    case PROP_GIMP:
+      display->gimp = g_value_get_object (value); /* don't ref the gimp */
+      display->config = GIMP_DISPLAY_CONFIG (display->gimp->config);
+      break;
+
     case PROP_IMAGE:
     case PROP_SHELL:
       g_assert_not_reached ();
       break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -193,12 +212,19 @@
     case PROP_ID:
       g_value_set_int (value, display->ID);
       break;
+
+    case PROP_GIMP:
+      g_value_set_object (value, display->gimp);
+      break;
+
     case PROP_IMAGE:
       g_value_set_object (value, display->image);
       break;
+
     case PROP_SHELL:
       g_value_set_object (value, display->shell);
       break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
       break;
@@ -317,7 +343,8 @@
 /*  public functions  */
 
 GimpDisplay *
-gimp_display_new (GimpImage       *image,
+gimp_display_new (Gimp            *gimp,
+                  GimpImage       *image,
                   GimpUnit         unit,
                   gdouble          scale,
                   GimpMenuFactory *menu_factory,
@@ -326,27 +353,30 @@
   GimpDisplay *display;
   gint         ID;
 
-  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
+  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
+  g_return_val_if_fail (image == NULL || GIMP_IS_IMAGE (image), NULL);
 
   /*  If there isn't an interface, never create a display  */
-  if (image->gimp->no_interface)
+  if (gimp->no_interface)
     return NULL;
 
   do
     {
-      ID = image->gimp->next_display_ID++;
+      ID = gimp->next_display_ID++;
 
-      if (image->gimp->next_display_ID == G_MAXINT)
-        image->gimp->next_display_ID = 1;
+      if (gimp->next_display_ID == G_MAXINT)
+        gimp->next_display_ID = 1;
     }
-  while (gimp_display_get_by_ID (image->gimp, ID));
+  while (gimp_display_get_by_ID (gimp, ID));
 
   display = g_object_new (GIMP_TYPE_DISPLAY,
-                          "id", ID,
+                          "id",   ID,
+                          "gimp", gimp,
                           NULL);
 
   /*  refs the image  */
-  gimp_display_connect (display, image);
+  if (image)
+    gimp_display_connect (display, image);
 
   /*  create the shell for the image  */
   display->shell = gimp_display_shell_new (display, unit, scale,
@@ -358,7 +388,7 @@
                     display);
 
   /* add the display to the list */
-  gimp_container_add (image->gimp->displays, GIMP_OBJECT (display));
+  gimp_container_add (gimp->displays, GIMP_OBJECT (display));
 
   return display;
 }
@@ -371,17 +401,16 @@
   g_return_if_fail (GIMP_IS_DISPLAY (display));
 
   /* remove the display from the list */
-  gimp_container_remove (display->image->gimp->displays,
+  gimp_container_remove (display->gimp->displays,
                          GIMP_OBJECT (display));
 
-  /*  stop any active tool  */
-  tool_manager_control_active (display->image->gimp, GIMP_TOOL_ACTION_HALT,
-                               display);
+  /*  unrefs the image  */
+  gimp_display_set_image (display, NULL);
 
-  active_tool = tool_manager_get_active (display->image->gimp);
+  active_tool = tool_manager_get_active (display->gimp);
 
   if (active_tool && active_tool->focus_display == display)
-    tool_manager_focus_display_active (display->image->gimp, NULL);
+    tool_manager_focus_display_active (display->gimp, NULL);
 
   /*  free the update area lists  */
   gimp_area_list_free (display->update_areas);
@@ -399,9 +428,6 @@
       gtk_widget_destroy (shell);
     }
 
-  /*  unrefs the image  */
-  gimp_display_disconnect (display);
-
   g_object_unref (display);
 }
 
@@ -435,28 +461,35 @@
 }
 
 void
-gimp_display_reconnect (GimpDisplay *display,
+gimp_display_set_image (GimpDisplay *display,
                         GimpImage   *image)
 {
-  GimpImage *old_image;
+  GimpImage *old_image = NULL;
 
   g_return_if_fail (GIMP_IS_DISPLAY (display));
-  g_return_if_fail (GIMP_IS_IMAGE (image));
+  g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
 
-  /*  stop any active tool  */
-  tool_manager_control_active (display->image->gimp, GIMP_TOOL_ACTION_HALT,
-                               display);
+  if (display->image)
+    {
+      /*  stop any active tool  */
+      tool_manager_control_active (display->gimp, GIMP_TOOL_ACTION_HALT,
+                                   display);
 
-  gimp_display_shell_disconnect (GIMP_DISPLAY_SHELL (display->shell));
+      gimp_display_shell_disconnect (GIMP_DISPLAY_SHELL (display->shell));
 
-  old_image = g_object_ref (display->image);
+      old_image = g_object_ref (display->image);
+
+      gimp_display_disconnect (display);
+    }
 
-  gimp_display_disconnect (display);
-  gimp_display_connect (display, image);
+  if (image)
+    gimp_display_connect (display, image);
 
-  g_object_unref (old_image);
+  if (old_image)
+    g_object_unref (old_image);
 
-  gimp_display_shell_reconnect (GIMP_DISPLAY_SHELL (display->shell));
+  if (image)
+    gimp_display_shell_reconnect (GIMP_DISPLAY_SHELL (display->shell));
 }
 
 void

Modified: trunk/app/display/gimpdisplay.h
==============================================================================
--- trunk/app/display/gimpdisplay.h	(original)
+++ trunk/app/display/gimpdisplay.h	Tue Mar 18 21:22:21 2008
@@ -37,15 +37,18 @@
 {
   GimpObject  parent_instance;
 
-  gint        ID;               /*  unique identifier for this display     */
+  gint               ID;           /*  unique identifier for this display  */
 
-  GimpImage  *image;            /*  pointer to the associated image        */
-  gint        instance;         /*  the instance # of this display as      */
-                                /*  taken from the image at creation       */
+  Gimp              *gimp;         /*  global gimp instance                */
+  GimpDisplayConfig *config;
 
-  GtkWidget  *shell;            /*  shell widget for this display          */
+  GimpImage         *image;        /*  pointer to the associated image     */
+  gint               instance;     /*  the instance # of this display as   */
+                                   /*  taken from the image at creation    */
 
-  GSList     *update_areas;     /*  Update areas list                      */
+  GtkWidget         *shell;        /*  shell widget for this display       */
+
+  GSList            *update_areas; /*  Update areas list                   */
 };
 
 struct _GimpDisplayClass
@@ -56,7 +59,8 @@
 
 GType         gimp_display_get_type    (void) G_GNUC_CONST;
 
-GimpDisplay * gimp_display_new         (GimpImage       *image,
+GimpDisplay * gimp_display_new         (Gimp            *gimp,
+                                        GimpImage       *image,
                                         GimpUnit         unit,
                                         gdouble          scale,
                                         GimpMenuFactory *menu_factory,
@@ -67,7 +71,7 @@
 GimpDisplay * gimp_display_get_by_ID   (Gimp            *gimp,
                                         gint             ID);
 
-void          gimp_display_reconnect   (GimpDisplay     *display,
+void          gimp_display_set_image   (GimpDisplay     *display,
                                         GimpImage       *image);
 
 void          gimp_display_update_area (GimpDisplay     *display,

Modified: trunk/app/display/gimpdisplayshell-appearance.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-appearance.c	(original)
+++ trunk/app/display/gimpdisplayshell-appearance.c	Tue Mar 18 21:22:21 2008
@@ -41,7 +41,6 @@
 #include "gimpdisplayoptions.h"
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-appearance.h"
-#include "gimpdisplayshell-callbacks.h"
 #include "gimpdisplayshell-selection.h"
 #include "gimpstatusbar.h"
 
@@ -63,7 +62,7 @@
 #define IS_ACTIVE_DISPLAY(shell) \
   ((shell)->display == \
    gimp_context_get_display (gimp_get_user_context \
-                             ((shell)->display->image->gimp)))
+                             ((shell)->display->gimp)))
 
 
 void

Modified: trunk/app/display/gimpdisplayshell-autoscroll.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-autoscroll.c	(original)
+++ trunk/app/display/gimpdisplayshell-autoscroll.c	Tue Mar 18 21:22:21 2008
@@ -22,8 +22,6 @@
 
 #include "display-types.h"
 
-#include "core/gimpimage.h"
-
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-autoscroll.h"
@@ -133,7 +131,7 @@
   if (dx || dy)
     {
       GimpDisplay *display     = shell->display;
-      GimpTool    *active_tool = tool_manager_get_active (display->image->gimp);
+      GimpTool    *active_tool = tool_manager_get_active (display->gimp);
 
       info->time += AUTOSCROLL_DT;
 
@@ -157,7 +155,7 @@
                                           x, y, width, height);
         }
 
-      tool_manager_motion_active (display->image->gimp,
+      tool_manager_motion_active (display->gimp,
                                   &image_coords,
                                   info->time, info->state,
                                   display);

Modified: trunk/app/display/gimpdisplayshell-callbacks.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-callbacks.c	(original)
+++ trunk/app/display/gimpdisplayshell-callbacks.c	Tue Mar 18 21:22:21 2008
@@ -111,7 +111,7 @@
   if (! shell->display || ! shell->display->shell)
     return TRUE;
 
-  gimp = shell->display->image->gimp;
+  gimp = shell->display->gimp;
 
   switch (event->type)
     {
@@ -202,7 +202,7 @@
       {
         GdkEventFocus *fevent = (GdkEventFocus *) event;
 
-        if (fevent->in && GIMP_DISPLAY_CONFIG (gimp->config)->activate_on_focus)
+        if (fevent->in && shell->display->config->activate_on_focus)
           set_display = TRUE;
       }
       break;
@@ -268,13 +268,9 @@
       break;
     }
 
+  /*  Setting the context's display automatically sets the image, too  */
   if (set_display)
-    {
-      Gimp *gimp = shell->display->image->gimp;
-
-      /*  Setting the context's display automatically sets the image, too  */
-      gimp_context_set_display (gimp_get_user_context (gimp), shell->display);
-    }
+    gimp_context_set_display (gimp_get_user_context (gimp), shell->display);
 
   return FALSE;
 }
@@ -283,13 +279,8 @@
 gimp_display_shell_canvas_realize (GtkWidget        *canvas,
                                    GimpDisplayShell *shell)
 {
-  GimpDisplayConfig     *config;
-  GimpDisplay           *display;
-  GimpCanvasPaddingMode  padding_mode;
-  GimpRGB                padding_color;
-
-  display = shell->display;
-  config  = GIMP_DISPLAY_CONFIG (display->image->gimp->config);
+  GimpCanvasPaddingMode padding_mode;
+  GimpRGB               padding_color;
 
   gtk_widget_grab_focus (shell->canvas);
 
@@ -383,6 +374,21 @@
   if (! shell->display || ! shell->display->shell)
     return TRUE;
 
+  if (! shell->display->image)
+    {
+      cairo_t *cr;
+
+      cr = gdk_cairo_create (widget->window);
+      gdk_cairo_region (cr, eevent->region);
+      cairo_clip (cr);
+
+      gimp_canvas_draw_drop_zone (GIMP_CANVAS (shell->canvas), cr);
+
+      cairo_destroy (cr);
+
+      return TRUE;
+    }
+
   /*  If the call to gimp_display_shell_pause() would cause a redraw,
    *  we need to make sure that no XOR drawing happens on areas that
    *  have already been cleared by the windowing system.
@@ -456,7 +462,7 @@
 {
   GdkDevice *current_device;
 
-  current_device = gimp_devices_get_current (shell->display->image->gimp);
+  current_device = gimp_devices_get_current (shell->display->gimp);
 
   shell->draw_cursor = ! current_device->has_cursor;
 }
@@ -496,12 +502,12 @@
                                   GdkModifierType   state,
                                   guint32           time)
 {
-  Gimp *gimp = shell->display->image->gimp;
+  Gimp *gimp = shell->display->gimp;
 
   if (shell->space_pressed)
     return;
 
-  switch (GIMP_DISPLAY_CONFIG (gimp->config)->space_bar_action)
+  switch (shell->display->config->space_bar_action)
     {
     case GIMP_SPACE_BAR_ACTION_NONE:
       return;
@@ -552,12 +558,12 @@
                                    GdkModifierType   state,
                                    guint32           time)
 {
-  Gimp *gimp = shell->display->image->gimp;
+  Gimp *gimp = shell->display->gimp;
 
   if (! shell->space_pressed && ! shell->space_release_pending)
     return;
 
-  switch (GIMP_DISPLAY_CONFIG (gimp->config)->space_bar_action)
+  switch (shell->display->config->space_bar_action)
     {
     case GIMP_SPACE_BAR_ACTION_NONE:
       break;
@@ -589,7 +595,7 @@
                                  GimpCoords       *image_coords,
                                  GdkModifierType   state)
 {
-  Gimp *gimp = shell->display->image->gimp;
+  Gimp *gimp = shell->display->gimp;
 
   tool_manager_focus_display_active (gimp, shell->display);
   tool_manager_modifier_state_active (gimp, state, shell->display);
@@ -630,8 +636,11 @@
     return TRUE;
 
   display = shell->display;
+  gimp    = display->gimp;
   image   = display->image;
-  gimp    = image->gimp;
+
+  if (! image)
+    return TRUE;
 
   gdk_display = gtk_widget_get_display (canvas);
 
@@ -855,7 +864,7 @@
             event_mask = (GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK);
 
             if (active_tool &&
-                (! GIMP_DISPLAY_CONFIG (gimp->config)->perfect_mouse ||
+                (! shell->display->config->perfect_mouse ||
                  (gimp_tool_control_get_motion_mode (active_tool->control) !=
                   GIMP_MOTION_MODE_EXACT)))
               {
@@ -1511,7 +1520,7 @@
 
   /*  cursor update support  */
 
-  if (GIMP_DISPLAY_CONFIG (gimp->config)->cursor_updating)
+  if (shell->display->config->cursor_updating)
     {
       active_tool = tool_manager_get_active (gimp);
 
@@ -1563,7 +1572,10 @@
 {
   GimpDisplay *display = shell->display;
 
-  if (display->image->gimp->busy)
+  if (display->gimp->busy)
+    return TRUE;
+
+  if (! display->image)
     return TRUE;
 
   if (event->type == GDK_BUTTON_PRESS && event->button == 1)
@@ -1571,7 +1583,7 @@
       GimpTool *active_tool;
       gboolean  sample_point;
 
-      active_tool  = tool_manager_get_active (display->image->gimp);
+      active_tool  = tool_manager_get_active (display->gimp);
       sample_point = (event->state & GDK_CONTROL_MASK);
 
       if (! ((sample_point && (GIMP_IS_COLOR_TOOL (active_tool) &&
@@ -1585,17 +1597,17 @@
         {
           GimpToolInfo *tool_info;
 
-          tool_info = gimp_get_tool_info (display->image->gimp,
+          tool_info = gimp_get_tool_info (display->gimp,
                                           sample_point ?
                                           "gimp-color-picker-tool" :
                                           "gimp-move-tool");
 
           if (tool_info)
-            gimp_context_set_tool (gimp_get_user_context (display->image->gimp),
+            gimp_context_set_tool (gimp_get_user_context (display->gimp),
                                    tool_info);
         }
 
-      active_tool = tool_manager_get_active (display->image->gimp);
+      active_tool = tool_manager_get_active (display->gimp);
 
       if (active_tool)
         {
@@ -1653,7 +1665,7 @@
                                         GdkEventButton   *event,
                                         GimpDisplayShell *shell)
 {
-  if (! shell->display->image->gimp->busy)
+  if (! shell->display->gimp->busy)
     {
       if (event->button == 1)
         {
@@ -1674,6 +1686,9 @@
                                             GdkEventButton   *bevent,
                                             GimpDisplayShell *shell)
 {
+  if (! shell->display->image)
+    return TRUE;
+
   if ((bevent->type == GDK_BUTTON_PRESS) && (bevent->button == 3))
     {
       gimp_ui_manager_ui_popup (shell->menubar_manager, "/quick-mask-popup",
@@ -1705,6 +1720,9 @@
                                      GdkEventButton   *bevent,
                                      GimpDisplayShell *shell)
 {
+  if (! shell->display->image)
+    return TRUE;
+
   if ((bevent->type == GDK_BUTTON_PRESS) && (bevent->button == 1))
     {
       gimp_navigation_editor_popup (shell, widget, bevent->x, bevent->y);

Modified: trunk/app/display/gimpdisplayshell-close.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-close.c	(original)
+++ trunk/app/display/gimpdisplayshell-close.c	Tue Mar 18 21:22:21 2008
@@ -29,6 +29,8 @@
 #include "config/gimpdisplayconfig.h"
 
 #include "core/gimp.h"
+#include "core/gimpcontainer.h"
+#include "core/gimpcontext.h"
 #include "core/gimpimage.h"
 
 #include "file/file-utils.h"
@@ -41,6 +43,10 @@
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-close.h"
+#include "gimpdisplayshell-cursor.h"
+#include "gimpdisplayshell-scale.h"
+#include "gimpdisplayshell-scroll.h"
+#include "gimpdisplayshell-selection.h"
 
 #include "gimp-intl.h"
 
@@ -55,6 +61,7 @@
 static void      gimp_display_shell_close_response     (GtkWidget        *widget,
                                                         gboolean          close,
                                                         GimpDisplayShell *shell);
+static void      gimp_display_shell_really_close       (GimpDisplayShell *shell);
 
 static void      gimp_time_since                       (guint  then,
                                                         gint  *hours,
@@ -76,7 +83,7 @@
   /*  FIXME: gimp_busy HACK not really appropriate here because we only
    *  want to prevent the busy image and display to be closed.  --Mitch
    */
-  if (image->gimp->busy)
+  if (shell->display->gimp->busy)
     return;
 
   /*  If the image has been modified, give the user a chance to save
@@ -84,15 +91,16 @@
    *  to an image canvas.  (a image with disp_count = 1)
    */
   if (! kill_it              &&
+      image                  &&
       image->disp_count == 1 &&
       image->dirty           &&
-      GIMP_DISPLAY_CONFIG (image->gimp->config)->confirm_on_close)
+      shell->display->config->confirm_on_close)
     {
       gimp_display_shell_close_dialog (shell, image);
     }
-  else
+  else if (image)
     {
-      gimp_display_delete (shell->display);
+      gimp_display_shell_really_close (shell);
     }
 }
 
@@ -277,7 +285,7 @@
   switch (response_id)
     {
     case GTK_RESPONSE_CLOSE:
-      gimp_display_delete (shell->display);
+      gimp_display_shell_really_close (shell);
       break;
 
     case RESPONSE_SAVE:
@@ -291,6 +299,41 @@
 }
 
 static void
+gimp_display_shell_really_close (GimpDisplayShell *shell)
+{
+  if (gimp_container_num_children (shell->display->gimp->displays) > 1)
+    {
+      gimp_display_delete (shell->display);
+    }
+  else
+    {
+      GimpContext *user_context;
+
+      gimp_display_shell_selection_control (shell, GIMP_SELECTION_OFF);
+
+      gimp_display_set_image (shell->display, NULL);
+
+      gimp_display_shell_expose_full (shell);
+
+      gimp_display_shell_scale (shell, GIMP_ZOOM_TO, 1.0);
+      gimp_display_shell_scroll_clamp_offsets (shell);
+      gimp_display_shell_scale_setup (shell);
+      gimp_display_shell_scaled (shell);
+
+      gimp_display_shell_set_cursor (shell, GIMP_CURSOR_MOUSE,
+                                     GIMP_TOOL_CURSOR_NONE,
+                                     GIMP_CURSOR_MODIFIER_NONE);
+
+      gimp_ui_manager_update (shell->menubar_manager, shell->display);
+
+      user_context = gimp_get_user_context (shell->display->gimp);
+
+      if (shell->display == gimp_context_get_display (user_context))
+        gimp_ui_manager_update (shell->popup_manager, shell->display);
+    }
+}
+
+static void
 gimp_time_since (guint  then,
                  gint  *hours,
                  gint  *minutes)

Modified: trunk/app/display/gimpdisplayshell-cursor.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-cursor.c	(original)
+++ trunk/app/display/gimpdisplayshell-cursor.c	Tue Mar 18 21:22:21 2008
@@ -46,6 +46,8 @@
                                                  gboolean            always_install);
 
 
+/*  public functions  */
+
 void
 gimp_display_shell_set_cursor (GimpDisplayShell   *shell,
                                GimpCursorType      cursor_type,
@@ -197,6 +199,9 @@
     }
 }
 
+
+/*  private functions  */
+
 static void
 gimp_display_shell_real_set_cursor (GimpDisplayShell   *shell,
                                     GimpCursorType      cursor_type,
@@ -204,17 +209,14 @@
                                     GimpCursorModifier  modifier,
                                     gboolean            always_install)
 {
-  GimpDisplayConfig *config;
-  GimpCursorFormat   cursor_format;
+  GimpCursorFormat cursor_format;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
-
   if (cursor_type != GIMP_CURSOR_NONE &&
       cursor_type != GIMP_CURSOR_BAD)
     {
-      switch (config->cursor_mode)
+      switch (shell->display->config->cursor_mode)
         {
         case GIMP_CURSOR_MODE_TOOL_ICON:
           break;
@@ -243,7 +245,7 @@
         }
     }
 
-  cursor_format = GIMP_GUI_CONFIG (config)->cursor_format;
+  cursor_format = GIMP_GUI_CONFIG (shell->display->config)->cursor_format;
 
   if (shell->cursor_format   != cursor_format ||
       shell->current_cursor  != cursor_type   ||

Modified: trunk/app/display/gimpdisplayshell-dnd.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-dnd.c	(original)
+++ trunk/app/display/gimpdisplayshell-dnd.c	Tue Mar 18 21:22:21 2008
@@ -169,7 +169,7 @@
 
   gimp_image_flush (image);
 
-  gimp_context_set_display (gimp_get_user_context (image->gimp),
+  gimp_context_set_display (gimp_get_user_context (shell->display->gimp),
                             shell->display);
 }
 
@@ -187,7 +187,10 @@
 
   GIMP_LOG (DND, NULL);
 
-  if (image->gimp->busy)
+  if (shell->display->gimp->busy)
+    return;
+
+  if (! image)
     return;
 
   if (GIMP_IS_LAYER (viewable))
@@ -240,7 +243,10 @@
 
   GIMP_LOG (DND, NULL);
 
-  if (image->gimp->busy)
+  if (shell->display->gimp->busy)
+    return;
+
+  if (! image)
     return;
 
   new_item = gimp_item_convert (GIMP_ITEM (viewable),
@@ -275,14 +281,18 @@
 
   GIMP_LOG (DND, NULL);
 
-  if (image->gimp->busy)
+  if (shell->display->gimp->busy)
+    return;
+
+  if (! image)
     return;
 
   if (! gimp_vectors_import_buffer (image,
                                     (const gchar *) svg_data, svg_data_len,
                                     TRUE, TRUE, -1, NULL, &error))
     {
-      gimp_message (image->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR,
+      gimp_message (shell->display->gimp, G_OBJECT (shell->display),
+                    GIMP_MESSAGE_ERROR,
                     "%s", error->message);
       g_clear_error (&error);
     }
@@ -301,7 +311,10 @@
   GimpImage    *image = shell->display->image;
   GimpDrawable *drawable;
 
-  if (image->gimp->busy)
+  if (shell->display->gimp->busy)
+    return;
+
+  if (! image)
     return;
 
   drawable = gimp_image_get_active_drawable (image);
@@ -377,7 +390,10 @@
 
   GIMP_LOG (DND, NULL);
 
-  if (image->gimp->busy)
+  if (shell->display->gimp->busy)
+    return;
+
+  if (! image)
     return;
 
   buffer = GIMP_BUFFER (viewable);
@@ -402,7 +418,7 @@
 {
   GimpDisplayShell *shell   = GIMP_DISPLAY_SHELL (data);
   GimpImage        *image   = shell->display->image;
-  GimpContext      *context = gimp_get_user_context (image->gimp);
+  GimpContext      *context = gimp_get_user_context (shell->display->gimp);
   GList            *list;
 
   GIMP_LOG (DND, NULL);
@@ -410,35 +426,55 @@
   for (list = uri_list; list; list = g_list_next (list))
     {
       const gchar       *uri   = list->data;
-      GList             *new_layers;
       GimpPDBStatusType  status;
       GError            *error = NULL;
+      gboolean           warn  = FALSE;
 
-      new_layers = file_open_layers (image->gimp, context,
-                                     GIMP_PROGRESS (shell->display),
-                                     image, FALSE,
-                                     uri, GIMP_RUN_INTERACTIVE, NULL,
-                                     &status, &error);
+      if (! shell->display->image)
+        {
+          image = file_open_with_display (shell->display->gimp, context,
+                                          GIMP_PROGRESS (shell->display),
+                                          uri, FALSE,
+                                          &status, &error);
 
-      if (new_layers)
+          if (! image && status != GIMP_PDB_CANCEL)
+            warn = TRUE;
+        }
+      else
         {
-          gint x, y;
-          gint width, height;
+          GList *new_layers;
 
-          gimp_display_shell_untransform_viewport (shell, &x, &y,
-                                                   &width, &height);
+          new_layers = file_open_layers (shell->display->gimp, context,
+                                         GIMP_PROGRESS (shell->display),
+                                         image, FALSE,
+                                         uri, GIMP_RUN_INTERACTIVE, NULL,
+                                         &status, &error);
+
+          if (new_layers)
+            {
+              gint x, y;
+              gint width, height;
+
+              gimp_display_shell_untransform_viewport (shell, &x, &y,
+                                                       &width, &height);
+
+              gimp_image_add_layers (image, new_layers, -1,
+                                     x, y, width, height,
+                                     _("Drop layers"));
+
+              g_list_free (new_layers);
+            }
+          else if (status != GIMP_PDB_CANCEL)
+            {
+              warn = TRUE;
+            }
+        }
 
-          gimp_image_add_layers (image, new_layers, -1,
-                                 x, y, width, height,
-                                 _("Drop layers"));
-
-          g_list_free (new_layers);
-       }
-      else if (status != GIMP_PDB_CANCEL)
+      if (warn)
         {
           gchar *filename = file_utils_uri_display_name (uri);
 
-          gimp_message (image->gimp, G_OBJECT (shell->display),
+          gimp_message (shell->display->gimp, G_OBJECT (shell->display),
                         GIMP_MESSAGE_ERROR,
                         _("Opening '%s' failed:\n\n%s"),
                         filename, error->message);
@@ -467,7 +503,10 @@
 
   GIMP_LOG (DND, NULL);
 
-  if (dest_image->gimp->busy)
+  if (shell->display->gimp->busy)
+    return;
+
+  if (! dest_image)
     return;
 
   channel = gimp_channel_new_from_component (image, component, NULL, NULL);
@@ -520,7 +559,10 @@
 
   GIMP_LOG (DND, NULL);
 
-  if (image->gimp->busy)
+  if (shell->display->gimp->busy)
+    return;
+
+  if (! image)
     return;
 
   new_layer =

Modified: trunk/app/display/gimpdisplayshell-draw.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-draw.c	(original)
+++ trunk/app/display/gimpdisplayshell-draw.c	Tue Mar 18 21:22:21 2008
@@ -119,7 +119,8 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (gimp_display_shell_get_show_guides (shell))
+  if (shell->display->image &&
+      gimp_display_shell_get_show_guides (shell))
     {
       GList *list;
 
@@ -141,7 +142,8 @@
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (area != NULL);
 
-  if (gimp_display_shell_get_show_grid (shell))
+  if (shell->display->image &&
+      gimp_display_shell_get_show_grid (shell))
     {
       GimpGrid   *grid;
       GimpCanvas *canvas;
@@ -417,7 +419,8 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (gimp_display_shell_get_show_sample_points (shell))
+  if (shell->display->image &&
+      gimp_display_shell_get_show_sample_points (shell))
     {
       GList *list;
 
@@ -474,7 +477,8 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (TRUE /* gimp_display_shell_get_show_vectors (shell) */)
+  if (shell->display->image &&
+      TRUE /* gimp_display_shell_get_show_vectors (shell) */)
     {
       GList *list;
 
@@ -507,7 +511,7 @@
                               gint              w,
                               gint              h)
 {
-  GimpProjection *proj = shell->display->image->projection;
+  GimpProjection *proj;
   TileManager    *tiles;
   gint            level;
   gint            level_width;
@@ -515,8 +519,12 @@
   gint            sx, sy;
   gint            sw, sh;
 
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell) &&
-                    GIMP_IS_PROJECTION (proj));
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  if (! shell->display->image)
+    return;
+
+  proj = shell->display->image->projection;
 
   level = gimp_projection_get_level (proj, shell->scale_x, shell->scale_y);
 

Modified: trunk/app/display/gimpdisplayshell-filter-dialog.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-filter-dialog.c	(original)
+++ trunk/app/display/gimpdisplayshell-filter-dialog.c	Tue Mar 18 21:22:21 2008
@@ -63,18 +63,15 @@
 gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
 {
   ColorDisplayDialog *cdd;
-  GimpImage          *image;
   GtkWidget          *editor;
 
   g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
 
-  image = shell->display->image;
-
   cdd = g_slice_new0 (ColorDisplayDialog);
 
   cdd->shell  = shell;
-  cdd->dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (image),
-                                          gimp_get_user_context (image->gimp),
+  cdd->dialog = gimp_viewable_dialog_new (GIMP_VIEWABLE (shell->display->image),
+                                          gimp_get_user_context (shell->display->gimp),
                                           _("Color Display Filters"),
                                           "gimp-display-filters",
                                           GIMP_STOCK_DISPLAY_FILTER,

Modified: trunk/app/display/gimpdisplayshell-handlers.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-handlers.c	(original)
+++ trunk/app/display/gimpdisplayshell-handlers.c	Tue Mar 18 21:22:21 2008
@@ -126,8 +126,7 @@
 void
 gimp_display_shell_connect (GimpDisplayShell *shell)
 {
-  GimpImage         *image;
-  GimpDisplayConfig *display_config;
+  GimpImage *image;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
@@ -135,8 +134,6 @@
 
   image = shell->display->image;
 
-  display_config = GIMP_DISPLAY_CONFIG (image->gimp->config);
-
   g_signal_connect (image, "clean",
                     G_CALLBACK (gimp_display_shell_clean_dirty_handler),
                     shell);
@@ -197,63 +194,63 @@
                     G_CALLBACK (gimp_display_shell_vectors_remove_handler),
                     shell);
 
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::transparency-size",
                     G_CALLBACK (gimp_display_shell_check_notify_handler),
                     shell);
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::transparency-type",
                     G_CALLBACK (gimp_display_shell_check_notify_handler),
                     shell);
 
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::image-title-format",
                     G_CALLBACK (gimp_display_shell_title_notify_handler),
                     shell);
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::image-status-format",
                     G_CALLBACK (gimp_display_shell_title_notify_handler),
                     shell);
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::navigation-preview-size",
                     G_CALLBACK (gimp_display_shell_nav_size_notify_handler),
                     shell);
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::monitor-resolution-from-windowing-system",
                     G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
                     shell);
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::monitor-xresolution",
                     G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
                     shell);
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::monitor-yresolution",
                     G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
                     shell);
 
-  g_signal_connect (display_config->default_view,
+  g_signal_connect (shell->display->config->default_view,
                     "notify::padding-mode",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
-  g_signal_connect (display_config->default_view,
+  g_signal_connect (shell->display->config->default_view,
                     "notify::padding-color",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
-  g_signal_connect (display_config->default_fullscreen_view,
+  g_signal_connect (shell->display->config->default_fullscreen_view,
                     "notify::padding-mode",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
-  g_signal_connect (display_config->default_fullscreen_view,
+  g_signal_connect (shell->display->config->default_fullscreen_view,
                     "notify::padding-color",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
 
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::marching-ants-speed",
                     G_CALLBACK (gimp_display_shell_ants_speed_notify_handler),
                     shell);
 
-  g_signal_connect (image->gimp->config,
+  g_signal_connect (shell->display->config,
                     "notify::zoom-quality",
                     G_CALLBACK (gimp_display_shell_quality_notify_handler),
                     shell);
@@ -265,8 +262,7 @@
 void
 gimp_display_shell_disconnect (GimpDisplayShell *shell)
 {
-  GimpImage         *image;
-  GimpDisplayConfig *display_config;
+  GimpImage *image;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
@@ -274,8 +270,6 @@
 
   image = shell->display->image;
 
-  display_config = GIMP_DISPLAY_CONFIG (image->gimp->config);
-
   if (shell->icon_idle_id)
     {
       g_source_remove (shell->icon_idle_id);
@@ -294,28 +288,28 @@
       shell->pen_gc = NULL;
     }
 
-  g_signal_handlers_disconnect_by_func (image->gimp->config,
+  g_signal_handlers_disconnect_by_func (shell->display->config,
                                         gimp_display_shell_quality_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (image->gimp->config,
+  g_signal_handlers_disconnect_by_func (shell->display->config,
                                         gimp_display_shell_ants_speed_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (display_config->default_fullscreen_view,
+  g_signal_handlers_disconnect_by_func (shell->display->config->default_fullscreen_view,
                                         gimp_display_shell_padding_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (display_config->default_view,
+  g_signal_handlers_disconnect_by_func (shell->display->config->default_view,
                                         gimp_display_shell_padding_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (image->gimp->config,
+  g_signal_handlers_disconnect_by_func (shell->display->config,
                                         gimp_display_shell_monitor_res_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (image->gimp->config,
+  g_signal_handlers_disconnect_by_func (shell->display->config,
                                         gimp_display_shell_nav_size_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (image->gimp->config,
+  g_signal_handlers_disconnect_by_func (shell->display->config,
                                         gimp_display_shell_title_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (image->gimp->config,
+  g_signal_handlers_disconnect_by_func (shell->display->config,
                                         gimp_display_shell_check_notify_handler,
                                         shell);
 
@@ -428,7 +422,7 @@
                                          GimpDisplayShell *shell)
 {
   gimp_display_shell_scale_resize (shell,
-                                   GIMP_DISPLAY_CONFIG (image->gimp->config)->resize_windows_on_resize,
+                                   shell->display->config->resize_windows_on_resize,
                                    TRUE);
 }
 
@@ -637,7 +631,7 @@
   GimpCanvasPaddingMode  padding_mode;
   GimpRGB                padding_color;
 
-  display_config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
+  display_config = shell->display->config;
 
   fullscreen = gimp_display_shell_get_fullscreen (shell);
 

Modified: trunk/app/display/gimpdisplayshell-layer-select.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-layer-select.c	(original)
+++ trunk/app/display/gimpdisplayshell-layer-select.c	Tue Mar 18 21:22:21 2008
@@ -85,7 +85,7 @@
     return;
 
   layer_select = layer_select_new (image, layer,
-                                   image->gimp->config->layer_preview_size);
+                                   GIMP_CORE_CONFIG (shell->display->config)->layer_preview_size);
   layer_select_advance (layer_select, move);
 
   gtk_window_set_screen (GTK_WINDOW (layer_select->shell),

Modified: trunk/app/display/gimpdisplayshell-preview.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-preview.c	(original)
+++ trunk/app/display/gimpdisplayshell-preview.c	Tue Mar 18 21:22:21 2008
@@ -161,7 +161,7 @@
   if (! gimp_display_shell_get_show_transform (shell) || ! shell->canvas)
     return;
 
-  tool = tool_manager_get_active (shell->display->image->gimp);
+  tool = tool_manager_get_active (shell->display->gimp);
 
   if (! GIMP_IS_TRANSFORM_TOOL (tool) ||
       ! GIMP_IS_DRAWABLE (tool->drawable))

Modified: trunk/app/display/gimpdisplayshell-render.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-render.c	(original)
+++ trunk/app/display/gimpdisplayshell-render.c	Tue Mar 18 21:22:21 2008
@@ -244,7 +244,7 @@
   info.dest_bpl   = info.dest_bpp * GIMP_DISPLAY_RENDER_BUF_WIDTH;
   info.dest_width = info.dest_bpp * info.w;
 
-  switch (GIMP_DISPLAY_CONFIG (image->gimp->config)->zoom_quality)
+  switch (shell->display->config->zoom_quality)
     {
     case GIMP_ZOOM_QUALITY_LOW:
       info.zoom_quality = GIMP_DISPLAY_ZOOM_FAST;

Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c	(original)
+++ trunk/app/display/gimpdisplayshell-scale.c	Tue Mar 18 21:22:21 2008
@@ -80,7 +80,7 @@
 
 /**
  * gimp_display_shell_scale_setup:
- * @shell:        the #GimpDisplayShell
+ * @shell: the #GimpDisplayShell
  *
  * Prepares the display for drawing the image at current scale and offset.
  * This preparation involves, for example, setting up scrollbars and rulers.
@@ -88,21 +88,35 @@
 void
 gimp_display_shell_scale_setup (GimpDisplayShell *shell)
 {
-  GtkRuler *hruler;
-  GtkRuler *vruler;
-  gfloat    sx, sy;
-  gint      image_width, image_height;
+  GimpImage *image;
+  GtkRuler  *hruler;
+  GtkRuler  *vruler;
+  gfloat     sx, sy;
+  gint       image_width, image_height;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
   if (! shell->display)
     return;
 
-  image_width  = gimp_image_get_width  (shell->display->image);
-  image_height = gimp_image_get_height (shell->display->image);
+  image = shell->display->image;
+
+  if (image)
+    {
+      image_width  = gimp_image_get_width  (image);
+      image_height = gimp_image_get_height (image);
+
+      sx = SCALEX (shell, image_width);
+      sy = SCALEY (shell, image_height);
+    }
+  else
+    {
+      image_width  = shell->disp_width;
+      image_height = shell->disp_height;
 
-  sx = SCALEX (shell, image_width);
-  sy = SCALEY (shell, image_height);
+      sx = image_width;
+      sy = image_height;
+    }
 
   shell->hsbdata->value          = shell->offset_x;
   shell->hsbdata->upper          = sx;
@@ -122,19 +136,37 @@
   hruler = GTK_RULER (shell->hrule);
   vruler = GTK_RULER (shell->vrule);
 
-  hruler->lower    = 0;
-  hruler->upper    = img2real (shell, TRUE,
-                               FUNSCALEX (shell, shell->disp_width));
-  hruler->max_size = img2real (shell, TRUE,
-                               MAX (image_width, image_height));
-
-  vruler->lower    = 0;
-  vruler->upper    = img2real (shell, FALSE,
-                               FUNSCALEY (shell, shell->disp_height));
-  vruler->max_size = img2real (shell, FALSE,
-                               MAX (image_width, image_height));
+  hruler->lower = 0;
+
+  if (image)
+    {
+      hruler->upper    = img2real (shell, TRUE,
+                                   FUNSCALEX (shell, shell->disp_width));
+      hruler->max_size = img2real (shell, TRUE,
+                                   MAX (image_width, image_height));
+    }
+  else
+    {
+      hruler->upper    = image_width;
+      hruler->max_size = MAX (image_width, image_height);
+    }
+
+  vruler->lower = 0;
+
+  if (image)
+    {
+      vruler->upper    = img2real (shell, FALSE,
+                                   FUNSCALEY (shell, shell->disp_height));
+      vruler->max_size = img2real (shell, FALSE,
+                                   MAX (image_width, image_height));
+    }
+  else
+    {
+      vruler->upper    = image_height;
+      vruler->max_size = MAX (image_width, image_height);
+    }
 
-  if (sx < shell->disp_width)
+  if (image && sx < shell->disp_width)
     {
       shell->disp_xoffset = (shell->disp_width - sx) / 2;
 
@@ -145,7 +177,7 @@
                                  FUNSCALEX (shell,
                                             (gdouble) shell->disp_xoffset));
     }
-  else
+  else if (image)
     {
       shell->disp_xoffset = 0;
 
@@ -156,8 +188,12 @@
                                  FUNSCALEX (shell,
                                             (gdouble) shell->offset_x));
     }
+  else
+    {
+      shell->disp_xoffset = 0;
+    }
 
-  if (sy < shell->disp_height)
+  if (image && sy < shell->disp_height)
     {
       shell->disp_yoffset = (shell->disp_height - sy) / 2;
 
@@ -168,7 +204,7 @@
                                  FUNSCALEY (shell,
                                             (gdouble) shell->disp_yoffset));
     }
-  else
+  else if (image)
     {
       shell->disp_yoffset = 0;
 
@@ -179,6 +215,10 @@
                                  FUNSCALEY (shell,
                                             (gdouble) shell->offset_y));
     }
+  else
+    {
+      shell->disp_yoffset = 0;
+    }
 
   gtk_widget_queue_draw (GTK_WIDGET (hruler));
   gtk_widget_queue_draw (GTK_WIDGET (vruler));
@@ -227,7 +267,7 @@
 
 /**
  * gimp_display_shell_scale_can_revert:
- * @shell:     the #GimpDisplayShell
+ * @shell: the #GimpDisplayShell
  *
  * Return value: %TRUE if a previous display scale exists, otherwise %FALSE.
  **/
@@ -256,8 +296,6 @@
 
   if (dot_for_dot != shell->dot_for_dot)
     {
-      Gimp *gimp = shell->display->image->gimp;
-
       /* freeze the active tool */
       gimp_display_shell_pause (shell);
 
@@ -266,7 +304,7 @@
       gimp_display_shell_scale_changed (shell);
 
       gimp_display_shell_scale_resize (shell,
-                                       GIMP_DISPLAY_CONFIG (gimp->config)->resize_windows_on_zoom,
+                                       shell->display->config->resize_windows_on_zoom,
                                        TRUE);
 
       /* re-enable the active tool */
@@ -350,10 +388,9 @@
                              gdouble           x,
                              gdouble           y)
 {
-  GimpDisplayConfig *config;
-  gdouble            current;
-  gdouble            offset_x;
-  gdouble            offset_y;
+  gdouble current;
+  gdouble offset_x;
+  gdouble offset_y;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
@@ -374,16 +411,14 @@
   offset_x *= scale;
   offset_y *= scale;
 
-  config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
-
   gimp_display_shell_scale_by_values (shell, scale,
                                       offset_x - x, offset_y - y,
-                                      config->resize_windows_on_zoom);
+                                      shell->display->config->resize_windows_on_zoom);
 }
 
 /**
  * gimp_display_shell_scale_fit_in:
- * @shell:     the #GimpDisplayShell
+ * @shell: the #GimpDisplayShell
  *
  * Sets the scale such that the entire image precisely fits in the display
  * area.
@@ -421,7 +456,7 @@
 
 /**
  * gimp_display_shell_scale_fill:
- * @shell:     the #GimpDisplayShell
+ * @shell: the #GimpDisplayShell
  *
  * Sets the scale such that the entire display area is precisely filled by the
  * image.
@@ -459,11 +494,11 @@
 
 /**
  * gimp_display_shell_scale_by_values:
- * @shell:          the #GimpDisplayShell
- * @scale:          the new scale
- * @offset_x:       the new X offset
- * @offset_y:       the new Y offset
- * @resize_window:  whether the display window should be resized
+ * @shell:         the #GimpDisplayShell
+ * @scale:         the new scale
+ * @offset_x:      the new X offset
+ * @offset_y:      the new Y offset
+ * @resize_window: whether the display window should be resized
  *
  * Directly sets the image scale and image offsets used by the display. If
  * @resize_window is %TRUE then the display window is resized to better
@@ -517,7 +552,7 @@
 
 /**
  * gimp_display_shell_scale_shrink_wrap:
- * @shell:          the #GimpDisplayShell
+ * @shell: the #GimpDisplayShell
  *
  * Convenience function with the same functionality as
  * gimp_display_shell_scale_resize(@shell, TRUE, TRUE).
@@ -546,12 +581,8 @@
                                  gboolean          resize_window,
                                  gboolean          redisplay)
 {
-  Gimp *gimp;
-
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  gimp = shell->display->image->gimp;
-
   /* freeze the active tool */
   gimp_display_shell_pause (shell);
 
@@ -571,7 +602,7 @@
 
 /**
  * gimp_display_shell_scale_dialog:
- * @shell:          the #GimpDisplayShell
+ * @shell: the #GimpDisplayShell
  *
  * Constructs and displays a dialog allowing the user to enter a custom display
  * scale.
@@ -612,7 +643,7 @@
 
   shell->scale_dialog =
     gimp_viewable_dialog_new (GIMP_VIEWABLE (image),
-                              gimp_get_user_context (image->gimp),
+                              gimp_get_user_context (shell->display->gimp),
                               _("Zoom Ratio"), "display_scale",
                               GTK_STOCK_ZOOM_100,
                               _("Select Zoom Ratio"),
@@ -801,20 +832,19 @@
           gboolean          xdir,
           gdouble           len)
 {
-  GimpImage *image = shell->display->image;
-  gdouble    xres;
-  gdouble    yres;
-  gdouble    res;
+  gdouble xres;
+  gdouble yres;
+  gdouble res;
 
   if (shell->unit == GIMP_UNIT_PIXEL)
     return len;
 
-  gimp_image_get_resolution (image, &xres, &yres);
+  gimp_image_get_resolution (shell->display->image, &xres, &yres);
 
   if (xdir)
     res = xres;
   else
     res = yres;
 
-  return len * _gimp_unit_get_factor (image->gimp, shell->unit) / res;
+  return len * _gimp_unit_get_factor (shell->display->gimp, shell->unit) / res;
 }

Modified: trunk/app/display/gimpdisplayshell-scroll.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.c	(original)
+++ trunk/app/display/gimpdisplayshell-scroll.c	Tue Mar 18 21:22:21 2008
@@ -90,16 +90,24 @@
 void
 gimp_display_shell_scroll_clamp_offsets (GimpDisplayShell *shell)
 {
-  gint sx, sy;
-
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  sx = SCALEX (shell, gimp_image_get_width  (shell->display->image));
-  sy = SCALEY (shell, gimp_image_get_height (shell->display->image));
+  if (shell->display->image)
+    {
+      gint sx, sy;
+
+      sx = SCALEX (shell, gimp_image_get_width  (shell->display->image));
+      sy = SCALEY (shell, gimp_image_get_height (shell->display->image));
 
-  shell->offset_x = CLAMP (shell->offset_x, 0,
-                           MAX (sx - shell->disp_width, 0));
+      shell->offset_x = CLAMP (shell->offset_x, 0,
+                               MAX (sx - shell->disp_width, 0));
 
-  shell->offset_y = CLAMP (shell->offset_y, 0,
-                           MAX (sy - shell->disp_height, 0));
+      shell->offset_y = CLAMP (shell->offset_y, 0,
+                               MAX (sy - shell->disp_height, 0));
+    }
+  else
+    {
+      shell->offset_x = 0;
+      shell->offset_y = 0;
+    }
 }

Modified: trunk/app/display/gimpdisplayshell-selection.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-selection.c	(original)
+++ trunk/app/display/gimpdisplayshell-selection.c	Tue Mar 18 21:22:21 2008
@@ -166,7 +166,7 @@
 {
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  if (shell->selection)
+  if (shell->selection && shell->display->image)
     {
       Selection *selection = shell->selection;
 
@@ -684,6 +684,11 @@
 selection_start_timeout (Selection *selection)
 {
   selection_free_segs (selection);
+  selection->timeout = 0;
+
+  if (! selection->shell->display->image)
+    return FALSE;
+
   selection_generate_segs (selection);
 
   selection->index = 0;
@@ -695,8 +700,7 @@
   if (! selection->hidden)
     {
       GimpCanvas        *canvas = GIMP_CANVAS (selection->shell->canvas);
-      GimpDisplayConfig *config = GIMP_DISPLAY_CONFIG
-        (selection->shell->display->image->gimp->config);
+      GimpDisplayConfig *config = selection->shell->display->config;
 
       selection_draw (selection);
 

Modified: trunk/app/display/gimpdisplayshell-title.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-title.c	(original)
+++ trunk/app/display/gimpdisplayshell-title.c	Tue Mar 18 21:22:21 2008
@@ -30,7 +30,6 @@
 
 #include "config/gimpdisplayconfig.h"
 
-#include "core/gimp.h"
 #include "core/gimpcontainer.h"
 #include "core/gimpimage.h"
 #include "core/gimpitem.h"
@@ -61,15 +60,12 @@
 void
 gimp_display_shell_title_init (GimpDisplayShell *shell)
 {
-  GimpDisplayConfig *config;
-  gchar              title[MAX_TITLE_BUF];
+  gchar title[MAX_TITLE_BUF];
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
-  config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
-
   gimp_display_shell_format_title (shell, title, sizeof (title),
-                                   config->image_status_format);
+                                   shell->display->config->image_status_format);
 
   gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "title",
                        "%s", title);
@@ -98,7 +94,7 @@
   gchar              title[MAX_TITLE_BUF];
 
   shell  = GIMP_DISPLAY_SHELL (data);
-  config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
+  config = shell->display->config;
 
   shell->title_idle_id = 0;
 
@@ -162,7 +158,13 @@
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
   image = shell->display->image;
-  gimp  = image->gimp;
+  gimp  = shell->display->gimp;
+
+  if (! image)
+    {
+      print (title, title_len, i, _("GIMP - Drop Files"));
+      return;
+    }
 
   gimp_zoom_model_get_fraction (shell->zoom, &num, &denom);
 

Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c	(original)
+++ trunk/app/display/gimpdisplayshell.c	Tue Mar 18 21:22:21 2008
@@ -432,7 +432,7 @@
 {
   GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
 
-  if (shell->display)
+  if (shell->display && shell->display->image)
     gimp_display_shell_disconnect (shell);
 
   if (shell->menubar_manager)
@@ -522,15 +522,12 @@
 gimp_display_shell_screen_changed (GtkWidget *widget,
                                    GdkScreen *previous)
 {
-  GimpDisplayShell  *shell = GIMP_DISPLAY_SHELL (widget);
-  GimpDisplayConfig *config;
+  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
 
   if (GTK_WIDGET_CLASS (parent_class)->screen_changed)
     GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous);
 
-  config = GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config);
-
-  if (GIMP_DISPLAY_CONFIG (config)->monitor_res_from_gdk)
+  if (shell->display->config->monitor_res_from_gdk)
     {
       gimp_get_screen_resolution (gtk_widget_get_screen (widget),
                                   &shell->monitor_xres,
@@ -538,8 +535,8 @@
     }
   else
     {
-      shell->monitor_xres = GIMP_DISPLAY_CONFIG (config)->monitor_xres;
-      shell->monitor_yres = GIMP_DISPLAY_CONFIG (config)->monitor_yres;
+      shell->monitor_xres = shell->display->config->monitor_xres;
+      shell->monitor_yres = shell->display->config->monitor_yres;
     }
 }
 
@@ -559,7 +556,7 @@
 {
   GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
 
-  gimp_context_set_display (gimp_get_user_context (shell->display->image->gimp),
+  gimp_context_set_display (gimp_get_user_context (shell->display->gimp),
                             shell->display);
 
   gimp_ui_manager_ui_popup (shell->popup_manager, "/dummy-menubar/image-popup",
@@ -584,7 +581,7 @@
   /* update the <Image>/View/Zoom menu */
   gimp_ui_manager_update (shell->menubar_manager, shell->display);
 
-  user_context = gimp_get_user_context (shell->display->image->gimp);
+  user_context = gimp_get_user_context (shell->display->gimp);
 
   if (shell->display == gimp_context_get_display (user_context))
     gimp_ui_manager_update (shell->popup_manager, shell->display);
@@ -622,9 +619,13 @@
   GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (managed);
   GimpImage        *image = shell->display->image;
 
-  return gimp_color_managed_get_icc_profile (GIMP_COLOR_MANAGED (image), len);
+  if (image)
+    return gimp_color_managed_get_icc_profile (GIMP_COLOR_MANAGED (image), len);
+
+  return NULL;
 }
 
+
 /*  public functions  */
 
 GtkWidget *
@@ -635,9 +636,7 @@
                         GimpUIManager   *popup_manager)
 {
   GimpDisplayShell      *shell;
-  GimpDisplayConfig     *display_config;
   GimpColorDisplayStack *filter;
-  Gimp                  *gimp;
   GtkWidget             *main_vbox;
   GtkWidget             *disp_vbox;
   GtkWidget             *upper_hbox;
@@ -667,14 +666,11 @@
   image_width  = gimp_image_get_width  (display->image);
   image_height = gimp_image_get_height (display->image);
 
-  gimp = display->image->gimp;
-  display_config = GIMP_DISPLAY_CONFIG (gimp->config);
-
-  shell->dot_for_dot = display_config->default_dot_for_dot;
+  shell->dot_for_dot = shell->display->config->default_dot_for_dot;
 
-  gimp_config_sync (G_OBJECT (display_config->default_view),
+  gimp_config_sync (G_OBJECT (shell->display->config->default_view),
                     G_OBJECT (shell->options), 0);
-  gimp_config_sync (G_OBJECT (display_config->default_fullscreen_view),
+  gimp_config_sync (G_OBJECT (shell->display->config->default_fullscreen_view),
                     G_OBJECT (shell->fullscreen_options), 0);
 
   gimp_zoom_model_zoom (shell->zoom, GIMP_ZOOM_TO, scale);
@@ -685,15 +681,15 @@
    */
   screen = gtk_widget_get_screen (GTK_WIDGET (shell));
 
-  if (display_config->monitor_res_from_gdk)
+  if (shell->display->config->monitor_res_from_gdk)
     {
       gimp_get_screen_resolution (screen,
                                   &shell->monitor_xres, &shell->monitor_yres);
     }
   else
     {
-      shell->monitor_xres = display_config->monitor_xres;
-      shell->monitor_yres = display_config->monitor_yres;
+      shell->monitor_xres = shell->display->config->monitor_xres;
+      shell->monitor_yres = shell->display->config->monitor_yres;
     }
 
   s_width  = gdk_screen_get_width (screen)  * 0.75;
@@ -702,7 +698,7 @@
   n_width  = SCALEX (shell, image_width);
   n_height = SCALEY (shell, image_height);
 
-  if (display_config->initial_zoom_to_fit)
+  if (shell->display->config->initial_zoom_to_fit)
     {
       /*  Limit to the size of the screen...  */
       if (n_width > s_width || n_height > s_height)
@@ -895,7 +891,7 @@
                            _("Access the image menu"),
                            GIMP_HELP_IMAGE_WINDOW_ORIGIN);
 
-  shell->canvas = gimp_canvas_new (GIMP_DISPLAY_CONFIG (shell->display->image->gimp->config));
+  shell->canvas = gimp_canvas_new (display->config);
 
   gimp_display_shell_selection_init (shell);
 
@@ -1117,7 +1113,7 @@
   gtk_widget_show (main_vbox);
 
   filter = gimp_display_shell_filter_new (shell,
-                                          gimp->config->color_management);
+                                          GIMP_CORE_CONFIG (shell->display->config)->color_management);
   if (filter)
     {
       gimp_display_shell_filter_set (shell, filter);
@@ -1162,25 +1158,39 @@
 gimp_display_shell_scale_changed (GimpDisplayShell *shell)
 {
   GimpImage *image;
-  gdouble    xres;
-  gdouble    yres;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
 
   image = shell->display->image;
 
-  gimp_image_get_resolution (image, &xres, &yres);
+  if (image)
+    {
+      gdouble xres;
+      gdouble yres;
+
+      gimp_image_get_resolution (image, &xres, &yres);
+
+      shell->scale_x = (gimp_zoom_model_get_factor (shell->zoom) *
+                        SCREEN_XRES (shell) / xres);
 
-  shell->scale_x = (gimp_zoom_model_get_factor (shell->zoom) *
-                    SCREEN_XRES (shell) / xres);
+      shell->scale_y = (gimp_zoom_model_get_factor (shell->zoom) *
+                        SCREEN_YRES (shell) / yres);
 
-  shell->scale_y = (gimp_zoom_model_get_factor (shell->zoom) *
-                    SCREEN_YRES (shell) / yres);
+      shell->x_dest_inc = gimp_image_get_width  (image);
+      shell->y_dest_inc = gimp_image_get_height (image);
+      shell->x_src_dec  = SCALEX (shell, gimp_image_get_width  (image));
+      shell->y_src_dec  = SCALEY (shell, gimp_image_get_height (image));
+    }
+  else
+    {
+      shell->scale_x = 1.0;
+      shell->scale_y = 1.0;
 
-  shell->x_dest_inc = gimp_image_get_width  (image);
-  shell->y_dest_inc = gimp_image_get_height (image);
-  shell->x_src_dec  = SCALEX (shell, gimp_image_get_width  (image));
-  shell->y_src_dec  = SCALEY (shell, gimp_image_get_height (image));
+      shell->x_dest_inc = shell->disp_width;
+      shell->y_dest_inc = shell->disp_height;
+      shell->x_src_dec  = shell->disp_width;
+      shell->y_src_dec  = shell->disp_height;
+    }
 }
 
 void
@@ -1269,7 +1279,7 @@
       gint    snap_distance;
       gdouble tx, ty;
 
-      snap_distance = GIMP_DISPLAY_CONFIG (image->gimp->config)->snap_distance;
+      snap_distance = shell->display->config->snap_distance;
 
       if (snap_width > 0 && snap_height > 0)
         {
@@ -1475,7 +1485,7 @@
 
       gimp_ui_manager_update (shell->menubar_manager, shell->display);
 
-      user_context = gimp_get_user_context (shell->display->image->gimp);
+      user_context = gimp_get_user_context (shell->display->gimp);
 
       if (shell->display == gimp_context_get_display (user_context))
         gimp_ui_manager_update (shell->popup_manager, shell->display);
@@ -1503,7 +1513,7 @@
   if (shell->paused_count == 1)
     {
       /*  pause the currently active tool  */
-      tool_manager_control_active (shell->display->image->gimp,
+      tool_manager_control_active (shell->display->gimp,
                                    GIMP_TOOL_ACTION_PAUSE,
                                    shell->display);
 
@@ -1533,7 +1543,7 @@
       gimp_display_shell_draw_vectors (shell);
 
       /* start the currently active tool */
-      tool_manager_control_active (shell->display->image->gimp,
+      tool_manager_control_active (shell->display->gimp,
                                    GIMP_TOOL_ACTION_RESUME,
                                    shell->display);
     }
@@ -1566,7 +1576,7 @@
     }
 
   pixbuf = gimp_viewable_get_pixbuf (GIMP_VIEWABLE (image),
-                                     gimp_get_user_context (image->gimp),
+                                     gimp_get_user_context (shell->display->gimp),
                                      width, height);
 
   gtk_window_set_icon (GTK_WINDOW (shell), pixbuf);

Modified: trunk/app/display/gimpnavigationeditor.c
==============================================================================
--- trunk/app/display/gimpnavigationeditor.c	(original)
+++ trunk/app/display/gimpnavigationeditor.c	Tue Mar 18 21:22:21 2008
@@ -325,7 +325,7 @@
 
   if (shell)
     {
-      Gimp              *gimp   = shell->display->image->gimp;
+      Gimp              *gimp   = shell->display->gimp;
       GimpDisplayConfig *config = GIMP_DISPLAY_CONFIG (gimp->config);
       GimpView          *view;
 
@@ -639,9 +639,10 @@
   if (renderer->dot_for_dot != shell->dot_for_dot)
     gimp_view_renderer_set_dot_for_dot (renderer, shell->dot_for_dot);
 
-  gimp_navigation_view_set_marker (GIMP_NAVIGATION_VIEW (editor->view),
-                                   shell->offset_x    / shell->scale_x,
-                                   shell->offset_y    / shell->scale_y,
-                                   shell->disp_width  / shell->scale_x,
-                                   shell->disp_height / shell->scale_y);
+  if (renderer->viewable)
+    gimp_navigation_view_set_marker (GIMP_NAVIGATION_VIEW (editor->view),
+                                     shell->offset_x    / shell->scale_x,
+                                     shell->offset_y    / shell->scale_y,
+                                     shell->disp_width  / shell->scale_x,
+                                     shell->disp_height / shell->scale_y);
 }

Modified: trunk/app/display/gimpstatusbar.c
==============================================================================
--- trunk/app/display/gimpstatusbar.c	(original)
+++ trunk/app/display/gimpstatusbar.c	Tue Mar 18 21:22:21 2008
@@ -27,6 +27,8 @@
 
 #include "display-types.h"
 
+#include "config/gimpdisplayconfig.h"
+
 #include "core/gimpimage.h"
 #include "core/gimpunit.h"
 #include "core/gimpprogress.h"
@@ -635,13 +637,12 @@
     }
   else /* show real world units */
     {
-      GimpImage *image       = shell->display->image;
-      gdouble    xres;
-      gdouble    yres;
-      gdouble    unit_factor = _gimp_unit_get_factor (image->gimp,
-                                                      shell->unit);
+      gdouble xres;
+      gdouble yres;
+      gdouble unit_factor = _gimp_unit_get_factor (shell->display->gimp,
+                                                   shell->unit);
 
-      gimp_image_get_resolution (image, &xres, &yres);
+      gimp_image_get_resolution (shell->display->image, &xres, &yres);
 
       gimp_statusbar_push (statusbar, context,
                            statusbar->cursor_format_str,
@@ -681,14 +682,13 @@
     }
   else /* show real world units */
     {
-      GimpImage *image       = shell->display->image;
-      gdouble    xres;
-      gdouble    yres;
-      gdouble    resolution;
-      gdouble    unit_factor = _gimp_unit_get_factor (image->gimp,
-                                                      shell->unit);
+      gdouble xres;
+      gdouble yres;
+      gdouble resolution;
+      gdouble unit_factor = _gimp_unit_get_factor (shell->display->gimp,
+                                                   shell->unit);
 
-      gimp_image_get_resolution (image, &xres, &yres);
+      gimp_image_get_resolution (shell->display->image, &xres, &yres);
 
       switch (axis)
         {
@@ -916,7 +916,8 @@
 
   shell = statusbar->shell;
 
-  if (x <  0                                             ||
+  if (! shell->display->image                            ||
+      x <  0                                             ||
       y <  0                                             ||
       x >= gimp_image_get_width  (shell->display->image) ||
       y >= gimp_image_get_height (shell->display->image))
@@ -1051,11 +1052,27 @@
   GimpImage    *image = shell->display->image;
   GtkTreeModel *model;
   const gchar  *text;
-  gdouble       xres;
-  gdouble       yres;
+  gint          image_width;
+  gint          image_height;
+  gdouble       image_xres;
+  gdouble       image_yres;
   gint          width;
   gint          diff;
 
+  if (image)
+    {
+      image_width  = gimp_image_get_width  (image);
+      image_height = gimp_image_get_height (image);
+      gimp_image_get_resolution (image, &image_xres, &image_yres);
+    }
+  else
+    {
+      image_width  = shell->disp_width;
+      image_height = shell->disp_height;
+      image_xres   = shell->display->config->monitor_xres;
+      image_yres   = shell->display->config->monitor_yres;
+    }
+
   g_signal_handlers_block_by_func (statusbar->scale_combo,
                                    gimp_statusbar_scale_changed, statusbar);
   gimp_scale_combo_box_set_scale (GIMP_SCALE_COMBO_BOX (statusbar->scale_combo),
@@ -1064,8 +1081,8 @@
                                      gimp_statusbar_scale_changed, statusbar);
 
   model = gtk_combo_box_get_model (GTK_COMBO_BOX (statusbar->unit_combo));
-  gimp_image_get_resolution (image, &xres, &yres);
-  gimp_unit_store_set_resolutions (GIMP_UNIT_STORE (model), xres, yres);
+  gimp_unit_store_set_resolutions (GIMP_UNIT_STORE (model),
+                                   image_xres, image_yres);
 
   g_signal_handlers_block_by_func (statusbar->unit_combo,
                                    gimp_statusbar_unit_changed, statusbar);
@@ -1088,17 +1105,15 @@
       g_snprintf (statusbar->cursor_format_str,
                   sizeof (statusbar->cursor_format_str),
                   "%%s%%.%df%%s%%.%df%%s",
-                  _gimp_unit_get_digits (image->gimp, shell->unit),
-                  _gimp_unit_get_digits (image->gimp, shell->unit));
+                  _gimp_unit_get_digits (shell->display->gimp, shell->unit),
+                  _gimp_unit_get_digits (shell->display->gimp, shell->unit));
       g_snprintf (statusbar->length_format_str,
                   sizeof (statusbar->length_format_str),
                   "%%s%%.%df%%s",
-                  _gimp_unit_get_digits (image->gimp, shell->unit));
+                  _gimp_unit_get_digits (shell->display->gimp, shell->unit));
     }
 
-  gimp_statusbar_update_cursor (statusbar,
-                                - gimp_image_get_width  (image),
-                                - gimp_image_get_height (image));
+  gimp_statusbar_update_cursor (statusbar, image_width, image_height);
 
   text = gtk_label_get_text (GTK_LABEL (statusbar->cursor_label));
 

Modified: trunk/app/gui/gui-vtable.c
==============================================================================
--- trunk/app/gui/gui-vtable.c	(original)
+++ trunk/app/gui/gui-vtable.c	Tue Mar 18 21:22:21 2008
@@ -59,6 +59,7 @@
 #include "display/gimpdisplay.h"
 #include "display/gimpdisplay-foreach.h"
 #include "display/gimpdisplayshell.h"
+#include "display/gimpdisplayshell-scale.h"
 
 #include "actions/plug-in-actions.h"
 
@@ -89,7 +90,8 @@
                                                 gint                 ID);
 static gint           gui_display_get_ID       (GimpObject          *display);
 static guint32        gui_display_get_window   (GimpObject          *display);
-static GimpObject   * gui_display_create       (GimpImage           *image,
+static GimpObject   * gui_display_create       (Gimp                *gimp,
+                                                GimpImage           *image,
                                                 GimpUnit             unit,
                                                 gdouble              scale);
 static void           gui_display_delete       (GimpObject          *display);
@@ -276,22 +278,52 @@
 }
 
 static GimpObject *
-gui_display_create (GimpImage *image,
+gui_display_create (Gimp      *gimp,
+                    GimpImage *image,
                     GimpUnit   unit,
                     gdouble    scale)
 {
-  GimpDisplay *display;
-  GList       *image_managers;
+  GimpContext *context = gimp_get_user_context (gimp);
+  GimpDisplay *display = NULL;
+
+  if (gimp_container_num_children (gimp->displays) == 1)
+    {
+      display = (GimpDisplay *)
+        gimp_container_get_child_by_index (gimp->displays, 0);
+
+      if (display->image)
+        display = NULL;
+    }
+
+  if (display)
+    {
+      gimp_display_set_image (display, image);
+      gimp_display_shell_set_unit (GIMP_DISPLAY_SHELL (display->shell), unit);
+      gimp_display_shell_scale (GIMP_DISPLAY_SHELL (display->shell),
+                                GIMP_ZOOM_TO, scale);
 
-  image_managers = gimp_ui_managers_from_name ("<Image>");
+      if (gimp_context_get_display (context) == display)
+        {
+          gimp_context_set_image (context, image);
+          gimp_context_display_changed (context);
+        }
+      else
+        {
+          gimp_context_set_display (context, display);
+        }
+    }
+  else
+    {
+      GList *image_managers = gimp_ui_managers_from_name ("<Image>");
 
-  g_return_val_if_fail (image_managers != NULL, NULL);
+      g_return_val_if_fail (image_managers != NULL, NULL);
 
-  display = gimp_display_new (image, unit, scale,
-                              global_menu_factory,
-                              image_managers->data);
+      display = gimp_display_new (gimp, image, unit, scale,
+                                  global_menu_factory,
+                                  image_managers->data);
 
-  gimp_context_set_display (gimp_get_user_context (image->gimp), display);
+      gimp_context_set_display (context, display);
+   }
 
   gimp_ui_manager_update (GIMP_DISPLAY_SHELL (display->shell)->menubar_manager,
                           display);



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