From e5b77fd6215a60d25ae3f85df8e259d0af9fb58a Mon Sep 17 00:00:00 2001 From: Jean-Philippe Orsini Date: Sat, 27 Sep 2014 11:25:48 +0200 Subject: [PATCH] added combo box for project in the new task dialog --- NEWS | 5 +++++ src/glade/ptask.glade | 41 ++++++++++++++++++++++++----------------- src/ui_newtask_diag.c | 32 +++++++++++++++++++++++++++++--- 3 files changed, 58 insertions(+), 20 deletions(-) diff --git a/NEWS b/NEWS index 7eac39b..553fd16 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ What's New ========== +v0.0.7 +------ + * added support of 2.3.0. + * added combo box for project in the new task dialog. + v0.0.6 ------ * added contextal menu item in the task tree: task done. diff --git a/src/glade/ptask.glade b/src/glade/ptask.glade index 468b473..173934b 100644 --- a/src/glade/ptask.glade +++ b/src/glade/ptask.glade @@ -210,6 +210,7 @@ True False + start 4 4 4 @@ -224,42 +225,50 @@ - + True - True + False start 4 4 4 4 - • + Priority: - 1 - 1 + 0 + 2 1 1 - + True False + start 4 4 4 4 - Priority: + prioritystore + 2 + + + + 0 + + - 0 + 1 2 1 1 - + True False start @@ -267,18 +276,16 @@ 4 4 4 - prioritystore - 2 - - - - 0 - + True + + + True + 1 - 2 + 1 1 1 diff --git a/src/ui_newtask_diag.c b/src/ui_newtask_diag.c index fdfec87..0f3fa4c 100644 --- a/src/ui_newtask_diag.c +++ b/src/ui_newtask_diag.c @@ -41,6 +41,27 @@ static const char *ui_get_priority(GtkComboBox *combo) } } +static void populate_project(GtkComboBoxText *w) +{ + struct task **tasks; + struct project **all_prjs, **prjs; + + tasks = tw_get_all_tasks("pending"); + + all_prjs = tw_get_projects(tasks); + + prjs = all_prjs; + while (*prjs) { + if (strcmp((*prjs)->name, "ALL")) + gtk_combo_box_text_append_text(w, (*prjs)->name); + + prjs++; + } + + tw_task_list_free(tasks); + tw_project_list_free(all_prjs); +} + void ui_newtask() { gint result; @@ -49,6 +70,7 @@ void ui_newtask() GtkEntry *entry; const char *desc, *prj, *prio; GtkComboBox *combo; + GtkComboBoxText *w_prj; log_debug("ui_newtask()"); @@ -60,6 +82,10 @@ void ui_newtask() diag = GTK_DIALOG(gtk_builder_get_object(builder, "diag_tasknew")); gtk_builder_connect_signals(builder, NULL); + w_prj = GTK_COMBO_BOX_TEXT(gtk_builder_get_object + (builder, "diag_tasknew_project")); + populate_project(w_prj); + result = gtk_dialog_run(diag); if (result == GTK_RESPONSE_ACCEPT) { @@ -69,9 +95,9 @@ void ui_newtask() (builder, "diag_tasknew_description")); desc = gtk_entry_get_text(entry); - entry = GTK_ENTRY(gtk_builder_get_object - (builder, "diag_tasknew_project")); - prj = gtk_entry_get_text(entry); + w_prj = GTK_COMBO_BOX_TEXT(gtk_builder_get_object + (builder, "diag_tasknew_project")); + prj = gtk_combo_box_text_get_active_text(w_prj); combo = GTK_COMBO_BOX(gtk_builder_get_object (builder, "diag_tasknew_priority")); -- 2.7.4