From 7004451e545560e1fd79ff22adc76a4c41d8840b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 7 May 2015 04:47:32 +0200 Subject: [PATCH] Create menu_list_get_entry --- menu/menu_display.c | 24 +----------------------- menu/menu_list.c | 26 ++++++++++++++++++++++++++ menu/menu_list.h | 3 +++ 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/menu/menu_display.c b/menu/menu_display.c index 5ec6232d11..92b3ea993c 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -214,32 +214,10 @@ bool menu_display_setting_label( const char *label, void *userdata) { - menu_file_list_cbs_t *cbs = NULL; - const char *entry_label = NULL; - const char *path = NULL; - menu_handle_t *menu = menu_driver_get_ptr(); - file_list_t *list = userdata ? (file_list_t*)userdata - : menu->menu_list->selection_buf; - if (!entry) return false; - menu_list_get_at_offset(list, i, &path, &entry_label, &entry->type); - - cbs = (menu_file_list_cbs_t*) - menu_list_get_actiondata_at_offset(list, - i); - - if (cbs && cbs->action_get_representation) - cbs->action_get_representation(list, - &entry->spacing, entry->type, i, label, - entry->value, sizeof(entry->value), - entry_label, path, - entry->path, sizeof(entry->path)); - - if (entry_label) - strlcpy(entry->label, entry_label, sizeof(entry->label)); - + menu_list_get_entry(entry, i, label, userdata); #if 0 RARCH_LOG("Entry label : %s\n", entry->label ? entry->label : "N/A"); RARCH_LOG("Entry path : %s\n", entry->path); diff --git a/menu/menu_list.c b/menu/menu_list.c index 074ea9114d..5a53cd7379 100644 --- a/menu/menu_list.c +++ b/menu/menu_list.c @@ -443,3 +443,29 @@ 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, + const char *label, void *userdata) +{ + const char *path = NULL; + const char *entry_label = NULL; + menu_file_list_cbs_t *cbs = NULL; + menu_handle_t *menu = menu_driver_get_ptr(); + file_list_t *list = userdata ? (file_list_t*)userdata + : menu->menu_list->selection_buf; + menu_list_get_at_offset(list, i, &path, &entry_label, &entry->type); + + cbs = (menu_file_list_cbs_t*) + menu_list_get_actiondata_at_offset(list, + i); + + if (cbs && cbs->action_get_representation) + cbs->action_get_representation(list, + &entry->spacing, entry->type, i, label, + entry->value, sizeof(entry->value), + entry_label, path, + entry->path, sizeof(entry->path)); + + if (entry_label) + strlcpy(entry->label, entry_label, sizeof(entry->label)); +} diff --git a/menu/menu_list.h b/menu/menu_list.h index fcde494d01..c83c348d85 100644 --- a/menu/menu_list.h +++ b/menu/menu_list.h @@ -105,6 +105,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, const char *label, + void *userdata); + #ifdef __cplusplus } #endif