summaryrefslogtreecommitdiff
path: root/gtk/gtk_completion.c
diff options
context:
space:
mode:
authorRob Kendrick <rjek@netsurf-browser.org>2006-07-25 20:55:10 +0000
committerRob Kendrick <rjek@netsurf-browser.org>2006-07-25 20:55:10 +0000
commit546efe6d6c2e9a8481c545988389962ac3e14459 (patch)
treeaa3143220324efa08d7ad973632d1d32af8762fa /gtk/gtk_completion.c
parent000f7502ba5ff036883c6484ca36594fc9ffb469 (diff)
downloadnetsurf-546efe6d6c2e9a8481c545988389962ac3e14459.tar.gz
netsurf-546efe6d6c2e9a8481c545988389962ac3e14459.tar.bz2
Initial work on URL completion in nsgtk. Some problems still exist.
1. It works without the code that should be required to make it do so. Boggle. 2. It appears to include the URLs to images and other resources as well as pages 3. Although you can highlight a completion with the cursor keys, pressing enter on one doesn't work - you need to click on it with the mouse. svn path=/trunk/netsurf/; revision=2795
Diffstat (limited to 'gtk/gtk_completion.c')
-rw-r--r--gtk/gtk_completion.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/gtk/gtk_completion.c b/gtk/gtk_completion.c
new file mode 100644
index 000000000..d173dde27
--- /dev/null
+++ b/gtk/gtk_completion.c
@@ -0,0 +1,59 @@
+/*
+ * This file is part of NetSurf, http://netsurf.sourceforge.net/
+ * Licensed under the GNU General Public License,
+ * http://www.opensource.org/licenses/gpl-license
+ * Copyright 2006 Rob Kendrick <rjek@rjek.com>
+ */
+
+#include <gtk/gtk.h>
+#include "netsurf/gtk/gtk_completion.h"
+#include "netsurf/content/urldb.h"
+#include "netsurf/utils/log.h"
+
+GtkListStore *nsgtk_completion_list;
+
+static void nsgtk_completion_empty(void);
+static bool nsgtk_completion_udb_callback(const char *url,
+ const struct url_data *data);
+
+void nsgtk_completion_init(void)
+{
+ nsgtk_completion_list = gtk_list_store_new(1, G_TYPE_STRING);
+
+}
+
+gboolean nsgtk_completion_match(GtkEntryCompletion *completion,
+ const gchar *key,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ char *b[4096]; /* no way of finding out its length :( */
+ gtk_tree_model_get(GTK_TREE_MODEL(nsgtk_completion_list), iter,
+ 0, b, -1);
+
+ /* TODO: work out why this works, when there's no code to implement
+ * it. I boggle. */
+
+ return TRUE;
+
+}
+
+void nsgtk_completion_empty(void)
+{
+ gtk_list_store_clear(nsgtk_completion_list);
+}
+
+bool nsgtk_completion_udb_callback(const char *url, const struct url_data *data)
+{
+ GtkTreeIter iter;
+ gtk_list_store_append(nsgtk_completion_list, &iter);
+ gtk_list_store_set(nsgtk_completion_list, &iter, 0, url, -1);
+ return true;
+}
+
+void nsgtk_completion_update(const char *prefix)
+{
+ nsgtk_completion_empty();
+ urldb_iterate_partial(prefix, nsgtk_completion_udb_callback);
+}
+