aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--lib/ephy-state.c6
-rw-r--r--src/ephy-session.c79
3 files changed, 69 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index af2243ab4..8b324ff10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
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.
+
+2004-10-30 Christian Persch <chpe@cvs.gnome.org>
+
* configure.ac:
Check for nsIDOMNSEvent::GetIsTrusted.
diff --git a/lib/ephy-state.c b/lib/ephy-state.c
index 32e4f1c48..04fa76d83 100644
--- a/lib/ephy-state.c
+++ b/lib/ephy-state.c
@@ -124,8 +124,7 @@ ensure_states (void)
static void
ephy_state_window_set_size (GtkWidget *window, EphyNode *node)
{
- int width;
- int height;
+ int width, height, w = -1, h = -1;
gboolean maximize, size;
width = ephy_node_get_property_int (node, EPHY_NODE_STATE_PROP_WIDTH);
@@ -133,7 +132,8 @@ ephy_state_window_set_size (GtkWidget *window, EphyNode *node)
maximize = ephy_node_get_property_boolean (node, EPHY_NODE_STATE_PROP_MAXIMIZE);
size = ephy_node_get_property_boolean (node, EPHY_NODE_STATE_PROP_SIZE);
- if (size)
+ gtk_window_get_default_size (GTK_WINDOW (window), &w, &h);
+ if (size && w == -1 && h == -1)
{
GdkScreen *screen;
int screen_width, screen_height;
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;