aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ephy-state.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ephy-state.c')
-rw-r--r--lib/ephy-state.c45
1 files changed, 4 insertions, 41 deletions
diff --git a/lib/ephy-state.c b/lib/ephy-state.c
index 90d06883c..0703ebddf 100644
--- a/lib/ephy-state.c
+++ b/lib/ephy-state.c
@@ -31,6 +31,7 @@
#define STATES_FILE "states.xml"
#define WINDOW_POSITION_UNSET -1
+#define EPHY_STATES_XML_VERSION "0.1"
enum
{
@@ -48,30 +49,13 @@ static EphyNodeDb *states_db = NULL;
static void
ephy_states_load (void)
{
- xmlDocPtr doc;
- xmlNodePtr root, child;
char *xml_file;
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);
-
- for (child = root->children; child != NULL; child = child->next)
- {
- EphyNode *node;
-
- node = ephy_node_new_from_xml (states_db, child);
- }
-
- xmlFreeDoc (doc);
+ ephy_node_db_load_from_xml (states_db, xml_file);
g_free (xml_file);
}
@@ -79,10 +63,6 @@ ephy_states_load (void)
static void
ephy_states_save (void)
{
- xmlDocPtr doc;
- xmlNodePtr root;
- GPtrArray *children;
- int i;
char *xml_file;
if (states == NULL) return;
@@ -91,25 +71,8 @@ ephy_states_save (void)
STATES_FILE,
NULL);
- /* save nodes to xml */
- xmlIndentTreeOutput = TRUE;
- doc = xmlNewDoc ("1.0");
-
- root = xmlNewDocNode (doc, NULL, "ephy_bookmarks", NULL);
- xmlDocSetRootElement (doc, root);
-
- children = ephy_node_get_children (states);
- for (i = 0; i < children->len; i++)
- {
- EphyNode *kid;
-
- kid = g_ptr_array_index (children, i);
-
- ephy_node_save_to_xml (kid, root);
- }
- ephy_node_thaw (states);
+ ephy_node_db_save_to_xml (states_db, xml_file);
- xmlSaveFormatFile (xml_file, doc, 1);
g_free (xml_file);
}
@@ -145,7 +108,7 @@ ensure_states (void)
{
if (states == NULL)
{
- states_db = ephy_node_db_new ("EphyStates");
+ states_db = ephy_node_db_new ("EphyStates", EPHY_STATES_XML_VERSION);
states = ephy_node_new_with_id (states_db, STATES_NODE_ID);
ephy_states_load ();
}