summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiscomfitor <michael.blumenkrantz@gmail.com>2013-10-19 23:36:53 +0100
committerdiscomfitor <michael.blumenkrantz@gmail.com>2013-10-19 23:36:53 +0100
commit8923e8d2ed9fe7348bfd52202ca1619ac641f9ef (patch)
tree27fff1bcbbd8c2dd2690b544d8cf69571d378f6c
parent09f272f5157d4294bff9d82dc430e209472e087e (diff)
add simple rss item viewer to config on double click
-rw-r--r--src/utils/erssd-config.c82
1 files changed, 78 insertions, 4 deletions
diff --git a/src/utils/erssd-config.c b/src/utils/erssd-config.c
index 3d420d0..d32bdcd 100644
--- a/src/utils/erssd-config.c
+++ b/src/utils/erssd-config.c
@@ -35,8 +35,12 @@ static Evas_Object *feed_list;
35static Evas_Object *button_add, *button_del; 35static Evas_Object *button_add, *button_del;
36static Evas_Object *radios[2]; 36static Evas_Object *radios[2];
37 37
38static Evas_Object *naviframe;
39static Evas_Object *feed_item_list;
40static Elm_Object_Item *feed_item_list_item;
41
38static Elm_Genlist_Item_Class feed_itc; 42static Elm_Genlist_Item_Class feed_itc;
39//static Elm_Genlist_Item_Class feed_item_itc; 43static Elm_Genlist_Item_Class feed_item_itc;
40 44
41static void 45static void
42_cache_refresh(int conn) 46_cache_refresh(int conn)
@@ -51,6 +55,26 @@ _feed_selected_cb(void *data EINA_UNUSED /* Rss_Feed */, Evas_Object *obj EINA_U
51 elm_object_disabled_set(button_del, 0); 55 elm_object_disabled_set(button_del, 0);
52} 56}
53 57
58static void
59_feed_activate(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
60{
61 Elm_Object_Item *it = event_info;
62 Rss_Feed *feed = elm_object_item_data_get(it);
63
64 if (evas_object_data_get(feed_item_list, "feed") != feed)
65 {
66 Eina_List *l;
67 Azy_Rss_Item *item;
68
69 evas_object_data_set(feed_item_list, "feed", feed);
70 elm_genlist_clear(feed_item_list);
71 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);
73 EINA_LIST_FREE(l, item)
74 elm_genlist_item_append(feed_item_list, &feed_item_itc, item, NULL, 0, NULL, item);
75 }
76 elm_naviframe_item_promote(feed_item_list_item);
77}
54 78
55static Eina_Error 79static Eina_Error
56_feed_image_cb(Azy_Client *cli, Azy_Content *content, Eina_Binbuf *buf) 80_feed_image_cb(Azy_Client *cli, Azy_Content *content, Eina_Binbuf *buf)
@@ -142,6 +166,27 @@ _feed_free(Rss_Feed *feed)
142} 166}
143 167
144static char * 168static char *
169_it_feed_text_get(Azy_Rss_Item *item, Evas_Object *obj EINA_UNUSED, const char *part)
170{
171 Eina_Stringshare *title = NULL;
172
173 if (!strcmp(part, "elm.text"))
174 {
175 title = azy_rss_item_title_get(item);
176 return title ? strdup(title) : NULL;
177 }
178 title = azy_rss_item_desc_get(item);
179 if (!title) title = azy_rss_item_content_get(item);
180 return title ? strdup(title) : NULL;
181}
182
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 *
145_it_text_get(Rss_Feed *feed, Evas_Object *obj EINA_UNUSED, const char *part) 190_it_text_get(Rss_Feed *feed, Evas_Object *obj EINA_UNUSED, const char *part)
146{ 191{
147 Eina_Stringshare *title = NULL; 192 Eina_Stringshare *title = NULL;
@@ -169,9 +214,13 @@ static Evas_Object *
169_it_content_get(Rss_Feed *feed, Evas_Object *obj, const char *part EINA_UNUSED) 214_it_content_get(Rss_Feed *feed, Evas_Object *obj, const char *part EINA_UNUSED)
170{ 215{
171 Evas_Object *o; 216 Evas_Object *o;
172 if (!feed->img_data) return NULL; 217
218 if ((!feed->img_data) && (!azy_rss_img_url_get(feed->rss))) return NULL;
173 o = elm_image_add(obj); 219 o = elm_image_add(obj);
174 elm_image_memfile_set(o, eina_binbuf_string_get(feed->img_data), eina_binbuf_length_get(feed->img_data), NULL, NULL); 220 if (feed->img_data)
221 elm_image_memfile_set(o, eina_binbuf_string_get(feed->img_data), eina_binbuf_length_get(feed->img_data), NULL, NULL);
222 else
223 elm_image_file_set(o, azy_rss_img_url_get(feed->rss), NULL);
175 evas_object_show(o); 224 evas_object_show(o);
176 return o; 225 return o;
177} 226}
@@ -403,10 +452,18 @@ main(int argc, char *argv[])
403 elm_win_resize_object_add(win, o); 452 elm_win_resize_object_add(win, o);
404 evas_object_show(o); 453 evas_object_show(o);
405 454
455 naviframe = o = elm_naviframe_add(win);
456 elm_object_style_set(o, "slide");
457 EXPAND(o);
458 FILL(o);
459 elm_naviframe_content_preserve_on_pop_set(o, 1);
460 elm_win_resize_object_add(win, o);
461 evas_object_show(o);
462
406 vbox = elm_box_add(win); 463 vbox = elm_box_add(win);
464 elm_naviframe_item_simple_push(naviframe, vbox);
407 EXPAND(vbox); 465 EXPAND(vbox);
408 FILL(vbox); 466 FILL(vbox);
409 elm_win_resize_object_add(win, vbox);
410 467
411 hbox = elm_box_add(win); 468 hbox = elm_box_add(win);
412 elm_box_horizontal_set(hbox, 1); 469 elm_box_horizontal_set(hbox, 1);
@@ -439,6 +496,7 @@ main(int argc, char *argv[])
439 elm_scroller_bounce_set(o, EINA_FALSE, EINA_FALSE); 496 elm_scroller_bounce_set(o, EINA_FALSE, EINA_FALSE);
440 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO); 497 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
441 elm_genlist_mode_set(o, ELM_LIST_COMPRESS); 498 elm_genlist_mode_set(o, ELM_LIST_COMPRESS);
499 evas_object_smart_callback_add(o, "activated", _feed_activate, NULL);
442 evas_object_show(o); 500 evas_object_show(o);
443 elm_box_pack_end(vbox, o); 501 elm_box_pack_end(vbox, o);
444 502
@@ -476,6 +534,17 @@ main(int argc, char *argv[])
476 evas_object_show(o); 534 evas_object_show(o);
477 */ 535 */
478 536
537 feed_item_list = o = elm_genlist_add(win);
538 EXPAND(o);
539 FILL(o);
540 elm_scroller_bounce_set(o, EINA_FALSE, EINA_FALSE);
541 elm_scroller_policy_set(o, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
542 elm_genlist_mode_set(o, ELM_LIST_COMPRESS);
543 feed_item_list_item = elm_naviframe_item_simple_push(naviframe, o);
544 evas_object_show(o);
545
546 elm_naviframe_item_simple_promote(naviframe, vbox);
547
479 evas_object_show(hbox); 548 evas_object_show(hbox);
480 549
481 evas_object_show(vbox); 550 evas_object_show(vbox);
@@ -488,6 +557,11 @@ main(int argc, char *argv[])
488 feed_itc.func.del = (Elm_Genlist_Item_Del_Cb)_it_del; 557 feed_itc.func.del = (Elm_Genlist_Item_Del_Cb)_it_del;
489 feed_itc.version = ELM_GENLIST_ITEM_CLASS_VERSION; 558 feed_itc.version = ELM_GENLIST_ITEM_CLASS_VERSION;
490 559
560 feed_item_itc.item_style = "double_label";
561 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;
564
491 erssd_util_feed_signal_cb_set(0, ERSSD_SIGNAL_FEED_UPDATED, _dbus_signal_feed_updated, NULL); 565 erssd_util_feed_signal_cb_set(0, ERSSD_SIGNAL_FEED_UPDATED, _dbus_signal_feed_updated, NULL);
492 erssd_util_feed_signal_cb_set(1, ERSSD_SIGNAL_FEED_UPDATED, _dbus_signal_feed_updated, (void*)1); 566 erssd_util_feed_signal_cb_set(1, ERSSD_SIGNAL_FEED_UPDATED, _dbus_signal_feed_updated, (void*)1);
493 567