From 65ace942fdabfd6116163a21eec7cd7bbd3cbcb1 Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Mon, 25 Jul 2011 19:06:10 +0000 Subject: introduce getter and setter functions. some variables didn't always have a value reflecting the browser's internal state. for example, if `default_encoding` was never set then `print @default_encoding` would always print a blank string. this introduces getter functions that ensure the value of a variable is always in sync with the internal state of the browser. also: setters, because sometimes you need to process user input before storing it. --- src/uzbl-core.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'src/uzbl-core.c') diff --git a/src/uzbl-core.c b/src/uzbl-core.c index b233f8b..8449c28 100644 --- a/src/uzbl-core.c +++ b/src/uzbl-core.c @@ -926,21 +926,6 @@ void handle_authentication (SoupSession *session, SoupMessage *msg, SoupAuth *au } } -void -retrieve_geometry() { - int w, h, x, y; - GString *buf = g_string_new(""); - - gtk_window_get_size(GTK_WINDOW(uzbl.gui.main_window), &w, &h); - gtk_window_get_position(GTK_WINDOW(uzbl.gui.main_window), &x, &y); - - g_string_printf(buf, "%dx%d+%d+%d", w, h, x, y); - - if(uzbl.gui.geometry) - g_free(uzbl.gui.geometry); - uzbl.gui.geometry = g_string_free(buf, FALSE); -} - /* Set up gtk, gobject, variable defaults and other things that tests and other * external applications need to do anyhow */ void @@ -1097,11 +1082,10 @@ main (int argc, char* argv[]) { builtins(); /* Check uzbl is in window mode before getting/setting geometry */ - if (uzbl.gui.main_window) { - if (uzbl.gui.geometry) - set_geometry(); - else - retrieve_geometry(); + if (uzbl.gui.main_window && uzbl.gui.geometry) { + gchar *geometry = g_strdup(uzbl.gui.geometry); + set_geometry(geometry); + g_free(geometry); } gchar *uri_override = (uzbl.state.uri ? g_strdup(uzbl.state.uri) : NULL); -- cgit v1.2.3