Summary Files Commits Branches @commit @diff @stats
path: root / bookmarks.c
diff options
context:
space:
mode:
Commit720eb415a73893bf4c3894c10e27c66996f7e67e (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2019-12-16 14:35:37 +0100
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-08-22 09:00:21 +0200
Files623ff17b265161d3bb3f1f4f878a517262e28368 /bookmarks.c
goodwolf-720eb415a73893bf4c3894c10e27c66996f7e67e.tar
goodwolf-720eb415a73893bf4c3894c10e27c66996f7e67e.tar.gz
goodwolf-720eb415a73893bf4c3894c10e27c66996f7e67e.zip
Parent41cfd1ccae96dda3378b9666e38e70e547fe87f2 (diff)
Fix setting up completion
1 files changed, 12 insertions, 12 deletions
-rw-r--r--bookmarks.c24
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);
}