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
22 #include <ui_taskpanel.h>
24 static GtkTextView *w_note;
25 static GtkEntry *w_description;
26 static GtkEntry *w_project;
27 static GtkComboBox *w_priority;
28 static GtkButton *w_tasksave_btn;
29 static GtkButton *w_taskdone_btn;
30 static GtkButton *w_taskcancel_btn;
32 static void enable(int enable)
36 gtk_widget_set_sensitive(GTK_WIDGET(w_tasksave_btn), enable);
37 gtk_widget_set_sensitive(GTK_WIDGET(w_taskdone_btn), enable);
38 gtk_widget_set_sensitive(GTK_WIDGET(w_taskcancel_btn), enable);
40 buf = gtk_text_view_get_buffer(w_note);
42 gtk_text_buffer_set_text(buf, "", 0);
43 gtk_widget_set_sensitive(GTK_WIDGET(w_note), enable);
46 gtk_entry_set_text(w_description, "");
47 gtk_widget_set_sensitive(GTK_WIDGET(w_description), enable);
50 gtk_entry_set_text(w_project, "");
51 gtk_widget_set_sensitive(GTK_WIDGET(w_project), enable);
54 gtk_combo_box_set_active(w_priority, 0);
55 gtk_widget_set_sensitive(GTK_WIDGET(w_priority), enable);
58 void ui_taskpanel_init(GtkBuilder *builder)
60 log_fct(__func__, "ENTER");
62 w_note = GTK_TEXT_VIEW(gtk_builder_get_object(builder, "tasknote"));
64 w_description = GTK_ENTRY(gtk_builder_get_object(builder,
66 w_project = GTK_ENTRY(gtk_builder_get_object(builder, "taskproject"));
67 w_priority = GTK_COMBO_BOX(gtk_builder_get_object(builder,
70 w_tasksave_btn = GTK_BUTTON(gtk_builder_get_object(builder,
72 w_taskdone_btn = GTK_BUTTON(gtk_builder_get_object(builder,
74 w_taskcancel_btn = GTK_BUTTON(gtk_builder_get_object(builder,
79 log_fct(__func__, "EXIT");
82 static int priority_to_int(const char *str)
96 void ui_taskpanel_update(struct task *task)
102 buf = gtk_text_view_get_buffer(w_note);
104 gtk_text_buffer_set_text(buf,
108 gtk_text_buffer_set_text(buf, "", 0);
110 gtk_entry_set_text(w_description, task->description);
113 gtk_entry_set_text(w_project, task->project);
115 gtk_entry_set_text(w_project, "");
117 priority = priority_to_int(task->priority);
118 gtk_combo_box_set_active(w_priority, priority);