diff options
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | lib/ephy-node.c | 17 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 120 |
3 files changed, 94 insertions, 55 deletions
@@ -1,5 +1,17 @@ 2003-04-27 Marco Pesenti Gritti <marco@it.gnome.org> + * lib/ephy-node.c: (real_remove_child): + + Emit removed signal after the node is actually removed. + This could cause bugs, test test test ;) + + * src/bookmarks/ephy-bookmarks.c: (topics_removed_cb): + + Update topics list and uncategorized folder on topics + removal. + +2003-04-27 Marco Pesenti Gritti <marco@it.gnome.org> + * src/bookmarks/ephy-bookmarks-editor.c: (ephy_bookmarks_editor_update_menu), (view_selection_changed_cb), (ephy_bookmarks_editor_construct): diff --git a/lib/ephy-node.c b/lib/ephy-node.c index 42477c6f3..387d85e38 100644 --- a/lib/ephy-node.c +++ b/lib/ephy-node.c @@ -1155,14 +1155,6 @@ real_remove_child (EphyNode *node, { EphyNodeParent *node_info; - write_lock_to_read_lock (node); - write_lock_to_read_lock (child); - - g_signal_emit (G_OBJECT (node), ephy_node_signals[CHILD_REMOVED], 0, child); - - read_lock_to_write_lock (node); - read_lock_to_write_lock (child); - node_info = g_hash_table_lookup (child->priv->parents, GINT_TO_POINTER (node->priv->id)); @@ -1193,6 +1185,15 @@ real_remove_child (EphyNode *node, g_hash_table_remove (child->priv->parents, GINT_TO_POINTER (node->priv->id)); } + + write_lock_to_read_lock (node); + write_lock_to_read_lock (child); + + g_signal_emit (G_OBJECT (node), ephy_node_signals[CHILD_REMOVED], 0, child); + + read_lock_to_write_lock (node); + read_lock_to_write_lock (child); + } void diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index 955a7ef35..99e5d5078 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -460,12 +460,85 @@ bookmarks_removed_cb (EphyNode *node, ephy_bookmarks_emit_data_changed (eb); } +static char * +get_topics_list (EphyBookmarks *eb, + EphyNode *bookmark, + gboolean *no_topics) +{ + GPtrArray *children; + int i; + GString *list; + + list = g_string_new (NULL); + *no_topics = TRUE; + + children = ephy_node_get_children (eb->priv->keywords); + for (i = 0; i < children->len; i++) + { + EphyNode *kid; + + kid = g_ptr_array_index (children, i); + + if (kid != eb->priv->notcategorized && + kid != eb->priv->favorites && + kid != eb->priv->bookmarks && + ephy_node_has_child (kid, bookmark)) + { + const char *topic; + topic = ephy_node_get_property_string + (kid, EPHY_NODE_KEYWORD_PROP_NAME); + g_string_append (list, topic); + no_topics = FALSE; + } + } + ephy_node_thaw (eb->priv->keywords); + + return g_string_free (list, FALSE); +} + +static void +update_topics_list (EphyNode *bookmark, const char *list) +{ + GValue value = { 0, }; + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, list); + ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS, + &value); + g_value_unset (&value); +} + + static void topics_removed_cb (EphyNode *node, EphyNode *child, EphyBookmarks *eb) { long id; + GPtrArray *children; + int i; + + children = ephy_node_get_children (child); + for (i = 0; i < children->len; i++) + { + EphyNode *kid; + gboolean no_topics; + char *list; + + kid = g_ptr_array_index (children, i); + list = get_topics_list (eb, kid, &no_topics); + + if (no_topics && + !ephy_node_has_child (eb->priv->notcategorized, kid)) + { + ephy_node_add_child + (eb->priv->notcategorized, kid); + } + + update_topics_list (kid, list); + + g_free (list); + } + ephy_node_thaw (child); id = ephy_node_get_id (child); g_signal_emit (eb, ephy_bookmarks_signals[TOPIC_REMOVE], @@ -920,53 +993,6 @@ ephy_bookmarks_has_keyword (EphyBookmarks *eb, return ephy_node_has_child (keyword, bookmark); } -static char * -get_topics_list (EphyBookmarks *eb, - EphyNode *bookmark, - gboolean *no_topics) -{ - GPtrArray *children; - int i; - GString *list; - - list = g_string_new (NULL); - *no_topics = TRUE; - - children = ephy_node_get_children (eb->priv->keywords); - for (i = 0; i < children->len; i++) - { - EphyNode *kid; - - kid = g_ptr_array_index (children, i); - - if (kid != eb->priv->notcategorized && - kid != eb->priv->favorites && - kid != eb->priv->bookmarks && - ephy_node_has_child (kid, bookmark)) - { - const char *topic; - topic = ephy_node_get_property_string - (kid, EPHY_NODE_KEYWORD_PROP_NAME); - g_string_append (list, topic); - no_topics = FALSE; - } - } - ephy_node_thaw (eb->priv->keywords); - - return g_string_free (list, FALSE); -} - -static void -update_topics_list (EphyNode *bookmark, const char *list) -{ - GValue value = { 0, }; - g_value_init (&value, G_TYPE_STRING); - g_value_set_string (&value, list); - ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS, - &value); - g_value_unset (&value); -} - void ephy_bookmarks_set_keyword (EphyBookmarks *eb, EphyNode *keyword, |