aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bookmarks/ephy-bookmarks.c')
-rw-r--r--src/bookmarks/ephy-bookmarks.c56
1 files changed, 51 insertions, 5 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 7770265f7..207b55e62 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -1186,11 +1186,12 @@ ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
return NULL;
}
-EphyNode *
-ephy_bookmarks_find_duplicate (EphyBookmarks *eb,
- EphyNode *bookmark)
+GPtrArray *
+ephy_bookmarks_find_duplicates (EphyBookmarks *eb,
+ EphyNode *bookmark)
{
GPtrArray *children;
+ GPtrArray *result;
const char *url;
int i;
@@ -1202,6 +1203,8 @@ ephy_bookmarks_find_duplicate (EphyBookmarks *eb,
(bookmark, EPHY_NODE_BMK_PROP_LOCATION);
g_return_val_if_fail (url != NULL, NULL);
+
+ result = g_ptr_array_new ();
children = ephy_node_get_children (eb->priv->bookmarks);
for (i = 0; i < children->len; i++)
@@ -1220,11 +1223,54 @@ ephy_bookmarks_find_duplicate (EphyBookmarks *eb,
if (location != NULL && strcmp (url, location) == 0)
{
- return kid;
+ g_ptr_array_add (result, kid);
}
}
- return NULL;
+ return result;
+}
+
+gint
+ephy_bookmarks_count_duplicates (EphyBookmarks *eb,
+ EphyNode *bookmark)
+{
+ GPtrArray *children;
+ const char *url;
+ int i, result;
+
+ g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), -1);
+ g_return_val_if_fail (eb->priv->bookmarks != NULL, -1);
+ g_return_val_if_fail (bookmark != NULL, -1);
+
+ url = ephy_node_get_property_string
+ (bookmark, EPHY_NODE_BMK_PROP_LOCATION);
+
+ g_return_val_if_fail (url != NULL, -1);
+
+ result = 0;
+
+ children = ephy_node_get_children (eb->priv->bookmarks);
+ for (i = 0; i < children->len; i++)
+ {
+ EphyNode *kid;
+ const char *location;
+
+ kid = g_ptr_array_index (children, i);
+ if (kid == bookmark)
+ {
+ continue;
+ }
+
+ location = ephy_node_get_property_string
+ (kid, EPHY_NODE_BMK_PROP_LOCATION);
+
+ if (location != NULL && strcmp (url, location) == 0)
+ {
+ result++;
+ }
+ }
+
+ return result;
}
void