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 {
_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,
.disable = _disable,
.show = _show,
.hide = _hide,
+ .get_object = _get_object,
};
struct controller *controller_create(Evas_Object *base)
#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;
.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;
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);
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");
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);