diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2004-10-31 04:39:13 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2004-10-31 04:39:13 +0800 |
commit | f55083ff83d130e53eb11f58713c380eb0f794b2 (patch) | |
tree | 053bd43a10e61f6e5a6fea931faf95d7b8a6a8f2 /src | |
parent | 4c41745e525a7fc35f29622e382ec7f881cc2e50 (diff) | |
download | gsoc2013-epiphany-f55083ff83d130e53eb11f58713c380eb0f794b2.tar gsoc2013-epiphany-f55083ff83d130e53eb11f58713c380eb0f794b2.tar.gz gsoc2013-epiphany-f55083ff83d130e53eb11f58713c380eb0f794b2.tar.bz2 gsoc2013-epiphany-f55083ff83d130e53eb11f58713c380eb0f794b2.tar.lz gsoc2013-epiphany-f55083ff83d130e53eb11f58713c380eb0f794b2.tar.xz gsoc2013-epiphany-f55083ff83d130e53eb11f58713c380eb0f794b2.tar.zst gsoc2013-epiphany-f55083ff83d130e53eb11f58713c380eb0f794b2.zip |
Fix restoring window size on crash recovery by moving the setting of the
2004-10-30 Christian Persch <chpe@cvs.gnome.org>
* lib/ephy-state.c: (ephy_state_window_set_size):
* src/ephy-session.c: (write_window_geometry), (int_from_string),
(restore_geometry), (ephy_session_load):
Fix restoring window size on crash recovery by moving the setting
of the size before the initial show which occurs from
ephy_shell_new_tab from parse_embed. Fixes bug #156881.
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-session.c | 79 |
1 files changed, 56 insertions, 23 deletions
diff --git a/src/ephy-session.c b/src/ephy-session.c index 60fb877c7..0dc040070 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -38,7 +38,9 @@ #include "ephy-debug.h" #include <glib/gi18n.h> +#include <errno.h> #include <string.h> +#include <stdlib.h> #include <gtk/gtkimage.h> #include <gtk/gtklabel.h> #include <gtk/gtkstock.h> @@ -477,7 +479,7 @@ static int write_window_geometry (xmlTextWriterPtr writer, GtkWindow *window) { - int x = 0, y = 0, width = 0, height = 0; + int x = 0, y = 0, width = -1, height = -1; int ret; /* get window geometry */ @@ -676,6 +678,55 @@ parse_embed (xmlNodePtr child, EphyWindow *window) } } +static gboolean +int_from_string (const char *string, + int *retval) +{ + char *tail = NULL; + long int val; + gboolean success = FALSE; + + errno = 0; + val = strtol (string, &tail, 0); + + if (errno == 0 && tail != NULL && tail[0] == '\0') + { + *retval = (int) val; + success = TRUE; + } + + return success; +} + +static void +restore_geometry (GtkWindow *window, + xmlNodePtr node) +{ + xmlChar *tmp; + int x = 0, y = 0, width = -1, height = -1; + gboolean success = TRUE; + + g_return_if_fail (window != NULL); + + tmp = xmlGetProp (node, (xmlChar *) "x"); + success &= int_from_string ((char *) tmp, &x); + xmlFree (tmp); + tmp = xmlGetProp (node, (xmlChar *) "y"); + success &= int_from_string ((char *) tmp, &y); + xmlFree (tmp); + tmp = xmlGetProp (node, (xmlChar *) "width"); + success &= int_from_string ((char *) tmp, &width); + xmlFree (tmp); + tmp = xmlGetProp (node, (xmlChar *) "height"); + success &= int_from_string ((char *) tmp, &height); + xmlFree (tmp); + + if (success) + { + gtk_window_move (window, x, y); + gtk_window_set_default_size (window, width, height); + } +} /* * ephy_session_load: * @session: a #EphySession @@ -716,7 +767,9 @@ ephy_session_load (EphySession *session, if (xmlStrEqual (child->name, (const xmlChar *) "window")) { widget = GTK_WIDGET (ephy_window_new ()); + restore_geometry (GTK_WINDOW (widget), child); parse_embed (child->children, EPHY_WINDOW (widget)); + gtk_window_present (GTK_WINDOW (widget)); } else if (xmlStrEqual (child->name, (const xmlChar *) "toolwindow")) { @@ -738,29 +791,9 @@ ephy_session_load (EphySession *session, widget = ephy_shell_get_history_window (ephy_shell); } } - } - if (widget) - { - xmlChar *tmp; - gulong x = 0, y = 0, width = 0, height = 0; - - tmp = xmlGetProp (child, (xmlChar *) "x"); - ephy_string_to_int ((char *) tmp, &x); - xmlFree (tmp); - tmp = xmlGetProp (child, (xmlChar *) "y"); - ephy_string_to_int ((char *) tmp, &y); - xmlFree (tmp); - tmp = xmlGetProp (child, (xmlChar *) "width"); - ephy_string_to_int ((char *) tmp, &width); - xmlFree (tmp); - tmp = xmlGetProp (child, (xmlChar *) "height"); - ephy_string_to_int ((char *) tmp, &height); - xmlFree (tmp); - gtk_window_move (GTK_WINDOW (widget), x, y); - gtk_window_set_default_size (GTK_WINDOW (widget), - width, height); - gtk_widget_show (widget); + restore_geometry (GTK_WINDOW (widget), child); + gtk_window_present (GTK_WINDOW (widget)); } child = child->next; |