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 static GtkTreeView *w_treeview;
33 static int priority_to_int(const char *str)
47 static gint priority_cmp(GtkTreeModel *model,
52 GValue v1 = {0,}, v2 = {0,};
53 const char *str1, *str2;
56 gtk_tree_model_get_value(model, a, COL_PRIORITY, &v1);
57 str1 = g_value_get_string(&v1);
58 i1 = priority_to_int(str1);
60 gtk_tree_model_get_value(model, b, COL_PRIORITY, &v2);
61 str2 = g_value_get_string(&v2);
62 i2 = priority_to_int(str2);
72 void ui_tasktree_init(GtkBuilder *builder)
76 w_treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "tasktree"));
78 model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
79 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model),
86 void ui_tasktree_load_settings(GSettings *settings)
89 GtkSortType sort_order;
92 sort_col_id = g_settings_get_int(settings, "tasks-sort-col");
93 sort_order = g_settings_get_int(settings, "tasks-sort-order");
94 model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
95 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
96 sort_col_id, sort_order);
99 void ui_tasktree_save_settings(GSettings *settings)
103 GtkSortType sort_order;
105 model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
106 gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(model),
109 log_debug("ui_tasktree_save_settings(): sort_col_id=%d", sort_col_id);
110 log_debug("ui_tasktree_save_settings(): sort_col_order=%d", sort_order);
112 g_settings_set_int(settings, "tasks-sort-col", sort_col_id);
113 g_settings_set_int(settings, "tasks-sort-order", sort_order);