Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commit3f164de8eb38f06138d908536b198dcd507a3a74 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2019-11-03 22:44:18 +0100
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-08-22 09:00:21 +0200
Filesc73d7d235182cf083bf34fb689e9be1c9a999ed5
goodwolf-3f164de8eb38f06138d908536b198dcd507a3a74.tar
goodwolf-3f164de8eb38f06138d908536b198dcd507a3a74.tar.gz
goodwolf-3f164de8eb38f06138d908536b198dcd507a3a74.zip
Parenta7ba36264f3a62013d393075bd992ac252d3e51a (diff)
bookmarks.c: Wildcard-based suggestion matching
1 files changed, 19 insertions, 0 deletions
-rw-r--r--bookmarks.c19
diff --git a/bookmarks.c b/bookmarks.c
index 23cb558..4bbfb8a 100644
--- a/bookmarks.c
+++ b/bookmarks.c
@@ -6,11 +6,30 @@
#include <gtk/gtk.h>
#include <libxml/xpath.h>
+gboolean
+location_completion_matches(GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, gpointer user_data)
+{
+ (void)user_data;
+ gchar *buffer;
+ gchar *pattern;
+ gboolean result;
+
+ pattern = g_strdup_printf("*%s*", key);
+
+ gtk_tree_model_get(gtk_entry_completion_get_model(completion), iter, 0, &buffer, -1);
+ result = g_pattern_match_simple(pattern, buffer);
+
+ g_free(buffer);
+ g_free(pattern);
+ return result;
+}
+
void
location_completion_setup(GtkListStore *list_store)
{
gtk_entry_completion_set_model(location_completion, GTK_TREE_MODEL(list_store));
gtk_entry_completion_set_text_column(location_completion, 0);
+ gtk_entry_completion_set_match_func(location_completion, location_completion_matches, NULL, NULL);
}
void