summaryrefslogtreecommitdiff
path: root/src/bin/sinks_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/sinks_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/sinks_view.c79
1 files changed, 32 insertions, 47 deletions
diff --git a/src/bin/sinks_view.c b/src/bin/sinks_view.c
index eb0c275..dbbfabc 100644
--- a/src/bin/sinks_view.c
+++ b/src/bin/sinks_view.c
@@ -9,36 +9,27 @@ struct Sinks_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 *sink_added;
15 Ecore_Event_Handler *sink_changed;
16 Ecore_Event_Handler *sink_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 Sinks_View *sv = data; 17 struct Sinks_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_sink_add_cb(void *data, int type EINA_UNUSED, void *info) 22_sink_added(void *data, void *info)
30{ 23{
31 struct Sinks_View *sv = data; 24 struct Sinks_View *sv = data;
32 Emix_Sink *sink = info; 25 Emix_Sink *sink = info;
33 26
34 elm_genlist_item_append(sv->genlist, sv->itc, sink, NULL, 27 elm_genlist_item_append(sv->genlist, sv->itc, sink, 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_sink_removed_cb(void *data, int type EINA_UNUSED, void *info) 32_sink_removed(void *data, void *info)
42{ 33{
43 struct Sinks_View *sv = data; 34 struct Sinks_View *sv = data;
44 Emix_Sink *ev = info; 35 Emix_Sink *ev = info;
@@ -56,12 +47,10 @@ _sink_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_sink_changed_cb(void *data, int type EINA_UNUSED, void *info) 53_sink_changed(void *data, void *info)
65{ 54{
66 struct Sinks_View *sv = data; 55 struct Sinks_View *sv = data;
67 Emix_Sink *sink = info; 56 Emix_Sink *sink = info;
@@ -98,28 +87,35 @@ _sink_changed_cb(void *data, int type EINA_UNUSED, void *info)
98 } 87 }
99 item = elm_genlist_item_next_get(item); 88 item = elm_genlist_item_next_get(item);
100 } 89 }
101
102 return ECORE_CALLBACK_PASS_ON;
103} 90}
104 91
105static void 92static void
106_del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, 93_events_cb(void *data, enum Emix_Event type, void *event_info)
107 void *event_info EINA_UNUSED)
108{ 94{
109 struct Sinks_View *sv = data; 95 switch (type)
110 96 {
111#define ECORE_EVENT_HANDLER_DEL(_handle) \ 97 case EMIX_SINK_ADDED_EVENT:
112 if (sv->_handle) \ 98 _sink_added(data, event_info);
113 { \ 99 break;
114 ecore_event_handler_del(sv->_handle); \ 100 case EMIX_SINK_CHANGED_EVENT:
115 sv->_handle = NULL; \ 101 _sink_changed(data, event_info);
102 break;
103 case EMIX_SINK_REMOVED_EVENT:
104 _sink_removed(data, event_info);
105 break;
106 case EMIX_DISCONNECTED_EVENT:
107 _disconnected(data);
108 break;
109 default:
110 break;
116 } 111 }
112}
117 113
118 ECORE_EVENT_HANDLER_DEL(disconnected) 114static void
119 ECORE_EVENT_HANDLER_DEL(sink_removed) 115_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED,
120 ECORE_EVENT_HANDLER_DEL(sink_changed) 116 void *event_info EINA_UNUSED)
121 ECORE_EVENT_HANDLER_DEL(sink_added) 117{
122#undef ECORE_EVENT_HANDLER_DEL 118 emix_event_callback_del(_events_cb);
123} 119}
124 120
125static char * 121static char *
@@ -231,7 +227,6 @@ _item_content_get(void *data, Evas_Object *obj, const char *part)
231 return item; 227 return item;
232} 228}
233 229
234
235Evas_Object * 230Evas_Object *
236sinks_view_add(Evas_Object *parent) 231sinks_view_add(Evas_Object *parent)
237{ 232{
@@ -251,14 +246,7 @@ sinks_view_add(Evas_Object *parent)
251 sv->genlist = elm_genlist_add(layout); 246 sv->genlist = elm_genlist_add(layout);
252 EINA_SAFETY_ON_NULL_GOTO(sv->genlist, err_genlist); 247 EINA_SAFETY_ON_NULL_GOTO(sv->genlist, err_genlist);
253 248
254 sv->disconnected = ecore_event_handler_add(EMIX_DISCONNECTED_EVENT, 249 emix_event_callback_add(_events_cb, sv);
255 _disconnected_cb, sv);
256 sv->sink_added = ecore_event_handler_add(EMIX_SINK_ADDED_EVENT,
257 _sink_add_cb, sv);
258 sv->sink_added = ecore_event_handler_add(EMIX_SINK_CHANGED_EVENT,
259 _sink_changed_cb, sv);
260 sv->sink_removed = ecore_event_handler_add(EMIX_SINK_REMOVED_EVENT,
261 _sink_removed_cb, sv);
262 250
263 sv->itc = elm_genlist_item_class_new(); 251 sv->itc = elm_genlist_item_class_new();
264 EINA_SAFETY_ON_NULL_GOTO(sv->itc, err_genlist); 252 EINA_SAFETY_ON_NULL_GOTO(sv->itc, err_genlist);
@@ -283,9 +271,6 @@ sinks_view_add(Evas_Object *parent)
283 return layout; 271 return layout;
284 272
285 err_genlist: 273 err_genlist:
286 ecore_event_handler_del(sv->sink_added);
287 ecore_event_handler_del(sv->sink_changed);
288 ecore_event_handler_del(sv->sink_removed);
289 free(layout); 274 free(layout);
290 err: 275 err:
291 free(sv); 276 free(sv);