aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@src.gnome.org>2004-02-11 22:38:55 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-02-11 22:38:55 +0800
commita4e3a5f2856a8c2d9e200d94b7b9154b1a76434b (patch)
tree812a1f48b0383af9475061249984caef74ded516 /src/bookmarks
parent79ccb3d443d31072de5718da6a3883aa35df9211 (diff)
downloadgsoc2013-epiphany-a4e3a5f2856a8c2d9e200d94b7b9154b1a76434b.tar
gsoc2013-epiphany-a4e3a5f2856a8c2d9e200d94b7b9154b1a76434b.tar.gz
gsoc2013-epiphany-a4e3a5f2856a8c2d9e200d94b7b9154b1a76434b.tar.bz2
gsoc2013-epiphany-a4e3a5f2856a8c2d9e200d94b7b9154b1a76434b.tar.lz
gsoc2013-epiphany-a4e3a5f2856a8c2d9e200d94b7b9154b1a76434b.tar.xz
gsoc2013-epiphany-a4e3a5f2856a8c2d9e200d94b7b9154b1a76434b.tar.zst
gsoc2013-epiphany-a4e3a5f2856a8c2d9e200d94b7b9154b1a76434b.zip
*** empty log message ***
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmark-action.c5
-rw-r--r--src/bookmarks/ephy-bookmarks-menu.c5
-rw-r--r--src/bookmarks/ephy-bookmarks.c115
-rw-r--r--src/bookmarks/ephy-topic-action.c5
4 files changed, 78 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;