aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-state.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-09-18 06:04:47 +0800
committerChristian Persch <chpe@src.gnome.org>2003-09-18 06:04:47 +0800
commit6d93635b94a93ff3188e88a46393083fbca7e603 (patch)
treeec38e729d6ce9251ad0ce2f737168e483ff979d9 /lib/ephy-state.c
parentff09416c7a185b6774c5f1e04c9673c9f0d86f71 (diff)
downloadgsoc2013-epiphany-6d93635b94a93ff3188e88a46393083fbca7e603.tar.gz
gsoc2013-epiphany-6d93635b94a93ff3188e88a46393083fbca7e603.tar.zst
gsoc2013-epiphany-6d93635b94a93ff3188e88a46393083fbca7e603.zip
Refactor node db loading functions into a common one in ephy-node-db.
2003-09-18 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-favicon-cache.c: (ephy_favicon_cache_init): * embed/ephy-history.c: (ephy_history_init): * lib/ephy-node-db.c: (ephy_node_db_load_from_file): * lib/ephy-node-db.h: * lib/ephy-state.c: (ensure_states): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_init): Refactor node db loading functions into a common one in ephy-node-db. Switch to using xmlReader api.
Diffstat (limited to 'lib/ephy-state.c')
-rw-r--r--lib/ephy-state.c57
1 files changed, 12 insertions, 45 deletions
diff --git a/lib/ephy-state.c b/lib/ephy-state.c
index 3cbcb5020..822f9f393 100644
--- a/lib/ephy-state.c
+++ b/lib/ephy-state.c
@@ -30,6 +30,7 @@
#include <gtk/gtkpaned.h>
#define STATES_FILE "states.xml"
+#define EPHY_STATES_XML_ROOT "ephy_states"
#define EPHY_STATES_XML_VERSION "1.0"
enum
@@ -48,50 +49,6 @@ static EphyNode *states = NULL;
static EphyNodeDb *states_db = NULL;
static void
-ephy_states_load (void)
-{
- xmlDocPtr doc;
- xmlNodePtr root, child;
- char *xml_file;
- char *tmp;
-
- xml_file = g_build_filename (ephy_dot_dir (),
- STATES_FILE,
- NULL);
-
- if (g_file_test (xml_file, G_FILE_TEST_EXISTS) == FALSE)
- return;
-
- doc = xmlParseFile (xml_file);
- g_assert (doc != NULL);
-
- root = xmlDocGetRootElement (doc);
-
- tmp = xmlGetProp (root, "version");
- if (tmp != NULL && strcmp (tmp, EPHY_STATES_XML_VERSION) == 0)
- {
- child = root->children;
- }
- else
- {
- g_warning ("Old version of states.xml discarded");
- child = NULL;
- }
- g_free (tmp);
-
- for (; child != NULL; child = child->next)
- {
- EphyNode *node;
-
- node = ephy_node_new_from_xml (states_db, child);
- }
-
- xmlFreeDoc (doc);
-
- g_free (xml_file);
-}
-
-static void
ephy_states_save (void)
{
xmlDocPtr doc;
@@ -161,9 +118,19 @@ ensure_states (void)
{
if (states == NULL)
{
+ char *xml_file;
+
+ xml_file = g_build_filename (ephy_dot_dir (),
+ STATES_FILE,
+ NULL);
+
states_db = ephy_node_db_new (EPHY_NODE_DB_STATES);
states = ephy_node_new_with_id (states_db, STATES_NODE_ID);
- ephy_states_load ();
+ ephy_node_db_load_from_file (states_db, xml_file,
+ EPHY_STATES_XML_ROOT,
+ EPHY_STATES_XML_VERSION);
+
+ g_free (xml_file);
}
}