<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkListStore" id="liststore2">
+ <columns>
+ <!-- column-name gchararray1 -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">pending</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">completed</col>
+ </row>
+ </data>
+ </object>
<object class="GtkWindow" id="window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">gtask</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
</object>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
+ <object class="GtkBox" id="box5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
+ <property name="label" translatable="yes">Status:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="status">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
+ <property name="model">liststore2</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext4"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
</child>
</object>
<packing>
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</object>
<packing>
<property name="left_attach">1</property>
- <property name="top_attach">1</property>
+ <property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
<object class="GtkEntry" id="taskdescription">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
+ <property name="margin_bottom">4</property>
<property name="invisible_char">•</property>
<property name="invisible_char_set">True</property>
</object>
<property name="height">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
+ <property name="margin_bottom">4</property>
+ <property name="label" translatable="yes">Project:</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="taskproject">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
+ <property name="invisible_char">•</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">True</property>
static struct task **tasks;
static GtkTextView *w_note;
static GtkEntry *w_description;
+static GtkEntry *w_project;
static GtkTreeView *w_treeview;
static GtkWidget *w_tasksave_btn;
+static GtkComboBox *w_status;
static struct task *get_selected_task(GtkTreeView *treeview)
{
return task;
}
+static void clear_task_panel()
+{
+ GtkTextBuffer *buf;
+
+ gtk_widget_set_sensitive(w_tasksave_btn, 0);
+
+ buf = gtk_text_view_get_buffer(w_note);
+ gtk_text_buffer_set_text(buf, "", 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(w_note), 0);
+
+ gtk_entry_set_text(w_description, "");
+ gtk_widget_set_sensitive(GTK_WIDGET(w_description), 0);
+
+ gtk_entry_set_text(w_project, "");
+ gtk_widget_set_sensitive(GTK_WIDGET(w_project), 0);
+}
+
static void refresh()
{
GtkTreeModel *model;
struct task *task;
int i;
GtkTreeIter iter;
-
- tasks = get_all_tasks();
+ int status;
+
+ clear_task_panel();
+
+ status = gtk_combo_box_get_active(w_status);
+ printf("status: %d\n", status);
+
+ switch (status) {
+ case 0:
+ tasks = get_all_tasks("pending");
+ break;
+ case 1:
+ tasks = get_all_tasks("completed");
+ break;
+ default:
+ tasks = get_all_tasks("pending");
+ }
model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
gtk_list_store_clear(GTK_LIST_STORE(model));
return FALSE;
}
+static int status_changed_cbk(GtkComboBox *w, gpointer data)
+{
+ printf("status_changed_cbk\n");
+ refresh();
+
+ return FALSE;
+}
+
static int cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
{
struct task *task;
if (task) {
- if (task->note) {
- buf = gtk_text_view_get_buffer(w_note);
+ buf = gtk_text_view_get_buffer(w_note);
+ if (task->note)
gtk_text_buffer_set_text(buf,
task->note,
strlen(task->note));
- }
+ else
+ gtk_text_buffer_set_text(buf, "", 0);
+ gtk_widget_set_sensitive(GTK_WIDGET(w_note), 1);
gtk_entry_set_text(w_description, task->description);
+ gtk_widget_set_sensitive(GTK_WIDGET(w_description), 1);
+
+ if (task->project)
+ gtk_entry_set_text(w_project, task->project);
+ else
+ gtk_entry_set_text(w_project, "");
+ gtk_widget_set_sensitive(GTK_WIDGET(w_project), 1);
+
gtk_widget_set_sensitive(w_tasksave_btn, 1);
} else {
- gtk_widget_set_sensitive(w_tasksave_btn, 0);
+ printf("clear task widgets\n");
+ clear_task_panel();
}
return FALSE;
w_description = GTK_ENTRY(gtk_builder_get_object(builder,
"taskdescription"));
+ w_project = GTK_ENTRY(gtk_builder_get_object(builder, "taskproject"));
+ w_status = GTK_COMBO_BOX(gtk_builder_get_object(builder, "status"));
refresh();
g_signal_connect(w_treeview,
"cursor-changed", (GCallback)cursor_changed_cbk,
tasks);
-
+ g_signal_connect(w_status,
+ "changed", (GCallback)status_changed_cbk,
+ tasks);
btn = GTK_WIDGET(gtk_builder_get_object(builder, "tasksave"));
g_signal_connect(btn,
"clicked", (GCallback)tasksave_clicked_cbk, tasks);