Summary Files Commits Branches @commit @diff @stats
path: root / bookmarks.c
diff options
context:
space:
mode:
Commitabb47b4c0faf2eadcdce62c285fea8af7edd8894 (patch)
Author
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2019-11-02 22:01:00 +0100
Committer
 Haelwenn (lanodan) Monnier <contact@hacktivis.me>
2020-08-22 08:42:57 +0200
Files169106ed05c388f6b29f40b0b872ef362ebcc6ba /bookmarks.c
goodwolf-abb47b4c0faf2eadcdce62c285fea8af7edd8894.tar
goodwolf-abb47b4c0faf2eadcdce62c285fea8af7edd8894.tar.gz
goodwolf-abb47b4c0faf2eadcdce62c285fea8af7edd8894.zip
Parentb6e995810f9cba4dac83d57643a5f9698699cbad (diff)
Add completion
1 files changed, 45 insertions, 0 deletions
-rw-r--r--bookmarks.c45
diff --git a/bookmarks.c b/bookmarks.c
new file mode 100644
index 0000000..f43ed46
--- /dev/null
+++ b/bookmarks.c
@@ -0,0 +1,45 @@
+#include "badwolf.h"
+#include "bookmarks.h"
+
+#include <gtk/gtk.h>
+#include <glib/gprintf.h> /* g_fprintf() */
+
+void
+location_completion_init()
+{
+ GtkTreeIter iter;
+ GtkListStore *list_store;
+ GIOChannel *file_channel;
+ GError *file_err = NULL;
+ gchar *file_line;
+
+ location_completion = gtk_entry_completion_new();
+
+ list_store = gtk_list_store_new(1, G_TYPE_STRING);
+
+ gchar *filename = g_build_filename(g_get_user_data_dir(), "badwolf", "URLs.txt", NULL);
+ g_fprintf(stderr, "URL Completion: loading at %s\n", filename);
+ file_channel = g_io_channel_new_file(filename, "r", &file_err);
+
+ if(file_channel != NULL)
+ {
+ while(G_IO_STATUS_NORMAL ==
+ g_io_channel_read_line(file_channel, &file_line, NULL, NULL, &file_err))
+ {
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set(list_store, &iter, 0, g_strchomp(file_line), -1);
+ }
+ g_free(file_line);
+ g_io_channel_unref(file_channel);
+ //g_io_channel_shutdown(file_channel, FALSE, &file_err);
+ g_fprintf(stderr, "URL Completion: Done.\n");
+ }
+ else
+ g_fprintf(stderr, "URL Completion: Failed to load file.\n");
+
+ gtk_list_store_append(list_store, &iter);
+ gtk_list_store_set(list_store, &iter, 0, homepage, -1);
+
+ gtk_entry_completion_set_model(location_completion, GTK_TREE_MODEL(list_store));
+ gtk_entry_completion_set_text_column(location_completion, 0);
+}