summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2015-07-21 19:19:18 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2015-07-21 19:21:14 +0900
commit88fa9aee622ac97e6214090040ca5878bd7e31d3 (patch)
treef259674dac3519631b5f3b756df5e7c4356f4992
parent9191302290493ef1485311f35f21b840b69140f1 (diff)
downloadair_mediahub-88fa9aee622ac97e6214090040ca5878bd7e31d3.tar.gz
air_mediahub-88fa9aee622ac97e6214090040ca5878bd7e31d3.tar.bz2
air_mediahub-88fa9aee622ac97e6214090040ca5878bd7e31d3.zip
musicplayer: add key down callback at control button
Change-Id: I7452c3ee9a665e2c64347c9cac439cfd4f31165b Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
-rw-r--r--include/util/controller.h1
-rw-r--r--src/util/controller.c20
-rw-r--r--src/view/mplayer.c21
3 files changed, 41 insertions, 1 deletions
diff --git a/include/util/controller.h b/include/util/controller.h
index 3f24bf2..babe7b5 100644
--- a/include/util/controller.h
+++ b/include/util/controller.h
@@ -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 {
diff --git a/src/util/controller.c b/src/util/controller.c
index b43c4f9..0e1c03c 100644
--- a/src/util/controller.c
+++ b/src/util/controller.c
@@ -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)
diff --git a/src/view/mplayer.c b/src/view/mplayer.c
index b75b14d..02012a4 100644
--- a/src/view/mplayer.c
+++ b/src/view/mplayer.c
@@ -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);