display project table
[ptask.git] / src / ui_projecttree.c
1 /*
2  * Copyright (C) 2012-2013 jeanfi@gmail.com
3  *
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.
8  *
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.
13  *
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
17  * 02110-1301 USA
18  */
19 #include <stdio.h>
20
21 #include <log.h>
22 #include <ui_projecttree.h>
23
24 static GtkTreeView *w_treeview;
25
26 void ui_projecttree_init(GtkBuilder *builder)
27 {
28         w_treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "projecttree"));
29 }
30
31 void ui_projecttree_update(struct task **ts)
32 {
33         struct project **prjs;
34         GtkTreeModel *model;
35         GtkTreeIter iter;
36
37         log_debug("ui_projecttree_update()");
38
39         model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
40         gtk_list_store_clear(GTK_LIST_STORE(model));
41
42         prjs = tw_get_projects(ts);
43         while (*prjs) {
44                 gtk_list_store_append(GTK_LIST_STORE(model), &iter);
45
46                 gtk_list_store_set(GTK_LIST_STORE(model),
47                                    &iter,
48                                    0, (*prjs)->name,
49                                    1, (*prjs)->count,
50                                    -1);
51
52                 prjs++;
53         }
54 }