Commit fe117413 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

added new function gimp_display_close() which decides if

2008-04-05  Sven Neumann  <sven@gimp.org>

	* app/display/gimpdisplay.[ch]: added new function
	gimp_display_close() which decides if gimp_display_delete() or
	gimp_display_empty() needs to be called.

	* app/display/gimpdisplay-foreach.[ch]: added new function
	gimp_displays_close() and removed the 'do_quit' parameter from
	gimp_displays_delete().

	* app/gui/gui.c (gui_exit_callback): changed accordingly.

	* app/display/gimpdisplayshell-close.c: removed
	gimp_display_shell_really_close() and call gimp_display_close()
	instead.

	* app/display/gimpdisplayshell.c (gimp_display_shell_empty): 
moved
	code to update the ui managers here.

	* app/actions/file-commands.c (file_save_cmd_callback)
	(file_close_cmd_callback)
	* app/dialogs/file-save-dialog.c (file_save_dialog_response)
	* app/dialogs/quit-dialog.c (quit_close_all_dialog_response):
	close displays instead of deleting them.

	* app/gui/gui-vtable.c (gui_display_delete): call
	gimp_display_close().


svn path=/trunk/; revision=25377
parent 46ca29df
2008-04-05 Sven Neumann <sven@gimp.org>
* app/display/gimpdisplay.[ch]: added new function
gimp_display_close() which decides if gimp_display_delete() or
gimp_display_empty() needs to be called.
* app/display/gimpdisplay-foreach.[ch]: added new function
gimp_displays_close() and removed the 'do_quit' parameter from
gimp_displays_delete().
* app/gui/gui.c (gui_exit_callback): changed accordingly.
* app/display/gimpdisplayshell-close.c: removed
gimp_display_shell_really_close() and call gimp_display_close()
instead.
* app/display/gimpdisplayshell.c (gimp_display_shell_empty): moved
code to update the ui managers here.
* app/actions/file-commands.c (file_save_cmd_callback)
(file_close_cmd_callback)
* app/dialogs/file-save-dialog.c (file_save_dialog_response)
* app/dialogs/quit-dialog.c (quit_close_all_dialog_response):
close displays instead of deleting them.
* app/gui/gui-vtable.c (gui_display_delete): call
gimp_display_close().
2008-04-05 Sven Neumann <sven@gimp.org>
* app/widgets/gimpcolormapeditor.c (gimp_colormap_editor_draw):
......
......@@ -302,7 +302,7 @@ file_save_cmd_callback (GtkAction *action,
if (save_mode == GIMP_SAVE_MODE_SAVE_AND_CLOSE &&
saved && ! display->image->dirty)
{
gimp_display_delete (display);
gimp_display_close (display);
}
}
......@@ -408,7 +408,7 @@ file_close_all_cmd_callback (GtkAction *action,
if (! gimp_displays_dirty (gimp))
{
gimp_displays_delete (gimp, FALSE);
gimp_displays_close (gimp);
}
else
{
......
......@@ -156,7 +156,7 @@ file_save_dialog_response (GtkWidget *save_dialog,
display = GIMP_DISPLAY_SHELL (parent)->display;
if (! display->image->dirty)
gimp_display_delete (display);
gimp_display_close (display);
}
}
}
......
......@@ -196,7 +196,7 @@ quit_close_all_dialog_response (GtkWidget *dialog,
if (do_quit)
gimp_exit (gimp, TRUE);
else
gimp_displays_delete (gimp, FALSE);
gimp_displays_close (gimp);
}
}
......
......@@ -139,30 +139,53 @@ gimp_displays_get_dirty_images (Gimp *gimp)
return NULL;
}
/**
* gimp_displays_delete:
* @gimp:
*
* Calls gimp_display_delete() an all displays in the display list.
* This closes all displays, including the first one which is usually
* kept open.
*/
void
gimp_displays_delete (Gimp *gimp,
gboolean quit)
gimp_displays_delete (Gimp *gimp)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
/* this removes the GimpDisplay from the list, so do a while loop
* "around" the first element to get them all
*/
while (GIMP_LIST (gimp->displays)->list)
while (! gimp_container_is_empty (gimp->displays))
{
GList *list = GIMP_LIST (gimp->displays)->list;
GimpDisplay *display = list->data;
GimpDisplay *display = GIMP_LIST (gimp->displays)->list->data;
if (list->next || quit)
{
gimp_display_delete (display);
}
else
{
gimp_display_empty (display);
break;
}
gimp_display_delete (display);
}
}
/**
* gimp_displays_close:
* @gimp:
*
* Calls gimp_display_close() an all displays in the display list. The
* first display will remain open without an image.
*/
void
gimp_displays_close (Gimp *gimp)
{
GList *list;
GList *iter;
g_return_if_fail (GIMP_IS_GIMP (gimp));
list = g_list_copy (GIMP_LIST (gimp->displays)->list);
for (iter = list; iter; iter = g_list_next (iter))
{
GimpDisplay *display = iter->data;
gimp_display_close (display);
}
g_list_free (list);
}
void
......
......@@ -22,8 +22,8 @@
gboolean gimp_displays_dirty (Gimp *gimp);
GimpContainer * gimp_displays_get_dirty_images (Gimp *gimp);
void gimp_displays_delete (Gimp *gimp,
gboolean quit);
void gimp_displays_delete (Gimp *gimp);
void gimp_displays_close (Gimp *gimp);
void gimp_displays_reconnect (Gimp *gimp,
GimpImage *old,
GimpImage *new);
......
......@@ -396,6 +396,13 @@ gimp_display_new (Gimp *gimp,
return display;
}
/**
* gimp_display_delete:
* @display:
*
* Closes the display and removes it from the display list. You should
* not call this function directly, use gimp_display_close() instead.
*/
void
gimp_display_delete (GimpDisplay *display)
{
......@@ -404,8 +411,7 @@ gimp_display_delete (GimpDisplay *display)
g_return_if_fail (GIMP_IS_DISPLAY (display));
/* remove the display from the list */
gimp_container_remove (display->gimp->displays,
GIMP_OBJECT (display));
gimp_container_remove (display->gimp->displays, GIMP_OBJECT (display));
/* unrefs the image */
gimp_display_set_image (display, NULL);
......@@ -434,6 +440,28 @@ gimp_display_delete (GimpDisplay *display)
g_object_unref (display);
}
/**
* gimp_display_close:
* @display:
*
* Closes the display. If this is the last display, it will remain
* open, but without an image.
*/
void
gimp_display_close (GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_DISPLAY (display));
if (gimp_container_num_children (display->gimp->displays) > 1)
{
gimp_display_delete (display);
}
else
{
gimp_display_empty (display);
}
}
gint
gimp_display_get_ID (GimpDisplay *display)
{
......
......@@ -67,6 +67,7 @@ GimpDisplay * gimp_display_new (Gimp *gimp,
GimpUIManager *popup_manager,
GimpDialogFactory *display_factory);
void gimp_display_delete (GimpDisplay *display);
void gimp_display_close (GimpDisplay *display);
gint gimp_display_get_ID (GimpDisplay *display);
GimpDisplay * gimp_display_get_by_ID (Gimp *gimp,
......
......@@ -57,8 +57,6 @@ static gboolean gimp_display_shell_close_time_changed (GimpMessageBox *box);
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,
gint *minutes);
......@@ -96,7 +94,7 @@ gimp_display_shell_close (GimpDisplayShell *shell,
}
else if (image)
{
gimp_display_shell_really_close (shell);
gimp_display_close (shell->display);
}
else
{
......@@ -289,7 +287,7 @@ gimp_display_shell_close_response (GtkWidget *widget,
switch (response_id)
{
case GTK_RESPONSE_CLOSE:
gimp_display_shell_really_close (shell);
gimp_display_close (shell->display);
break;
case RESPONSE_SAVE:
......@@ -302,28 +300,6 @@ gimp_display_shell_close_response (GtkWidget *widget,
}
}
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_empty (shell->display);
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,
......
......@@ -1245,6 +1245,7 @@ void
gimp_display_shell_empty (GimpDisplayShell *shell)
{
GimpSessionInfo *session_info;
GimpContext *user_context;
gint width;
gint height;
......@@ -1298,6 +1299,15 @@ gimp_display_shell_empty (GimpDisplayShell *shell)
gimp_display_shell_expose_full (shell);
gtk_window_resize (GTK_WINDOW (shell), width, height);
/* update the ui managers */
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 gboolean
......
......@@ -363,7 +363,7 @@ gui_display_create (Gimp *gimp,
static void
gui_display_delete (GimpObject *display)
{
gimp_display_delete (GIMP_DISPLAY (display));
gimp_display_close (GIMP_DISPLAY (display));
}
static void
......
......@@ -584,7 +584,7 @@ gui_exit_callback (Gimp *gimp,
gui_display_changed,
gimp);
gimp_displays_delete (gimp, TRUE);
gimp_displays_delete (gimp);
gimp_tools_save (gimp, gui_config->save_tool_options, FALSE);
gimp_tools_exit (gimp);
......
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