summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Ferrare <kevin@rockbox.org>2005-11-16 17:23:49 +0000
committerKevin Ferrare <kevin@rockbox.org>2005-11-16 17:23:49 +0000
commit15046f99b3840c07bdd9d52e7014c6e775267c55 (patch)
treea34131db64c53b7bb9353e870cd5266d0dbc9e2d
parent2a7546ab752dd10901aa7df10d93cd286a68d4bf (diff)
downloadrockbox-15046f99b3840c07bdd9d52e7014c6e775267c55.tar.gz
rockbox-15046f99b3840c07bdd9d52e7014c6e775267c55.tar.bz2
rockbox-15046f99b3840c07bdd9d52e7014c6e775267c55.zip
show/hide icons now works properly in playlist viewer
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7911 a1c6a512-1295-4272-9138-f99709370657
-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 @@
void gui_list_init(struct gui_list * gui_list,
- list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
void * data
)
{
- gui_list->callback_get_item_icon = callback_get_item_icon;
+ gui_list->callback_get_item_icon = NULL;
gui_list->callback_get_item_name = callback_get_item_name;
gui_list->display = NULL;
gui_list_set_nb_items(gui_list, 0);
@@ -126,8 +125,7 @@ void gui_list_draw(struct gui_list * gui_list)
int cursor_pos = 0;
int icon_pos = 1;
int text_pos;
- bool draw_icons = (gui_list->callback_get_item_icon != NULL &&
- global_settings.show_icons) ;
+ bool draw_icons = (gui_list->callback_get_item_icon != NULL ) ;
bool draw_cursor;
int i;
@@ -363,7 +361,6 @@ void gui_list_del_item(struct gui_list * gui_list)
*/
void gui_synclist_init(
struct gui_synclist * lists,
- list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
void * data
)
@@ -372,7 +369,6 @@ void gui_synclist_init(
FOR_NB_SCREENS(i)
{
gui_list_init(&(lists->gui_list[i]),
- callback_get_item_icon,
callback_get_item_name,
data);
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)
gui_list_set_nb_items(&(lists->gui_list[i]), nb_items);
}
}
+void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback)
+{
+ int i;
+ FOR_NB_SCREENS(i)
+ {
+ gui_list_set_icon_callback(&(lists->gui_list[i]), icon_callback);
+ }
+}
void gui_synclist_draw(struct gui_synclist * lists)
{
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
* to a given item number
* - callback_get_item_name : pointer to a function that associates a label
* to a given item number
+ * - data : extra data passed to the list callback
*/
extern void gui_list_init(struct gui_list * gui_list,
- list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
void * data
);
@@ -146,7 +146,7 @@ extern void gui_list_init(struct gui_list * gui_list,
/*
* Sets the numbers of items the list can currently display
* note that the list's context like the currently pointed item is resetted
- * - gui_list : the list structure to initialize
+ * - gui_list : the list structure
* - nb_items : the numbers of items you want
*/
#define gui_list_set_nb_items(gui_list, nb) \
@@ -154,7 +154,7 @@ extern void gui_list_init(struct gui_list * gui_list,
/*
* Returns the numbers of items currently in the list
- * - gui_list : the list structure to initialize
+ * - gui_list : the list structure
*/
#define gui_list_get_nb_items(gui_list) \
(gui_list)->nb_items
@@ -170,6 +170,14 @@ extern void gui_list_put_selection_in_screen(struct gui_list * gui_list,
bool put_from_end);
/*
+ * Sets the icon callback function
+ * - gui_list : the list structure
+ * - _callback : the callback function
+ */
+#define gui_list_set_icon_callback(gui_list, _callback) \
+ (gui_list)->callback_get_item_icon=_callback
+
+/*
* Attach the scrolling list to a screen
* (The previous screen attachement is lost)
* - gui_list : the list structure
@@ -277,14 +285,14 @@ struct gui_synclist
extern void gui_synclist_init(
struct gui_synclist * lists,
- list_get_icon callback_get_item_icon,
list_get_name callback_get_item_name,
void * data
);
extern void gui_synclist_set_nb_items(struct gui_synclist * lists, int nb_items);
-
+extern void gui_synclist_set_icon_callback(struct gui_synclist * lists, list_get_icon icon_callback);
#define gui_synclist_get_nb_items(lists) \
gui_list_get_nb_items(&((lists)->gui_list[0]))
+
extern int gui_synclist_get_sel_pos(struct gui_synclist * lists);
#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
return -1;
menus[menu].items = (struct menu_item*)mitems; /* de-const */
gui_synclist_init(&(menus[menu].synclist),
- NULL, &menu_get_itemname, &menus[menu]);
+ &menu_get_itemname, &menus[menu]);
+ gui_synclist_set_icon_callback(&(menus[menu].synclist), NULL);
gui_synclist_set_nb_items(&(menus[menu].synclist), count);
menus[menu].callback = callback;
#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)
if (!playlist_viewer_init(&viewer, filename, false))
goto exit;
- gui_synclist_init(&playlist_lists, playlist_callback_icons,
- playlist_callback_name, &viewer);
+ gui_synclist_init(&playlist_lists, playlist_callback_name, &viewer);
+ gui_synclist_set_icon_callback(&playlist_lists,
+ global_settings.playlist_viewer_icons?&playlist_callback_icons:NULL);
gui_synclist_set_nb_items(&playlist_lists, viewer.num_tracks);
gui_synclist_select_item(&playlist_lists, viewer.selected_track);
gui_synclist_draw(&playlist_lists);
@@ -773,6 +774,11 @@ bool playlist_viewer_ex(char* filename)
ret = true;
goto exit;
}
+ gui_synclist_set_icon_callback(
+ &playlist_lists,
+ global_settings.playlist_viewer_icons?
+ &playlist_callback_icons:NULL
+ );
gui_synclist_draw(&playlist_lists);
break;
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)
gui_buttonbar_set_display(&tree_buttonbar, &(screens[SCREEN_MAIN]) );
#endif
gui_syncstatusbar_init(&statusbars);
- gui_synclist_init(&tree_lists, &tree_get_fileicon, &tree_get_filename, &tc);
+ gui_synclist_init(&tree_lists, &tree_get_filename, &tc);
+ gui_synclist_set_icon_callback(&tree_lists,
+ global_settings.show_icons?&tree_get_fileicon:NULL);
#ifndef SIMULATOR
dirbrowse();
#else
@@ -338,6 +340,8 @@ static int update_dir(void)
}
}
gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
+ gui_synclist_set_icon_callback(&tree_lists,
+ global_settings.show_icons?&tree_get_fileicon:NULL);
if( tc.selected_item >= tc.filesindir)
tc.selected_item=tc.filesindir-1;