aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-08-31 20:44:50 +0800
committerXan Lopez <xan@igalia.com>2012-08-31 20:44:50 +0800
commit293e537064e497f2e54ffa74d1d969d651e804e1 (patch)
treee2ef7832d88b610665e14743f306cefbc3a6f2a1 /src
parent91b9b4b6aa199d3feac08f8ae8f8398064ab0d44 (diff)
downloadgsoc2013-epiphany-293e537064e497f2e54ffa74d1d969d651e804e1.tar
gsoc2013-epiphany-293e537064e497f2e54ffa74d1d969d651e804e1.tar.gz
gsoc2013-epiphany-293e537064e497f2e54ffa74d1d969d651e804e1.tar.bz2
gsoc2013-epiphany-293e537064e497f2e54ffa74d1d969d651e804e1.tar.lz
gsoc2013-epiphany-293e537064e497f2e54ffa74d1d969d651e804e1.tar.xz
gsoc2013-epiphany-293e537064e497f2e54ffa74d1d969d651e804e1.tar.zst
gsoc2013-epiphany-293e537064e497f2e54ffa74d1d969d651e804e1.zip
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]
Diffstat (limited to 'src')
-rw-r--r--src/ephy-session.c38
1 files changed, 8 insertions, 30 deletions
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 <errno.h>
@@ -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)
{