(no commit message)
authorJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 30 Apr 2013 10:01:36 +0000 (10:01 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Tue, 30 Apr 2013 10:01:36 +0000 (10:01 +0000)
src/glade/prss.glade
src/main.c

index 6f583aa..ad392ef 100644 (file)
@@ -5,11 +5,6 @@
     <property name="label" translatable="yes">Refresh</property>
     <property name="stock_id">gtk-refresh</property>
   </object>
-  <object class="GtkAction" id="preferences_action">
-    <property name="label" translatable="yes">Preferences</property>
-    <property name="stock_id">gtk-preferences</property>
-    <signal name="activate" handler="preferences_action_activate_cbk" swapped="no"/>
-  </object>
   <object class="GtkListStore" id="feed_store">
     <columns>
       <!-- column-name gchararray1 -->
   </object>
   <object class="GtkListStore" id="headline_store">
     <columns>
-      <!-- column-name gchararray1 -->
+      <!-- column-name title -->
       <column type="gchararray"/>
-      <!-- column-name gpointer1 -->
+      <!-- column-name id -->
       <column type="gint"/>
+      <!-- column-name date -->
+      <column type="gchararray"/>
     </columns>
   </object>
   <object class="GtkListStore" id="liststore1">
       </row>
     </data>
   </object>
+  <object class="GtkAction" id="preferences_action">
+    <property name="label" translatable="yes">Preferences</property>
+    <property name="stock_id">gtk-preferences</property>
+    <signal name="activate" handler="preferences_action_activate_cbk" swapped="no"/>
+  </object>
   <object class="GtkDialog" id="settings_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
                           <object class="GtkTreeSelection" id="treeview-selection2"/>
                         </child>
                         <child>
-                          <object class="GtkTreeViewColumn" id="treeviewcolumn2">
-                            <property name="spacing">3</property>
-                            <property name="max_width">0</property>
+                          <object class="GtkTreeViewColumn" id="col_headine_title">
+                            <property name="resizable">True</property>
+                            <property name="sizing">fixed</property>
+                            <property name="fixed_width">300</property>
+                            <property name="min_width">300</property>
                             <property name="title" translatable="yes">Headline</property>
                             <child>
                               <object class="GtkCellRendererText" id="cellrenderertext1"/>
                             </child>
                           </object>
                         </child>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="col_headine_date">
+                            <property name="resizable">True</property>
+                            <property name="sizing">fixed</property>
+                            <property name="fixed_width">50</property>
+                            <property name="min_width">50</property>
+                            <property name="title" translatable="yes">Date</property>
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext3"/>
+                              <attributes>
+                                <attribute name="markup">2</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
index 2661e4a..59f3999 100644 (file)
@@ -51,7 +51,8 @@ enum {
 
 enum {
        COL_HEADLINE_TITLE,
-       COL_HEADLINE_ID
+       COL_HEADLINE_ID,
+       COL_HEADLINE_DATE
 };
 
 static struct option long_options[] = {
@@ -276,14 +277,37 @@ static struct headline *get_selected_headline(GtkTreeIter *iter)
        return NULL;
 }
 
+static char *headline_get_formated_headline(struct headline *h)
+{
+       if (h->unread)
+               return g_strdup_printf("<b>%s</b>", h->title);
+       else
+               return strdup(h->title);
+}
+
+static char *headline_get_date(struct headline *h)
+{
+       struct tm *tmp;
+       char date[200];
+
+       tmp = localtime(&h->date);
+       
+       if (h->unread)
+               strftime(date, sizeof(date), "<b>%D</b>", tmp);
+       else
+               strftime(date, sizeof(date), "%D", tmp);
+
+       return strdup(date);
+}
+
 int feed_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
 {
        GtkTreeIter iter;
        GtkTreeModel *headline_model;
        GtkListStore *headline_store;
        struct feed *feed;
-       struct headline **headlines;
-       char *title;
+       struct headline **headlines, *h;
+       char *title, *date;
 
        if (model_state)
                return TRUE;
@@ -303,22 +327,23 @@ int feed_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
                        while (headlines && *headlines) {
                                gtk_list_store_append(headline_store, &iter);
 
-                               if ((*headlines)->unread)
-                                       title = g_strdup_printf
-                                               ("<b>%s</b>",
-                                                (*headlines)->title);
-                               else
-                                       title = strdup((*headlines)->title);
+                               h = *headlines;
+
+                               title = headline_get_formated_headline(h);
+                               date = headline_get_date(h);
 
                                gtk_list_store_set(headline_store,
                                                   &iter,
                                                   COL_HEADLINE_TITLE,
                                                   title,
                                                   COL_HEADLINE_ID,
-                                                  (*headlines)->id,
+                                                  h->id,
+                                                  COL_HEADLINE_DATE,
+                                                  date,
                                                   -1);
 
-                               free(title);
+                               g_free(title);
+                               free(date);
 
                                headlines++;
                        }