#include "badwolf.h" #include "bookmarks.h" #include #include /* 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); }