display project table
authorJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 29 Nov 2013 08:49:25 +0000 (08:49 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Fri, 29 Nov 2013 08:49:25 +0000 (08:49 +0000)
src/Makefile.am
src/Makefile.in
src/glade/ptask.glade
src/list.c [new file with mode: 0644]
src/list.h [new file with mode: 0644]
src/main.c
src/tw.c
src/tw.h
src/ui_projecttree.c [new file with mode: 0644]
src/ui_projecttree.h [new file with mode: 0644]

index e8dae2f..3b096b0 100644 (file)
@@ -11,14 +11,16 @@ LIBS = $(JSON_LIBS) $(GTK_LIBS)
 
 bin_PROGRAMS = ptask
 
-ptask_SOURCES = main.c \
+ptask_SOURCES = list.c list.h \
        log.c log.h \
+       main.c \
        note.c note.h \
        pstr.c pstr.h \
        ptime.c ptime.h \
        tw.c tw.h \
        ui.c ui.h \
-       ui_newtask_diag.c ui_newtask_diag.h
+       ui_newtask_diag.c ui_newtask_diag.h \
+       ui_projecttree.c ui_projecttree.h
 
 dist_man_MANS = ptask.1
 
index 3b3042d..2b707ce 100644 (file)
@@ -65,9 +65,10 @@ CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
 PROGRAMS = $(bin_PROGRAMS)
-am_ptask_OBJECTS = main.$(OBJEXT) log.$(OBJEXT) note.$(OBJEXT) \
-       pstr.$(OBJEXT) ptime.$(OBJEXT) tw.$(OBJEXT) ui.$(OBJEXT) \
-       ui_newtask_diag.$(OBJEXT)
+am_ptask_OBJECTS = list.$(OBJEXT) log.$(OBJEXT) main.$(OBJEXT) \
+       note.$(OBJEXT) pstr.$(OBJEXT) ptime.$(OBJEXT) tw.$(OBJEXT) \
+       ui.$(OBJEXT) ui_newtask_diag.$(OBJEXT) \
+       ui_projecttree.$(OBJEXT)
 ptask_OBJECTS = $(am_ptask_OBJECTS)
 ptask_LDADD = $(LDADD)
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
@@ -289,14 +290,16 @@ SUBDIRS = glade
 # -export-dynamic is need for defining handlers in the glade file.
 AM_LDFLAGS = -Wl,--as-needed  -export-dynamic
 AM_CPPFLAGS = -Wall -Werror $(GTK_CFLAGS) $(JSON_CFLAGS)
-ptask_SOURCES = main.c \
+ptask_SOURCES = list.c list.h \
        log.c log.h \
+       main.c \
        note.c note.h \
        pstr.c pstr.h \
        ptime.c ptime.h \
        tw.c tw.h \
        ui.c ui.h \
-       ui_newtask_diag.c ui_newtask_diag.h
+       ui_newtask_diag.c ui_newtask_diag.h \
+       ui_projecttree.c ui_projecttree.h
 
 dist_man_MANS = ptask.1
 gsettings_SCHEMAS = ptask.gschema.xml
@@ -385,6 +388,7 @@ mostlyclean-compile:
 distclean-compile:
        -rm -f *.tab.c
 
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/note.Po@am__quote@
@@ -393,6 +397,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tw.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_newtask_diag.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ui_projecttree.Po@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@   $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
index c56a143..731c12f 100644 (file)
@@ -1,6 +1,26 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
+  <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">Low</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Medium</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">High</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="diag_tasknew">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
       <action-widget response="0">button2</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkListStore" id="prioritystore">
+  <object class="GtkListStore" id="projectstore">
     <columns>
-      <!-- column-name priority -->
+      <!-- column-name gchararray1 -->
       <column type="gchararray"/>
+      <!-- column-name gint1 -->
+      <column type="gint"/>
     </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">None</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Low</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Medium</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">High</col>
-      </row>
-    </data>
   </object>
   <object class="GtkListStore" id="statusstore">
     <columns>
     <property name="default_width">640</property>
     <property name="default_height">480</property>
     <child>
-      <object class="GtkBox" id="box1">
+      <object class="GtkBox" id="box2">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="margin_left">4</property>
         <child>
           <object class="GtkPaned" id="paned1">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="orientation">vertical</property>
-            <property name="position">200</property>
-            <property name="position_set">True</property>
+            <property name="can_focus">False</property>
             <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow2">
+              <object class="GtkScrolledWindow" id="scrolledwindow3">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="margin_bottom">4</property>
+                <property name="can_focus">False</property>
                 <property name="shadow_type">in</property>
                 <child>
-                  <object class="GtkTreeView" id="treeview">
+                  <object class="GtkTreeView" id="projecttree">
                     <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="model">taskstore</property>
-                    <property name="headers_clickable">False</property>
-                    <property name="search_column">1</property>
-                    <property name="enable_grid_lines">both</property>
-                    <property name="enable_tree_lines">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="model">projectstore</property>
                     <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection"/>
-                    </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>
+                      <object class="GtkTreeSelection" id="treeview-selection2"/>
                     </child>
                     <child>
-                      <object class="GtkTreeViewColumn" id="project">
-                        <property name="min_width">10</property>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn1">
                         <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"/>
+                          <object class="GtkCellRendererText" id="cellrenderertext7"/>
                           <attributes>
-                            <attribute name="text">2</attribute>
+                            <attribute name="text">0</attribute>
                           </attributes>
                         </child>
                       </object>
                     </child>
                     <child>
-                      <object class="GtkTreeViewColumn" id="description">
-                        <property name="fixed_width">10</property>
-                        <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>
+                      <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+                        <property name="title" translatable="yes">Count</property>
                         <child>
-                          <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                          <object class="GtkCellRendererText" id="cellrenderertext8"/>
                           <attributes>
                             <attribute name="text">1</attribute>
                           </attributes>
               </packing>
             </child>
             <child>
-              <object class="GtkBox" id="box2">
+              <object class="GtkPaned" id="paned2">
                 <property name="visible">True</property>
-                <property name="can_focus">False</property>
+                <property name="can_focus">True</property>
                 <property name="orientation">vertical</property>
+                <property name="position">200</property>
+                <property name="position_set">True</property>
                 <child>
-                  <object class="GtkGrid" id="grid2">
+                  <object class="GtkScrolledWindow" id="scrolledwindow2">
                     <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="can_focus">True</property>
                     <property name="margin_bottom">4</property>
+                    <property name="shadow_type">in</property>
                     <child>
-                      <object class="GtkLabel" id="label1">
+                      <object class="GtkTreeView" id="treeview">
                         <property name="visible">True</property>
-                        <property name="can_focus">False</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="label" translatable="yes">Description:</property>
+                        <property name="model">taskstore</property>
+                        <property name="headers_clickable">False</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="GtkTreeSelection" id="treeview-selection3"/>
+                        </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="project">
+                            <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>
+                                <attribute name="text">2</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="description">
+                            <property name="fixed_width">10</property>
+                            <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>
+                                <attribute name="text">1</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
                       </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>
+                  </object>
+                  <packing>
+                    <property name="resize">False</property>
+                    <property name="shrink">True</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkBox" id="box3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="orientation">vertical</property>
                     <child>
-                      <object class="GtkLabel" id="label2">
+                      <object class="GtkGrid" id="grid2">
                         <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>
-                        <property name="label" translatable="yes">Note:</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">4</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkScrolledWindow" id="scrolledwindow1">
-                        <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="hexpand">True</property>
-                        <property name="vexpand">True</property>
-                        <property name="shadow_type">in</property>
+                        <property name="margin_bottom">4</property>
+                        <child>
+                          <object class="GtkLabel" id="label1">
+                            <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="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="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>
+                            <property name="label" translatable="yes">Note:</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">4</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
                         <child>
-                          <object class="GtkTextView" id="tasknote">
+                          <object class="GtkScrolledWindow" id="scrolledwindow1">
                             <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="hexpand">True</property>
+                            <property name="vexpand">True</property>
+                            <property name="shadow_type">in</property>
+                            <child>
+                              <object class="GtkTextView" id="tasknote">
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                              </object>
+                            </child>
                           </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">4</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <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>
+                          <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>
+                        <child>
+                          <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>
+                            <property name="label" translatable="yes">Project:</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">3</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">3</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">2</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">2</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButtonBox" id="buttonbox2">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="layout_style">start</property>
+                            <child>
+                              <object class="GtkButton" id="taskdone">
+                                <property name="label" translatable="yes">Mark Done</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <signal name="clicked" handler="taskdone_clicked_cbk" swapped="no"/>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">True</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">2</property>
+                            <property name="height">1</property>
+                          </packing>
                         </child>
                       </object>
                       <packing>
-                        <property name="left_attach">1</property>
-                        <property name="top_attach">4</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <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>
-                      <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>
-                    <child>
-                      <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>
-                        <property name="label" translatable="yes">Project:</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">3</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">3</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">2</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkComboBox" id="taskpriority">
+                      <object class="GtkBox" id="box6">
                         <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>
+                          <object class="GtkButton" id="tasksave">
+                            <property name="label" translatable="yes">Save</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="image_position">top</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
                         </child>
-                      </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="GtkButtonBox" id="buttonbox2">
-                        <property name="visible">True</property>
-                        <property name="can_focus">False</property>
-                        <property name="layout_style">start</property>
                         <child>
-                          <object class="GtkButton" id="taskdone">
-                            <property name="label" translatable="yes">Mark Done</property>
+                          <object class="GtkButton" id="taskcancel">
+                            <property name="label" translatable="yes">Cancel</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
                             <property name="receives_default">True</property>
-                            <signal name="clicked" handler="taskdone_clicked_cbk" swapped="no"/>
                           </object>
                           <packing>
                             <property name="expand">False</property>
                             <property name="fill">True</property>
-                            <property name="position">0</property>
+                            <property name="position">2</property>
                           </packing>
                         </child>
                       </object>
                       <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">2</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkBox" id="box3">
-                    <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>
-                    <child>
-                      <object class="GtkButton" id="tasksave">
-                        <property name="label" translatable="yes">Save</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="image_position">top</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="taskcancel">
-                        <property name="label" translatable="yes">Cancel</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                      </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">False</property>
-                    <property name="position">2</property>
+                    <property name="resize">True</property>
+                    <property name="shrink">True</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="resize">True</property>
+                <property name="resize">False</property>
                 <property name="shrink">True</property>
               </packing>
             </child>
diff --git a/src/list.c b/src/list.c
new file mode 100644 (file)
index 0000000..d4c4806
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "list.h"
+
+int list_length(void **list)
+{
+       int n;
+
+       if (!list)
+               return 0;
+
+       n = 0;
+       while (*list) {
+               n++;
+               list++;
+       }
+
+       return n;
+}
+
+void **list_add(void **list, void *item)
+{
+       int n;
+       void **result;
+
+       n = list_length(list);
+
+       result = malloc((n + 1 + 1) * sizeof(void *));
+
+       if (list)
+               memcpy(result, list, n * sizeof(void *));
+
+       result[n] = item;
+       result[n + 1] = NULL;
+
+       return result;
+}
+
+void list_free(void **list)
+{
+       free(list);
+}
diff --git a/src/list.h b/src/list.h
new file mode 100644 (file)
index 0000000..91aa116
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+
+#ifndef _P_LIST_H_
+#define _P_LIST_H_
+
+int list_length(void **list);
+void **list_add(void **list, void *item);
+void list_free(void **list);
+
+#endif
index 2171895..1a2509e 100644 (file)
@@ -32,6 +32,7 @@
 #include "note.h"
 #include "tw.h"
 #include <ui.h>
+#include <ui_projecttree.h>
 
 static const char *program_name;
 static struct task **tasks;
@@ -203,6 +204,7 @@ void refresh()
                                           COL_PRIORITY, (*tasks_cur)->priority,
                                           -1);
                }
+               ui_projecttree_update(tasks);
        } else {
                dialog = gtk_message_dialog_new(NULL,
                                                GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -463,6 +465,8 @@ int main(int argc, char **argv)
                 NULL);
        window = create_window(builder, settings);
 
+       ui_projecttree_init(builder);
+
        w_treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
        model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
        gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model),
index 926a039..6c25697 100644 (file)
--- a/src/tw.c
+++ b/src/tw.c
@@ -24,6 +24,7 @@
 
 #include <json/json.h>
 
+#include <list.h>
 #include <log.h>
 #include "note.h"
 #include <pstr.h>
@@ -180,7 +181,7 @@ struct task **tw_get_all_tasks(const char *status)
                        tasks[i]->project
                                = strdup(json_object_get_string(json));
                else
-                       tasks[i]->project = NULL;
+                       tasks[i]->project = strdup("");
 
                json = json_object_object_get(jtask, "priority");
                if (json)
@@ -373,3 +374,54 @@ void tw_task_list_free(struct task **tasks)
 
        free(tasks);
 }
+
+static struct project *project_list_get(struct project **prj, const char *name)
+{
+       while (*prj)
+               if (!strcmp((*prj)->name, name))
+                       return *prj;
+               else
+                       prj++;
+       return NULL;
+}
+
+static struct project *project_new(const char *name, int count)
+{
+       struct project *prj;
+
+       prj = malloc(sizeof(struct project));
+
+       prj->name = strdup(name);
+       prj->count = count;
+
+       return prj;
+}
+
+struct project **tw_get_projects(struct task **tasks)
+{
+       struct task **t_cur;
+       struct project **prjs, **tmp, *prj;
+       const char *prj_name;
+
+       log_debug("tw_get_projects()");
+
+       prjs = malloc(sizeof(struct project *));
+       *prjs = NULL;
+
+       for (t_cur = tasks; *t_cur; t_cur++) {
+               prj_name = (*t_cur)->project;
+               prj = project_list_get(prjs, prj_name);
+               if (prj) {
+                       prj->count++;
+               } else {
+                       prj = project_new(prj_name, 1);
+                       
+                       tmp = (struct project **)list_add((void **)prjs, prj);
+                       
+                       list_free((void **)prjs);
+                       prjs = tmp;
+               }
+       }
+
+       return prjs;
+}
index 41a1789..a8c0791 100644 (file)
--- a/src/tw.h
+++ b/src/tw.h
@@ -17,8 +17,8 @@
  * 02110-1301 USA
  */
 
-#ifndef _GTASK_TW_H_
-#define _GTASK_TW_H_
+#ifndef _PTASK_TW_H_
+#define _PTASK_TW_H_
 
 struct task {
        int id;
@@ -30,6 +30,11 @@ struct task {
        char *priority;
 };
 
+struct project {
+       char *name;
+       int count;
+};
+
 struct task **tw_get_all_tasks(const char *status);
 void tw_modify_description(const char *uuid, const char *newdesc);
 void tw_modify_project(const char *uuid, const char *newproj);
@@ -37,5 +42,6 @@ void tw_modify_priority(const char *uuid, const char *priority);
 void tw_done(const char *uuid);
 void tw_add(const char *newdesc, const char *prj, const char *prio);
 void tw_task_list_free(struct task **tasks);
+struct project **tw_get_projects(struct task **tasks);
 
 #endif
diff --git a/src/ui_projecttree.c b/src/ui_projecttree.c
new file mode 100644 (file)
index 0000000..d993a17
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#include <stdio.h>
+
+#include <log.h>
+#include <ui_projecttree.h>
+
+static GtkTreeView *w_treeview;
+
+void ui_projecttree_init(GtkBuilder *builder)
+{
+       w_treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "projecttree"));
+}
+
+void ui_projecttree_update(struct task **ts)
+{
+       struct project **prjs;
+       GtkTreeModel *model;
+       GtkTreeIter iter;
+
+       log_debug("ui_projecttree_update()");
+
+       model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
+       gtk_list_store_clear(GTK_LIST_STORE(model));
+
+       prjs = tw_get_projects(ts);
+       while (*prjs) {
+               gtk_list_store_append(GTK_LIST_STORE(model), &iter);
+
+               gtk_list_store_set(GTK_LIST_STORE(model),
+                                  &iter,
+                                  0, (*prjs)->name,
+                                  1, (*prjs)->count,
+                                  -1);
+
+               prjs++;
+       }
+}
diff --git a/src/ui_projecttree.h b/src/ui_projecttree.h
new file mode 100644 (file)
index 0000000..d4848d9
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012-2013 jeanfi@gmail.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ */
+#ifndef _PTASK_UI_PROJECTTREE_H_
+#define _PTASK_UI_PROJECTTREE_H_
+
+#include <gtk/gtk.h>
+
+#include <tw.h>
+
+void ui_projecttree_init(GtkBuilder *builder);
+void ui_projecttree_update(struct task **);
+
+#endif