summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/gui/list.c16
-rw-r--r--apps/gui/list.h18
-rw-r--r--apps/menu.c3
-rw-r--r--apps/playlist_viewer.c10
-rw-r--r--apps/tree.c6
5 files changed, 38 insertions, 15 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c
index df398eaa58..ac084984eb 100644
--- a/apps/gui/list.c
+++ b/apps/gui/list.c
@@ -40,12 +40,11 @@
40 40
41 41
42void gui_list_init(struct gui_list * gui_list, 42void gui_list_init(struct gui_list * gui_list,
43 list_get_icon callback_get_item_icon,
44 list_get_name callback_get_item_name, 43 list_get_name callback_get_item_name,
45 void * data 44 void * data
46 ) 45 )
47{ 46{
48 gui_list->callback_get_item_icon = callback_get_item_icon; 47 gui_list->callback_get_item_icon = NULL;
49 gui_list->callback_get_item_name = callback_get_item_name; 48 gui_list->callback_get_item_name = callback_get_item_name;
50 gui_list->display = NULL; 49 gui_list->display = NULL;
51 gui_list_set_nb_items(gui_list, 0); 50 gui_list_set_nb_items(gui_list, 0);
@@ -126,8 +125,7 @@ void gui_list_draw(struct gui_list * gui_list)
126 int cursor_pos = 0; 125 int cursor_pos = 0;
127 int icon_pos = 1; 126 int icon_pos = 1;
128 int text_pos; 127 int text_pos;
129 bool draw_icons = (gui_list->callback_get_item_icon != NULL && 128 bool draw_icons = (gui_list->callback_get_item_icon != NULL ) ;
130 global_settings.show_icons) ;
131 bool draw_cursor; 129 bool draw_cursor;
132 int i; 130 int i;
133 131
@@ -363,7 +361,6 @@ void gui_list_del_item(struct gui_list * gui_list)
363 */ 361 */
364void gui_synclist_init( 362void gui_synclist_init(
365 struct gui_synclist * lists, 363 struct gui_synclist * lists,
366 list_get_icon callback_get_item_icon,
367 list_get_name callback_get_item_name, 364 list_get_name callback_get_item_name,
368 void * data 365 void * data
369 ) 366 )
@@ -372,7 +369,6 @@ void gui_synclist_init(
372 FOR_NB_SCREENS(i) 369 FOR_NB_SCREENS(i)
373 { 370 {
374 gui_list_init(&(lists->gui_list[i]), 371 gui_list_init(&(lists->gui_list[i]),
375 callback_get_item_icon,
376 callback_get_item_name, 372 callback_get_item_name,
377 data); 373 data);
378 gui_list_set_display(&(lists->gui_list[i]), &(screens[i])); 374 gui_list_set_display(&(lists->gui_list[i]), &(screens[i]));
@@ -387,6 +383,14 @@ void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items)
387 gui_list_set_nb_items(&(lists->gui_list[i]), nb_items); 383 gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
388 } 384 }
389} 385}
386void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback)
387{
388 int i;
389 FOR_NB_SCREENS(i)
390 {
391 gui_list_set_icon_callback(&(lists->gui_list[i]), icon_callback);
392 }
393}
390 394
391void gui_synclist_draw(struct gui_synclist * lists) 395void gui_synclist_draw(struct gui_synclist * lists)
392{ 396{
diff --git a/apps/gui/list.h b/apps/gui/list.h
index 42a8677637..3e5b38e5b1 100644
--- a/apps/gui/list.h
+++ b/apps/gui/list.h
@@ -136,9 +136,9 @@ struct gui_list
136 * to a given item number 136 * to a given item number
137 * - callback_get_item_name : pointer to a function that associates a label 137 * - callback_get_item_name : pointer to a function that associates a label
138 * to a given item number 138 * to a given item number
139 * - data : extra data passed to the list callback
139 */ 140 */
140extern void gui_list_init(struct gui_list * gui_list, 141extern void gui_list_init(struct gui_list * gui_list,
141 list_get_icon callback_get_item_icon,
142 list_get_name callback_get_item_name, 142 list_get_name callback_get_item_name,
143 void * data 143 void * data
144 ); 144 );
@@ -146,7 +146,7 @@ extern void gui_list_init(struct gui_list * gui_list,
146/* 146/*
147 * Sets the numbers of items the list can currently display 147 * Sets the numbers of items the list can currently display
148 * note that the list's context like the currently pointed item is resetted 148 * note that the list's context like the currently pointed item is resetted
149 * - gui_list : the list structure to initialize 149 * - gui_list : the list structure
150 * - nb_items : the numbers of items you want 150 * - nb_items : the numbers of items you want
151 */ 151 */
152#define gui_list_set_nb_items(gui_list, nb) \ 152#define gui_list_set_nb_items(gui_list, nb) \
@@ -154,7 +154,7 @@ extern void gui_list_init(struct gui_list * gui_list,
154 154
155/* 155/*
156 * Returns the numbers of items currently in the list 156 * Returns the numbers of items currently in the list
157 * - gui_list : the list structure to initialize 157 * - gui_list : the list structure
158 */ 158 */
159#define gui_list_get_nb_items(gui_list) \ 159#define gui_list_get_nb_items(gui_list) \
160 (gui_list)->nb_items 160 (gui_list)->nb_items
@@ -170,6 +170,14 @@ extern void gui_list_put_selection_in_screen(struct gui_list * gui_list,
170 bool put_from_end); 170 bool put_from_end);
171 171
172/* 172/*
173 * Sets the icon callback function
174 * - gui_list : the list structure
175 * - _callback : the callback function
176 */
177#define gui_list_set_icon_callback(gui_list, _callback) \
178 (gui_list)->callback_get_item_icon=_callback
179
180/*
173 * Attach the scrolling list to a screen 181 * Attach the scrolling list to a screen
174 * (The previous screen attachement is lost) 182 * (The previous screen attachement is lost)
175 * - gui_list : the list structure 183 * - gui_list : the list structure
@@ -277,14 +285,14 @@ struct gui_synclist
277 285
278extern void gui_synclist_init( 286extern void gui_synclist_init(
279 struct gui_synclist * lists, 287 struct gui_synclist * lists,
280 list_get_icon callback_get_item_icon,
281 list_get_name callback_get_item_name, 288 list_get_name callback_get_item_name,
282 void * data 289 void * data
283 ); 290 );
284extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items); 291extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
285 292extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback);
286#define gui_synclist_get_nb_items(lists) \ 293#define gui_synclist_get_nb_items(lists) \
287 gui_list_get_nb_items(&((lists)->gui_list[0])) 294 gui_list_get_nb_items(&((lists)->gui_list[0]))
295
288extern int gui_synclist_get_sel_pos(struct gui_synclist * lists); 296extern int gui_synclist_get_sel_pos(struct gui_synclist * lists);
289 297
290#define gui_synclist_get_sel_pos(lists) \ 298#define gui_synclist_get_sel_pos(lists) \
diff --git a/apps/menu.c b/apps/menu.c
index 474593b435..42ae2b8890 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -96,7 +96,8 @@ int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, in
96 return -1; 96 return -1;
97 menus[menu].items = (struct menu_item*)mitems; /* de-const */ 97 menus[menu].items = (struct menu_item*)mitems; /* de-const */
98 gui_synclist_init(&(menus[menu].synclist), 98 gui_synclist_init(&(menus[menu].synclist),
99 NULL, &menu_get_itemname, &menus[menu]); 99 &menu_get_itemname, &menus[menu]);
100 gui_synclist_set_icon_callback(&(menus[menu].synclist), NULL);
100 gui_synclist_set_nb_items(&(menus[menu].synclist), count); 101 gui_synclist_set_nb_items(&(menus[menu].synclist), count);
101 menus[menu].callback = callback; 102 menus[menu].callback = callback;
102#ifdef HAS_BUTTONBAR 103#ifdef HAS_BUTTONBAR
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 3f0e27d9e9..58789b2561 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -618,8 +618,9 @@ bool playlist_viewer_ex(char* filename)
618 if (!playlist_viewer_init(&viewer, filename, false)) 618 if (!playlist_viewer_init(&viewer, filename, false))
619 goto exit; 619 goto exit;
620 620
621 gui_synclist_init(&playlist_lists, playlist_callback_icons, 621 gui_synclist_init(&playlist_lists, playlist_callback_name, &viewer);
622 playlist_callback_name, &viewer); 622 gui_synclist_set_icon_callback(&playlist_lists,
623 global_settings.playlist_viewer_icons?&playlist_callback_icons:NULL);
623 gui_synclist_set_nb_items(&playlist_lists, viewer.num_tracks); 624 gui_synclist_set_nb_items(&playlist_lists, viewer.num_tracks);
624 gui_synclist_select_item(&playlist_lists, viewer.selected_track); 625 gui_synclist_select_item(&playlist_lists, viewer.selected_track);
625 gui_synclist_draw(&playlist_lists); 626 gui_synclist_draw(&playlist_lists);
@@ -773,6 +774,11 @@ bool playlist_viewer_ex(char* filename)
773 ret = true; 774 ret = true;
774 goto exit; 775 goto exit;
775 } 776 }
777 gui_synclist_set_icon_callback(
778 &playlist_lists,
779 global_settings.playlist_viewer_icons?
780 &playlist_callback_icons:NULL
781 );
776 gui_synclist_draw(&playlist_lists); 782 gui_synclist_draw(&playlist_lists);
777 break; 783 break;
778 784
diff --git a/apps/tree.c b/apps/tree.c
index 5b9d5b04a6..bfeac6c545 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -229,7 +229,9 @@ void browse_root(void)
229 gui_buttonbar_set_display(&tree_buttonbar, &(screens[SCREEN_MAIN]) ); 229 gui_buttonbar_set_display(&tree_buttonbar, &(screens[SCREEN_MAIN]) );
230#endif 230#endif
231 gui_syncstatusbar_init(&statusbars); 231 gui_syncstatusbar_init(&statusbars);
232 gui_synclist_init(&tree_lists, &tree_get_fileicon, &tree_get_filename, &tc); 232 gui_synclist_init(&tree_lists, &tree_get_filename, &tc);
233 gui_synclist_set_icon_callback(&tree_lists,
234 global_settings.show_icons?&tree_get_fileicon:NULL);
233#ifndef SIMULATOR 235#ifndef SIMULATOR
234 dirbrowse(); 236 dirbrowse();
235#else 237#else
@@ -338,6 +340,8 @@ static int update_dir(void)
338 } 340 }
339 } 341 }
340 gui_synclist_set_nb_items(&tree_lists, tc.filesindir); 342 gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
343 gui_synclist_set_icon_callback(&tree_lists,
344 global_settings.show_icons?&tree_get_fileicon:NULL);
341 if( tc.selected_item >= tc.filesindir) 345 if( tc.selected_item >= tc.filesindir)
342 tc.selected_item=tc.filesindir-1; 346 tc.selected_item=tc.filesindir-1;
343 347