aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-history.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-11-01 21:43:47 +0800
committerChristian Persch <chpe@src.gnome.org>2003-11-01 21:43:47 +0800
commit3dd224ab9286d3099a503d21a0771417372b377e (patch)
tree98edf929a0a041cad9942dcb37a64384bba34ba1 /embed/ephy-history.c
parent0cbb825713bb897942a709b09f98d0f123075794 (diff)
downloadgsoc2013-epiphany-3dd224ab9286d3099a503d21a0771417372b377e.tar
gsoc2013-epiphany-3dd224ab9286d3099a503d21a0771417372b377e.tar.gz
gsoc2013-epiphany-3dd224ab9286d3099a503d21a0771417372b377e.tar.bz2
gsoc2013-epiphany-3dd224ab9286d3099a503d21a0771417372b377e.tar.lz
gsoc2013-epiphany-3dd224ab9286d3099a503d21a0771417372b377e.tar.xz
gsoc2013-epiphany-3dd224ab9286d3099a503d21a0771417372b377e.tar.zst
gsoc2013-epiphany-3dd224ab9286d3099a503d21a0771417372b377e.zip
Only save history db if there have been changes. Fixes bug #125973.
2003-11-01 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-history.c: (ephy_history_save), (hosts_added_cb), (hosts_removed_cb), (hosts_changed_cb), (pages_added_cb), (pages_removed_cb), (pages_changed_cb), (ephy_history_init): Only save history db if there have been changes. Fixes bug #125973.
Diffstat (limited to 'embed/ephy-history.c')
-rw-r--r--embed/ephy-history.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/embed/ephy-history.c b/embed/ephy-history.c
index 1c4cb3b28..1f269af70 100644
--- a/embed/ephy-history.c
+++ b/embed/ephy-history.c
@@ -57,6 +57,7 @@ struct EphyHistoryPrivate
GStaticRWLock *pages_hash_lock;
int autosave_timeout;
guint update_hosts_idle;
+ gboolean dirty;
};
enum
@@ -183,6 +184,12 @@ ephy_history_save (EphyHistory *eb)
LOG ("Saving history")
+ /* only save if there are changes */
+ if (eb->priv->dirty == FALSE)
+ {
+ return;
+ }
+
/* save nodes to xml */
xmlIndentTreeOutput = TRUE;
doc = xmlNewDoc ("1.0");
@@ -214,7 +221,12 @@ ephy_history_save (EphyHistory *eb)
}
ephy_node_thaw (eb->priv->pages);
- ephy_file_save_xml (eb->priv->xml_file, doc);
+ if (ephy_file_save_xml (eb->priv->xml_file, doc))
+ {
+ /* save was successful */
+ eb->priv->dirty = FALSE;
+ }
+
xmlFreeDoc(doc);
}
@@ -223,6 +235,8 @@ hosts_added_cb (EphyNode *node,
EphyNode *child,
EphyHistory *eb)
{
+ eb->priv->dirty = TRUE;
+
g_static_rw_lock_writer_lock (eb->priv->hosts_hash_lock);
g_hash_table_insert (eb->priv->hosts_hash,
@@ -238,6 +252,8 @@ hosts_removed_cb (EphyNode *node,
guint old_index,
EphyHistory *eb)
{
+ eb->priv->dirty = TRUE;
+
g_static_rw_lock_writer_lock (eb->priv->hosts_hash_lock);
g_hash_table_remove (eb->priv->hosts_hash,
@@ -247,10 +263,20 @@ hosts_removed_cb (EphyNode *node,
}
static void
+hosts_changed_cb (EphyNode *node,
+ EphyNode *child,
+ EphyHistory *eb)
+{
+ eb->priv->dirty = TRUE;
+}
+
+static void
pages_added_cb (EphyNode *node,
EphyNode *child,
EphyHistory *eb)
{
+ eb->priv->dirty = TRUE;
+
g_static_rw_lock_writer_lock (eb->priv->pages_hash_lock);
g_hash_table_insert (eb->priv->pages_hash,
@@ -266,6 +292,8 @@ pages_removed_cb (EphyNode *node,
guint old_index,
EphyHistory *eb)
{
+ eb->priv->dirty = TRUE;
+
g_static_rw_lock_writer_lock (eb->priv->pages_hash_lock);
g_hash_table_remove (eb->priv->pages_hash,
@@ -274,6 +302,14 @@ pages_removed_cb (EphyNode *node,
g_static_rw_lock_writer_unlock (eb->priv->pages_hash_lock);
}
+static void
+pages_changed_cb (EphyNode *node,
+ EphyNode *child,
+ EphyHistory *eb)
+{
+ eb->priv->dirty = TRUE;
+}
+
static gboolean
periodic_save_cb (EphyHistory *eh)
{
@@ -436,6 +472,10 @@ ephy_history_init (EphyHistory *eb)
EPHY_NODE_CHILD_REMOVED,
(EphyNodeCallback) pages_removed_cb,
G_OBJECT (eb));
+ ephy_node_signal_connect_object (eb->priv->pages,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback) pages_changed_cb,
+ G_OBJECT (eb));
/* Hosts */
eb->priv->hosts = ephy_node_new_with_id (db, HOSTS_NODE_ID);
@@ -448,6 +488,10 @@ ephy_history_init (EphyHistory *eb)
EPHY_NODE_CHILD_REMOVED,
(EphyNodeCallback) hosts_removed_cb,
G_OBJECT (eb));
+ ephy_node_signal_connect_object (eb->priv->hosts,
+ EPHY_NODE_CHILD_CHANGED,
+ (EphyNodeCallback) hosts_changed_cb,
+ G_OBJECT (eb));
ephy_node_add_child (eb->priv->hosts, eb->priv->pages);
@@ -459,6 +503,9 @@ ephy_history_init (EphyHistory *eb)
(GHFunc) connect_page_removed_from_host,
eb);
+ /* mark as clean */
+ eb->priv->dirty = FALSE;
+
/* setup the periodic history saving callback */
eb->priv->autosave_timeout =
g_timeout_add (HISTORY_SAVE_INTERVAL,