diff options
author | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-07-06 19:48:37 +0800 |
---|---|---|
committer | Marco Pesenti Gritti <mpeseng@src.gnome.org> | 2003-07-06 19:48:37 +0800 |
commit | 03d457e1fcc30913c79ffbd89a0028cf50426d5c (patch) | |
tree | dcb62e52e32051bf1dc464119a498d6c2167b63a /src | |
parent | e34a73d3a57c3cdba064b6790874ac77dfc60b74 (diff) | |
download | gsoc2013-epiphany-03d457e1fcc30913c79ffbd89a0028cf50426d5c.tar gsoc2013-epiphany-03d457e1fcc30913c79ffbd89a0028cf50426d5c.tar.gz gsoc2013-epiphany-03d457e1fcc30913c79ffbd89a0028cf50426d5c.tar.bz2 gsoc2013-epiphany-03d457e1fcc30913c79ffbd89a0028cf50426d5c.tar.lz gsoc2013-epiphany-03d457e1fcc30913c79ffbd89a0028cf50426d5c.tar.xz gsoc2013-epiphany-03d457e1fcc30913c79ffbd89a0028cf50426d5c.tar.zst gsoc2013-epiphany-03d457e1fcc30913c79ffbd89a0028cf50426d5c.zip |
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/ephy-bookmarks-import.c | 4 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 42 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.h | 2 | ||||
-rw-r--r-- | src/bookmarks/ephy-new-bookmark.c | 2 |
4 files changed, 37 insertions, 13 deletions
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 |