From aad3ac6ddd62d5cd1b3421f5bf45ccdcf1b0ed35 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Thu, 16 May 2002 14:54:55 +0000 Subject: Ask e_shell_prepare_for_quit() before destroying the view if it's the last * e-shell.c (view_delete_event_cb): Ask e_shell_prepare_for_quit() before destroying the view if it's the last one. * e-shell-view-menu.c (command_close): Synthesize a delete_event on the view instead of directly destroying it. svn path=/trunk/; revision=16931 --- shell/ChangeLog | 8 ++++++++ shell/e-shell-view-menu.c | 9 ++++++++- shell/e-shell.c | 13 +++++++++++-- 3 files changed, 27 insertions(+), 3 deletions(-) (limited to 'shell') diff --git a/shell/ChangeLog b/shell/ChangeLog index 421bd64a6b..ed436547f3 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,11 @@ +2002-05-16 Ettore Perazzoli + + * e-shell.c (view_delete_event_cb): Ask e_shell_prepare_for_quit() + before destroying the view if it's the last one. + + * e-shell-view-menu.c (command_close): Synthesize a delete_event + on the view instead of directly destroying it. + 2002-05-15 Ettore Perazzoli * e-shell-view-menu.c (command_quit): Check with diff --git a/shell/e-shell-view-menu.c b/shell/e-shell-view-menu.c index efbb5898a5..52261abc1f 100644 --- a/shell/e-shell-view-menu.c +++ b/shell/e-shell-view-menu.c @@ -130,10 +130,17 @@ command_close (BonoboUIComponent *uih, const char *path) { EShellView *shell_view; + GdkEvent delete_event; shell_view = E_SHELL_VIEW (data); - gtk_object_destroy (GTK_OBJECT (shell_view)); + /* Send a delete_event to the window. This way we make sure that the + behaviors for delete_event and the menu item are the same. */ + + delete_event.any.type = GDK_DELETE; + delete_event.any.window = GTK_WIDGET (shell_view)->window; + delete_event.any.send_event = 0; + gtk_widget_event (GTK_WIDGET (shell_view), &delete_event); } static void diff --git a/shell/e-shell.c b/shell/e-shell.c index 6353a45f55..3799a2b513 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -953,8 +953,17 @@ view_delete_event_cb (GtkWidget *widget, shell = E_SHELL (data); e_shell_save_settings (shell); - /* Destroy it */ - return FALSE; + if (g_list_length (shell->priv->views) != 1) { + /* If it's not the last view, just destroy it. */ + return FALSE; + } + + /* If it's the last view, ask for confirm before actually destroying + this view. */ + if (e_shell_prepare_for_quit (shell)) + return FALSE; + else + return TRUE; } static void -- cgit v1.2.3