aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--embed/ephy-favicon-cache.c9
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c4
-rw-r--r--src/bookmarks/ephy-bookmarks.c42
-rw-r--r--src/bookmarks/ephy-bookmarks.h2
-rw-r--r--src/bookmarks/ephy-new-bookmark.c2
5 files changed, 39 insertions, 20 deletions
diff --git a/embed/ephy-favicon-cache.c b/embed/ephy-favicon-cache.c
index b4fdc2884..d5b7374b3 100644
--- a/embed/ephy-favicon-cache.c
+++ b/embed/ephy-favicon-cache.c
@@ -29,7 +29,7 @@
#include "ephy-node.h"
#include "ephy-debug.h"
-#define EPHY_FAVICON_CACHE_XML_VERSION "0.1"
+#define EPHY_FAVICON_CACHE_XML_VERSION "1.0"
#define EPHY_FAVICON_CACHE_OBSOLETE_DAYS 30
@@ -124,7 +124,6 @@ ephy_favicon_cache_load (EphyFaviconCache *eb)
{
xmlDocPtr doc;
xmlNodePtr root, child;
- char *tmp;
if (g_file_test (eb->priv->xml_file, G_FILE_TEST_EXISTS) == FALSE)
return;
@@ -134,10 +133,6 @@ ephy_favicon_cache_load (EphyFaviconCache *eb)
root = xmlDocGetRootElement (doc);
- tmp = xmlGetProp (root, "version");
- g_assert (tmp != NULL && strcmp (tmp, EPHY_FAVICON_CACHE_XML_VERSION) == 0);
- g_free (tmp);
-
for (child = root->children; child != NULL; child = child->next)
{
EphyNode *node;
@@ -265,7 +260,7 @@ ephy_favicon_cache_init (EphyFaviconCache *cache)
cache->priv = g_new0 (EphyFaviconCachePrivate, 1);
- db = ephy_node_db_new ("EphyFaviconCache");
+ db = ephy_node_db_new (EPHY_NODE_DB_SITEICONS);
cache->priv->db = db;
cache->priv->xml_file = g_build_filename (ephy_dot_dir (),
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 8a50fc62c..55deca320 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -421,8 +421,6 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks,
g_string_free (name, TRUE);
g_string_free (url, TRUE);
- ephy_bookmarks_save (bookmarks);
-
return TRUE;
}
@@ -444,7 +442,5 @@ ephy_bookmarks_import_xbel (EphyBookmarks *bookmarks,
xmlFreeDoc (doc);
- ephy_bookmarks_save (bookmarks);
-
return TRUE;
}
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 86e824fc3..7d35dc9e2 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -37,13 +37,15 @@
#include <libgnomevfs/gnome-vfs-utils.h>
#define EPHY_BOOKMARKS_XML_VERSION "0.1"
-
+#define BOOKMARKS_SAVE_DELAY (3 * 1000)
#define MAX_FAVORITES_NUM 10
struct EphyBookmarksPrivate
{
EphyToolbarsModel *toolbars_model;
gboolean init_defaults;
+ gboolean dirty;
+ guint save_timeout_id;
char *xml_file;
EphyNodeDb *db;
EphyNode *bookmarks;
@@ -222,8 +224,6 @@ ephy_bookmarks_init_defaults (EphyBookmarks *eb)
id = ephy_node_get_id (node);
ephy_toolbars_model_add_bookmark (eb->priv->toolbars_model, FALSE, id);
}
-
- ephy_bookmarks_save (eb);
}
static void
@@ -338,7 +338,7 @@ ephy_bookmarks_load (EphyBookmarks *eb)
return TRUE;
}
-void
+static void
ephy_bookmarks_save (EphyBookmarks *eb)
{
xmlDocPtr doc;
@@ -395,6 +395,29 @@ ephy_bookmarks_save (EphyBookmarks *eb)
g_free (rdf_file);
}
+static gboolean
+save_bookmarks_delayed (EphyBookmarks *bookmarks)
+{
+ ephy_bookmarks_save (bookmarks);
+ bookmarks->priv->dirty = FALSE;
+ bookmarks->priv->save_timeout_id = 0;
+
+ return FALSE;
+}
+
+static void
+ephy_bookmarks_set_dirty (EphyBookmarks *bookmarks)
+{
+ if (!bookmarks->priv->dirty)
+ {
+ bookmarks->priv->dirty = TRUE;
+ bookmarks->priv->save_timeout_id =
+ g_timeout_add (BOOKMARKS_SAVE_DELAY,
+ (GSourceFunc) save_bookmarks_delayed,
+ bookmarks);
+ }
+}
+
static double
get_history_item_score (EphyHistory *eh, const char *page)
{
@@ -522,6 +545,7 @@ bookmarks_changed_cb (EphyNode *node,
EphyBookmarks *eb)
{
ephy_bookmarks_emit_data_changed (eb);
+ ephy_bookmarks_set_dirty (eb);
}
static void
@@ -532,6 +556,7 @@ bookmarks_removed_cb (EphyNode *node,
{
ephy_bookmarks_emit_data_changed (eb);
g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
+ ephy_bookmarks_set_dirty (eb);
}
static char *
@@ -629,7 +654,8 @@ ephy_bookmarks_init (EphyBookmarks *eb)
db = ephy_node_db_new ("EphyBookmarks");
eb->priv->db = db;
-
+ eb->priv->dirty = FALSE;
+ eb->priv->save_timeout_id = 0;
eb->priv->xml_file = g_build_filename (ephy_dot_dir (),
"bookmarks.xml",
NULL);
@@ -722,6 +748,11 @@ ephy_bookmarks_finalize (GObject *object)
g_return_if_fail (eb->priv != NULL);
+ if (eb->priv->save_timeout_id != 0)
+ {
+ g_source_remove (eb->priv->save_timeout_id);
+ }
+
ephy_bookmarks_save (eb);
ephy_node_unref (eb->priv->bookmarks);
@@ -801,6 +832,7 @@ ephy_bookmarks_add (EphyBookmarks *eb,
ephy_bookmarks_emit_data_changed (eb);
g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0);
+ ephy_bookmarks_save (eb);
return bm;
}
diff --git a/src/bookmarks/ephy-bookmarks.h b/src/bookmarks/ephy-bookmarks.h
index 2a72a8810..55c03bca0 100644
--- a/src/bookmarks/ephy-bookmarks.h
+++ b/src/bookmarks/ephy-bookmarks.h
@@ -69,8 +69,6 @@ EphyNode *ephy_bookmarks_get_from_id (EphyBookmarks *eb,
/* Bookmarks */
-void ephy_bookmarks_save (EphyBookmarks *eb);
-
EphyNode *ephy_bookmarks_add (EphyBookmarks *eb,
const char *title,
const char *url);
diff --git a/src/bookmarks/ephy-new-bookmark.c b/src/bookmarks/ephy-new-bookmark.c
index 7c3599a2f..8cad27263 100644
--- a/src/bookmarks/ephy-new-bookmark.c
+++ b/src/bookmarks/ephy-new-bookmark.c
@@ -173,8 +173,6 @@ ephy_new_bookmark_add (EphyNewBookmark *new_bookmark)
}
g_free (title);
-
- ephy_bookmarks_save (new_bookmark->priv->bookmarks);
}
static void