summaryrefslogtreecommitdiff
path: root/src/bin/playbacks_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/playbacks_view.c
parentd25435a066491ce2dd4d740313af3b4db817e450 (diff)
Using callbacks instead of Ecore_Events
Also the volume meter functionality was removed.
Diffstat (limited to 'src/bin/playbacks_view.c')
-rw-r--r--src/bin/playbacks_view.c110
1 files changed, 37 insertions, 73 deletions
diff --git a/src/bin/playbacks_view.c b/src/bin/playbacks_view.c
index 3483f06..43b818a 100644
--- a/src/bin/playbacks_view.c
+++ b/src/bin/playbacks_view.c
@@ -10,40 +10,27 @@ struct Playbacks_View
10 Evas_Object *self; 10 Evas_Object *self;
11 Evas_Object *genlist; 11 Evas_Object *genlist;
12 Elm_Genlist_Item_Class *itc; 12 Elm_Genlist_Item_Class *itc;
13
14 Ecore_Event_Handler *disconnected;
15 Ecore_Event_Handler *sink_input_added;
16 Ecore_Event_Handler *sink_input_changed;
17 Ecore_Event_Handler *sink_input_removed;
18 Ecore_Event_Handler *sink_added;
19 Ecore_Event_Handler *sink_removed;
20}; 13};
21 14
22 static Eina_Bool 15 static void
23_disconnected_cb(void *data, int type EINA_UNUSED, void *info EINA_UNUSED) 16_disconnected(void *data)
24{ 17{
25 struct Playbacks_View *pv = data; 18 struct Playbacks_View *pv = data;
26 elm_genlist_clear(pv->genlist); 19 elm_genlist_clear(pv->genlist);
27
28 return ECORE_CALLBACK_PASS_ON;
29} 20}
30 21
31static Eina_Bool 22static void
32_sink_input_add_cb(void *data, int type EINA_UNUSED, 23_sink_input_added(void *data, void *info)
33 void *info)
34{ 24{
35 struct Playbacks_View *pv = data; 25 struct Playbacks_View *pv = data;
36 Emix_Sink_Input *input = info; 26 Emix_Sink_Input *input = info;
37 27
38 elm_genlist_item_append(pv->genlist, pv->itc, input, NULL, 28 elm_genlist_item_append(pv->genlist, pv->itc, input, NULL,
39 ELM_GENLIST_ITEM_NONE, NULL, pv); 29 ELM_GENLIST_ITEM_NONE, NULL, pv);
40
41 return ECORE_CALLBACK_DONE;
42} 30}
43 31
44static Eina_Bool 32static void
45_sink_input_removed_cb(void *data, int type EINA_UNUSED, 33_sink_input_removed(void *data, void *info)
46 void *info)
47{ 34{
48 struct Playbacks_View *pv = data; 35 struct Playbacks_View *pv = data;
49 Emix_Sink_Input *ev = info; 36 Emix_Sink_Input *ev = info;
@@ -61,20 +48,17 @@ _sink_input_removed_cb(void *data, int type EINA_UNUSED,
61 } 48 }
62 while ((item = elm_genlist_item_next_get(item))); 49 while ((item = elm_genlist_item_next_get(item)));
63 } 50 }
64
65 return ECORE_CALLBACK_PASS_ON;
66} 51}
67 52
68static Eina_Bool 53static void
69_sink_input_changed_cb(void *data, int type EINA_UNUSED, 54_sink_input_changed(void *data, void *info)
70 void *info)
71{ 55{
72 struct Playbacks_View *pv = data; 56 struct Playbacks_View *pv = data;
73 Emix_Sink_Input *ev = info; 57 Emix_Sink_Input *ev = info;
74 Elm_Object_Item *item = elm_genlist_first_item_get(pv->genlist); 58 Elm_Object_Item *item = elm_genlist_first_item_get(pv->genlist);
75 Evas_Object *it; 59 Evas_Object *it;
76 60
77 while (item) 61 while (item)
78 { 62 {
79 if (ev == elm_object_item_data_get(item)) 63 if (ev == elm_object_item_data_get(item))
80 { 64 {
@@ -89,50 +73,46 @@ _sink_input_changed_cb(void *data, int type EINA_UNUSED,
89 } 73 }
90 item = elm_genlist_item_next_get(item); 74 item = elm_genlist_item_next_get(item);
91 } 75 }
92
93 return ECORE_CALLBACK_PASS_ON;
94} 76}
95 77
96static Eina_Bool 78static void
97_sink_added_cb(void *data, int type EINA_UNUSED, void *info EINA_UNUSED) 79_sink_event(void *data)
98{ 80{
99 struct Playbacks_View *pv = data; 81 struct Playbacks_View *pv = data;
100 elm_genlist_realized_items_update(pv->genlist); 82 elm_genlist_realized_items_update(pv->genlist);
101
102 return ECORE_CALLBACK_PASS_ON;
103} 83}
104 84
105static Eina_Bool 85static void
106_sink_removed_cb(void *data, int type EINA_UNUSED, void *info EINA_UNUSED) 86_events_cb(void *data, enum Emix_Event type, void *event_info)
107{ 87{
108 struct Playbacks_View *pv = data; 88 switch (type)
109 89 {
110 elm_genlist_realized_items_update(pv->genlist); 90 case EMIX_SINK_ADDED_EVENT:
111 return ECORE_CALLBACK_PASS_ON; 91 case EMIX_SINK_REMOVED_EVENT:
92 _sink_event(data);
93 break;
94 case EMIX_DISCONNECTED_EVENT:
95 _disconnected(data);
96 break;
97 case EMIX_SINK_INPUT_ADDED_EVENT:
98 _sink_input_added(data, event_info);
99 break;
100 case EMIX_SINK_INPUT_CHANGED_EVENT:
101 _sink_input_changed(data, event_info);
102 break;
103 case EMIX_SINK_INPUT_REMOVED_EVENT:
104 _sink_input_removed(data, event_info);
105 break;
106 default:
107 break;
108 }
112} 109}
113 110
114static void 111static void
115_del_cb(void *data, 112_del_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED,
116 Evas *e EINA_UNUSED,
117 Evas_Object *o EINA_UNUSED,
118 void *event_info EINA_UNUSED) 113 void *event_info EINA_UNUSED)
119{ 114{
120 struct Playbacks_View *pv = data; 115 emix_event_callback_del(_events_cb);
121
122#define ECORE_EVENT_HANDLER_DEL(_handle) \
123 if (pv->_handle) \
124 { \
125 ecore_event_handler_del(pv->_handle); \
126 pv->_handle = NULL; \
127 }
128
129 ECORE_EVENT_HANDLER_DEL(disconnected)
130 ECORE_EVENT_HANDLER_DEL(sink_input_added)
131 ECORE_EVENT_HANDLER_DEL(sink_input_changed)
132 ECORE_EVENT_HANDLER_DEL(sink_input_removed)
133 ECORE_EVENT_HANDLER_DEL(sink_removed)
134 ECORE_EVENT_HANDLER_DEL(sink_added)
135#undef ECORE_EVENT_HANDLER_DEL
136} 116}
137 117
138static char * 118static char *
@@ -267,18 +247,7 @@ playbacks_view_add(Evas_Object *parent)
267 pv->genlist = elm_genlist_add(layout); 247 pv->genlist = elm_genlist_add(layout);
268 EINA_SAFETY_ON_NULL_GOTO(pv->genlist, err_genlist); 248 EINA_SAFETY_ON_NULL_GOTO(pv->genlist, err_genlist);
269 249
270 pv->disconnected = ecore_event_handler_add(EMIX_DISCONNECTED_EVENT, 250 emix_event_callback_add(_events_cb, pv);
271 _disconnected_cb, pv);
272 pv->sink_input_added = ecore_event_handler_add(EMIX_SINK_INPUT_ADDED_EVENT,
273 _sink_input_add_cb, pv);
274 pv->sink_input_added = ecore_event_handler_add(EMIX_SINK_INPUT_CHANGED_EVENT,
275 _sink_input_changed_cb, pv);
276 pv->sink_input_removed = ecore_event_handler_add(EMIX_SINK_INPUT_REMOVED_EVENT,
277 _sink_input_removed_cb, pv);
278 pv->sink_removed = ecore_event_handler_add(EMIX_SINK_REMOVED_EVENT,
279 _sink_removed_cb, pv);
280 pv->sink_added = ecore_event_handler_add(EMIX_SINK_ADDED_EVENT,
281 _sink_added_cb, pv);
282 251
283 pv->itc = elm_genlist_item_class_new(); 252 pv->itc = elm_genlist_item_class_new();
284 EINA_SAFETY_ON_NULL_GOTO(pv->itc, err_genlist); 253 EINA_SAFETY_ON_NULL_GOTO(pv->itc, err_genlist);
@@ -303,11 +272,6 @@ playbacks_view_add(Evas_Object *parent)
303 return layout; 272 return layout;
304 273
305 err_genlist: 274 err_genlist:
306 ecore_event_handler_del(pv->sink_input_added);
307 ecore_event_handler_del(pv->sink_input_changed);
308 ecore_event_handler_del(pv->sink_input_removed);
309 ecore_event_handler_del(pv->sink_added);
310 ecore_event_handler_del(pv->sink_removed);
311 free(layout); 275 free(layout);
312 err: 276 err:
313 free(pv); 277 free(pv);