From e3396ef5e3ae7fd5674eda19a893e7dca88bce35 Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Sat, 10 Jan 2004 16:35:56 +0000 Subject: Implement history disabling. 2004-01-10 Christian Persch * embed/ephy-history.c: (ephy_history_get_type), (ephy_history_set_enabled), (ephy_history_set_property), (ephy_history_get_property), (ephy_history_class_init), (page_removed_from_host_cb), (disable_history_notifier), (ephy_history_init), (ephy_history_finalize), (ephy_history_new), (ephy_history_get_host), (ephy_history_visited), (ephy_history_add_page), (ephy_history_set_page_title), (ephy_history_clear), (ephy_history_is_enabled): * embed/ephy-history.h: * lib/ephy-node-db.c: (ephy_node_db_get_property), (ephy_node_db_set_property), (ephy_node_db_set_immutable): * lib/ephy-node-db.h: * lib/ephy-prefs.h: * src/bookmarks/ephy-bookmarks.c: (clear_favorites), (history_cleared_cb), (ephy_setup_history_notifiers): Implement history disabling. --- src/bookmarks/ephy-bookmarks.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/bookmarks') diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 1a8a703d5..b0b1190fa 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -390,6 +390,41 @@ history_site_visited_cb (EphyHistory *gh, const char *url, EphyBookmarks *eb) add_to_favorites (eb, node, gh); } +static void +clear_favorites (EphyBookmarks *bookmarks) +{ + EphyNode *node; + GPtrArray *children; + int i; + gboolean was_immutable; + + /* clear the favourites */ + + was_immutable = ephy_node_db_is_immutable (bookmarks->priv->db); + ephy_node_db_set_immutable (bookmarks->priv->db, FALSE); + + node = bookmarks->priv->favorites; + children = ephy_node_get_children (node); + for (i = children->len - 1; i >= 0; i--) + { + EphyNode *kid; + + kid = g_ptr_array_index (children, i); + + ephy_node_remove_child (node, kid); + } + + ephy_node_db_set_immutable (bookmarks->priv->db, was_immutable); + + ephy_bookmarks_update_favorites (bookmarks); +} + +static void +history_cleared_cb (EphyHistory *history, EphyBookmarks *bookmarks) +{ + clear_favorites (bookmarks); +} + static void ephy_setup_history_notifiers (EphyBookmarks *eb) { @@ -397,8 +432,15 @@ ephy_setup_history_notifiers (EphyBookmarks *eb) history = EPHY_HISTORY (ephy_embed_shell_get_global_history (embed_shell)); + if (ephy_history_is_enabled (history) == FALSE) + { + clear_favorites (eb); + } + g_signal_connect (history, "visited", G_CALLBACK (history_site_visited_cb), eb); + g_signal_connect (history, "cleared", + G_CALLBACK (history_cleared_cb), eb); } static void -- cgit v1.2.3