[epiphany] ephy-window: save the session when the last window is closed manually



commit 381ce4af310607cc84ac1e84abbecda2d7d3e7d9
Author: Xan Lopez <xan igalia com>
Date:   Fri Mar 30 11:44:03 2012 +0200

    ephy-window: save the session when the last window is closed manually
    
    If the user closes the last window manually (pressing the [x] button
    in the window) she probably wants to save the session contents too, so
    do that. This is consistent with the behavior of Firefox and Chrome.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=673122

 src/ephy-window.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index ee1c0c2..a54f7f2 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -49,6 +49,7 @@
 #include "ephy-page-menu-action.h"
 #include "ephy-prefs.h"
 #include "ephy-private.h"
+#include "ephy-session.h"
 #include "ephy-settings.h"
 #include "ephy-shell.h"
 #include "ephy-state.h"
@@ -994,8 +995,10 @@ ephy_window_delete_event (GtkWidget *widget,
 			  GdkEventAny *event)
 {
 	EphyWindow *window = EPHY_WINDOW (widget);
+	EphySession *session;
 	EphyEmbed *modified_embed = NULL;
-	GList *tabs, *l;
+	GList *tabs, *l, *windows;
+	guint number_windows;
 	gboolean modified = FALSE;
 
 	/* We ignore the delete_event if the disable_quit lockdown has been set
@@ -1039,6 +1042,18 @@ ephy_window_delete_event (GtkWidget *widget,
 		return TRUE;
 	}
 
+	/* If this is the last window, save its state in the session. */
+	session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
+	windows = ephy_session_get_windows (session);
+	number_windows = g_list_length (windows);
+	g_list_free (windows);
+
+	if (number_windows == 1)
+	{
+		ephy_session_close (session);
+		return TRUE;
+	}
+
 	/* See bug #114689 */
 	gtk_widget_hide (widget);
 



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