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
28 static const char *ui_get_priority(GtkComboBox *combo)
32 prio = gtk_combo_box_get_active(combo);
46 static void populate_project(GtkComboBoxText *w)
49 struct project **all_prjs, **prjs;
51 tasks = tw_get_all_tasks("pending");
53 all_prjs = tw_get_projects(tasks);
57 if (strcmp((*prjs)->name, "ALL"))
58 gtk_combo_box_text_append_text(w, (*prjs)->name);
63 tw_task_list_free(tasks);
64 tw_project_list_free(all_prjs);
70 static GtkDialog *diag;
73 const char *desc, *prj, *prio;
75 GtkComboBoxText *w_prj;
77 log_debug("ui_newtask()");
79 builder = gtk_builder_new();
80 gtk_builder_add_from_file
82 PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "ptask.glade",
84 diag = GTK_DIALOG(gtk_builder_get_object(builder, "diag_tasknew"));
85 gtk_builder_connect_signals(builder, NULL);
87 w_prj = GTK_COMBO_BOX_TEXT(gtk_builder_get_object
88 (builder, "diag_tasknew_project"));
89 populate_project(w_prj);
91 result = gtk_dialog_run(diag);
93 if (result == GTK_RESPONSE_ACCEPT) {
94 log_debug("ui_newtask(): ok");
96 entry = GTK_ENTRY(gtk_builder_get_object
97 (builder, "diag_tasknew_description"));
98 desc = gtk_entry_get_text(entry);
100 w_prj = GTK_COMBO_BOX_TEXT(gtk_builder_get_object
101 (builder, "diag_tasknew_project"));
102 prj = gtk_combo_box_text_get_active_text(w_prj);
104 combo = GTK_COMBO_BOX(gtk_builder_get_object
105 (builder, "diag_tasknew_priority"));
106 prio = ui_get_priority(combo);
108 log_debug("ui_newtask(): description=%s project=%s priority=%d",
113 tw_add(desc, prj, prio);
116 log_debug("ui_newtask(): cancel");
119 g_object_unref(G_OBJECT(builder));
121 gtk_widget_destroy(GTK_WIDGET(diag));