simplify the simpelist api slightly so not every struct member needs to be init manually.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15236 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7736947b74
commit
5eac0108f9
|
@ -180,23 +180,18 @@ static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
|
|||
static bool dbg_os(void)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
info.title = IF_COP("Core and ") "Stack usage:";
|
||||
simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:", 1,
|
||||
#if NUM_CORES == 1
|
||||
info.count = MAXTHREADS;
|
||||
MAXTHREADS,
|
||||
#else
|
||||
info.count = MAXTHREADS+NUM_CORES;
|
||||
MAXTHREADS+NUM_CORES,
|
||||
#endif
|
||||
info.selection_size = 1;
|
||||
#ifdef ROCKBOX_HAS_LOGF
|
||||
info.hide_selection = false;
|
||||
#else
|
||||
NULL);
|
||||
#ifndef ROCKBOX_HAS_LOGF
|
||||
info.hide_selection = true;
|
||||
#endif
|
||||
info.scroll_all = false;
|
||||
info.action_callback = dbg_threads_action_callback;
|
||||
info.get_icon = NULL;
|
||||
info.get_name = threads_getname;
|
||||
info.callback_data = NULL;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
|
||||
|
@ -736,15 +731,9 @@ static char* dbg_partitions_getname(int selected_item, void * data, char *buffer
|
|||
bool dbg_partitions(void)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
info.title = "Partition Info";
|
||||
info.count = 4;
|
||||
info.selection_size = 2;
|
||||
simplelist_info_init(&info, "Partition Info", 2, 4, NULL);
|
||||
info.hide_selection = true;
|
||||
info.scroll_all = false;
|
||||
info.action_callback = NULL;
|
||||
info.get_icon = NULL;
|
||||
info.get_name = dbg_partitions_getname;
|
||||
info.callback_data = NULL;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
#endif
|
||||
|
@ -1794,22 +1783,15 @@ static int disk_callback(int btn, struct gui_synclist *lists)
|
|||
static bool dbg_disk_info(void)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
simplelist_info_init(&info, "Disk Info", 1,1, NULL);
|
||||
#if defined(HAVE_MMC) || defined(HAVE_HOTSWAP)
|
||||
char title[16];
|
||||
int card = 0;
|
||||
info.callback_data = (void*)&card;
|
||||
info.title = title;
|
||||
#else
|
||||
info.callback_data = NULL;
|
||||
info.title = "Disk Info";
|
||||
#endif
|
||||
info.count = 1;
|
||||
info.selection_size = 1;
|
||||
info.action_callback = disk_callback;
|
||||
info.hide_selection = true;
|
||||
info.scroll_all = false;
|
||||
info.get_icon = NULL;
|
||||
info.get_name = NULL;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
#endif /* !SIMULATOR */
|
||||
|
@ -1839,15 +1821,9 @@ static int dircache_callback(int btn, struct gui_synclist *lists)
|
|||
static bool dbg_dircache_info(void)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
info.title = "Dircache Info";
|
||||
info.count = 7;
|
||||
info.selection_size = 1;
|
||||
simplelist_info_init(&info, "Dircache Info", 1, 7, NULL);
|
||||
info.action_callback = dircache_callback;
|
||||
info.hide_selection = true;
|
||||
info.scroll_all = false;
|
||||
info.get_icon = NULL;
|
||||
info.get_name = NULL;
|
||||
info.callback_data = NULL;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
|
||||
|
@ -1878,15 +1854,9 @@ static int database_callback(int btn, struct gui_synclist *lists)
|
|||
static bool dbg_tagcache_info(void)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
info.title = "Database Info";
|
||||
info.count = 7;
|
||||
info.selection_size = 1;
|
||||
simplelist_info_init(&info, "Database Info", 1, 7, NULL);
|
||||
info.action_callback = database_callback;
|
||||
info.hide_selection = true;
|
||||
info.scroll_all = false;
|
||||
info.get_icon = NULL;
|
||||
info.get_name = NULL;
|
||||
info.callback_data = NULL;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
#endif
|
||||
|
@ -2026,18 +1996,13 @@ static int radio_callback(int btn, struct gui_synclist *lists)
|
|||
static bool dbg_fm_radio(void)
|
||||
{
|
||||
struct simplelist_info info;
|
||||
simplelist_info_init(&info, "FM Radio", 1, 1, NULL);
|
||||
simplelist_set_line_count(0);
|
||||
simplelist_addline(SIMPLELIST_ADD_LINE, "HW detected: %s", radio_hardware_present() ? "yes" : "no");
|
||||
simplelist_addline(SIMPLELIST_ADD_LINE, "HW detected: %s",
|
||||
radio_hardware_present() ? "yes" : "no");
|
||||
|
||||
info.title = "FM Radio";
|
||||
info.count = 1;
|
||||
info.selection_size = 1;
|
||||
info.action_callback = radio_hardware_present()?radio_callback : NULL;
|
||||
info.hide_selection = true;
|
||||
info.scroll_all = false;
|
||||
info.get_icon = NULL;
|
||||
info.get_name = NULL;
|
||||
info.callback_data = NULL;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
#endif /* CONFIG_TUNER */
|
||||
|
|
|
@ -487,14 +487,10 @@ int filetype_list_viewers(const char* current_file)
|
|||
return PLUGIN_OK;
|
||||
}
|
||||
#endif
|
||||
info.title = str(LANG_ONPLAY_OPEN_WITH);
|
||||
info.count = count;
|
||||
info.selection_size = 1; info.hide_selection = false;
|
||||
info.scroll_all = false;
|
||||
simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), 1, count, &data);
|
||||
info.action_callback = openwith_action_callback;
|
||||
info.get_name = openwith_get_name;
|
||||
info.get_icon = openwith_get_icon;
|
||||
info.callback_data = &data;
|
||||
return simplelist_show_list(&info);
|
||||
}
|
||||
|
||||
|
|
|
@ -1167,6 +1167,8 @@ bool simplelist_show_list(struct simplelist_info *info)
|
|||
gui_synclist_set_title(&lists, info->title, NOICON);
|
||||
if (info->get_icon)
|
||||
gui_synclist_set_icon_callback(&lists, info->get_icon);
|
||||
if (info->get_talk)
|
||||
gui_synclist_set_voice_callback(&lists, info->get_talk);
|
||||
|
||||
gui_synclist_hide_selection_marker(&lists, info->hide_selection);
|
||||
|
||||
|
@ -1206,7 +1208,20 @@ bool simplelist_show_list(struct simplelist_info *info)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
void simplelist_info_init(struct simplelist_info *info, char* title,
|
||||
int selection_size, int count, void* data)
|
||||
{
|
||||
info->title = title;
|
||||
info->count = count;
|
||||
info->selection_size = selection_size;
|
||||
info->hide_selection = false;
|
||||
info->scroll_all = false;
|
||||
info->action_callback = NULL;
|
||||
info->get_icon = NULL;
|
||||
info->get_name = NULL;
|
||||
info->get_talk = NULL;
|
||||
info->callback_data = data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -243,7 +243,19 @@ extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists,
|
|||
extern bool gui_synclist_do_button(struct gui_synclist * lists,
|
||||
unsigned *action,
|
||||
enum list_wrap);
|
||||
|
||||
|
||||
/* If the list has a pending postponed scheduled announcement, that
|
||||
may become due before the next get_action tmieout. This function
|
||||
adjusts the get_action timeout appropriately. */
|
||||
extern int list_do_action_timeout(struct gui_synclist *lists, int timeout);
|
||||
/* This one combines a get_action call (with timeout overridden by
|
||||
list_do_action_timeout) with the gui_synclist_do_button call, for
|
||||
convenience. */
|
||||
extern bool list_do_action(int context, int timeout,
|
||||
struct gui_synclist *lists, int *action,
|
||||
enum list_wrap wrap);
|
||||
|
||||
|
||||
/** Simplelist implementation.
|
||||
USe this if you dont need to reimplement the list code,
|
||||
and just need to show a list
|
||||
|
@ -262,6 +274,7 @@ struct simplelist_info {
|
|||
lists == the lists sturct so the callack can get selection and count etc. */
|
||||
list_get_icon *get_icon; /* can be NULL */
|
||||
list_get_name *get_name; /* NULL if you're using simplelist_addline() */
|
||||
list_speak_item *get_talk; /* can be NULL to not speak */
|
||||
void *callback_data; /* data for callbacks */
|
||||
};
|
||||
|
||||
|
@ -281,20 +294,21 @@ int simplelist_get_line_count(void);
|
|||
#define SIMPLELIST_ADD_LINE (SIMPLELIST_MAX_LINES+1)
|
||||
void simplelist_addline(int line_number, const char *fmt, ...);
|
||||
|
||||
/* setup the info struct. members not setup in this function need to be assigned manually
|
||||
members set in this function:
|
||||
info.hide_selection = false;
|
||||
info.scroll_all = false;
|
||||
info.action_callback = NULL;
|
||||
info.get_icon = NULL;
|
||||
info.get_name = NULL;
|
||||
info.get_voice = NULL;
|
||||
*/
|
||||
void simplelist_info_init(struct simplelist_info *info, char* title,
|
||||
int selection_size, int count, void* data);
|
||||
|
||||
/* show a list.
|
||||
if list->action_callback != NULL it is called with the action ACTION_REDRAW
|
||||
before the list is dislplayed for the first time */
|
||||
bool simplelist_show_list(struct simplelist_info *info);
|
||||
|
||||
/* If the list has a pending postponed scheduled announcement, that
|
||||
may become due before the next get_action tmieout. This function
|
||||
adjusts the get_action timeout appropriately. */
|
||||
extern int list_do_action_timeout(struct gui_synclist *lists, int timeout);
|
||||
/* This one combines a get_action call (with timeout overridden by
|
||||
list_do_action_timeout) with the gui_synclist_do_button call, for
|
||||
convenience. */
|
||||
extern bool list_do_action(int context, int timeout,
|
||||
struct gui_synclist *lists, int *action,
|
||||
enum list_wrap wrap);
|
||||
|
||||
#endif /* _GUI_LIST_H_ */
|
||||
|
|
Loading…
Reference in New Issue
Block a user