diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/debug_menu.c | 59 | ||||
-rw-r--r-- | apps/filetypes.c | 6 | ||||
-rw-r--r-- | apps/gui/list.c | 17 | ||||
-rw-r--r-- | apps/gui/list.h | 38 |
4 files changed, 55 insertions, 65 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 397a853857..b654bb6dcc 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -180,23 +180,18 @@ static int dbg_threads_action_callback(int action, struct gui_synclist *lists) | |||
180 | static bool dbg_os(void) | 180 | static bool dbg_os(void) |
181 | { | 181 | { |
182 | struct simplelist_info info; | 182 | struct simplelist_info info; |
183 | info.title = IF_COP("Core and ") "Stack usage:"; | 183 | simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:", 1, |
184 | #if NUM_CORES == 1 | 184 | #if NUM_CORES == 1 |
185 | info.count = MAXTHREADS; | 185 | MAXTHREADS, |
186 | #else | 186 | #else |
187 | info.count = MAXTHREADS+NUM_CORES; | 187 | MAXTHREADS+NUM_CORES, |
188 | #endif | 188 | #endif |
189 | info.selection_size = 1; | 189 | NULL); |
190 | #ifdef ROCKBOX_HAS_LOGF | 190 | #ifndef ROCKBOX_HAS_LOGF |
191 | info.hide_selection = false; | ||
192 | #else | ||
193 | info.hide_selection = true; | 191 | info.hide_selection = true; |
194 | #endif | 192 | #endif |
195 | info.scroll_all = false; | ||
196 | info.action_callback = dbg_threads_action_callback; | 193 | info.action_callback = dbg_threads_action_callback; |
197 | info.get_icon = NULL; | ||
198 | info.get_name = threads_getname; | 194 | info.get_name = threads_getname; |
199 | info.callback_data = NULL; | ||
200 | return simplelist_show_list(&info); | 195 | return simplelist_show_list(&info); |
201 | } | 196 | } |
202 | 197 | ||
@@ -736,15 +731,9 @@ static char* dbg_partitions_getname(int selected_item, void * data, char *buffer | |||
736 | bool dbg_partitions(void) | 731 | bool dbg_partitions(void) |
737 | { | 732 | { |
738 | struct simplelist_info info; | 733 | struct simplelist_info info; |
739 | info.title = "Partition Info"; | 734 | simplelist_info_init(&info, "Partition Info", 2, 4, NULL); |
740 | info.count = 4; | ||
741 | info.selection_size = 2; | ||
742 | info.hide_selection = true; | 735 | info.hide_selection = true; |
743 | info.scroll_all = false; | ||
744 | info.action_callback = NULL; | ||
745 | info.get_icon = NULL; | ||
746 | info.get_name = dbg_partitions_getname; | 736 | info.get_name = dbg_partitions_getname; |
747 | info.callback_data = NULL; | ||
748 | return simplelist_show_list(&info); | 737 | return simplelist_show_list(&info); |
749 | } | 738 | } |
750 | #endif | 739 | #endif |
@@ -1794,22 +1783,15 @@ static int disk_callback(int btn, struct gui_synclist *lists) | |||
1794 | static bool dbg_disk_info(void) | 1783 | static bool dbg_disk_info(void) |
1795 | { | 1784 | { |
1796 | struct simplelist_info info; | 1785 | struct simplelist_info info; |
1786 | simplelist_info_init(&info, "Disk Info", 1,1, NULL); | ||
1797 | #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP) | 1787 | #if defined(HAVE_MMC) || defined(HAVE_HOTSWAP) |
1798 | char title[16]; | 1788 | char title[16]; |
1799 | int card = 0; | 1789 | int card = 0; |
1800 | info.callback_data = (void*)&card; | 1790 | info.callback_data = (void*)&card; |
1801 | info.title = title; | 1791 | info.title = title; |
1802 | #else | ||
1803 | info.callback_data = NULL; | ||
1804 | info.title = "Disk Info"; | ||
1805 | #endif | 1792 | #endif |
1806 | info.count = 1; | ||
1807 | info.selection_size = 1; | ||
1808 | info.action_callback = disk_callback; | 1793 | info.action_callback = disk_callback; |
1809 | info.hide_selection = true; | 1794 | info.hide_selection = true; |
1810 | info.scroll_all = false; | ||
1811 | info.get_icon = NULL; | ||
1812 | info.get_name = NULL; | ||
1813 | return simplelist_show_list(&info); | 1795 | return simplelist_show_list(&info); |
1814 | } | 1796 | } |
1815 | #endif /* !SIMULATOR */ | 1797 | #endif /* !SIMULATOR */ |
@@ -1839,15 +1821,9 @@ static int dircache_callback(int btn, struct gui_synclist *lists) | |||
1839 | static bool dbg_dircache_info(void) | 1821 | static bool dbg_dircache_info(void) |
1840 | { | 1822 | { |
1841 | struct simplelist_info info; | 1823 | struct simplelist_info info; |
1842 | info.title = "Dircache Info"; | 1824 | simplelist_info_init(&info, "Dircache Info", 1, 7, NULL); |
1843 | info.count = 7; | ||
1844 | info.selection_size = 1; | ||
1845 | info.action_callback = dircache_callback; | 1825 | info.action_callback = dircache_callback; |
1846 | info.hide_selection = true; | 1826 | info.hide_selection = true; |
1847 | info.scroll_all = false; | ||
1848 | info.get_icon = NULL; | ||
1849 | info.get_name = NULL; | ||
1850 | info.callback_data = NULL; | ||
1851 | return simplelist_show_list(&info); | 1827 | return simplelist_show_list(&info); |
1852 | } | 1828 | } |
1853 | 1829 | ||
@@ -1878,15 +1854,9 @@ static int database_callback(int btn, struct gui_synclist *lists) | |||
1878 | static bool dbg_tagcache_info(void) | 1854 | static bool dbg_tagcache_info(void) |
1879 | { | 1855 | { |
1880 | struct simplelist_info info; | 1856 | struct simplelist_info info; |
1881 | info.title = "Database Info"; | 1857 | simplelist_info_init(&info, "Database Info", 1, 7, NULL); |
1882 | info.count = 7; | ||
1883 | info.selection_size = 1; | ||
1884 | info.action_callback = database_callback; | 1858 | info.action_callback = database_callback; |
1885 | info.hide_selection = true; | 1859 | info.hide_selection = true; |
1886 | info.scroll_all = false; | ||
1887 | info.get_icon = NULL; | ||
1888 | info.get_name = NULL; | ||
1889 | info.callback_data = NULL; | ||
1890 | return simplelist_show_list(&info); | 1860 | return simplelist_show_list(&info); |
1891 | } | 1861 | } |
1892 | #endif | 1862 | #endif |
@@ -2026,18 +1996,13 @@ static int radio_callback(int btn, struct gui_synclist *lists) | |||
2026 | static bool dbg_fm_radio(void) | 1996 | static bool dbg_fm_radio(void) |
2027 | { | 1997 | { |
2028 | struct simplelist_info info; | 1998 | struct simplelist_info info; |
1999 | simplelist_info_init(&info, "FM Radio", 1, 1, NULL); | ||
2029 | simplelist_set_line_count(0); | 2000 | simplelist_set_line_count(0); |
2030 | simplelist_addline(SIMPLELIST_ADD_LINE, "HW detected: %s", radio_hardware_present() ? "yes" : "no"); | 2001 | simplelist_addline(SIMPLELIST_ADD_LINE, "HW detected: %s", |
2002 | radio_hardware_present() ? "yes" : "no"); | ||
2031 | 2003 | ||
2032 | info.title = "FM Radio"; | ||
2033 | info.count = 1; | ||
2034 | info.selection_size = 1; | ||
2035 | info.action_callback = radio_hardware_present()?radio_callback : NULL; | 2004 | info.action_callback = radio_hardware_present()?radio_callback : NULL; |
2036 | info.hide_selection = true; | 2005 | info.hide_selection = true; |
2037 | info.scroll_all = false; | ||
2038 | info.get_icon = NULL; | ||
2039 | info.get_name = NULL; | ||
2040 | info.callback_data = NULL; | ||
2041 | return simplelist_show_list(&info); | 2006 | return simplelist_show_list(&info); |
2042 | } | 2007 | } |
2043 | #endif /* CONFIG_TUNER */ | 2008 | #endif /* CONFIG_TUNER */ |
diff --git a/apps/filetypes.c b/apps/filetypes.c index b5825044f1..3f1fa7d19b 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -487,14 +487,10 @@ int filetype_list_viewers(const char* current_file) | |||
487 | return PLUGIN_OK; | 487 | return PLUGIN_OK; |
488 | } | 488 | } |
489 | #endif | 489 | #endif |
490 | info.title = str(LANG_ONPLAY_OPEN_WITH); | 490 | simplelist_info_init(&info, str(LANG_ONPLAY_OPEN_WITH), 1, count, &data); |
491 | info.count = count; | ||
492 | info.selection_size = 1; info.hide_selection = false; | ||
493 | info.scroll_all = false; | ||
494 | info.action_callback = openwith_action_callback; | 491 | info.action_callback = openwith_action_callback; |
495 | info.get_name = openwith_get_name; | 492 | info.get_name = openwith_get_name; |
496 | info.get_icon = openwith_get_icon; | 493 | info.get_icon = openwith_get_icon; |
497 | info.callback_data = &data; | ||
498 | return simplelist_show_list(&info); | 494 | return simplelist_show_list(&info); |
499 | } | 495 | } |
500 | 496 | ||
diff --git a/apps/gui/list.c b/apps/gui/list.c index d9725e451a..cc66e25a48 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -1167,6 +1167,8 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
1167 | gui_synclist_set_title(&lists, info->title, NOICON); | 1167 | gui_synclist_set_title(&lists, info->title, NOICON); |
1168 | if (info->get_icon) | 1168 | if (info->get_icon) |
1169 | gui_synclist_set_icon_callback(&lists, info->get_icon); | 1169 | gui_synclist_set_icon_callback(&lists, info->get_icon); |
1170 | if (info->get_talk) | ||
1171 | gui_synclist_set_voice_callback(&lists, info->get_talk); | ||
1170 | 1172 | ||
1171 | gui_synclist_hide_selection_marker(&lists, info->hide_selection); | 1173 | gui_synclist_hide_selection_marker(&lists, info->hide_selection); |
1172 | 1174 | ||
@@ -1206,7 +1208,20 @@ bool simplelist_show_list(struct simplelist_info *info) | |||
1206 | return false; | 1208 | return false; |
1207 | } | 1209 | } |
1208 | 1210 | ||
1209 | 1211 | void simplelist_info_init(struct simplelist_info *info, char* title, | |
1212 | int selection_size, int count, void* data) | ||
1213 | { | ||
1214 | info->title = title; | ||
1215 | info->count = count; | ||
1216 | info->selection_size = selection_size; | ||
1217 | info->hide_selection = false; | ||
1218 | info->scroll_all = false; | ||
1219 | info->action_callback = NULL; | ||
1220 | info->get_icon = NULL; | ||
1221 | info->get_name = NULL; | ||
1222 | info->get_talk = NULL; | ||
1223 | info->callback_data = data; | ||
1224 | } | ||
1210 | 1225 | ||
1211 | 1226 | ||
1212 | 1227 | ||
diff --git a/apps/gui/list.h b/apps/gui/list.h index 253dd9bdbf..7b9ef94ba8 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h | |||
@@ -243,7 +243,19 @@ extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, | |||
243 | extern bool gui_synclist_do_button(struct gui_synclist * lists, | 243 | extern bool gui_synclist_do_button(struct gui_synclist * lists, |
244 | unsigned *action, | 244 | unsigned *action, |
245 | enum list_wrap); | 245 | enum list_wrap); |
246 | 246 | ||
247 | /* If the list has a pending postponed scheduled announcement, that | ||
248 | may become due before the next get_action tmieout. This function | ||
249 | adjusts the get_action timeout appropriately. */ | ||
250 | extern int list_do_action_timeout(struct gui_synclist *lists, int timeout); | ||
251 | /* This one combines a get_action call (with timeout overridden by | ||
252 | list_do_action_timeout) with the gui_synclist_do_button call, for | ||
253 | convenience. */ | ||
254 | extern bool list_do_action(int context, int timeout, | ||
255 | struct gui_synclist *lists, int *action, | ||
256 | enum list_wrap wrap); | ||
257 | |||
258 | |||
247 | /** Simplelist implementation. | 259 | /** Simplelist implementation. |
248 | USe this if you dont need to reimplement the list code, | 260 | USe this if you dont need to reimplement the list code, |
249 | and just need to show a list | 261 | and just need to show a list |
@@ -262,6 +274,7 @@ struct simplelist_info { | |||
262 | lists == the lists sturct so the callack can get selection and count etc. */ | 274 | lists == the lists sturct so the callack can get selection and count etc. */ |
263 | list_get_icon *get_icon; /* can be NULL */ | 275 | list_get_icon *get_icon; /* can be NULL */ |
264 | list_get_name *get_name; /* NULL if you're using simplelist_addline() */ | 276 | list_get_name *get_name; /* NULL if you're using simplelist_addline() */ |
277 | list_speak_item *get_talk; /* can be NULL to not speak */ | ||
265 | void *callback_data; /* data for callbacks */ | 278 | void *callback_data; /* data for callbacks */ |
266 | }; | 279 | }; |
267 | 280 | ||
@@ -281,20 +294,21 @@ int simplelist_get_line_count(void); | |||
281 | #define SIMPLELIST_ADD_LINE (SIMPLELIST_MAX_LINES+1) | 294 | #define SIMPLELIST_ADD_LINE (SIMPLELIST_MAX_LINES+1) |
282 | void simplelist_addline(int line_number, const char *fmt, ...); | 295 | void simplelist_addline(int line_number, const char *fmt, ...); |
283 | 296 | ||
297 | /* setup the info struct. members not setup in this function need to be assigned manually | ||
298 | members set in this function: | ||
299 | info.hide_selection = false; | ||
300 | info.scroll_all = false; | ||
301 | info.action_callback = NULL; | ||
302 | info.get_icon = NULL; | ||
303 | info.get_name = NULL; | ||
304 | info.get_voice = NULL; | ||
305 | */ | ||
306 | void simplelist_info_init(struct simplelist_info *info, char* title, | ||
307 | int selection_size, int count, void* data); | ||
308 | |||
284 | /* show a list. | 309 | /* show a list. |
285 | if list->action_callback != NULL it is called with the action ACTION_REDRAW | 310 | if list->action_callback != NULL it is called with the action ACTION_REDRAW |
286 | before the list is dislplayed for the first time */ | 311 | before the list is dislplayed for the first time */ |
287 | bool simplelist_show_list(struct simplelist_info *info); | 312 | bool simplelist_show_list(struct simplelist_info *info); |
288 | 313 | ||
289 | /* If the list has a pending postponed scheduled announcement, that | ||
290 | may become due before the next get_action tmieout. This function | ||
291 | adjusts the get_action timeout appropriately. */ | ||
292 | extern int list_do_action_timeout(struct gui_synclist *lists, int timeout); | ||
293 | /* This one combines a get_action call (with timeout overridden by | ||
294 | list_do_action_timeout) with the gui_synclist_do_button call, for | ||
295 | convenience. */ | ||
296 | extern bool list_do_action(int context, int timeout, | ||
297 | struct gui_synclist *lists, int *action, | ||
298 | enum list_wrap wrap); | ||
299 | |||
300 | #endif /* _GUI_LIST_H_ */ | 314 | #endif /* _GUI_LIST_H_ */ |