<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
- <object class="GtkListStore" id="liststore1">
- <columns>
- <!-- column-name id -->
- <column type="gint"/>
- <!-- column-name description -->
- <column type="gchararray"/>
- <!-- column-name project -->
- <column type="gchararray"/>
- </columns>
+ <object class="GtkDialog" id="diag_tasknew">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">New Task</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox" id="dialog-vbox1">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area1">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-ok</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button2">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </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="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox" id="box6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <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">Description:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="diag_tasknew_description">
+ <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>
+ </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">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-3">button1</action-widget>
+ <action-widget response="0">button2</action-widget>
+ </action-widgets>
</object>
- <object class="GtkListStore" id="liststore2">
+ <object class="GtkListStore" id="statusstore">
<columns>
<!-- column-name gchararray1 -->
<column type="gchararray"/>
</row>
</data>
</object>
+ <object class="GtkListStore" id="taskstore">
+ <columns>
+ <!-- column-name id -->
+ <column type="gint"/>
+ <!-- column-name description -->
+ <column type="gchararray"/>
+ <!-- column-name project -->
+ <column type="gchararray"/>
+ <!-- column-name uuid -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkWindow" id="window">
<property name="can_focus">False</property>
<property name="title" translatable="yes">gtask</property>
<object class="GtkBox" id="box1">
<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="orientation">vertical</property>
<child>
<object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkButton" id="refresh">
- <property name="label" translatable="yes">refresh</property>
+ <object class="GtkButtonBox" id="buttonbox1">
<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>
- <signal name="clicked" handler="refresh_clicked_cbk" swapped="no"/>
+ <property name="can_focus">False</property>
+ <property name="layout_style">start</property>
+ <child>
+ <object class="GtkButton" id="refresh">
+ <property name="label" translatable="yes">Refresh</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="refresh_clicked_cbk" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="newtask">
+ <property name="label" translatable="yes">New Task</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <signal name="clicked" handler="newtask_clicked_cbk" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<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="fill">False</property>
<property name="position">0</property>
</packing>
</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="model">statusstore</property>
<property name="active">0</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4"/>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<property name="margin_right">4</property>
<property name="margin_top">4</property>
<property name="margin_bottom">4</property>
- <property name="model">liststore1</property>
+ <property name="model">taskstore</property>
<property name="headers_clickable">False</property>
<property name="expander_column">treeviewcolumn1</property>
- <property name="search_column">0</property>
+ <property name="search_column">1</property>
<property name="enable_grid_lines">both</property>
<property name="enable_tree_lines">True</property>
<child internal-child="selection">
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
<property name="min_width">10</property>
<property name="title" translatable="yes">Project</property>
+ <property name="clickable">True</property>
+ <property name="reorderable">True</property>
+ <property name="sort_indicator">True</property>
+ <property name="sort_column_id">2</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext3"/>
<attributes>
<property name="min_width">30</property>
<property name="title" translatable="yes">Description</property>
<property name="expand">True</property>
+ <property name="clickable">True</property>
+ <property name="reorderable">True</property>
+ <property name="sort_indicator">True</property>
+ <property name="sort_column_id">1</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext2"/>
<attributes>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">center</property>
<property name="margin_left">4</property>
<property name="margin_right">4</property>
<property name="margin_top">4</property>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="halign">start</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>
<child>
<object class="GtkButton" id="tasksave">
- <property name="label" translatable="yes">OK</property>
+ <property name="label" translatable="yes">Save</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
static GtkWidget *w_tasksave_btn;
static GtkComboBox *w_status;
+enum {
+ COL_ID,
+ COL_DESCRIPTION,
+ COL_PROJECT,
+ COL_UUID
+};
+
static struct task *get_selected_task(GtkTreeView *treeview)
{
GtkTreePath *path;
GtkTreeViewColumn *cols;
- gint *i;
- struct task *task;
+ struct task **tasks_cur;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ GValue value = {0,};
+ const char *uuid;
printf("get_selected_task\n");
gtk_tree_view_get_cursor(treeview, &path, &cols);
if (path) {
- i = gtk_tree_path_get_indices(path);
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
+ gtk_tree_model_get_iter(model, &iter, path);
+ gtk_tree_model_get_value(model, &iter, COL_UUID, &value);
- if (i) {
- printf("row selected: %d\n", *i);
+ uuid = g_value_get_string(&value);
- task = tasks[*i];
- } else {
- task = NULL;
- }
+ for(tasks_cur = tasks; *tasks_cur; tasks_cur++)
+ if (!strcmp((*tasks_cur)->uuid, uuid))
+ return *tasks_cur;
gtk_tree_path_free(path);
- } else {
- task = NULL;
}
- return task;
+ return NULL;
}
static void clear_task_panel()
if (task->project)
gtk_list_store_set(GTK_LIST_STORE(model),
&iter,
- 2, task->project,
+ COL_PROJECT, task->project,
-1);
gtk_list_store_set(GTK_LIST_STORE(model),
&iter,
- 0, (*tasks_cur)->id,
- 1, (*tasks_cur)->description,
+ COL_ID, (*tasks_cur)->id,
+ COL_DESCRIPTION, (*tasks_cur)->description,
+ COL_UUID, (*tasks_cur)->uuid,
-1);
}
}
return FALSE;
}
+int newtask_clicked_cbk(GtkButton *btn, gpointer data)
+{
+ gint result;
+ static GtkDialog *diag;
+ GtkBuilder *builder;
+ GtkEntry *entry;
+ const char *ctxt;
+
+ printf("newtask_clicked_cbk\n");
+
+ builder = gtk_builder_new();
+ gtk_builder_add_from_file
+ (builder,
+ PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "gtask.glade",
+ NULL);
+ diag = GTK_DIALOG(gtk_builder_get_object(builder, "diag_tasknew"));
+ gtk_builder_connect_signals(builder, NULL);
+
+ result = gtk_dialog_run(diag);
+
+ if (result == GTK_RESPONSE_ACCEPT) {
+ printf("ok\n");
+ entry = GTK_ENTRY(gtk_builder_get_object
+ (builder, "diag_tasknew_description"));
+ ctxt = gtk_entry_get_text(entry);
+
+ printf("%s\n", ctxt);
+
+ tw_add(ctxt);
+ refresh();
+ } else {
+ printf("cancel\n");
+ }
+
+ g_object_unref(G_OBJECT(builder));
+
+ gtk_widget_destroy(GTK_WIDGET(diag));
+
+ return FALSE;
+}
+
static int status_changed_cbk(GtkComboBox *w, gpointer data)
{
printf("status_changed_cbk\n");