From 9a95f982831dbb94e3c9779f9d1df015c44f56d5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 5 Sep 2015 00:50:17 +0200 Subject: [PATCH] Turn menu_list_pop into static function --- menu/cbs/menu_cbs_ok.c | 10 ++++++---- menu/menu_entry.c | 3 ++- menu/menu_input.c | 9 +++++---- menu/menu_iterate.c | 4 ++-- menu/menu_list.c | 24 ++++++++++++------------ menu/menu_list.h | 4 +--- 6 files changed, 28 insertions(+), 26 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index b3cd5e2f9a..54bd58442f 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -460,6 +460,7 @@ static int action_ok_playlist_entry(const char *path, content_playlist_t *playlist = g_defaults.history; bool is_history = true; menu_handle_t *menu = menu_driver_get_ptr(); + menu_navigation_t *nav = menu_navigation_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); uint32_t hash_label = menu_hash_calculate(label); @@ -517,7 +518,7 @@ static int action_ok_playlist_entry(const char *path, { case MENU_LABEL_COLLECTION: case MENU_LABEL_RDB_ENTRY_START_CONTENT: - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); break; default: menu_list_flush_stack(menu_list, NULL, MENU_SETTINGS); @@ -869,8 +870,9 @@ static int action_ok_core_deferred_set(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char core_display_name[PATH_MAX_LENGTH]; - menu_handle_t *menu = menu_driver_get_ptr(); - menu_list_t *menu_list = menu_list_get_ptr(); + menu_handle_t *menu = menu_driver_get_ptr(); + menu_navigation_t *nav = menu_navigation_get_ptr(); + menu_list_t *menu_list = menu_list_get_ptr(); if (!menu || !menu_list) return -1; @@ -888,7 +890,7 @@ static int action_ok_core_deferred_set(const char *path, content_playlist_write_file(menu->playlist); - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); return -1; } diff --git a/menu/menu_entry.c b/menu/menu_entry.c index 241e07a8f8..1ab85cfeba 100644 --- a/menu/menu_entry.c +++ b/menu/menu_entry.c @@ -33,10 +33,11 @@ /* Clicks the back button */ int menu_entry_go_back(void) { + menu_navigation_t *nav = menu_navigation_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); if (!menu_list) return -1; - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); return 0; } diff --git a/menu/menu_input.c b/menu/menu_input.c index 1dda2bf532..203181da46 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -722,7 +722,7 @@ static int menu_input_mouse_frame( } if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_R)) - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_DOWN)) menu_navigation_increment(nav, 1); @@ -767,7 +767,7 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse, if ((unsigned)menu_input->mouse.y < disp->header_height) { - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); return 0; } if ( @@ -830,6 +830,7 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs, { int ret = 0; menu_display_t *disp = menu_display_get_ptr(); + menu_navigation_t *nav = menu_navigation_get_ptr(); menu_list_t *menu_list = menu_list_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr(); settings_t *settings = config_get_ptr(); @@ -880,7 +881,7 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs, if (!menu_input->pointer.dragging) { if ((unsigned)menu_input->pointer.start_y < disp->header_height) - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); else if (menu_input->pointer.ptr <= menu_list_get_size(menu_list)-1) { menu_input->pointer.oldpressed[0] = false; @@ -904,7 +905,7 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs, if (!menu_input->pointer.oldback) { menu_input->pointer.oldback = true; - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); } } menu_input->pointer.oldback = menu_input->pointer.back; diff --git a/menu/menu_iterate.c b/menu/menu_iterate.c index 133094e899..5ed7f2cb25 100644 --- a/menu/menu_iterate.c +++ b/menu/menu_iterate.c @@ -469,7 +469,7 @@ int menu_iterate(bool render_this_frame, unsigned action) break; case ITERATE_TYPE_BIND: if (menu_input_bind_iterate(menu->state.msg, sizeof(menu->state.msg))) - menu_list_pop_stack(menu_list); + menu_list_pop_stack(menu_list, &nav->selection_ptr); else menu->state.do_messagebox = true; if (render_this_frame) @@ -527,7 +527,7 @@ int menu_iterate(bool render_this_frame, unsigned action) } if (menu->state.do_pop_stack && action == MENU_ACTION_OK) - menu_list_pop(menu_list->menu_stack, menu->state.pop_selected); + menu_list_pop_stack(menu_list, menu->state.pop_selected); if (menu->state.do_post_iterate) menu_input_post_iterate(&ret, action); diff --git a/menu/menu_list.c b/menu/menu_list.c index 6db28a47f9..b875878401 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -133,6 +133,16 @@ static INLINE int menu_list_flush_stack_type( return needle ? strcmp(needle, label) : (type != final_type); } +static void menu_list_pop(file_list_t *list, size_t *directory_ptr) +{ + if (list->size != 0) + menu_driver_list_free(list, list->size - 1, list->size - 1); + + file_list_pop(list, directory_ptr); + + menu_driver_list_set_selection(list); +} + void menu_list_flush_stack(menu_list_t *list, const char *needle, unsigned final_type) { @@ -157,9 +167,8 @@ void menu_list_flush_stack(menu_list_t *list, } } -void menu_list_pop_stack(menu_list_t *list) +void menu_list_pop_stack(menu_list_t *list, size_t *directory_ptr) { - menu_navigation_t *nav = menu_navigation_get_ptr(); if (!list) return; @@ -168,19 +177,10 @@ void menu_list_pop_stack(menu_list_t *list) menu_driver_list_cache(MENU_LIST_PLAIN, 0); - menu_list_pop(list->menu_stack, &nav->selection_ptr); + menu_list_pop(list->menu_stack, directory_ptr); menu_entries_set_refresh(false); } -void menu_list_pop(file_list_t *list, size_t *directory_ptr) -{ - if (list->size != 0) - menu_driver_list_free(list, list->size - 1, list->size - 1); - - file_list_pop(list, directory_ptr); - - menu_driver_list_set_selection(list); -} void menu_list_clear(file_list_t *list) { diff --git a/menu/menu_list.h b/menu/menu_list.h index 929c9fa849..be18d99dd2 100644 --- a/menu/menu_list.h +++ b/menu/menu_list.h @@ -78,9 +78,7 @@ menu_list_t *menu_list_new(void); void menu_list_flush_stack(menu_list_t *list, const char *needle, unsigned final_type); -void menu_list_pop(file_list_t *list, size_t *directory_ptr); - -void menu_list_pop_stack(menu_list_t *list); +void menu_list_pop_stack(menu_list_t *list, size_t *directory_ptr); void menu_list_get_at_offset(const file_list_t *list, size_t idx, const char **path, const char **label, unsigned *file_type,