diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bookmarks/ephy-bookmark-action.c | 5 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks-menu.c | 5 | ||||
-rw-r--r-- | src/bookmarks/ephy-bookmarks.c | 115 | ||||
-rw-r--r-- | src/bookmarks/ephy-topic-action.c | 5 | ||||
-rw-r--r-- | src/ephy-completion-model.c | 1 | ||||
-rw-r--r-- | src/ephy-location-action.c | 1 |
6 files changed, 80 insertions, 52 deletions
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c index 7d7c27f0e..ee2104506 100644 --- a/src/bookmarks/ephy-bookmark-action.c +++ b/src/bookmarks/ephy-bookmark-action.c @@ -509,7 +509,10 @@ sync_bookmark_properties (GtkAction *action, EphyNode *bmk) } static void -bookmarks_child_changed_cb (EphyNode *node, EphyNode *child, GtkAction *action) +bookmarks_child_changed_cb (EphyNode *node, + EphyNode *child, + guint property_id, + GtkAction *action) { gulong id; diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c index 8e6e6a140..c3e8e944c 100644 --- a/src/bookmarks/ephy-bookmarks-menu.c +++ b/src/bookmarks/ephy-bookmarks-menu.c @@ -414,7 +414,10 @@ sync_topic_properties (GtkAction *action, EphyNode *bmk) } static void -topic_child_changed_cb (EphyNode *node, EphyNode *child, EphyBookmarksMenu *menu) +topic_child_changed_cb (EphyNode *node, + EphyNode *child, + guint property_id, + EphyBookmarksMenu *menu) { GtkAction *action; char name[64]; diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c index a8be4a515..4b460a577 100644 --- a/src/bookmarks/ephy-bookmarks.c +++ b/src/bookmarks/ephy-bookmarks.c @@ -440,10 +440,67 @@ ephy_setup_history_notifiers (EphyBookmarks *eb) } static void +update_bookmark_keywords (EphyBookmarks *eb, EphyNode *bookmark) +{ + GValue value = { 0, }; + GPtrArray *children; + int i; + GString *list; + const char *title; + char *normalized_keywords, *case_normalized_keywords; + + list = g_string_new (NULL); + + 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); + g_string_append (list, " "); + } + } + + title = ephy_node_get_property_string + (bookmark, EPHY_NODE_BMK_PROP_TITLE); + g_string_append (list, " "); + g_string_append (list, title); + + normalized_keywords = g_utf8_normalize (list->str, -1, G_NORMALIZE_ALL); + case_normalized_keywords = g_utf8_casefold (normalized_keywords, -1); + + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, case_normalized_keywords); + ephy_node_set_property (bookmark, EPHY_NODE_BMK_PROP_KEYWORDS, + &value); + g_value_unset (&value); + + g_string_free (list, TRUE); + g_free (normalized_keywords); + g_free (case_normalized_keywords); +} + +static void bookmarks_changed_cb (EphyNode *node, EphyNode *child, + guint property_id, EphyBookmarks *eb) { + if (property_id == EPHY_NODE_BMK_PROP_TITLE) + { + update_bookmark_keywords (eb, child); + } + ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY); } @@ -457,17 +514,11 @@ bookmarks_removed_cb (EphyNode *node, ephy_bookmarks_save_delayed (eb, BOOKMARKS_SAVE_DELAY); } -static char * -get_topics_list (EphyBookmarks *eb, - EphyNode *bookmark, - gboolean *no_topics) +static gboolean +bookmark_is_categorized (EphyBookmarks *eb, EphyNode *bookmark) { 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++) @@ -481,30 +532,13 @@ get_topics_list (EphyBookmarks *eb, 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; + return TRUE; } } - 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); + return FALSE; } - static void topics_removed_cb (EphyNode *node, EphyNode *child, @@ -518,22 +552,17 @@ topics_removed_cb (EphyNode *node, 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 && + if (bookmark_is_categorized (eb, kid) && !ephy_node_has_child (eb->priv->notcategorized, kid)) { ephy_node_add_child (eb->priv->notcategorized, kid); } - update_topics_list (kid, list); - - g_free (list); + update_bookmark_keywords (eb, kid); } g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0); @@ -1146,15 +1175,10 @@ ephy_bookmarks_set_keyword (EphyBookmarks *eb, EphyNode *keyword, EphyNode *bookmark) { - gboolean no_topics; - char *list; - if (ephy_node_has_child (keyword, bookmark)) return; ephy_node_add_child (keyword, bookmark); - list = get_topics_list (eb, bookmark, &no_topics); - if (ephy_node_has_child (eb->priv->notcategorized, bookmark)) { LOG ("Remove from categorized bookmarks") @@ -1162,8 +1186,7 @@ ephy_bookmarks_set_keyword (EphyBookmarks *eb, (eb->priv->notcategorized, bookmark); } - update_topics_list (bookmark, list); - g_free (list); + update_bookmark_keywords (eb, bookmark); g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0); } @@ -1173,16 +1196,11 @@ ephy_bookmarks_unset_keyword (EphyBookmarks *eb, EphyNode *keyword, EphyNode *bookmark) { - gboolean no_topics; - char *list; - if (!ephy_node_has_child (keyword, bookmark)) return; ephy_node_remove_child (keyword, bookmark); - list = get_topics_list (eb, bookmark, &no_topics); - - if (no_topics && + if (!bookmark_is_categorized (eb, bookmark) && !ephy_node_has_child (eb->priv->notcategorized, bookmark)) { LOG ("Add to not categorized bookmarks") @@ -1190,8 +1208,7 @@ ephy_bookmarks_unset_keyword (EphyBookmarks *eb, (eb->priv->notcategorized, bookmark); } - update_topics_list (bookmark, list); - g_free (list); + update_bookmark_keywords (eb, bookmark); g_signal_emit (G_OBJECT (eb), ephy_bookmarks_signals[TREE_CHANGED], 0); } diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c index 095cf250c..dad2e73d9 100644 --- a/src/bookmarks/ephy-topic-action.c +++ b/src/bookmarks/ephy-topic-action.c @@ -610,7 +610,10 @@ sync_topic_properties (GtkAction *action, EphyNode *bmk) } static void -topic_child_changed_cb (EphyNode *node, EphyNode *child, GtkAction *action) +topic_child_changed_cb (EphyNode *node, + EphyNode *child, + guint property_id, + GtkAction *action) { gulong id; diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c index fd5437934..851174fc3 100644 --- a/src/ephy-completion-model.c +++ b/src/ephy-completion-model.c @@ -193,6 +193,7 @@ root_child_added_cb (EphyNode *node, static void root_child_changed_cb (EphyNode *node, EphyNode *child, + guint property_id, EphyCompletionModel *model) { GtkTreePath *path; diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index ff6dd64e9..06171aaa5 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -442,6 +442,7 @@ actions_child_added_cb (EphyNode *node, static void actions_child_changed_cb (EphyNode *node, EphyNode *child, + guint property_id, EphyLocationAction *action) { update_actions_list (action); |