diff options
author | Cosimo Cecchi <cosimoc@svn.gnome.org> | 2007-09-13 01:36:53 +0800 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@src.gnome.org> | 2007-09-13 01:36:53 +0800 |
commit | 85e48eed9e19e82448ad60d4252edec04ad8dbd0 (patch) | |
tree | dfea55195a7cbbf16bbcce3261f70c4bd168b12c /src/ephy-session.c | |
parent | 662bc04565b5f871500166b3e86ee3f6fbb2b429 (diff) | |
download | gsoc2013-epiphany-85e48eed9e19e82448ad60d4252edec04ad8dbd0.tar.gz gsoc2013-epiphany-85e48eed9e19e82448ad60d4252edec04ad8dbd0.tar.zst gsoc2013-epiphany-85e48eed9e19e82448ad60d4252edec04ad8dbd0.zip |
Make session recovery focus work properly and remember the active tab.
2007-09-12 Cosimo Cecchi <cosimoc@svn.gnome.org>
* 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
Diffstat (limited to 'src/ephy-session.c')
-rw-r--r-- | src/ephy-session.c | 36 |
1 files changed, 35 insertions, 1 deletions
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 <glib/gi18n.h> #include <gtk/gtkmain.h> @@ -44,6 +45,7 @@ #include <gtk/gtkstock.h> #include <gtk/gtkhbox.h> #include <gtk/gtkvbox.h> +#include <gtk/gtknotebook.h> #include <gtk/gtkdialog.h> #include <gtk/gtkmessagedialog.h> @@ -1089,6 +1091,20 @@ write_tab (xmlTextWriterPtr writer, } 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")) |