From 85e48eed9e19e82448ad60d4252edec04ad8dbd0 Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 12 Sep 2007 17:36:53 +0000 Subject: Make session recovery focus work properly and remember the active tab. 2007-09-12 Cosimo Cecchi * src/ephy-session.c: (write_active_tab), (write_ephy_window), (ephy_session_load): Make session recovery focus work properly and remember the active tab. Fixes bug #317272. svn path=/trunk/; revision=7393 --- ChangeLog | 8 ++++++++ src/ephy-session.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index cec759852..bc5770ddd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-09-12 Cosimo Cecchi + + * src/ephy-session.c: (write_active_tab), (write_ephy_window), + (ephy_session_load): + + Make session recovery focus work properly and remember the active tab. + Fixes bug #317272. + 2007-09-12 Cosimo Cecchi * src/ephy-lockdown.c: (update_window): diff --git a/src/ephy-session.c b/src/ephy-session.c index e381e27ff..a167e73cb 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -36,6 +36,7 @@ #include "ephy-debug.h" #include "ephy-stock-icons.h" #include "ephy-glib-compat.h" +#include "ephy-notebook.h" #include #include @@ -44,6 +45,7 @@ #include #include #include +#include #include #include @@ -1088,6 +1090,20 @@ write_tab (xmlTextWriterPtr writer, return ret; } +static int +write_active_tab (xmlTextWriterPtr writer, + GtkWidget *notebook) +{ + int ret; + int current; + + current = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook)); + + ret = xmlTextWriterWriteFormatAttribute (writer, (const xmlChar *) "active-tab", "%d", current); + return ret; +} + + static int write_window_geometry (xmlTextWriterPtr writer, GtkWindow *window) @@ -1151,10 +1167,12 @@ write_ephy_window (xmlTextWriterPtr writer, EphyWindow *window) { GList *tabs, *l; + GtkWidget *notebook; const char *role; int ret; tabs = ephy_window_get_tabs (window); + notebook = ephy_window_get_notebook (window); /* Do not save an empty EphyWindow. * This only happens when the window was newly opened. @@ -1167,6 +1185,9 @@ write_ephy_window (xmlTextWriterPtr writer, ret = write_window_geometry (writer, GTK_WINDOW (window)); if (ret < 0) return ret; + ret = write_active_tab (writer, notebook); + if (ret < 0) return ret; + role = gtk_window_get_role (GTK_WINDOW (window)); if (role != NULL) { @@ -1444,6 +1465,10 @@ ephy_session_load (EphySession *session, { if (xmlStrEqual (child->name, (const xmlChar *) "window")) { + xmlChar *tmp; + gboolean success; + int active_tab; + window = ephy_window_new (); widget = GTK_WIDGET (window); restore_geometry (GTK_WINDOW (widget), child); @@ -1454,8 +1479,17 @@ ephy_session_load (EphySession *session, parse_embed (child->children, window, session); /* Set focus to something sane */ - gtk_widget_grab_focus (ephy_window_get_notebook (window)); + tmp = xmlGetProp (child, (xmlChar *) "active-tab"); + success = int_from_string ((char *) tmp, &active_tab); + xmlFree (tmp); + if (success) + { + GtkWidget *notebook; + notebook = ephy_window_get_notebook (window); + gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), active_tab); + } + gtk_widget_grab_focus (GTK_WIDGET (ephy_window_get_active_tab (window))); gtk_widget_show (widget); } else if (xmlStrEqual (child->name, (const xmlChar *) "toolwindow")) -- cgit v1.2.3