From: Jean-Philippe Orsini Date: Tue, 30 Apr 2013 10:01:36 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.wpitchoune.net/gitweb/?p=prss.git;a=commitdiff_plain;h=c15a1b330bc1435c92221214108e398fd9dc1271 --- diff --git a/src/glade/prss.glade b/src/glade/prss.glade index 6f583aa..ad392ef 100644 --- a/src/glade/prss.glade +++ b/src/glade/prss.glade @@ -5,11 +5,6 @@ Refresh gtk-refresh - - Preferences - gtk-preferences - - @@ -20,10 +15,12 @@ - + - + + + @@ -40,6 +37,11 @@ + + Preferences + gtk-preferences + + False 5 @@ -465,9 +467,11 @@ - - 3 - 0 + + True + fixed + 300 + 300 Headline @@ -477,6 +481,21 @@ + + + True + fixed + 50 + 50 + Date + + + + 2 + + + + diff --git a/src/main.c b/src/main.c index 2661e4a..59f3999 100644 --- a/src/main.c +++ b/src/main.c @@ -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("%s", 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), "%D", 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 - ("%s", - (*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++; }