summaryrefslogtreecommitdiff
path: root/src/bin/sources_view.c
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-10-26 22:13:22 -0200
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-10-29 23:57:10 -0200
commit1324b2b07d36a5fed73837c769b0d3af57dff283 (patch)
tree3d67bb6bb9e240e597b3dc09b116f58bb5962665 /src/bin/sources_view.c
parentd25435a066491ce2dd4d740313af3b4db817e450 (diff)
Using callbacks instead of Ecore_Events
Also the volume meter functionality was removed.
Diffstat (limited to '')
-rw-r--r--src/bin/sources_view.c79
1 files changed, 32 insertions, 47 deletions
diff --git a/src/bin/sources_view.c b/src/bin/sources_view.c
index 12b0f04..470dfba 100644
--- a/src/bin/sources_view.c
+++ b/src/bin/sources_view.c
@@ -9,36 +9,27 @@ struct Sources_View
9 Evas_Object *self; 9 Evas_Object *self;
10 Evas_Object *genlist; 10 Evas_Object *genlist;
11 Elm_Genlist_Item_Class *itc; 11 Elm_Genlist_Item_Class *itc;
12
13 Ecore_Event_Handler *disconnected;
14 Ecore_Event_Handler *source_added;
15 Ecore_Event_Handler *source_changed;
16 Ecore_Event_Handler *source_removed;
17}; 12};
18 13
19static Eina_Bool 14static void
20_disconnected_cb(void *data, int type EINA_UNUSED, void *info EINA_UNUSED) 15_disconnected(void *data)
21{ 16{
22 struct Sources_View *sv = data; 17 struct Sources_View *sv = data;
23 elm_genlist_clear(sv->genlist); 18 elm_genlist_clear(sv->genlist);
24
25 return ECORE_CALLBACK_PASS_ON;
26} 19}
27 20
28static Eina_Bool 21static void
29_source_add_cb(void *data, int type EINA_UNUSED, void *info) 22_source_added(void *data, void *info)
30{ 23{
31 struct Sources_View *sv = data; 24 struct Sources_View *sv = data;
32 Emix_Source *source= info; 25 Emix_Source *source= info;
33 26
34 elm_genlist_item_append(sv->genlist, sv->itc, source, NULL, 27 elm_genlist_item_append(sv->genlist, sv->itc, source, NULL,
35 ELM_GENLIST_ITEM_NONE, NULL, sv); 28 ELM_GENLIST_ITEM_NONE, NULL, sv);
36
37 return ECORE_CALLBACK_PASS_ON;
38} 29}
39 30
40static Eina_Bool 31static void
41_source_removed_cb(void *data, int type EINA_UNUSED, void *info) 32_source_removed(void *data, void *info)
42{ 33{
43 struct Sources_View *sv = data; 34 struct Sources_View *sv = data;
44 Emix_Source *source = info; 35 Emix_Source *source = info;
@@ -56,12 +47,10 @@ _source_removed_cb(void *data, int type EINA_UNUSED, void *info)
56 } 47 }
57 while ((item = elm_genlist_item_next_get(item))); 48 while ((item = elm_genlist_item_next_get(item)));
58 } 49 }
59
60 return ECORE_CALLBACK_PASS_ON;
61} 50}
62 51
63static Eina_Bool 52static void
64_source_changed_cb(void *data, int type EINA_UNUSED, void *info) 53_source_changed(void *data, void *info)
65{ 54{
66 struct Sources_View *sv = data; 55 struct Sources_View *sv = data;
67 Emix_Source *source = info; 56 Emix_Source *source = info;
@@ -83,28 +72,35 @@ _source_changed_cb(void *data, int type EINA_UNUSED, void *info)
83 } 72 }
84 item = elm_genlist_item_next_get(item); 73 item = elm_genlist_item_next_get(item);
85 } 74 }
86
87 return ECORE_CALLBACK_PASS_ON;
88} 75}
89 76
90static void 77static void
91_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, 78_events_cb(void *data, enum Emix_Event type, void *event_info)
92 void *event_info EINA_UNUSED)
93{ 79{
94 struct Sources_View *sv = data; 80 switch (type)
95 81 {
96#define ECORE_EVENT_HANDLER_DEL(_handle) \ 82 case EMIX_SOURCE_ADDED_EVENT:
97 if (sv->_handle) \ 83 _source_added(data, event_info);
98 { \ 84 break;
99 ecore_event_handler_del(sv->_handle); \ 85 case EMIX_SOURCE_CHANGED_EVENT:
100 sv->_handle = NULL; \ 86 _source_changed(data, event_info);
87 break;
88 case EMIX_SOURCE_REMOVED_EVENT:
89 _source_removed(data, event_info);
90 break;
91 case EMIX_DISCONNECTED_EVENT:
92 _disconnected(data);
93 break;
94 default:
95 break;
101 } 96 }
97}
102 98
103 ECORE_EVENT_HANDLER_DEL(disconnected) 99static void
104 ECORE_EVENT_HANDLER_DEL(source_removed) 100_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED,
105 ECORE_EVENT_HANDLER_DEL(source_changed) 101 void *event_info EINA_UNUSED)
106 ECORE_EVENT_HANDLER_DEL(source_added) 102{
107#undef ECORE_EVENT_HANDLER_DEL 103 emix_event_callback_del(_events_cb);
108} 104}
109 105
110static char * 106static char *
@@ -201,14 +197,7 @@ sources_view_add(Evas_Object *parent)
201 sv->genlist = elm_genlist_add(layout); 197 sv->genlist = elm_genlist_add(layout);
202 EINA_SAFETY_ON_NULL_GOTO(sv->genlist, err_genlist); 198 EINA_SAFETY_ON_NULL_GOTO(sv->genlist, err_genlist);
203 199
204 sv->disconnected = ecore_event_handler_add(EMIX_DISCONNECTED_EVENT, 200 emix_event_callback_add(_events_cb, sv);
205 _disconnected_cb, sv);
206 sv->source_added = ecore_event_handler_add(EMIX_SOURCE_ADDED_EVENT,
207 _source_add_cb, sv);
208 sv->source_added = ecore_event_handler_add(EMIX_SOURCE_CHANGED_EVENT,
209 _source_changed_cb, sv);
210 sv->source_removed = ecore_event_handler_add(EMIX_SOURCE_REMOVED_EVENT,
211 _source_removed_cb, sv);
212 201
213 sv->itc = elm_genlist_item_class_new(); 202 sv->itc = elm_genlist_item_class_new();
214 EINA_SAFETY_ON_NULL_GOTO(sv->itc, err_genlist); 203 EINA_SAFETY_ON_NULL_GOTO(sv->itc, err_genlist);
@@ -227,10 +216,6 @@ sources_view_add(Evas_Object *parent)
227 return layout; 216 return layout;
228 217
229 err_genlist: 218 err_genlist:
230 ecore_event_handler_del(sv->disconnected);
231 ecore_event_handler_del(sv->source_added);
232 ecore_event_handler_del(sv->source_changed);
233 ecore_event_handler_del(sv->source_removed);
234 free(layout); 219 free(layout);
235 err: 220 err:
236 free(sv); 221 free(sv);