2 * Copyright (C) 2012-2013 jeanfi@gmail.com
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #include <ui_projecttree.h>
30 static GtkTreeView *w_treeview;
32 void ui_projecttree_init(GtkBuilder *builder)
34 w_treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder,
38 const char *ui_projecttree_get_project()
41 GtkTreeViewColumn *cols;
49 gtk_tree_view_get_cursor(w_treeview, &path, &cols);
52 model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
53 gtk_tree_model_get_iter(model, &iter, path);
54 gtk_tree_model_get_value(model, &iter, COL_NAME, &value);
56 prj = g_value_get_string(&value);
67 void ui_projecttree_update(struct task **ts)
69 struct project **prjs, **cur;
75 model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
76 gtk_list_store_clear(GTK_LIST_STORE(model));
78 prjs = tw_get_projects(ts);
79 for (cur = prjs; *cur; cur++) {
80 gtk_list_store_append(GTK_LIST_STORE(model), &iter);
82 gtk_list_store_set(GTK_LIST_STORE(model),
84 COL_NAME, (*cur)->name,
85 COL_COUNT, (*cur)->count,
89 tw_project_list_free(prjs);