diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-10-21 01:27:17 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-10-21 01:27:17 +0000 |
commit | 5eac0108f973bc5a132807775f9815b789e0c787 (patch) | |
tree | 6360f95b81a7ae3b1ccbcfb0b657cc4a6029e6bb /apps/gui | |
parent | 7736947b74a4d272e68d7ea84bcbe6f681b723e4 (diff) | |
download | rockbox-5eac0108f973bc5a132807775f9815b789e0c787.tar.gz rockbox-5eac0108f973bc5a132807775f9815b789e0c787.zip |
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
Diffstat (limited to 'apps/gui')
-rw-r--r-- | apps/gui/list.c | 17 | ||||
-rw-r--r-- | apps/gui/list.h | 38 |
2 files changed, 42 insertions, 13 deletions
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_ */ |