aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-05-25 06:37:40 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-05-25 06:37:40 +0800
commita13c22de498a4d994644ee3e97a4ecabec42c805 (patch)
tree591a08d0c0b5b58370506e875e92ddd914f6b62c /src/bookmarks
parent5402d87b1b65023672ec302aca8203af0850f33e (diff)
downloadgsoc2013-epiphany-a13c22de498a4d994644ee3e97a4ecabec42c805.tar
gsoc2013-epiphany-a13c22de498a4d994644ee3e97a4ecabec42c805.tar.gz
gsoc2013-epiphany-a13c22de498a4d994644ee3e97a4ecabec42c805.tar.bz2
gsoc2013-epiphany-a13c22de498a4d994644ee3e97a4ecabec42c805.tar.lz
gsoc2013-epiphany-a13c22de498a4d994644ee3e97a4ecabec42c805.tar.xz
gsoc2013-epiphany-a13c22de498a4d994644ee3e97a4ecabec42c805.tar.zst
gsoc2013-epiphany-a13c22de498a4d994644ee3e97a4ecabec42c805.zip
Revert latest node changes. Parents nodes need to be saved first and it's
2003-05-25 Marco Pesenti Gritti <marco@it.gnome.org> * embed/ephy-favicon-cache.c: (ephy_favicon_cache_load), (ephy_favicon_cache_save), (ephy_favicon_cache_init), (ephy_favicon_cache_finalize): * embed/ephy-history.c: (ephy_history_load), (ephy_history_save), (ephy_history_init): * lib/ephy-node-db.c: (ephy_node_db_get_property), (ephy_node_db_set_property), (ephy_node_db_class_init), (ephy_node_db_init), (ephy_node_db_finalize), (ephy_node_db_new), (_ephy_node_db_remove_id): * lib/ephy-node-db.h: * lib/ephy-node.c: (ephy_node_save_to_xml): * lib/ephy-node.h: * lib/ephy-state.c: (ephy_states_load), (ephy_states_save), (ensure_states): * src/bookmarks/ephy-bookmarks.c: (ephy_bookmarks_load), (ephy_bookmarks_save), (ephy_bookmarks_init): Revert latest node changes. Parents nodes need to be saved first and it's easier to do that in a not generic way :/
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmarks.c73
1 files changed, 70 insertions, 3 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index dd747559e..9e7c9dacc 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -265,15 +265,82 @@ ephy_bookmarks_init_defaults (EphyBookmarks *eb)
static gboolean
ephy_bookmarks_load (EphyBookmarks *eb)
{
- return ephy_node_db_load_from_xml (eb->priv->db, eb->priv->xml_file);
+ xmlDocPtr doc;
+ xmlNodePtr root, child;
+ char *tmp;
+
+ if (g_file_test (eb->priv->xml_file, G_FILE_TEST_EXISTS) == FALSE)
+ return FALSE;
+
+ doc = xmlParseFile (eb->priv->xml_file);
+ g_return_val_if_fail (doc != NULL, FALSE);
+
+ root = xmlDocGetRootElement (doc);
+
+ tmp = xmlGetProp (root, "version");
+ g_assert (tmp != NULL && strcmp (tmp, EPHY_BOOKMARKS_XML_VERSION) == 0);
+ g_free (tmp);
+
+ for (child = root->children; child != NULL; child = child->next)
+ {
+ EphyNode *node;
+
+ node = ephy_node_new_from_xml (eb->priv->db, child);
+ }
+
+ xmlFreeDoc (doc);
+
+ return TRUE;
}
void
ephy_bookmarks_save (EphyBookmarks *eb)
{
+ xmlDocPtr doc;
+ xmlNodePtr root;
+ GPtrArray *children;
+ int i;
char *rdf_file;
- ephy_node_db_save_to_xml (eb->priv->db, eb->priv->xml_file);
+ LOG ("Saving bookmarks")
+
+ /* save nodes to xml */
+ xmlIndentTreeOutput = TRUE;
+ doc = xmlNewDoc ("1.0");
+
+ root = xmlNewDocNode (doc, NULL, "ephy_bookmarks", NULL);
+ xmlSetProp (root, "version", EPHY_BOOKMARKS_XML_VERSION);
+ xmlDocSetRootElement (doc, root);
+
+ children = ephy_node_get_children (eb->priv->keywords);
+ for (i = 0; i < children->len; i++)
+ {
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+
+ if (kid != eb->priv->bookmarks &&
+ kid != eb->priv->favorites &&
+ kid != eb->priv->notcategorized)
+ {
+ ephy_node_save_to_xml (kid, root);
+ }
+ }
+ ephy_node_thaw (eb->priv->keywords);
+
+ children = ephy_node_get_children (eb->priv->bookmarks);
+ 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 (eb->priv->bookmarks);
+
+ xmlSaveFormatFile (eb->priv->xml_file, doc, 1);
+ xmlFreeDoc(doc);
/* Export bookmarks in rdf */
rdf_file = g_build_filename (ephy_dot_dir (),
@@ -519,7 +586,7 @@ ephy_bookmarks_init (EphyBookmarks *eb)
eb->priv = g_new0 (EphyBookmarksPrivate, 1);
- db = ephy_node_db_new ("EphyBookmarks", EPHY_BOOKMARKS_XML_VERSION);
+ db = ephy_node_db_new ("EphyBookmarks");
eb->priv->db = db;
eb->priv->xml_file = g_build_filename (ephy_dot_dir (),