From 293e537064e497f2e54ffa74d1d969d651e804e1 Mon Sep 17 00:00:00 2001 From: Xan Lopez Date: Fri, 31 Aug 2012 14:44:50 +0200 Subject: ephy-session: use ephy_string_to_int instead of reimplementing it EphySession had a private, almost-identical copy. Just use the function in lib/ephy-string.[ch] --- src/ephy-session.c | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) (limited to 'src/ephy-session.c') diff --git a/src/ephy-session.c b/src/ephy-session.c index 5ba166447..6674ee108 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -35,6 +35,7 @@ #include "ephy-prefs.h" #include "ephy-settings.h" #include "ephy-shell.h" +#include "ephy-string.h" #include "ephy-window.h" #include @@ -1017,49 +1018,27 @@ parse_embed (xmlNodePtr child, } } -static gboolean -int_from_string (const char *string, - int *retval) -{ - char *tail = NULL; - long int val; - gboolean success = FALSE; - - if (string == NULL) return 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; + gulong x = 0, y = 0, width = 0, height = 0; gboolean success = TRUE; g_return_if_fail (window != NULL); tmp = xmlGetProp (node, (xmlChar *) "x"); - success &= int_from_string ((char *) tmp, &x); + success &= ephy_string_to_int ((char *) tmp, &x); xmlFree (tmp); tmp = xmlGetProp (node, (xmlChar *) "y"); - success &= int_from_string ((char *) tmp, &y); + success &= ephy_string_to_int ((char *) tmp, &y); xmlFree (tmp); tmp = xmlGetProp (node, (xmlChar *) "width"); - success &= int_from_string ((char *) tmp, &width); + success &= ephy_string_to_int ((char *) tmp, &width); xmlFree (tmp); tmp = xmlGetProp (node, (xmlChar *) "height"); - success &= int_from_string ((char *) tmp, &height); + success &= ephy_string_to_int ((char *) tmp, &height); xmlFree (tmp); if (success) @@ -1073,7 +1052,6 @@ restore_geometry (GtkWindow *window, gtk_window_move (window, x, y); gtk_window_set_default_size (window, width, height); - } } @@ -1162,9 +1140,9 @@ ephy_session_load_from_string (EphySession *session, if (tmp != NULL) { gboolean success; - int active_tab; + gulong active_tab; - success = int_from_string ((char *) tmp, &active_tab); + success = ephy_string_to_int ((char *) tmp, &active_tab); xmlFree (tmp); if (success) { -- cgit v1.2.3