summaryrefslogtreecommitdiffstats
path: root/apps/bookmark.c
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2007-11-18 12:59:08 +0000
committerMagnus Holmgren <magnushol@gmail.com>2007-11-18 12:59:08 +0000
commit47167e70224cfce4fe68ac836b2b694bbe203bfb (patch)
tree97695e71b8d19c03187b8f191269781a5b6697da /apps/bookmark.c
parent6ef2db2c1127954e22001d8663fb2ab9de5c2665 (diff)
downloadrockbox-47167e70224cfce4fe68ac836b2b694bbe203bfb.tar.gz
rockbox-47167e70224cfce4fe68ac836b2b694bbe203bfb.tar.bz2
rockbox-47167e70224cfce4fe68ac836b2b694bbe203bfb.zip
In the recent bookmarks list, show playlist/directory name, in addition to the file name.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15656 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/bookmark.c')
-rw-r--r--apps/bookmark.c70
1 files changed, 58 insertions, 12 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c
index 184281ba87..e0e9f8bd37 100644
--- a/apps/bookmark.c
+++ b/apps/bookmark.c
@@ -70,6 +70,7 @@ struct bookmark_list
int total_count;
bool show_dont_resume;
bool reload;
+ bool show_playlist_name;
char* items[];
};
@@ -507,6 +508,22 @@ static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line)
return bookmarks->start + bookmarks->count;
}
+static char* strrsplt(char* str, int c)
+{
+ char* s = strrchr(str, c);
+
+ if (s != NULL)
+ {
+ *s++ = '\0';
+ }
+ else
+ {
+ s = str;
+ }
+
+ return s;
+}
+
static char* get_bookmark_info(int list_index, void* data, char *buffer)
{
struct bookmark_list* bookmarks = (struct bookmark_list*) data;
@@ -568,22 +585,49 @@ static char* get_bookmark_info(int list_index, void* data, char *buffer)
}
if (!parse_bookmark(bookmarks->items[index - bookmarks->start],
- &resume_index, NULL, NULL, NULL, NULL, 0, &resume_time, NULL,
- &shuffle, global_filename))
+ &resume_index, NULL, NULL, NULL, global_temp_buffer,
+ sizeof(global_temp_buffer), &resume_time, NULL, &shuffle,
+ global_filename))
{
return list_index % 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID) : " ";
}
if (list_index % 2 == 0)
{
- char* dot = strrchr(global_filename, '.');
+ char *name;
+ char *format;
+ int len = strlen(global_temp_buffer);
+
+ if (bookmarks->show_playlist_name && len > 0)
+ {
+ name = global_temp_buffer;
+ len--;
+
+ if (name[len] != '/')
+ {
+ strrsplt(name, '.');
+ }
+ else if (len > 1)
+ {
+ name[len] = '\0';
+ }
- if (dot)
+ if (len > 1)
+ {
+ name = strrsplt(name, '/');
+ }
+
+ format = "%s : %s";
+ }
+ else
{
- *dot = '\0';
+ name = global_filename;
+ format = "%s";
}
-
- return global_filename;
+
+ strrsplt(global_filename, '.');
+ snprintf(buffer, MAX_PATH, format, name, global_filename);
+ return buffer;
}
else
{
@@ -616,6 +660,8 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu
bookmarks->show_dont_resume = show_dont_resume;
bookmarks->filename = bookmark_file_name;
bookmarks->start = 0;
+ bookmarks->show_playlist_name
+ = strcmp(bookmark_file_name, RECENT_BOOKMARK_FILE) == 0;
gui_synclist_init(&list, &get_bookmark_info, (void*) bookmarks, false, 2);
gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK),
Icon_Bookmark);
@@ -791,11 +837,10 @@ static void say_bookmark(const char* bookmark,
{
int resume_index;
long ms;
- char dir[MAX_PATH];
bool enqueue = false; /* only the first voice is not queued */
if (!parse_bookmark(bookmark, &resume_index, NULL, NULL, NULL,
- dir, sizeof(dir), &ms, NULL, NULL, NULL))
+ global_temp_buffer, sizeof(global_temp_buffer), &ms, NULL, NULL, NULL))
{
talk_id(LANG_BOOKMARK_INVALID, true);
return;
@@ -805,11 +850,12 @@ static void say_bookmark(const char* bookmark,
#if 0
if (global_settings.talk_dir >= 3)
{ /* "talkbox" enabled */
- char* last = strrchr(dir, '/');
+ char* last = strrchr(global_temp_buffer, '/');
if (last)
{ /* compose filename for talkbox */
- strncpy(last + 1, dir_thumbnail_name, sizeof(dir)-(last-dir)-1);
- talk_file(dir, enqueue);
+ strncpy(last + 1, dir_thumbnail_name,
+ sizeof(global_temp_buffer) - (last - global_temp_buffer) - 1);
+ talk_file(global_temp_buffer, enqueue);
enqueue = true;
}
}