From: Jean-Philippe Orsini Date: Tue, 30 Apr 2013 09:03:16 +0000 (+0000) Subject: (no commit message) X-Git-Url: https://git.wpitchoune.net/gitweb/?p=prss.git;a=commitdiff_plain;h=4e47217ca7b179bf07e58ba965d03c2265d09def --- diff --git a/src/main.c b/src/main.c index 132aec1..2661e4a 100644 --- a/src/main.c +++ b/src/main.c @@ -97,30 +97,34 @@ static void print_help() GtkTreeView *w_feedtree; GtkTreeView *w_headlinetree; +static char *feed_get_formated_title(struct feed *f) +{ + if (f->unread) + return g_strdup_printf("%s (%d)", + f->title, + f->unread); + else + return strdup(f->title); +} + void update() { struct feed **feeds; - GtkTreeModel *model, *headlinemodel; + GtkTreeModel *model, *headline_model; GtkTreeIter iter; char *title; model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_feedtree)); + headline_model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_headlinetree)); log_debug("update(): clear feed tree."); model_state = 1; gtk_list_store_clear(GTK_LIST_STORE(model)); - headlinemodel = gtk_tree_view_get_model(w_headlinetree); - gtk_list_store_clear(GTK_LIST_STORE(headlinemodel)); + gtk_list_store_clear(GTK_LIST_STORE(headline_model)); log_debug("update(): clear feed tree done."); feeds = ttrss_get_feeds(); while (feeds && *feeds) { - if ((*feeds)->unread) - title = g_strdup_printf("%s (%d)", - (*feeds)->title, - (*feeds)->unread); - else - title = strdup((*feeds)->title); - + title = feed_get_formated_title(*feeds); gtk_list_store_append(GTK_LIST_STORE(model), &iter); @@ -129,12 +133,12 @@ void update() COL_FEED_TITLE, title, COL_FEED_ID, (*feeds)->id, -1); - free(title); - - ttrs_download_headline_content(feeds); - + g_free(title); feeds++; } + + ttrs_download_headline_content(feeds); + model_state = 0; log_debug("update() done");