More refactoring / getting rid of code duplication

This commit is contained in:
twinaphex 2015-01-24 20:44:28 +01:00
parent bcca74e266
commit 3ca29e8cea
4 changed files with 17 additions and 21 deletions

View File

@ -245,12 +245,7 @@ int menu_entries_push_horizontal_menu_list(menu_handle_t *menu,
MENU_FILE_CONTENTLIST_ENTRY,
0);
driver.menu->scroll_indices_size = 0;
menu_entries_build_scroll_indices(list);
menu_entries_refresh(list);
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
driver.menu_ctx->populate_entries(menu, path, label, menu_type);
menu_list_populate_generic(menu, list, path, label, menu_type);
return 0;
}
@ -499,12 +494,7 @@ int menu_entries_parse_list(
menu_list_sort_on_alt(list);
}
driver.menu->scroll_indices_size = 0;
menu_entries_build_scroll_indices(list);
menu_entries_refresh(list);
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
driver.menu_ctx->populate_entries(driver.menu, dir, label, type);
menu_list_populate_generic(driver.menu, list, dir, label, type);
return 0;
}

View File

@ -1622,7 +1622,7 @@ static int deferred_push_core_list_deferred(void *data, void *userdata,
menu_list_sort_on_alt(list);
menu_list_populate_generic(list, path, label, type);
menu_list_populate_generic(driver.menu, list, path, label, type);
return 0;
}
@ -1642,7 +1642,7 @@ static int deferred_push_database_manager_list_deferred(void *data, void *userda
menu_list_sort_on_alt(list);
menu_list_populate_generic(list, path, label, type);
menu_list_populate_generic(driver.menu, list, path, label, type);
return 0;
}
@ -2307,7 +2307,7 @@ static int deferred_push_core_manager_list(void *data, void *userdata,
0, 0);
#endif
menu_list_populate_generic(list, path, label, type);
menu_list_populate_generic(driver.menu, list, path, label, type);
return 0;
}
@ -2363,7 +2363,7 @@ static int deferred_push_history_list(void *data, void *userdata,
MENU_FILE_PLAYLIST_ENTRY, 0);
}
menu_list_populate_generic(list, path, label, type);
menu_list_populate_generic(driver.menu, list, path, label, type);
return 0;
}
@ -2390,7 +2390,7 @@ static int deferred_push_content_actions(void *data, void *userdata,
menu_list_push(list, "Reset", "restart_content", MENU_SETTING_ACTION_RESET, 0);
}
menu_list_populate_generic(list, path, label, type);
menu_list_populate_generic(driver.menu, list, path, label, type);
return 0;
}

View File

@ -306,15 +306,21 @@ void menu_list_sort_on_alt(file_list_t *list)
file_list_sort_on_alt(list);
}
int menu_list_populate_generic(file_list_t *list, const char *path,
int menu_list_populate_generic(void *data,
file_list_t *list, const char *path,
const char *label, unsigned type)
{
menu_handle_t *menu = (menu_handle_t*)data;
if (!menu)
return -1;
driver.menu->scroll_indices_size = 0;
menu_entries_build_scroll_indices(list);
menu_entries_refresh(list);
if (driver.menu_ctx && driver.menu_ctx->populate_entries)
driver.menu_ctx->populate_entries(driver.menu, path, label, type);
driver.menu_ctx->populate_entries(menu, path, label, type);
return 0;
}

View File

@ -94,8 +94,8 @@ void menu_list_get_alt_at_offset(const file_list_t *list, size_t idx,
void menu_list_set_alt_at_offset(file_list_t *list, size_t idx,
const char *alt);
int menu_list_populate_generic(file_list_t *list, const char *path,
const char *label, unsigned type);
int menu_list_populate_generic(void *data, file_list_t *list,
const char *path, const char *label, unsigned type);
#ifdef __cplusplus
}