aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-bookmarks.c
diff options
context:
space:
mode:
authorPeter Harvey <peter.a.harvey@gmail.com>2006-01-31 07:02:35 +0800
committerPeter Anthony Harvey <paharvey@src.gnome.org>2006-01-31 07:02:35 +0800
commit5a25f384ec84c94e89e07558296620dc74681e7b (patch)
tree21464a9c77288b240f7ca52a23a18627acc5cbdf /src/bookmarks/ephy-bookmarks.c
parent7d08bb7e103b567fd9fc707d4625be9a1335f3fd (diff)
downloadgsoc2013-epiphany-5a25f384ec84c94e89e07558296620dc74681e7b.tar
gsoc2013-epiphany-5a25f384ec84c94e89e07558296620dc74681e7b.tar.gz
gsoc2013-epiphany-5a25f384ec84c94e89e07558296620dc74681e7b.tar.bz2
gsoc2013-epiphany-5a25f384ec84c94e89e07558296620dc74681e7b.tar.lz
gsoc2013-epiphany-5a25f384ec84c94e89e07558296620dc74681e7b.tar.xz
gsoc2013-epiphany-5a25f384ec84c94e89e07558296620dc74681e7b.tar.zst
gsoc2013-epiphany-5a25f384ec84c94e89e07558296620dc74681e7b.zip
src/bookmarks/ephy-bookmark-properties.c src/bookmarks/ephy-bookmarks.c
2006-01-30 Peter Harvey <peter.a.harvey@gmail.com> * src/bookmarks/ephy-bookmark-properties.c * src/bookmarks/ephy-bookmarks.c * src/bookmarks/ephy-bookmarks.h Made the 'Similar' button show more bookmarks, and separate into 'identical' and 'similar'.
Diffstat (limited to 'src/bookmarks/ephy-bookmarks.c')
-rw-r--r--src/bookmarks/ephy-bookmarks.c81
1 files changed, 38 insertions, 43 deletions
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 207b55e62..36a3455d5 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -1186,53 +1186,36 @@ ephy_bookmarks_find_bookmark (EphyBookmarks *eb,
return NULL;
}
-GPtrArray *
-ephy_bookmarks_find_duplicates (EphyBookmarks *eb,
- EphyNode *bookmark)
+static gboolean
+is_similar (const char *url1, const char *url2)
{
- GPtrArray *children;
- GPtrArray *result;
- const char *url;
- int i;
-
- g_return_val_if_fail (EPHY_IS_BOOKMARKS (eb), NULL);
- g_return_val_if_fail (eb->priv->bookmarks != NULL, NULL);
- g_return_val_if_fail (bookmark != NULL, NULL);
-
- url = ephy_node_get_property_string
- (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++)
+ while(*url1 == *url2 && *url1 != '\0' &&
+ *url1 != '#' && *url1 != '?')
{
- 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)
- {
- g_ptr_array_add (result, kid);
- }
+ url1++;
+ url2++;
}
-
- return result;
+ if(*url1 == *url2) return TRUE;
+ if(*url1 == '\0')
+ {
+ if(*url2 == '#') return TRUE;
+ if(*url2 == '?') return TRUE;
+ if(*url2 == '/' && *(url2+1) == '\0') return TRUE;
+ }
+ if(*url2 == '\0')
+ {
+ if(*url1 == '#') return TRUE;
+ if(*url1 == '?') return TRUE;
+ if(*url1 == '/' && *(url1+1) == '\0') return TRUE;
+ }
+ return FALSE;
}
gint
-ephy_bookmarks_count_duplicates (EphyBookmarks *eb,
- EphyNode *bookmark)
+ephy_bookmarks_get_similar (EphyBookmarks *eb,
+ EphyNode *bookmark,
+ GPtrArray *identical,
+ GPtrArray *similar)
{
GPtrArray *children;
const char *url;
@@ -1264,9 +1247,21 @@ ephy_bookmarks_count_duplicates (EphyBookmarks *eb,
location = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_LOCATION);
- if (location != NULL && strcmp (url, location) == 0)
+ if (location != NULL)
{
- result++;
+ if(identical != NULL && strcmp (url, location) == 0)
+ {
+ g_ptr_array_add (identical, kid);
+ result++;
+ }
+ else if(is_similar (url, location))
+ {
+ if (similar != NULL)
+ {
+ g_ptr_array_add (similar, kid);
+ }
+ result++;
+ }
}
}