[Xfce4-commits] <midori:master> Implement katze_array_find_uri for finding duplicates
Christian Dywan
noreply at xfce.org
Fri Oct 2 21:32:03 CEST 2009
Updating branch refs/heads/master
to 41385a9e5ee638777fdb0a23610c4ca9aabef76a (commit)
from a6ee2320e85fe9b34aa076dc14f52a8258fcc873 (commit)
commit 41385a9e5ee638777fdb0a23610c4ca9aabef76a
Author: Christian Dywan <christian at twotoasts.de>
Date: Fri Oct 2 21:27:31 2009 +0200
Implement katze_array_find_uri for finding duplicates
katze/katze-array.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
katze/katze-array.h | 4 ++++
2 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/katze/katze-array.c b/katze/katze-array.c
index 5df9291..93a3f56 100644
--- a/katze/katze-array.c
+++ b/katze/katze-array.c
@@ -375,7 +375,11 @@ katze_array_find_token (KatzeArray* array,
i = 0;
while ((item = g_list_nth_data (array->items, i++)))
{
- const gchar* found_token = katze_item_get_token ((KatzeItem*)item);
+ const gchar* found_token;
+
+ if (!KATZE_IS_ITEM (item))
+ continue;
+ found_token = ((KatzeItem*)item)->token;
if (!g_strcmp0 (found_token, token))
return item;
}
@@ -383,6 +387,45 @@ katze_array_find_token (KatzeArray* array,
}
/**
+ * katze_array_find_uri:
+ * @array: a #KatzeArray
+ * @uri: an URI
+ *
+ * Looks up an item in the array which has the specified URI.
+ *
+ * This function will silently fail if the type of the list
+ * is not based on #GObject and only #KatzeItem children
+ * are checked for their token, any other objects are skipped.
+ *
+ * Return value: an item, or %NULL
+ *
+ * Since: 0.2.0
+ **/
+gpointer
+katze_array_find_uri (KatzeArray* array,
+ const gchar* uri)
+{
+ guint i;
+ gpointer item;
+
+ if (!katze_array_is_a (array, G_TYPE_OBJECT))
+ return NULL;
+
+ i = 0;
+ while ((item = g_list_nth_data (array->items, i++)))
+ {
+ const gchar* found_uri;
+
+ if (!KATZE_IS_ITEM (item))
+ continue;
+ found_uri = ((KatzeItem*)item)->uri;
+ if (!g_strcmp0 (found_uri, uri))
+ return item;
+ }
+ return NULL;
+}
+
+/**
* katze_array_get_length:
* @array: a #KatzeArray
*
diff --git a/katze/katze-array.h b/katze/katze-array.h
index 89bfea9..af3370d 100644
--- a/katze/katze-array.h
+++ b/katze/katze-array.h
@@ -65,6 +65,10 @@ gpointer
katze_array_find_token (KatzeArray* array,
const gchar* token);
+gpointer
+katze_array_find_uri (KatzeArray* array,
+ const gchar* uri);
+
guint
katze_array_get_length (KatzeArray* array);
More information about the Xfce4-commits
mailing list