Commit b9ccf189 authored by Martin Nordholts's avatar Martin Nordholts

Bug 650348 - Window unmaximizes when a document is closed

Refactor GimpImageWindow session management. As far as session
management goes, there are four states and four transitions that are
interesting.

The states are:

 State    Window mode     Images opened
 ------------------------------------------
  s1          swm               0
  s2          swm              >0
  s3          mwm               0
  s4          mwm              >0

The transitions are:

  Transition     Description
 -------------------------------------------
      t1         Enter single-window mode (swm)
      t2         Enter multi-window mwm (mwm)
      t3         Open an image
      t4         Close an image

When thinking of it like this, it is pretty easy to see when to call
gimp_image_window_session_clear() and when to call
gimp_image_window_session_apply(). So kill
gimp_image_window_set_entry_id() and handle all transitions in
gimp_image_window_session_update().
parent a5ef5113
......@@ -37,6 +37,8 @@ UI:
better
- Add a canvas item for the transform grid, fixing a major speed
regression, and add the same guides options as in the rectangle tools
- Don't unmaximize the single-window mode image window when closing
images
Core:
......
......@@ -173,11 +173,9 @@ 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,
gboolean from_switch_page);
const gchar *new_entry_id);
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);
......@@ -419,11 +417,9 @@ gimp_image_window_constructed (GObject *object)
G_CALLBACK (gimp_image_window_config_notify),
window, G_CONNECT_SWAPPED);
private->entry_id = gimp_image_window_config_to_entry_id (config);
gimp_image_window_session_update (window,
NULL /*new_display*/,
FALSE /*from_switch_page*/);
gimp_image_window_config_to_entry_id (config));
}
static void
......@@ -1494,8 +1490,9 @@ gimp_image_window_config_notify (GimpImageWindow *window,
/* 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));
gimp_image_window_session_update (window,
NULL /*new_display*/,
gimp_image_window_config_to_entry_id (config));
}
}
......@@ -1608,7 +1605,7 @@ gimp_image_window_switch_page (GtkNotebook *notebook,
gimp_image_window_session_update (window,
active_display,
TRUE /*from_switch_page*/);
NULL /*new_entry_id*/);
gimp_ui_manager_update (private->menubar_manager, active_display);
}
......@@ -1670,7 +1667,7 @@ gimp_image_window_image_notify (GimpDisplay *display,
gimp_image_window_session_update (window,
display,
FALSE /*from_switch_page*/);
NULL /*new_entry_id*/);
view = gtk_notebook_get_tab_label (GTK_NOTEBOOK (private->notebook),
GTK_WIDGET (gimp_display_get_shell (display)));
......@@ -1736,24 +1733,73 @@ gimp_image_window_session_apply (GimpImageWindow *window,
static void
gimp_image_window_session_update (GimpImageWindow *window,
GimpDisplay *new_display,
gboolean from_switch_page)
const gchar *new_entry_id)
{
GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
if (private->entry_id == NULL)
return;
/* Handle changes to the entry id */
if (new_entry_id)
{
if (! private->entry_id)
{
/* We're initializing. If we're in single-window mode, this
* will be the only window, so start to session manage
* it. If we're in multi-window mode, we will find out if we
* should session manage ourselves when we get a display
*/
if (strcmp (new_entry_id, GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID) == 0)
{
gimp_image_window_session_apply (window, new_entry_id);
}
}
else if (strcmp (private->entry_id, new_entry_id) != 0)
{
/* The entry id changed, immediately and always stop session
* managing the old entry
*/
gimp_image_window_session_clear (window);
if (strcmp (new_entry_id, GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID) == 0)
{
/* If there is only one imageless display, we shall
* become the empty image window
*/
if (private->active_shell &&
private->active_shell->display &&
! gimp_display_get_image (private->active_shell->display) &&
g_list_length (private->shells) <= 1)
{
gimp_image_window_session_apply (window, new_entry_id);
}
}
else if (strcmp (new_entry_id, GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID) == 0)
{
/* As soon as we become the single image window, we
* shall session manage ourself until single-window mode
* is exited
*/
gimp_image_window_session_apply (window, new_entry_id);
}
}
private->entry_id = new_entry_id;
}
if (strcmp (private->entry_id, GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID) == 0)
/* Handle changes to the displays. When in single-window mode, we
* just keep session managing the single image window. We only need
* to care about the multi-window mode case here
*/
if (new_display &&
strcmp (private->entry_id, GIMP_EMPTY_IMAGE_WINDOW_ENTRY_ID) == 0)
{
if (new_display && gimp_display_get_image (new_display))
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 (new_display &&
! gimp_display_get_image (new_display) &&
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
......@@ -1762,18 +1808,6 @@ gimp_image_window_session_update (GimpImageWindow *window,
gimp_image_window_session_apply (window, private->entry_id);
}
}
else if (strcmp (private->entry_id, GIMP_SINGLE_IMAGE_WINDOW_ENTRY_ID) == 0)
{
/* Always session manage the single image window, but not if all
* we did was switch tabs
*/
if (! from_switch_page)
gimp_image_window_session_apply (window, private->entry_id);
}
else
{
g_assert_not_reached ();
}
}
static const gchar *
......@@ -1784,27 +1818,6 @@ gimp_image_window_config_to_entry_id (GimpGuiConfig *config)
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,
FALSE /*from_switch_page*/);
}
static void
gimp_image_window_shell_scaled (GimpDisplayShell *shell,
GimpImageWindow *window)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment