added combo box for project in the new task dialog
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 27 Sep 2014 09:25:48 +0000 (11:25 +0200)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sat, 27 Sep 2014 09:25:48 +0000 (11:25 +0200)
NEWS
src/glade/ptask.glade
src/ui_newtask_diag.c

diff --git a/NEWS b/NEWS
index 7eac39b..553fd16 100644 (file)
--- 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.
index 468b473..173934b 100644 (file)
               <object class="GtkLabel" id="label7">
                 <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>
               </packing>
             </child>
             <child>
-              <object class="GtkEntry" id="diag_tasknew_project">
+              <object class="GtkLabel" id="label8">
                 <property name="visible">True</property>
-                <property name="can_focus">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="invisible_char">•</property>
+                <property name="label" translatable="yes">Priority:</property>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
+                <property name="left_attach">0</property>
+                <property name="top_attach">2</property>
                 <property name="width">1</property>
                 <property name="height">1</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label8">
+              <object class="GtkComboBox" id="diag_tasknew_priority">
                 <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>
+                <property name="model">prioritystore</property>
+                <property name="active">2</property>
+                <child>
+                  <object class="GtkCellRendererText" id="cellrenderertext1"/>
+                  <attributes>
+                    <attribute name="text">0</attribute>
+                  </attributes>
+                </child>
               </object>
               <packing>
-                <property name="left_attach">0</property>
+                <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="GtkComboBox" id="diag_tasknew_priority">
+              <object class="GtkComboBoxText" id="diag_tasknew_project">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="halign">start</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">2</property>
-                <child>
-                  <object class="GtkCellRendererText" id="cellrenderertext1"/>
-                  <attributes>
-                    <attribute name="text">0</attribute>
-                  </attributes>
+                <property name="has_entry">True</property>
+                <child internal-child="entry">
+                  <object class="GtkEntry" id="comboboxtext-entry">
+                    <property name="can_focus">True</property>
+                  </object>
                 </child>
               </object>
               <packing>
                 <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
+                <property name="top_attach">1</property>
                 <property name="width">1</property>
                 <property name="height">1</property>
               </packing>
index fdfec87..0f3fa4c 100644 (file)
@@ -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"));