summaryrefslogtreecommitdiff
path: root/gtk/completion.c
blob: a0df08ad951acc1c53d76bb1f81a46da6ff11e56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Copyright 2006 Rob Kendrick <rjek@rjek.com>
 *
 * This file is part of NetSurf, http://www.netsurf-browser.org/
 *
 * NetSurf is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 2 of the License.
 *
 * NetSurf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gtk/gtk.h>
#include "gtk/completion.h"

#include "content/urldb.h"
#include "utils/log.h"
#include "utils/nsoption.h"

GtkListStore *nsgtk_completion_list;

static void nsgtk_completion_empty(void);
static bool nsgtk_completion_udb_callback(nsurl *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(nsurl *url, const struct url_data *data)
{
	GtkTreeIter iter;

	if (data->visits != 0) {
		gtk_list_store_append(nsgtk_completion_list, &iter);
		gtk_list_store_set(nsgtk_completion_list, &iter, 0,
				nsurl_access(url), -1);
	}
	return true;
}

void nsgtk_completion_update(const char *prefix)
{
	nsgtk_completion_empty();
	if (nsoption_bool(url_suggestion) == true) {
		urldb_iterate_partial(prefix, nsgtk_completion_udb_callback);
	}
}