(no commit message)
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 16 Oct 2012 21:47:12 +0000 (21:47 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 16 Oct 2012 21:47:12 +0000 (21:47 +0000)
src/glade/gtask.glade
src/main.c

index f02c3b3..1bdc745 100644 (file)
       <action-widget response="0">button2</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkListStore" id="prioritystore">
+    <columns>
+      <!-- column-name priority -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">None</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">High</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Medium</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Low</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkListStore" id="statusstore">
     <columns>
       <!-- column-name gchararray1 -->
       <column type="gchararray"/>
       <!-- column-name uuid -->
       <column type="gchararray"/>
+      <!-- column-name priority -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkWindow" id="window">
                     <property name="margin_top">4</property>
                     <property name="margin_bottom">4</property>
                     <property name="model">taskstore</property>
-                    <property name="headers_clickable">False</property>
                     <property name="expander_column">treeviewcolumn1</property>
                     <property name="search_column">1</property>
                     <property name="enable_grid_lines">both</property>
                       </object>
                     </child>
                     <child>
+                      <object class="GtkTreeViewColumn" id="Priority">
+                        <property name="title" translatable="yes">priority</property>
+                        <property name="sort_column_id">4</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext5"/>
+                          <attributes>
+                            <attribute name="text">4</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                    </child>
+                    <child>
                       <object class="GtkTreeViewColumn" id="treeviewcolumn3">
                         <property name="min_width">10</property>
                         <property name="title" translatable="yes">Project</property>
                       </object>
                       <packing>
                         <property name="left_attach">0</property>
-                        <property name="top_attach">2</property>
+                        <property name="top_attach">3</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </packing>
                       </object>
                       <packing>
                         <property name="left_attach">1</property>
-                        <property name="top_attach">2</property>
+                        <property name="top_attach">3</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
                       </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">2</property>
+                        <property name="width">1</property>
+                        <property name="height">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="label6">
+                        <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>
+                        <property name="label" translatable="yes">Priority:</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="GtkComboBox" id="taskpriority">
+                        <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="model">prioritystore</property>
+                        <property name="active">0</property>
+                        <child>
+                          <object class="GtkCellRendererText" id="cellrenderertext6"/>
+                          <attributes>
+                            <attribute name="text">0</attribute>
+                          </attributes>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="left_attach">1</property>
                         <property name="top_attach">1</property>
                         <property name="width">1</property>
                         <property name="height">1</property>
index fd58304..864edb9 100644 (file)
@@ -33,6 +33,7 @@ static GtkEntry *w_project;
 static GtkTreeView *w_treeview;
 static GtkWidget *w_tasksave_btn;
 static GtkComboBox *w_status;
+static GtkComboBox *w_priority;
 
 enum {
        COL_ID,
@@ -88,6 +89,9 @@ static void clear_task_panel()
 
        gtk_entry_set_text(w_project, "");
        gtk_widget_set_sensitive(GTK_WIDGET(w_project), 0);
+
+       gtk_combo_box_set_active(w_priority, 0);
+       gtk_widget_set_sensitive(GTK_WIDGET(w_priority), 0);
 }
 
 static void refresh()
@@ -142,9 +146,10 @@ static int tasksave_clicked_cbk(GtkButton *btn, gpointer data)
 {
        struct task *task;
        GtkTextBuffer *buf;
-       char *txt;
+       char *txt, *pri;
        GtkTextIter sIter, eIter;
        const char *ctxt;
+       int priority;
 
        task = get_selected_task(GTK_TREE_VIEW(w_treeview));
 
@@ -170,6 +175,26 @@ static int tasksave_clicked_cbk(GtkButton *btn, gpointer data)
        if (!task->project || strcmp(ctxt, task->project))
                tw_modify_project(task->uuid, ctxt);
 
+       priority = gtk_combo_box_get_active(w_priority);
+       printf("priority: %d\n", priority);
+
+       switch (priority) {
+       case 1:
+               pri = "H";
+               break;
+       case 2:
+               pri = "M";
+               break;
+       case 3:
+               pri = "L";
+               break;
+       default:
+               pri = "";
+       }
+
+       if (strcmp(task->priority, pri))
+               tw_modify_priority(task->uuid, pri);
+
        refresh();
 
        return FALSE;
@@ -236,6 +261,7 @@ static int cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
 {
        struct task *task;
        GtkTextBuffer *buf;
+       int priority;
 
        printf("cursor_changed_cbk\n");
 
@@ -262,6 +288,18 @@ static int cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
                gtk_widget_set_sensitive(GTK_WIDGET(w_project), 1);
 
                gtk_widget_set_sensitive(w_tasksave_btn, 1);
+
+               gtk_widget_set_sensitive(GTK_WIDGET(w_priority), 1);
+               if (!strcmp(task->priority, "H"))
+                       priority = 1;
+               else if (!strcmp(task->priority, "M"))
+                       priority = 2;
+               else if (!strcmp(task->priority, "L"))
+                       priority = 3;
+               else
+                       priority = 0;
+
+               gtk_combo_box_set_active(w_priority, priority);
        } else {
                printf("clear task widgets\n");
                clear_task_panel();
@@ -292,6 +330,8 @@ int main(int argc, char **argv)
                                                         "taskdescription"));
        w_project = GTK_ENTRY(gtk_builder_get_object(builder, "taskproject"));
        w_status = GTK_COMBO_BOX(gtk_builder_get_object(builder, "status"));
+       w_priority = GTK_COMBO_BOX(gtk_builder_get_object(builder,
+                                                         "taskpriority"));
 
        refresh();