From 9122576870df76e1f2aec454b28e995d2ce5c50a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 26 Jan 2015 08:45:36 +0100 Subject: [PATCH] Add action select callback --- menu/drivers_backend/menu_common_backend.c | 4 ++-- menu/menu_driver.h | 1 + menu/menu_entries_cbs.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/menu/drivers_backend/menu_common_backend.c b/menu/drivers_backend/menu_common_backend.c index d00189fe51..6f38df64e9 100644 --- a/menu/drivers_backend/menu_common_backend.c +++ b/menu/drivers_backend/menu_common_backend.c @@ -616,8 +616,8 @@ static int menu_common_iterate(unsigned action) ret = cbs->action_toggle(type_offset, label_offset, action); break; case MENU_ACTION_SELECT: - menu_list_push_stack(driver.menu->menu_list, "", "info_screen", - 0, driver.menu->selection_ptr); + if (cbs && cbs->action_select) + ret = cbs->action_select(type_offset, label_offset, action); break; case MENU_ACTION_REFRESH: diff --git a/menu/menu_driver.h b/menu/menu_driver.h index cafde3a05d..e897b999bd 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -150,6 +150,7 @@ typedef struct menu_file_list_cbs int (*action_cancel)(const char *path, const char *label, unsigned type, size_t idx); int (*action_start)(unsigned type, const char *label, unsigned action); + int (*action_select)(unsigned type, const char *label, unsigned action); int (*action_content_list_switch)(void *data, void *userdata, const char *path, const char *label, unsigned type); int (*action_toggle)(unsigned type, const char *label, unsigned action); diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c index 907bc90222..5d7566b2ac 100644 --- a/menu/menu_entries_cbs.c +++ b/menu/menu_entries_cbs.c @@ -2723,12 +2723,29 @@ static int menu_entries_cbs_init_bind_ok_first(menu_file_list_cbs_t *cbs, return 0; } +static int action_select_default(unsigned type, const char *label, + unsigned action) +{ + menu_list_push_stack(driver.menu->menu_list, "", "info_screen", + 0, driver.menu->selection_ptr); + return 0; +} + static int action_start_lookup_setting(unsigned type, const char *label, unsigned action) { return menu_action_setting_set(type, label, MENU_ACTION_START); } +static void menu_entries_cbs_init_bind_select(menu_file_list_cbs_t *cbs, + const char *path, const char *label, unsigned type, size_t idx) +{ + if (!cbs) + return; + + cbs->action_select = action_select_default; +} + static void menu_entries_cbs_init_bind_start(menu_file_list_cbs_t *cbs, const char *path, const char *label, unsigned type, size_t idx) { @@ -3067,6 +3084,7 @@ void menu_entries_cbs_init(void *data, menu_entries_cbs_init_bind_ok(cbs, path, label, type, idx); menu_entries_cbs_init_bind_cancel(cbs, path, label, type, idx); menu_entries_cbs_init_bind_start(cbs, path, label, type, idx); + menu_entries_cbs_init_bind_select(cbs, path, label, type, idx); menu_entries_cbs_init_bind_content_list_switch(cbs, path, label, type, idx); menu_entries_cbs_init_bind_up_or_down(cbs, path, label, type, idx); menu_entries_cbs_init_bind_toggle(cbs, path, label, type, idx);