diff options
author | Magnus Holmgren <magnushol@gmail.com> | 2007-11-18 12:59:08 +0000 |
---|---|---|
committer | Magnus Holmgren <magnushol@gmail.com> | 2007-11-18 12:59:08 +0000 |
commit | 47167e70224cfce4fe68ac836b2b694bbe203bfb (patch) | |
tree | 97695e71b8d19c03187b8f191269781a5b6697da /apps | |
parent | 6ef2db2c1127954e22001d8663fb2ab9de5c2665 (diff) | |
download | rockbox-47167e70224cfce4fe68ac836b2b694bbe203bfb.tar.gz 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')
-rw-r--r-- | apps/bookmark.c | 70 |
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 | |||
70 | int total_count; | 70 | int total_count; |
71 | bool show_dont_resume; | 71 | bool show_dont_resume; |
72 | bool reload; | 72 | bool reload; |
73 | bool show_playlist_name; | ||
73 | char* items[]; | 74 | char* items[]; |
74 | }; | 75 | }; |
75 | 76 | ||
@@ -507,6 +508,22 @@ static int buffer_bookmarks(struct bookmark_list* bookmarks, int first_line) | |||
507 | return bookmarks->start + bookmarks->count; | 508 | return bookmarks->start + bookmarks->count; |
508 | } | 509 | } |
509 | 510 | ||
511 | static char* strrsplt(char* str, int c) | ||
512 | { | ||
513 | char* s = strrchr(str, c); | ||
514 | |||
515 | if (s != NULL) | ||
516 | { | ||
517 | *s++ = '\0'; | ||
518 | } | ||
519 | else | ||
520 | { | ||
521 | s = str; | ||
522 | } | ||
523 | |||
524 | return s; | ||
525 | } | ||
526 | |||
510 | static char* get_bookmark_info(int list_index, void* data, char *buffer) | 527 | static char* get_bookmark_info(int list_index, void* data, char *buffer) |
511 | { | 528 | { |
512 | struct bookmark_list* bookmarks = (struct bookmark_list*) data; | 529 | struct bookmark_list* bookmarks = (struct bookmark_list*) data; |
@@ -568,22 +585,49 @@ static char* get_bookmark_info(int list_index, void* data, char *buffer) | |||
568 | } | 585 | } |
569 | 586 | ||
570 | if (!parse_bookmark(bookmarks->items[index - bookmarks->start], | 587 | if (!parse_bookmark(bookmarks->items[index - bookmarks->start], |
571 | &resume_index, NULL, NULL, NULL, NULL, 0, &resume_time, NULL, | 588 | &resume_index, NULL, NULL, NULL, global_temp_buffer, |
572 | &shuffle, global_filename)) | 589 | sizeof(global_temp_buffer), &resume_time, NULL, &shuffle, |
590 | global_filename)) | ||
573 | { | 591 | { |
574 | return list_index % 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID) : " "; | 592 | return list_index % 2 == 0 ? (char*) str(LANG_BOOKMARK_INVALID) : " "; |
575 | } | 593 | } |
576 | 594 | ||
577 | if (list_index % 2 == 0) | 595 | if (list_index % 2 == 0) |
578 | { | 596 | { |
579 | char* dot = strrchr(global_filename, '.'); | 597 | char *name; |
598 | char *format; | ||
599 | int len = strlen(global_temp_buffer); | ||
600 | |||
601 | if (bookmarks->show_playlist_name && len > 0) | ||
602 | { | ||
603 | name = global_temp_buffer; | ||
604 | len--; | ||
605 | |||
606 | if (name[len] != '/') | ||
607 | { | ||
608 | strrsplt(name, '.'); | ||
609 | } | ||
610 | else if (len > 1) | ||
611 | { | ||
612 | name[len] = '\0'; | ||
613 | } | ||
580 | 614 | ||
581 | if (dot) | 615 | if (len > 1) |
616 | { | ||
617 | name = strrsplt(name, '/'); | ||
618 | } | ||
619 | |||
620 | format = "%s : %s"; | ||
621 | } | ||
622 | else | ||
582 | { | 623 | { |
583 | *dot = '\0'; | 624 | name = global_filename; |
625 | format = "%s"; | ||
584 | } | 626 | } |
585 | 627 | ||
586 | return global_filename; | 628 | strrsplt(global_filename, '.'); |
629 | snprintf(buffer, MAX_PATH, format, name, global_filename); | ||
630 | return buffer; | ||
587 | } | 631 | } |
588 | else | 632 | else |
589 | { | 633 | { |
@@ -616,6 +660,8 @@ static char* select_bookmark(const char* bookmark_file_name, bool show_dont_resu | |||
616 | bookmarks->show_dont_resume = show_dont_resume; | 660 | bookmarks->show_dont_resume = show_dont_resume; |
617 | bookmarks->filename = bookmark_file_name; | 661 | bookmarks->filename = bookmark_file_name; |
618 | bookmarks->start = 0; | 662 | bookmarks->start = 0; |
663 | bookmarks->show_playlist_name | ||
664 | = strcmp(bookmark_file_name, RECENT_BOOKMARK_FILE) == 0; | ||
619 | gui_synclist_init(&list, &get_bookmark_info, (void*) bookmarks, false, 2); | 665 | gui_synclist_init(&list, &get_bookmark_info, (void*) bookmarks, false, 2); |
620 | gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK), | 666 | gui_synclist_set_title(&list, str(LANG_BOOKMARK_SELECT_BOOKMARK), |
621 | Icon_Bookmark); | 667 | Icon_Bookmark); |
@@ -791,11 +837,10 @@ static void say_bookmark(const char* bookmark, | |||
791 | { | 837 | { |
792 | int resume_index; | 838 | int resume_index; |
793 | long ms; | 839 | long ms; |
794 | char dir[MAX_PATH]; | ||
795 | bool enqueue = false; /* only the first voice is not queued */ | 840 | bool enqueue = false; /* only the first voice is not queued */ |
796 | 841 | ||
797 | if (!parse_bookmark(bookmark, &resume_index, NULL, NULL, NULL, | 842 | if (!parse_bookmark(bookmark, &resume_index, NULL, NULL, NULL, |
798 | dir, sizeof(dir), &ms, NULL, NULL, NULL)) | 843 | global_temp_buffer, sizeof(global_temp_buffer), &ms, NULL, NULL, NULL)) |
799 | { | 844 | { |
800 | talk_id(LANG_BOOKMARK_INVALID, true); | 845 | talk_id(LANG_BOOKMARK_INVALID, true); |
801 | return; | 846 | return; |
@@ -805,11 +850,12 @@ static void say_bookmark(const char* bookmark, | |||
805 | #if 0 | 850 | #if 0 |
806 | if (global_settings.talk_dir >= 3) | 851 | if (global_settings.talk_dir >= 3) |
807 | { /* "talkbox" enabled */ | 852 | { /* "talkbox" enabled */ |
808 | char* last = strrchr(dir, '/'); | 853 | char* last = strrchr(global_temp_buffer, '/'); |
809 | if (last) | 854 | if (last) |
810 | { /* compose filename for talkbox */ | 855 | { /* compose filename for talkbox */ |
811 | strncpy(last + 1, dir_thumbnail_name, sizeof(dir)-(last-dir)-1); | 856 | strncpy(last + 1, dir_thumbnail_name, |
812 | talk_file(dir, enqueue); | 857 | sizeof(global_temp_buffer) - (last - global_temp_buffer) - 1); |
858 | talk_file(global_temp_buffer, enqueue); | ||
813 | enqueue = true; | 859 | enqueue = true; |
814 | } | 860 | } |
815 | } | 861 | } |