Moved completion_fill to settings.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 7 May 2018 21:38:42 +0000 (23:38 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 7 May 2018 21:38:42 +0000 (23:38 +0200)
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.

src/completion.c
src/completion.h
src/setting.c

index 709861c..2532f85 100644 (file)
@@ -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)
 {
index 1cfc9c4..b37cec1 100644 (file)
@@ -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 */
index c0d6695..9b2065b 100644 (file)
@@ -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;
 }