From 6f07210d4d0e04a50dd64ca447952ef18ce07b8b Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Mon, 6 Aug 2007 09:16:45 +0000 Subject: Make ephy_history_set_enabled actually disable history and not delete it. 2007-08-06 Diego Escalante Urrelo * embed/ephy-history.c: * embed/ephy-history.h: Make ephy_history_set_enabled actually disable history and not delete it. Also make it public. svn path=/trunk/; revision=7244 --- embed/ephy-history.c | 56 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 18 deletions(-) (limited to 'embed/ephy-history.c') diff --git a/embed/ephy-history.c b/embed/ephy-history.c index bc84c4bca..a59314865 100644 --- a/embed/ephy-history.c +++ b/embed/ephy-history.c @@ -124,22 +124,6 @@ ephy_history_get_type (void) return type; } -static void -ephy_history_set_enabled (EphyHistory *history, - gboolean enabled) -{ - LOG ("ephy_history_set_enabled %d", enabled); - - history->priv->enabled = enabled; - - ephy_node_db_set_immutable (history->priv->db, !enabled); - - if (enabled == FALSE) - { - ephy_history_clear (history); - } -} - static void ephy_history_set_property (GObject *object, guint prop_id, @@ -169,7 +153,7 @@ ephy_history_get_property (GObject *object, case PROP_ENABLED: g_value_set_boolean (value, history->priv->enabled); break; - } + } } static void @@ -288,7 +272,7 @@ ephy_history_save (EphyHistory *eb) int ret; /* only save if there are changes */ - if (eb->priv->dirty == FALSE) + if (eb->priv->dirty == FALSE && eb->priv->enabled) { return; } @@ -1031,3 +1015,39 @@ ephy_history_is_enabled (EphyHistory *history) return history->priv->enabled; } + +void +ephy_history_set_enabled (EphyHistory *history, + gboolean enabled) +{ + int ret; + + ret = 1; + + LOG ("ephy_history_set_enabled %d", enabled); + + /* Write history only when disabling it, not when reenabling it */ + if (!enabled && history->priv->dirty) + { + ret = ephy_node_db_write_to_xml_safe + (history->priv->db, (const xmlChar *)history->priv->xml_file, + EPHY_HISTORY_XML_ROOT, + EPHY_HISTORY_XML_VERSION, + NULL, /* comment */ + history->priv->hosts, + (EphyNodeFilterFunc) save_filter, history->priv->pages, + history->priv->pages, NULL, NULL, + NULL); + } + + if (ret >=0) + { + /* save was successful */ + history->priv->dirty = FALSE; + } + + history->priv->enabled = enabled; + + ephy_node_db_set_immutable (history->priv->db, !enabled); +} + -- cgit v1.2.3