[epiphany] ephy-session: use ephy_string_to_int instead of reimplementing it
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-session: use ephy_string_to_int instead of reimplementing it
- Date: Fri, 31 Aug 2012 12:46:45 +0000 (UTC)
commit 293e537064e497f2e54ffa74d1d969d651e804e1
Author: Xan Lopez <xan igalia com>
Date: Fri Aug 31 14:44:50 2012 +0200
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 files changed, 8 insertions(+), 30 deletions(-)
---
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 5ba1664..6674ee1 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)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]