Use menu_list_get_entry for menu_entries_cbs_iterate.c

This commit is contained in:
twinaphex 2015-05-08 11:41:41 +02:00
parent 4ac4aae81a
commit a57cfde1cd
8 changed files with 24 additions and 26 deletions

View File

@ -305,7 +305,7 @@ static void glui_render_menu_list(runloop_t *runloop,
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH];
bool selected = false;
menu_list_get_entry(&entry, i, NULL);
menu_list_get_entry(&entry, i, NULL, true);
selected = menu_list_entry_is_currently_selected(&entry);
menu_animation_ticker_line(entry_title_buf, glui->ticker_limit,

View File

@ -493,7 +493,7 @@ static void rgui_render(void)
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH];
bool selected = false;
menu_list_get_entry(&entry, i, NULL);
menu_list_get_entry(&entry, i, NULL, true);
selected = menu_list_entry_is_currently_selected(&entry);
if (i > (menu->navigation.selection_ptr + 100))

View File

@ -234,7 +234,7 @@ static void rmenu_render(void)
entry_title_buf[PATH_MAX_LENGTH], type_str_buf[PATH_MAX_LENGTH];
bool selected = false;
menu_list_get_entry(&entry, i, NULL);
menu_list_get_entry(&entry, i, NULL, true);
selected = menu_list_entry_is_currently_selected(&entry);
menu_animation_ticker_line(entry_title_buf, RMENU_TERM_WIDTH - (entry.spacing + 1 + 2),

View File

@ -605,7 +605,7 @@ static void rmenu_xui_render(void)
menu_entry_t entry;
wchar_t msg_left[PATH_MAX_LENGTH], msg_right[PATH_MAX_LENGTH];
menu_list_get_entry(&entry, i, NULL);
menu_list_get_entry(&entry, i, NULL, true);
mbstowcs(msg_left, entry.path, sizeof(msg_left) / sizeof(wchar_t));
mbstowcs(msg_right, entry.value, sizeof(msg_right) / sizeof(wchar_t));

View File

@ -1020,7 +1020,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, gl_t *gl,
icon_y > global->video_data.height + xmb->icon.size)
continue;
menu_list_get_entry(&entry, i, list);
menu_list_get_entry(&entry, i, list, true);
if (entry.type == MENU_FILE_CONTENTLIST_ENTRY)
strlcpy(entry.path, path_basename(entry.path), sizeof(entry.path));

View File

@ -484,29 +484,25 @@ static int action_iterate_message(const char *label, unsigned action)
static int action_iterate_switch(const char *label, unsigned action)
{
unsigned type_offset = 0;
const char *label_offset = NULL;
const char *path_offset = NULL;
menu_entry_t entry;
menu_file_list_cbs_t *cbs = NULL;
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();
size_t selected = menu_navigation_get_current_selection();
if (!menu)
return 0;
cbs = (menu_file_list_cbs_t*)
menu_list_get_actiondata_at_offset(menu_list->selection_buf,
selected);
menu_list_get_entry(&entry, selected, NULL, false);
cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(menu_list->selection_buf, selected);
menu_list_get_at_offset(menu_list->selection_buf,
selected, &path_offset, &label_offset, &type_offset);
switch (action)
{
case MENU_ACTION_UP:
case MENU_ACTION_DOWN:
if (cbs && cbs->action_up_or_down)
return cbs->action_up_or_down(type_offset, label_offset, action);
return cbs->action_up_or_down(entry.type, entry.label, action);
break;
case MENU_ACTION_SCROLL_UP:
menu_navigation_descend_alphabet(nav, &nav->selection_ptr);
@ -517,25 +513,25 @@ static int action_iterate_switch(const char *label, unsigned action)
case MENU_ACTION_CANCEL:
if (cbs && cbs->action_cancel)
return cbs->action_cancel(path_offset, label_offset, type_offset, selected);
return cbs->action_cancel(entry.path, entry.label, entry.type, selected);
break;
case MENU_ACTION_OK:
if (cbs && cbs->action_ok)
return cbs->action_ok(path_offset, label_offset, type_offset, selected);
return cbs->action_ok(entry.path, entry.label, entry.type, selected);
break;
case MENU_ACTION_START:
if (cbs && cbs->action_start)
return cbs->action_start(type_offset, label_offset, action);
return cbs->action_start(entry.type, entry.label, action);
break;
case MENU_ACTION_LEFT:
case MENU_ACTION_RIGHT:
if (cbs && cbs->action_toggle)
return cbs->action_toggle(type_offset, label_offset, action, false);
return cbs->action_toggle(entry.type, entry.label, action, false);
break;
case MENU_ACTION_SELECT:
if (cbs && cbs->action_select)
return cbs->action_select(type_offset, label_offset, action);
return cbs->action_select(entry.type, entry.label, action);
break;
case MENU_ACTION_REFRESH:

View File

@ -447,7 +447,8 @@ int menu_list_populate_generic(file_list_t *list, const char *path,
return 0;
}
void menu_list_get_entry(menu_entry_t *entry, size_t i, void *userdata)
void menu_list_get_entry(menu_entry_t *entry, size_t i, void *userdata,
bool use_representation)
{
const char *label = NULL;
const char *path = NULL;
@ -470,7 +471,7 @@ void menu_list_get_entry(menu_entry_t *entry, size_t i, void *userdata)
cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(list, i);
if (cbs && cbs->action_get_representation)
if (cbs && cbs->action_get_representation && use_representation)
cbs->action_get_representation(list,
&entry->spacing, entry->type, i, label,
entry->value, sizeof(entry->value),
@ -491,7 +492,7 @@ bool menu_list_entry_is_currently_selected(menu_entry_t *entry)
return (entry->id == nav->selection_ptr);
}
int menu_list_get_current_entry_id(void)
int menu_list_get_current_entry_id(bool use_representation)
{
size_t i;
menu_list_t *menu_list = menu_list_get_ptr();
@ -500,7 +501,8 @@ int menu_list_get_current_entry_id(void)
for (i = 0; i < end; i++)
{
menu_entry_t entry;
menu_list_get_entry(&entry, i, NULL);
menu_list_get_entry(&entry, i,
NULL, use_representation);
if (menu_list_entry_is_currently_selected(&entry))
return i;

View File

@ -107,9 +107,9 @@ void menu_list_set_alt_at_offset(file_list_t *list, size_t idx,
int menu_list_populate_generic(file_list_t *list,
const char *path, const char *label, unsigned type);
void menu_list_get_entry(menu_entry_t *entry, size_t i, void *userdata);
void menu_list_get_entry(menu_entry_t *entry, size_t i, void *userdata, bool use_representation);
int menu_list_get_current_entry_id(void);
int menu_list_get_current_entry_id(bool use_representation);
bool menu_list_entry_is_currently_selected(menu_entry_t *entry);