musicplayer: add key down callback at control button 93/44393/1
authorMinkyu Kang <mk7.kang@samsung.com>
Tue, 21 Jul 2015 10:19:18 +0000 (19:19 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Tue, 21 Jul 2015 10:21:14 +0000 (19:21 +0900)
Change-Id: I7452c3ee9a665e2c64347c9cac439cfd4f31165b
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
include/util/controller.h
src/util/controller.c
src/view/mplayer.c

index 3f24bf2..babe7b5 100644 (file)
@@ -30,6 +30,7 @@ struct controller_ops {
                        void (*func)(void *, const char *), void *data);
        void (*focus)(void *handle, int loc, bool foc);
        void (*signal)(void *handle, int loc, const char *signal);
+       Evas_Object *(*get_object)(void *handle, int loc);
 };
 
 struct controller {
index b43c4f9..0e1c03c 100644 (file)
@@ -268,6 +268,25 @@ static void _hide(void *handle)
        _disable(handle);
 }
 
+static Evas_Object *_get_object(void *handle, int loc)
+{
+       struct _priv *p;
+       struct _control *ctl;
+
+       if (!handle) {
+               _ERR("invalid parameter");
+               return NULL;
+       }
+
+       p = handle;
+
+       ctl = eina_list_nth(p->list, loc);
+       if (!ctl)
+               return NULL;
+
+       return ctl->obj;
+}
+
 static struct controller_ops _operations = {
        .add_control = _add_control,
        .add_callback = _add_callback,
@@ -277,6 +296,7 @@ static struct controller_ops _operations = {
        .disable = _disable,
        .show = _show,
        .hide = _hide,
+       .get_object = _get_object,
 };
 
 struct controller *controller_create(Evas_Object *base)
index b75b14d..02012a4 100644 (file)
@@ -35,7 +35,7 @@
 
 #define STYLE_MUSIC_BTN "music_btn"
 #define PART_MUSIC_BTN "control_btn"
-#define PLAY_BTN_LOC 2
+#define PLAY_BTN_LOC 1
 
 struct _list_data {
        app_media *am;
@@ -517,6 +517,10 @@ static input_handler _list_handler = {
        .key_down = _key_down,
 };
 
+static input_handler _btn_handler = {
+       .key_down = _key_down,
+};
+
 static void _add_playlist_item(struct _priv *priv)
 {
        Elm_Genlist_Item_Class *ic;
@@ -584,6 +588,10 @@ static bool _ui_init(struct _priv *priv)
                ctl->ops->add_control(ctl->handle,
                                btn_player[i].name, btn_player[i].loc,
                                STYLE_MUSIC_BTN, PART_MUSIC_BTN);
+
+               obj = ctl->ops->get_object(ctl->handle, i);
+               if (obj)
+                       inputmgr_add_callback(obj, 0, &_btn_handler, priv);
        }
 
        ctl->ops->add_callback(ctl->handle, _callback_music, priv);
@@ -747,6 +755,9 @@ static void _update(void *view_data, int update_type, void *data)
 static void _destroy(void *view_data)
 {
        struct _priv *priv;
+       struct controller *ctl;
+       Evas_Object *obj;
+       int i;
 
        if (!view_data) {
                _ERR("failed to get view data");
@@ -755,6 +766,14 @@ static void _destroy(void *view_data)
 
        priv = view_data;
 
+       ctl = priv->ctl;
+
+       for (i = 0; i < ARRAY_SIZE(btn_player); i++) {
+               obj = ctl->ops->get_object(ctl->handle, i);
+               if (obj)
+                       inputmgr_remove_callback(obj, &_btn_handler);
+       }
+
        _list_free(priv);
        inputmgr_remove_callback(priv->list, &_list_handler);