From: Daniel Carl Date: Mon, 7 May 2018 21:38:42 +0000 (+0200) Subject: Moved completion_fill to settings. X-Git-Url: https://git.owens.tech/assets/favicon.png/assets/favicon.png/git?a=commitdiff_plain;h=31c08cf99acb4d301cdf277f54201ea702504caf;p=vimb.git Moved completion_fill to settings. This function intensional should be used by other components. But there is only one component using this, so it's better to move this away. --- diff --git a/src/completion.c b/src/completion.c index 709861c..2532f85 100644 --- a/src/completion.c +++ b/src/completion.c @@ -233,38 +233,6 @@ gboolean completion_next(Client *c, gboolean back) return TRUE; } -/** - * Fills the given list store by matching data of also given src list. - */ -gboolean completion_fill(GtkListStore *store, const char *input, GList *src) -{ - gboolean found = FALSE; - GtkTreeIter iter; - - /* If no filter input given - copy all entries into the data store. */ - if (!input || !*input) { - for (GList *l = src; l; l = l->next) { - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1); - found = TRUE; - } - return found; - } - - /* If filter input is given - copy matching list entires into data store. - * Strings are compared by prefix matching. */ - for (GList *l = src; l; l = l->next) { - char *value = (char*)l->data; - if (g_str_has_prefix(value, input)) { - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1); - found = TRUE; - } - } - - return found; -} - static gboolean tree_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean selected, gpointer data) { diff --git a/src/completion.h b/src/completion.h index 1cfc9c4..b37cec1 100644 --- a/src/completion.h +++ b/src/completion.h @@ -41,6 +41,5 @@ gboolean completion_create(Client *c, GtkTreeModel *model, CompletionSelectFunc selfunc, gboolean back); void completion_init(Client *c); gboolean completion_next(Client *c, gboolean back); -gboolean completion_fill(GtkListStore *store, const char *input, GList *src); #endif /* end of include guard: _COMPLETION_H */ diff --git a/src/setting.c b/src/setting.c index c0d6695..9b2065b 100644 --- a/src/setting.c +++ b/src/setting.c @@ -262,10 +262,33 @@ VbCmdResult setting_run(Client *c, char *name, const char *param) gboolean setting_fill_completion(Client *c, GtkListStore *store, const char *input) { - GList *src = g_hash_table_get_keys(c->config.settings); - gboolean found = completion_fill(store, input, src); - g_list_free(src); + GtkTreeIter iter; + gboolean found = FALSE; + GList *src = g_hash_table_get_keys(c->config.settings); + + /* If no filter input given - copy all entries into the data store. */ + if (!input || !*input) { + for (GList *l = src; l; l = l->next) { + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1); + found = TRUE; + } + g_list_free(src); + return found; + } + /* If filter input is given - copy matching list entires into data store. + * Strings are compared by prefix matching. */ + for (GList *l = src; l; l = l->next) { + char *value = (char*)l->data; + if (g_str_has_prefix(value, input)) { + gtk_list_store_append(store, &iter); + gtk_list_store_set(store, &iter, COMPLETION_STORE_FIRST, l->data, -1); + found = TRUE; + } + } + + g_list_free(src); return found; }