diff options
Fix setting up completion
1 files changed, 12 insertions, 12 deletions
| -rw-r--r-- | bookmarks.c | 24 |
diff --git a/bookmarks.c b/bookmarks.c index 8a69814..59faf95 100644 --- a/bookmarks.c +++ b/bookmarks.c @@ -7,7 +7,7 @@ #include <gtk/gtk.h> #include <libxml/xpath.h> -gboolean +static gboolean location_completion_matches(GtkEntryCompletion *completion, const gchar *key, GtkTreeIter *iter, @@ -29,15 +29,15 @@ location_completion_matches(GtkEntryCompletion *completion, } void -location_completion_setup(GtkListStore *list_store) +bookmarks_completion_setup(GtkEntryCompletion *location_completion, GtkTreeModel *tree_model) { - gtk_entry_completion_set_model(location_completion, GTK_TREE_MODEL(list_store)); + gtk_entry_completion_set_model(location_completion, tree_model); gtk_entry_completion_set_text_column(location_completion, 0); gtk_entry_completion_set_match_func(location_completion, location_completion_matches, NULL, NULL); gtk_entry_completion_set_inline_selection(location_completion, BADWOLF_LOCATION_INLINE_SELECTION); } -void +static void location_completion_cleanup(xmlXPathObjectPtr xpathObj, xmlXPathContextPtr xpathCtx, xmlDocPtr doc) { if(xpathObj != NULL) xmlXPathFreeObject(xpathObj); @@ -45,7 +45,7 @@ location_completion_cleanup(xmlXPathObjectPtr xpathObj, xmlXPathContextPtr xpath if(doc != NULL) xmlFreeDoc(doc); } -GtkTreeIter +static GtkTreeIter load_xpath_results(GtkListStore *list_store, xmlNodeSetPtr nodes) { GtkTreeIter iter; @@ -65,8 +65,8 @@ load_xpath_results(GtkListStore *list_store, xmlNodeSetPtr nodes) return iter; } -void -location_completion_init() +GtkTreeModel * +bookmarks_completion_init() { const xmlChar *xpathExpr = "//bookmark/@href"; char *filename = g_build_filename(g_get_user_data_dir(), "badwolf", "bookmarks.xbel", NULL); @@ -76,7 +76,6 @@ location_completion_init() GtkTreeIter iter; GtkListStore *list_store = gtk_list_store_new(1, G_TYPE_STRING); - location_completion = gtk_entry_completion_new(); gtk_list_store_append(list_store, &iter); gtk_list_store_set(list_store, &iter, 0, homepage, -1); @@ -86,7 +85,7 @@ location_completion_init() { g_fprintf(stderr, "Bookmarks: unable to parse file \"%s\"\n", filename); location_completion_cleanup(xpathObj, xpathCtx, doc); - return; + return NULL; } xpathCtx = xmlXPathNewContext(doc); @@ -94,7 +93,7 @@ location_completion_init() { g_fprintf(stderr, "Bookmarks: unable to create new XPath context\n"); location_completion_cleanup(xpathObj, xpathCtx, doc); - return; + return NULL; } xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx); @@ -102,13 +101,14 @@ location_completion_init() { g_fprintf(stderr, "Bookmarks: unable to evaluate xpath expression \"%s\"\n", xpathExpr); location_completion_cleanup(xpathObj, xpathCtx, doc); - return; + return NULL; } iter = load_xpath_results(list_store, xpathObj->nodesetval); location_completion_cleanup(xpathObj, xpathCtx, doc); - location_completion_setup(list_store); g_fprintf(stderr, "Bookmarks: Done.\n"); + + return GTK_TREE_MODEL(list_store); } |