diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | lib/ephy-state.c | 8 | ||||
-rw-r--r-- | src/ephy-session.c | 79 | ||||
-rw-r--r-- | src/ephy-window.c | 1 |
4 files changed, 71 insertions, 27 deletions
@@ -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..70e8ae5a8 100644 --- a/lib/ephy-state.c +++ b/lib/ephy-state.c @@ -124,16 +124,16 @@ 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; - +g_print("ephy-state!\n"); width = ephy_node_get_property_int (node, EPHY_NODE_STATE_PROP_WIDTH); height = ephy_node_get_property_int (node, EPHY_NODE_STATE_PROP_HEIGHT); 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 6ff0eaa73..b80543493 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/gtkdialog.h> #include <gtk/gtkimage.h> #include <gtk/gtklabel.h> @@ -512,7 +514,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 */ @@ -711,6 +713,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_print ("restore geometry!\n"); + 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 @@ -751,7 +802,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")) { @@ -773,29 +826,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; diff --git a/src/ephy-window.c b/src/ephy-window.c index 8c6439644..5e97ca14d 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2658,6 +2658,7 @@ ephy_window_show (GtkWidget *widget) if (!window->priv->has_size) { +g_print ("initial show!\n"); EphyTab *tab; int width, height; |