[gnome-software/wip/temp/ubuntu-xenial-rebased: 62/326] Hack up a simple search filter
- From: Iain Lane <iainl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/temp/ubuntu-xenial-rebased: 62/326] Hack up a simple search filter
- Date: Fri, 29 Apr 2016 09:52:32 +0000 (UTC)
commit 39e99e9badad879e1b22693d545edba8c4ac6311
Author: Robert Ancell <robert ancell canonical com>
Date: Tue Jan 26 15:03:08 2016 +1300
Hack up a simple search filter
src/plugins/gs-plugin-snappy.c | 26 ++++++++++++++++++++++++--
1 files changed, 24 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/gs-plugin-snappy.c b/src/plugins/gs-plugin-snappy.c
index ca1f2dc..247465d 100644
--- a/src/plugins/gs-plugin-snappy.c
+++ b/src/plugins/gs-plugin-snappy.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <gs-plugin.h>
#include <gio/gunixsocketaddress.h>
#include <libsoup/soup.h>
@@ -349,10 +350,31 @@ gs_plugin_add_installed (GsPlugin *plugin,
}
static gboolean
+string_contains (const gchar *string, const gchar *fragment)
+{
+ gint i, j;
+
+ for (i = 0; string[i]; i++) {
+ for (j = 0; fragment[j] && string[i+j] && tolower (string[i+j]) == tolower (fragment[j]);
j++);
+ if (fragment[j] == '\0')
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
matches_search (const gchar *id, JsonObject *object, gpointer data)
{
- gchar **values = data;
- return TRUE;
+ gchar **search_terms = data;
+ gint i;
+
+ for (i = 0; search_terms[i]; i++)
+ if (string_contains (json_object_get_string_member (object, "name"), search_terms[i]) ||
+ string_contains (json_object_get_string_member (object, "description"), search_terms[i]))
+ return TRUE;
+
+ return FALSE;
}
gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]