From 65c59eb9f1f13e1fca36738dce52e050bf26aaa7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 10 Dec 2015 19:38:46 +0100 Subject: [PATCH] Cleanups --- menu/drivers/menu_generic.c | 12 ++++++------ menu/drivers/menu_generic.h | 2 +- menu/drivers/zarch.c | 13 +++++-------- menu/menu_driver.c | 3 ++- menu/menu_driver.h | 2 +- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 3b4362bba8..d078024aef 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -37,9 +37,9 @@ #include "../../runloop.h" #include "../../verbosity.h" -static int action_iterate_help(char *s, size_t len, const char *label) +static int action_iterate_help(menu_handle_t *menu, + char *s, size_t len, const char *label) { - menu_handle_t *menu = menu_driver_get_ptr(); settings_t *settings = config_get_ptr(); switch (menu->help_screen_type) @@ -214,7 +214,7 @@ static enum action_iterate_type action_iterate_type(uint32_t hash) * * Returns: 0 on success, -1 if we need to quit out of the loop. **/ -int generic_menu_iterate(enum menu_action action) +int generic_menu_iterate(void *data, void *userdata, enum menu_action action) { size_t selection; menu_entry_t entry; @@ -223,7 +223,7 @@ int generic_menu_iterate(enum menu_action action) int ret = 0; uint32_t label_hash = 0; uint32_t hash = 0; - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = (menu_handle_t*)data; file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); @@ -246,7 +246,7 @@ int generic_menu_iterate(enum menu_action action) switch (iterate_type) { case ITERATE_TYPE_HELP: - ret = action_iterate_help(menu->menu_state.msg, sizeof(menu->menu_state.msg), label); + ret = action_iterate_help(menu, menu->menu_state.msg, sizeof(menu->menu_state.msg), label); BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_POST_ITERATE); if (ret == 1 || action == MENU_ACTION_OK) @@ -332,7 +332,7 @@ end: int menu_iterate_render(void) { const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr(); - menu_handle_t *menu = menu_driver_get_ptr(); + menu_handle_t *menu = menu_driver_get_ptr(); if (!menu) return -1; diff --git a/menu/drivers/menu_generic.h b/menu/drivers/menu_generic.h index 5742d29cb4..8efcfbeee3 100644 --- a/menu/drivers/menu_generic.h +++ b/menu/drivers/menu_generic.h @@ -39,7 +39,7 @@ enum action_iterate_type ITERATE_TYPE_BIND }; -int generic_menu_iterate(enum menu_action action); +int generic_menu_iterate(void *data, void *userdata, enum menu_action action); bool generic_menu_init_list(void *data); diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 5d0d5a4933..126ca87df8 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1191,21 +1191,18 @@ static void zarch_context_reset(void *data) zarch_zui_font(); } -static int zarch_iterate(enum menu_action action) +static int zarch_iterate(void *data, void *userdata, enum menu_action action) { - int ret = 0; - int action_id; + int action_id, ret = 0; menu_entry_t entry; - zui_t *zui = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); - enum menu_action act = (enum menu_action)action; bool perform_action = true; + enum menu_action act = (enum menu_action)action; + menu_handle_t *menu = (menu_handle_t*)data; + zui_t *zui = (zui_t*)userdata; if (!menu) return 0; - zui = (zui_t*)menu->userdata; - if (!zui) return -1; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &action_id)) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 1975ea70e5..280a69a7ee 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -275,7 +275,8 @@ int menu_driver_iterate(enum menu_action action) const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr(); if (driver->iterate) - return driver->iterate(action); + return driver->iterate(menu_driver_data, + menu_driver_data ? menu_driver_data->userdata : NULL, action); return -1; } diff --git a/menu/menu_driver.h b/menu/menu_driver.h index af6d4f34b2..9fceaf5586 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -250,7 +250,7 @@ typedef struct menu_ctx_driver { void (*set_texture)(void); void (*render_messagebox)(void *data, const char *msg); - int (*iterate)(enum menu_action action); + int (*iterate)(void *data, void *userdata, enum menu_action action); void (*render)(void *data); void (*frame)(void *data); void* (*init)(void);