Refactor menu_navigation_get_current_selection

This commit is contained in:
twinaphex 2015-09-06 01:58:00 +02:00
parent 4242005611
commit 028e07e3e0
5 changed files with 9 additions and 7 deletions

View File

@ -1609,7 +1609,8 @@ static int action_ok_load_archive_detect_core(const char *path,
{
int ret = 0;
global_t *global = global_get_ptr();
size_t selected = menu_navigation_get_current_selection();
menu_navigation_t *nav = menu_navigation_get_ptr();
size_t selected = menu_navigation_get_selection(nav);
menu_handle_t *menu = menu_driver_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
const char *menu_path = menu ? menu->scratch2_buf : NULL;

View File

@ -918,8 +918,9 @@ void menu_input_post_iterate(int *ret, unsigned action)
menu_entry_t entry = {{0}};
menu_input_t *menu_input = menu_input_get_ptr();
menu_list_t *menu_list = menu_list_get_ptr();
menu_navigation_t *nav = menu_navigation_get_ptr();
settings_t *settings = config_get_ptr();
size_t selected = menu_navigation_get_current_selection();
size_t selected = menu_navigation_get_selection(nav);
menu_file_list_cbs_t *cbs = menu_list_get_actiondata_at_offset
(menu_list->selection_buf, selected);

View File

@ -166,7 +166,8 @@ static int action_iterate_info(char *s, size_t len, const char *label)
uint32_t label_hash = 0;
menu_file_list_cbs_t *cbs = NULL;
menu_list_t *menu_list = menu_list_get_ptr();
size_t i = menu_navigation_get_current_selection();
menu_navigation_t *nav = menu_navigation_get_ptr();
size_t i = menu_navigation_get_selection(nav);
if (!menu_list)
return 0;
@ -497,7 +498,7 @@ int menu_iterate(bool render_this_frame, unsigned action)
menu->state.do_pop_stack = true;
break;
case ITERATE_TYPE_DEFAULT:
selected = menu_navigation_get_current_selection();
selected = menu_navigation_get_selection(nav);
/* FIXME: selected > selection_buf->list->size, i don't know why. */
selected = max(min(selected, menu_list_get_size(menu_list)-1), 0);

View File

@ -254,9 +254,8 @@ void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out)
menu_driver_navigation_ascend_alphabet(ptr_out);
}
ssize_t menu_navigation_get_current_selection(void)
ssize_t menu_navigation_get_selection(menu_navigation_t *nav)
{
menu_navigation_t *nav = menu_navigation_get_ptr();
if (!nav)
return -1;
return nav->selection_ptr;

View File

@ -106,7 +106,7 @@ void menu_navigation_descend_alphabet(menu_navigation_t *nav, size_t *ptr_out);
**/
void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out);
ssize_t menu_navigation_get_current_selection(void);
ssize_t menu_navigation_get_selection(menu_navigation_t *nav);
#ifdef __cplusplus
}