summaryrefslogtreecommitdiff
path: root/src/examples/emotion/emotion_generic_example.c
diff options
context:
space:
mode:
authorAvi Levin <avi.levin@samsung.com>2015-04-26 14:49:26 +0300
committerDaniel Zaoui <daniel.zaoui@samsung.com>2015-06-07 11:00:52 +0300
commitf9c116a48749c642eb31154a4cfb5f60a110dcba (patch)
tree2cbf4d8891d6aa65c5f8867cb95549947208b864 /src/examples/emotion/emotion_generic_example.c
parentb563efc52ffbc02ae33d4901326a583102975cbb (diff)
emotion: porting evas smart callbacks to eo
Diffstat (limited to 'src/examples/emotion/emotion_generic_example.c')
-rw-r--r--src/examples/emotion/emotion_generic_example.c80
1 files changed, 54 insertions, 26 deletions
diff --git a/src/examples/emotion/emotion_generic_example.c b/src/examples/emotion/emotion_generic_example.c
index 9320230..5bd869c 100644
--- a/src/examples/emotion/emotion_generic_example.c
+++ b/src/examples/emotion/emotion_generic_example.c
@@ -1,5 +1,8 @@
1//Compile with: 1//Compile with:
2// gcc -o emotion_generic_example emotion_generic_example.c `pkg-config --libs --cflags emotion evas ecore ecore-evas eina` 2// gcc -o emotion_generic_example emotion_generic_example.c `pkg-config --libs --cflags emotion evas ecore ecore-evas eina eo`
3
4#define EFL_EO_API_SUPPORT
5#define EFL_BETA_API_SUPPORT
3 6
4#include <Ecore.h> 7#include <Ecore.h>
5#include <Ecore_Evas.h> 8#include <Ecore_Evas.h>
@@ -15,18 +18,24 @@
15static Eina_List *filenames = NULL; 18static Eina_List *filenames = NULL;
16static Eina_List *curfile = NULL; 19static Eina_List *curfile = NULL;
17 20
18static void 21static Eina_Bool
19_playback_started_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED) 22_playback_started_cb(void *data EINA_UNUSED,
23 Eo *o EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
20{ 24{
21 printf("Emotion object started playback.\n"); 25 printf("Emotion object started playback.\n");
26
27 return EINA_TRUE;
22} 28}
23 29
24static void 30static Eina_Bool
25_playback_stopped_cb(void *data EINA_UNUSED, Evas_Object *o, void *event_info EINA_UNUSED) 31_playback_stopped_cb(void *data EINA_UNUSED,
32 Eo *o, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
26{ 33{
27 printf("Emotion playback stopped.\n"); 34 printf("Emotion playback stopped.\n");
28 emotion_object_play_set(o, EINA_FALSE); 35 emotion_object_play_set(o, EINA_FALSE);
29 emotion_object_position_set(o, 0); 36 emotion_object_position_set(o, 0);
37
38 return EINA_TRUE;
30} 39}
31 40
32static Evas_Object * 41static Evas_Object *
@@ -36,10 +45,10 @@ _create_emotion_object(Evas *e)
36 45
37 emotion_object_init(em, "generic"); 46 emotion_object_init(em, "generic");
38 47
39 evas_object_smart_callback_add( 48 eo_do(em, eo_event_callback_add
40 em, "playback_started", _playback_started_cb, NULL); 49 (EMOTION_OBJECT_EVENT_PLAYBACK_STARTED, _playback_started_cb, NULL));
41 evas_object_smart_callback_add( 50 eo_do(em, eo_event_callback_add
42 em, "playback_finished", _playback_stopped_cb, NULL); 51 (EMOTION_OBJECT_EVENT_PLAYBACK_FINISHED, _playback_stopped_cb, NULL));
43 52
44 return em; 53 return em;
45} 54}
@@ -123,40 +132,63 @@ _on_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *
123 } 132 }
124} 133}
125 134
126static void 135static Eina_Bool
127_frame_decode_cb(void *data EINA_UNUSED, Evas_Object *o EINA_UNUSED, void *event_info EINA_UNUSED) 136_frame_decode_cb(void *data EINA_UNUSED,
137 Eo *o EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
128{ 138{
129 // fprintf(stderr, "smartcb: frame_decode\n"); 139 // fprintf(stderr, "smartcb: frame_decode\n");
140
141 return EINA_TRUE;
130} 142}
131 143
132static void 144static Eina_Bool
133_length_change_cb(void *data EINA_UNUSED, Evas_Object *o, void *event_info EINA_UNUSED) 145_length_change_cb(void *data EINA_UNUSED,
146 Eo *o, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
134{ 147{
135 fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(o)); 148 fprintf(stderr, "smartcb: length_change: %0.3f\n", emotion_object_play_length_get(o));
149
150 return EINA_TRUE;
136} 151}
137 152
138static void 153static Eina_Bool
139_position_update_cb(void *data EINA_UNUSED, Evas_Object *o, void *event_info EINA_UNUSED) 154_position_update_cb(void *data EINA_UNUSED,
155 Eo *o, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
140{ 156{
141 fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(o)); 157 fprintf(stderr, "smartcb: position_update: %0.3f\n", emotion_object_position_get(o));
158
159 return EINA_TRUE;
142} 160}
143 161
144static void 162static Eina_Bool
145_progress_change_cb(void *data EINA_UNUSED, Evas_Object *o, void *event_info EINA_UNUSED) 163_progress_change_cb(void *data EINA_UNUSED,
164 Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
146{ 165{
147 fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n", 166 fprintf(stderr, "smartcb: progress_change: %0.3f, %s\n",
148 emotion_object_progress_status_get(o), 167 emotion_object_progress_status_get(obj),
149 emotion_object_progress_info_get(o)); 168 emotion_object_progress_info_get(obj));
169
170 return EINA_TRUE;
150} 171}
151 172
152static void 173static Eina_Bool
153_frame_resize_cb(void *data EINA_UNUSED, Evas_Object *o, void *event_info EINA_UNUSED) 174_frame_resize_cb(void *data EINA_UNUSED,
175 Eo *o, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED)
154{ 176{
155 int w, h; 177 int w, h;
156 emotion_object_size_get(o, &w, &h); 178 emotion_object_size_get(o, &w, &h);
157 fprintf(stderr, "smartcb: frame_resize: %dx%d\n", w, h); 179 fprintf(stderr, "smartcb: frame_resize: %dx%d\n", w, h);
180
181 return EINA_TRUE;
158} 182}
159 183
184static const Eo_Callback_Array_Item emotion_object_example_callbacks[] = {
185 { EMOTION_OBJECT_EVENT_FRAME_DECODE, _frame_decode_cb },
186 { EMOTION_OBJECT_EVENT_LENGTH_CHANGE, _length_change_cb },
187 { EMOTION_OBJECT_EVENT_POSITION_UPDATE, _position_update_cb },
188 { EMOTION_OBJECT_EVENT_PROGRESS_CHANGE, _progress_change_cb },
189 { NULL, NULL }
190};
191
160int 192int
161main(int argc, const char *argv[]) 193main(int argc, const char *argv[])
162{ 194{
@@ -206,11 +238,7 @@ main(int argc, const char *argv[])
206 evas_object_resize(em, WIDTH, HEIGHT); 238 evas_object_resize(em, WIDTH, HEIGHT);
207 evas_object_show(em); 239 evas_object_show(em);
208 240
209 evas_object_smart_callback_add(em, "frame_decode", _frame_decode_cb, NULL); 241 eo_do(em, eo_event_callback_array_add(emotion_object_example_callbacks, NULL));
210 evas_object_smart_callback_add(em, "length_change", _length_change_cb, NULL);
211 evas_object_smart_callback_add(em, "position_update", _position_update_cb, NULL);
212 evas_object_smart_callback_add(em, "progress_change", _progress_change_cb, NULL);
213 evas_object_smart_callback_add(em, "frame_resize", _frame_resize_cb, NULL);
214 242
215 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em); 243 evas_object_event_callback_add(bg, EVAS_CALLBACK_KEY_DOWN, _on_key_down, em);
216 evas_object_focus_set(bg, EINA_TRUE); 244 evas_object_focus_set(bg, EINA_TRUE);