summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiscomfitor <michael.blumenkrantz@gmail.com>2013-10-19 23:55:13 +0100
committerdiscomfitor <michael.blumenkrantz@gmail.com>2013-10-19 23:55:13 +0100
commitb14c94396029a36ea682569f1cd9257c7b904f65 (patch)
tree868c4a82ebdf0ead913481cd1e5a9f1a2393e320
parent8923e8d2ed9fe7348bfd52202ca1619ac641f9ef (diff)
reuse existing loaded unread feed items
-rw-r--r--src/utils/erssd-config.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/utils/erssd-config.c b/src/utils/erssd-config.c
index d32bdcd..9775585 100644
--- a/src/utils/erssd-config.c
+++ b/src/utils/erssd-config.c
@@ -55,6 +55,23 @@ _feed_selected_cb(void *data EINA_UNUSED /* Rss_Feed */, Evas_Object *obj EINA_U
55 elm_object_disabled_set(button_del, 0); 55 elm_object_disabled_set(button_del, 0);
56} 56}
57 57
58static int
59_sort_cb(Elm_Object_Item *a, Elm_Object_Item *b)
60{
61 Azy_Rss_Item *aa, *bb;
62
63 aa = elm_object_item_data_get(a);
64 bb = elm_object_item_data_get(b);
65
66 if (azy_rss_item_pubdate_get(aa) > azy_rss_item_pubdate_get(bb))
67 return -1;
68
69 if (azy_rss_item_pubdate_get(aa) < azy_rss_item_pubdate_get(bb))
70 return 1;
71
72 return 0;
73}
74
58static void 75static void
59_feed_activate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) 76_feed_activate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
60{ 77{
@@ -63,15 +80,16 @@ _feed_activate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event
63 80
64 if (evas_object_data_get(feed_item_list, "feed") != feed) 81 if (evas_object_data_get(feed_item_list, "feed") != feed)
65 { 82 {
66 Eina_List *l;
67 Azy_Rss_Item *item; 83 Azy_Rss_Item *item;
84 Eina_Iterator *iter;
68 85
69 evas_object_data_set(feed_item_list, "feed", feed); 86 evas_object_data_set(feed_item_list, "feed", feed);
70 elm_genlist_clear(feed_item_list); 87 elm_genlist_clear(feed_item_list);
71 elm_object_item_text_set(feed_item_list_item, azy_rss_title_get(feed->rss)); 88 elm_object_item_text_set(feed_item_list_item, azy_rss_title_get(feed->rss));
72 l = erssd_util_eet_feed_unread_get(ef_cache[feed->conn], feed->url); 89 iter = eina_hash_iterator_data_new(feed->unread_items);
73 EINA_LIST_FREE(l, item) 90 EINA_ITERATOR_FOREACH(iter, item)
74 elm_genlist_item_append(feed_item_list, &feed_item_itc, item, NULL, 0, NULL, item); 91 elm_genlist_item_sorted_insert(feed_item_list, &feed_item_itc, item, NULL, 0, (Eina_Compare_Cb)_sort_cb, NULL, item);
92 eina_iterator_free(iter);
75 } 93 }
76 elm_naviframe_item_promote(feed_item_list_item); 94 elm_naviframe_item_promote(feed_item_list_item);
77} 95}
@@ -180,12 +198,6 @@ _it_feed_text_get(Azy_Rss_Item *item, Evas_Object *obj EINA_UNUSED, const char *
180 return title ? strdup(title) : NULL; 198 return title ? strdup(title) : NULL;
181} 199}
182 200
183static void
184_it_feed_del(Azy_Rss_Item *item, Evas_Object *obj EINA_UNUSED)
185{
186 azy_rss_item_free(item);
187}
188
189static char * 201static char *
190_it_text_get(Rss_Feed *feed, Evas_Object *obj EINA_UNUSED, const char *part) 202_it_text_get(Rss_Feed *feed, Evas_Object *obj EINA_UNUSED, const char *part)
191{ 203{
@@ -559,7 +571,6 @@ main(int argc, char *argv[])
559 571
560 feed_item_itc.item_style = "double_label"; 572 feed_item_itc.item_style = "double_label";
561 feed_item_itc.func.text_get = (Elm_Genlist_Item_Text_Get_Cb)_it_feed_text_get; 573 feed_item_itc.func.text_get = (Elm_Genlist_Item_Text_Get_Cb)_it_feed_text_get;
562 feed_item_itc.func.del = (Elm_Genlist_Item_Del_Cb)_it_feed_del;
563 feed_item_itc.version = ELM_GENLIST_ITEM_CLASS_VERSION; 574 feed_item_itc.version = ELM_GENLIST_ITEM_CLASS_VERSION;
564 575
565 erssd_util_feed_signal_cb_set(0, ERSSD_SIGNAL_FEED_UPDATED, _dbus_signal_feed_updated, NULL); 576 erssd_util_feed_signal_cb_set(0, ERSSD_SIGNAL_FEED_UPDATED, _dbus_signal_feed_updated, NULL);