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
26 static const char *ui_get_priority(GtkComboBox *combo)
30 prio = gtk_combo_box_get_active(combo);
44 static void populate_project(GtkComboBoxText *w)
47 struct project **all_prjs, **prjs;
49 tasks = tw_get_all_tasks("pending");
51 all_prjs = tw_get_projects(tasks);
55 if (strcmp((*prjs)->name, "ALL"))
56 gtk_combo_box_text_append_text(w, (*prjs)->name);
61 tw_task_list_free(tasks);
62 tw_project_list_free(all_prjs);
68 static GtkDialog *diag;
71 const char *desc, *prj, *prio;
73 GtkComboBoxText *w_prj;
75 log_debug("ui_newtask()");
77 builder = gtk_builder_new();
78 gtk_builder_add_from_file
80 PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "ptask.glade",
82 diag = GTK_DIALOG(gtk_builder_get_object(builder, "diag_tasknew"));
83 gtk_builder_connect_signals(builder, NULL);
85 w_prj = GTK_COMBO_BOX_TEXT(gtk_builder_get_object
86 (builder, "diag_tasknew_project"));
87 populate_project(w_prj);
89 result = gtk_dialog_run(diag);
91 if (result == GTK_RESPONSE_ACCEPT) {
92 log_debug("ui_newtask(): ok");
94 entry = GTK_ENTRY(gtk_builder_get_object
95 (builder, "diag_tasknew_description"));
96 desc = gtk_entry_get_text(entry);
98 w_prj = GTK_COMBO_BOX_TEXT(gtk_builder_get_object
99 (builder, "diag_tasknew_project"));
100 prj = gtk_combo_box_text_get_active_text(w_prj);
102 combo = GTK_COMBO_BOX(gtk_builder_get_object
103 (builder, "diag_tasknew_priority"));
104 prio = ui_get_priority(combo);
106 log_debug("ui_newtask(): description=%s project=%s priority=%d",
111 tw_add(desc, prj, prio);
114 log_debug("ui_newtask(): cancel");
117 g_object_unref(G_OBJECT(builder));
119 gtk_widget_destroy(GTK_WIDGET(diag));