diff options
author | Ondrej Čerman | 2020-01-09 21:20:26 +0100 |
---|---|---|
committer | Ondrej Čerman | 2020-01-09 21:20:26 +0100 |
commit | f04d8e4dc6404151882c57ad4721dad9db2768cb (patch) | |
tree | 984ea5bd0dba6e973ff7c011cd435f373057b6db /src | |
parent | db79afa3901792bfa018516c1ca8b34140a6e308 (diff) |
Added quick search
Diffstat (limited to 'src')
-rw-r--r-- | src/gui.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -166,6 +166,23 @@ static void clear_btn_clicked(GtkButton *button, gpointer user_data) { } } +static gboolean mid_search_eq_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter) { + gchar *iter_string = NULL, *lc_iter_string = NULL, *lc_key = NULL; + gboolean result; + + gtk_tree_model_get(model, iter, column, &iter_string, -1); + lc_iter_string = g_utf8_strdown(iter_string, -1); + lc_key = g_utf8_strdown(key, -1); + + result = (g_strrstr(lc_iter_string, lc_key) == NULL); + + g_free(iter_string); + g_free(lc_iter_string); + g_free(lc_key); + + return result; +} + int start_gui (SensorSource *ss) { GtkWidget *about_btn; GtkWidget *clear_btn; @@ -215,12 +232,17 @@ int start_gui (SensorSource *ss) { model = create_model(); treeview = gtk_tree_view_new_with_model(model); - g_object_unref(model); gtk_container_add (GTK_CONTAINER(sw), treeview); add_columns(GTK_TREE_VIEW(treeview)); gtk_widget_show_all(window); + gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), COLUMN_NAME); + gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(treeview), + (GtkTreeViewSearchEqualFunc)mid_search_eq_func, model, NULL); + + g_object_unref(model); + if (check_zen()){ sensor_sources = ss; init_sensors(); |