diff options
author | Magnus Holmgren <magnushol@gmail.com> | 2007-02-17 13:36:44 +0000 |
---|---|---|
committer | Magnus Holmgren <magnushol@gmail.com> | 2007-02-17 13:36:44 +0000 |
commit | 14ba91eaa9a94411457cc396a4c7c5e39e63a00a (patch) | |
tree | a550e288bda8052a05feb5355df0a16f39897466 /apps | |
parent | 471d881979e0027737a435fd03efea493ea696f3 (diff) | |
download | rockbox-14ba91eaa9a94411457cc396a4c7c5e39e63a00a.tar.gz rockbox-14ba91eaa9a94411457cc396a4c7c5e39e63a00a.zip |
A few more bookmark code tweaks. Also improves how the bookmark selection screen is displayed on Archos players.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12350 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/bookmark.c | 104 | ||||
-rw-r--r-- | apps/gui/gwps-common.c | 36 | ||||
-rw-r--r-- | apps/gui/gwps-common.h | 1 | ||||
-rw-r--r-- | apps/misc.c | 21 | ||||
-rw-r--r-- | apps/misc.h | 9 | ||||
-rw-r--r-- | apps/screens.c | 3 |
6 files changed, 67 insertions, 107 deletions
diff --git a/apps/bookmark.c b/apps/bookmark.c index 0bcdb131ca..1352b2a708 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c | |||
@@ -225,10 +225,8 @@ static bool write_bookmark(bool create_bookmark_file) | |||
225 | } | 225 | } |
226 | } | 226 | } |
227 | 227 | ||
228 | if (success) | 228 | gui_syncsplash(HZ, true, str(success ? LANG_BOOKMARK_CREATE_SUCCESS |
229 | gui_syncsplash(HZ, true, str(LANG_BOOKMARK_CREATE_SUCCESS)); | 229 | : LANG_BOOKMARK_CREATE_FAILURE)); |
230 | else | ||
231 | gui_syncsplash(HZ, true, str(LANG_BOOKMARK_CREATE_FAILURE)); | ||
232 | 230 | ||
233 | return true; | 231 | return true; |
234 | } | 232 | } |
@@ -380,11 +378,6 @@ bool bookmark_autoload(const char* file) | |||
380 | fd = open(global_bookmark_file_name, O_RDONLY); | 378 | fd = open(global_bookmark_file_name, O_RDONLY); |
381 | if(fd<0) | 379 | if(fd<0) |
382 | return false; | 380 | return false; |
383 | if(-1 == lseek(fd, 0, SEEK_END)) | ||
384 | { | ||
385 | close(fd); | ||
386 | return false; | ||
387 | } | ||
388 | close(fd); | 381 | close(fd); |
389 | if(global_settings.autoloadbookmark == BOOKMARK_YES) | 382 | if(global_settings.autoloadbookmark == BOOKMARK_YES) |
390 | { | 383 | { |
@@ -555,16 +548,9 @@ static char* select_bookmark(const char* bookmark_file_name) | |||
555 | case ACTION_BMS_SELECT: | 548 | case ACTION_BMS_SELECT: |
556 | /* User wants to use this bookmark */ | 549 | /* User wants to use this bookmark */ |
557 | #ifdef HAVE_LCD_BITMAP | 550 | #ifdef HAVE_LCD_BITMAP |
558 | if (global_settings.statusbar) | 551 | FOR_NB_SCREENS(i) |
559 | { | 552 | screens[i].setmargins(0, global_settings.statusbar |
560 | FOR_NB_SCREENS(i) | 553 | ? STATUSBAR_HEIGHT : 0); |
561 | screens[i].setmargins(0, STATUSBAR_HEIGHT); | ||
562 | } | ||
563 | else | ||
564 | { | ||
565 | FOR_NB_SCREENS(i) | ||
566 | screens[i].setmargins(0, 0); | ||
567 | } | ||
568 | #endif | 554 | #endif |
569 | action_signalscreenchange(); | 555 | action_signalscreenchange(); |
570 | return bookmark; | 556 | return bookmark; |
@@ -674,8 +660,8 @@ static void display_bookmark(const char* bookmark, | |||
674 | long ms = 0; | 660 | long ms = 0; |
675 | int repeat_mode = 0; | 661 | int repeat_mode = 0; |
676 | bool playlist_shuffle = false; | 662 | bool playlist_shuffle = false; |
677 | int len; | ||
678 | char *dot; | 663 | char *dot; |
664 | char time_buf[32]; | ||
679 | int i; | 665 | int i; |
680 | 666 | ||
681 | /* getting the index and the time into the file */ | 667 | /* getting the index and the time into the file */ |
@@ -712,49 +698,34 @@ static void display_bookmark(const char* bookmark, | |||
712 | statusbar_icon_shuffle(); | 698 | statusbar_icon_shuffle(); |
713 | 699 | ||
714 | /* File Name */ | 700 | /* File Name */ |
715 | len=strlen(global_filename); | 701 | dot = strrchr(global_filename, '.'); |
716 | if (len>3) | 702 | |
717 | dot=strrchr(global_filename + len - 4, '.'); | ||
718 | else | ||
719 | dot=NULL; | ||
720 | if (dot) | 703 | if (dot) |
721 | *dot='\0'; | 704 | *dot='\0'; |
705 | |||
722 | FOR_NB_SCREENS(i) | 706 | FOR_NB_SCREENS(i) |
723 | screens[i].puts_scroll(0, 0, (unsigned char *)global_filename); | 707 | screens[i].puts_scroll(0, 0, (unsigned char *)global_filename); |
708 | |||
724 | if (dot) | 709 | if (dot) |
725 | *dot='.'; | 710 | *dot='.'; |
726 | 711 | ||
727 | /* bookmark number */ | 712 | /* bookmark number */ |
728 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), "%s: %2d/%2d", | 713 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), "%s: %d/%d", |
729 | str(LANG_BOOKMARK_SELECT_BOOKMARK_TEXT), | 714 | str(LANG_BOOKMARK_SELECT_BOOKMARK_TEXT), |
730 | bookmark_id + 1, bookmark_count); | 715 | bookmark_id + 1, bookmark_count); |
731 | FOR_NB_SCREENS(i) | 716 | FOR_NB_SCREENS(i) |
732 | screens[i].puts_scroll(0, 1, (unsigned char *)global_temp_buffer); | 717 | screens[i].puts_scroll(0, 1, (unsigned char *)global_temp_buffer); |
733 | 718 | ||
734 | /* bookmark resume index */ | 719 | /* bookmark resume index */ |
735 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), "%s: %2d", | 720 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), "%s: %d", |
736 | str(LANG_BOOKMARK_SELECT_INDEX_TEXT), resume_index+1); | 721 | str(LANG_BOOKMARK_SELECT_INDEX_TEXT), resume_index+1); |
737 | FOR_NB_SCREENS(i) | 722 | FOR_NB_SCREENS(i) |
738 | screens[i].puts_scroll(0, 2, (unsigned char *)global_temp_buffer); | 723 | screens[i].puts_scroll(0, 2, (unsigned char *)global_temp_buffer); |
739 | 724 | ||
740 | /* elapsed time*/ | 725 | /* elapsed time*/ |
741 | if ( ms < 3600000 ) | 726 | format_time(time_buf, sizeof(time_buf), ms); |
742 | { | 727 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), "%s: %s", |
743 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), "%s: %ld:%02d", | 728 | str(LANG_BOOKMARK_SELECT_TIME_TEXT), time_buf); |
744 | str(LANG_BOOKMARK_SELECT_TIME_TEXT), | ||
745 | ms / 60000, | ||
746 | (unsigned int)(ms % 60000) / 1000); | ||
747 | /* unsigned int: hinting for 16bits archs */ | ||
748 | } | ||
749 | else | ||
750 | { | ||
751 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), | ||
752 | "%s: %ld:%02ld:%02d", | ||
753 | str(LANG_BOOKMARK_SELECT_TIME_TEXT), | ||
754 | ms / 3600000, | ||
755 | ms % 3600000 / 60000, | ||
756 | (unsigned int)(ms % 60000) / 1000); | ||
757 | } | ||
758 | FOR_NB_SCREENS(i) | 729 | FOR_NB_SCREENS(i) |
759 | screens[i].puts_scroll(0, 3, (unsigned char *)global_temp_buffer); | 730 | screens[i].puts_scroll(0, 3, (unsigned char *)global_temp_buffer); |
760 | 731 | ||
@@ -764,35 +735,21 @@ static void display_bookmark(const char* bookmark, | |||
764 | screens[i].puts_scroll(0, 4, str(LANG_BOOKMARK_SELECT_PLAY)); | 735 | screens[i].puts_scroll(0, 4, str(LANG_BOOKMARK_SELECT_PLAY)); |
765 | screens[i].puts_scroll(0, 5, str(LANG_BOOKMARK_SELECT_EXIT)); | 736 | screens[i].puts_scroll(0, 5, str(LANG_BOOKMARK_SELECT_EXIT)); |
766 | screens[i].puts_scroll(0, 6, str(LANG_BOOKMARK_SELECT_DELETE)); | 737 | screens[i].puts_scroll(0, 6, str(LANG_BOOKMARK_SELECT_DELETE)); |
738 | screens[i].update(); | ||
767 | } | 739 | } |
768 | #else | 740 | #else |
769 | (void)bookmark_id; | 741 | dot = strrchr(global_filename, '.'); |
770 | len=strlen(global_filename); | 742 | |
771 | if (len>3) | ||
772 | dot=strrchr(global_filename+len-4,'.'); | ||
773 | else | ||
774 | dot=NULL; | ||
775 | if (dot) | 743 | if (dot) |
776 | *dot='\0'; | 744 | *dot='\0'; |
777 | if ( ms < 3600000 ) | 745 | |
778 | { | 746 | format_time(time_buf, sizeof(time_buf), ms); |
779 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), | 747 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), |
780 | "%2d, %ld:%02ld, %s,", | 748 | "%d/%d, %s, %s", (bookmark_id + 1), bookmark_count, |
781 | (bookmark_count+1), | 749 | time_buf, global_filename); |
782 | ms / 60000, | 750 | |
783 | ms % 60000 / 1000, | 751 | if (dot) |
784 | global_filename); | 752 | *dot='.'; |
785 | } | ||
786 | else | ||
787 | { | ||
788 | snprintf(global_temp_buffer, sizeof(global_temp_buffer), | ||
789 | "%2d, %ld:%02ld:%02ld, %s,", | ||
790 | (bookmark_count+1), | ||
791 | ms / 60000, | ||
792 | ms % 3600000 / 60000, | ||
793 | ms % 60000 / 1000, | ||
794 | global_filename); | ||
795 | } | ||
796 | 753 | ||
797 | gui_syncstatusbar_draw(&statusbars, false); | 754 | gui_syncstatusbar_draw(&statusbars, false); |
798 | 755 | ||
@@ -801,13 +758,6 @@ static void display_bookmark(const char* bookmark, | |||
801 | screens[i].puts_scroll(0,0,global_temp_buffer); | 758 | screens[i].puts_scroll(0,0,global_temp_buffer); |
802 | screens[i].puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER)); | 759 | screens[i].puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER)); |
803 | } | 760 | } |
804 | if (dot) | ||
805 | *dot='.'; | ||
806 | #endif | ||
807 | |||
808 | #ifdef HAVE_LCD_BITMAP | ||
809 | FOR_NB_SCREENS(i) | ||
810 | screens[i].update(); | ||
811 | #endif | 761 | #endif |
812 | } | 762 | } |
813 | 763 | ||
@@ -1047,7 +997,7 @@ static bool generate_bookmark_file_name(const char *in) | |||
1047 | } | 997 | } |
1048 | 998 | ||
1049 | /* ----------------------------------------------------------------------- */ | 999 | /* ----------------------------------------------------------------------- */ |
1050 | /* Returns the bookmark name for the current playlist */ | 1000 | /* Returns true if a bookmark file exists for the current playlist */ |
1051 | /* ----------------------------------------------------------------------- */ | 1001 | /* ----------------------------------------------------------------------- */ |
1052 | bool bookmark_exist(void) | 1002 | bool bookmark_exist(void) |
1053 | { | 1003 | { |
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c index 2037ad57a5..d533e33f9c 100644 --- a/apps/gui/gwps-common.c +++ b/apps/gui/gwps-common.c | |||
@@ -371,24 +371,6 @@ static void gui_wps_statusbar_draw(struct gui_wps *wps, bool force) | |||
371 | gui_statusbar_draw((wps)->statusbar, (force)) | 371 | gui_statusbar_draw((wps)->statusbar, (force)) |
372 | #endif | 372 | #endif |
373 | 373 | ||
374 | /* Format time into buf. | ||
375 | * | ||
376 | * buf - buffer to format to. | ||
377 | * buf_size - size of buffer. | ||
378 | * time - time to format, in milliseconds. | ||
379 | */ | ||
380 | void gui_wps_format_time(char* buf, int buf_size, long time) | ||
381 | { | ||
382 | if ( time < 3600000 ) { | ||
383 | snprintf(buf, buf_size, "%d:%02d", | ||
384 | (int) (time % 3600000 / 60000), (int) (time % 60000 / 1000)); | ||
385 | } else { | ||
386 | snprintf(buf, buf_size, "%d:%02d:%02d", | ||
387 | (int) (time / 3600000), (int) (time % 3600000 / 60000), | ||
388 | (int) (time % 60000 / 1000)); | ||
389 | } | ||
390 | } | ||
391 | |||
392 | /* Extract a part from a path. | 374 | /* Extract a part from a path. |
393 | * | 375 | * |
394 | * buf - buffer extract part to. | 376 | * buf - buffer extract part to. |
@@ -688,20 +670,20 @@ static char* get_tag(struct wps_data* wps_data, | |||
688 | 670 | ||
689 | case 'c': /* Current Time in Song */ | 671 | case 'c': /* Current Time in Song */ |
690 | *flags |= WPS_REFRESH_DYNAMIC; | 672 | *flags |= WPS_REFRESH_DYNAMIC; |
691 | gui_wps_format_time(buf, buf_size, | 673 | format_time(buf, buf_size, |
692 | id3->elapsed + wps_state.ff_rewind_count); | 674 | id3->elapsed + wps_state.ff_rewind_count); |
693 | return buf; | 675 | return buf; |
694 | 676 | ||
695 | case 'r': /* Remaining Time in Song */ | 677 | case 'r': /* Remaining Time in Song */ |
696 | *flags |= WPS_REFRESH_DYNAMIC; | 678 | *flags |= WPS_REFRESH_DYNAMIC; |
697 | gui_wps_format_time(buf, buf_size, | 679 | format_time(buf, buf_size, |
698 | id3->length - id3->elapsed - | 680 | id3->length - id3->elapsed - |
699 | wps_state.ff_rewind_count); | 681 | wps_state.ff_rewind_count); |
700 | return buf; | 682 | return buf; |
701 | 683 | ||
702 | case 't': /* Total Time */ | 684 | case 't': /* Total Time */ |
703 | *flags |= WPS_REFRESH_STATIC; | 685 | *flags |= WPS_REFRESH_STATIC; |
704 | gui_wps_format_time(buf, buf_size, id3->length); | 686 | format_time(buf, buf_size, id3->length); |
705 | return buf; | 687 | return buf; |
706 | 688 | ||
707 | #ifdef HAVE_LCD_BITMAP | 689 | #ifdef HAVE_LCD_BITMAP |
@@ -835,8 +817,8 @@ static char* get_tag(struct wps_data* wps_data, | |||
835 | } | 817 | } |
836 | else | 818 | else |
837 | { | 819 | { |
838 | gui_wps_format_time(buf, buf_size, \ | 820 | format_time(buf, buf_size, \ |
839 | get_sleep_timer() * 1000); | 821 | get_sleep_timer() * 1000); |
840 | return buf; | 822 | return buf; |
841 | } | 823 | } |
842 | } | 824 | } |
@@ -2252,7 +2234,7 @@ static void draw_player_fullbar(struct gui_wps *gwps, char* buf, int buf_size) | |||
2252 | time=(state->id3->elapsed + state->ff_rewind_count); | 2234 | time=(state->id3->elapsed + state->ff_rewind_count); |
2253 | 2235 | ||
2254 | memset(timestr, 0, sizeof(timestr)); | 2236 | memset(timestr, 0, sizeof(timestr)); |
2255 | gui_wps_format_time(timestr, sizeof(timestr), time); | 2237 | format_time(timestr, sizeof(timestr), time); |
2256 | for(lcd_char_pos=0; lcd_char_pos<6; lcd_char_pos++) { | 2238 | for(lcd_char_pos=0; lcd_char_pos<6; lcd_char_pos++) { |
2257 | digits[lcd_char_pos] = map_fullbar_char(timestr[lcd_char_pos]); | 2239 | digits[lcd_char_pos] = map_fullbar_char(timestr[lcd_char_pos]); |
2258 | } | 2240 | } |
diff --git a/apps/gui/gwps-common.h b/apps/gui/gwps-common.h index b4d6df589a..77bec83951 100644 --- a/apps/gui/gwps-common.h +++ b/apps/gui/gwps-common.h | |||
@@ -23,7 +23,6 @@ | |||
23 | 23 | ||
24 | #include "gwps.h" | 24 | #include "gwps.h" |
25 | 25 | ||
26 | void gui_wps_format_time(char* buf, int buf_size, long time); | ||
27 | void fade(bool fade_in); | 26 | void fade(bool fade_in); |
28 | void gui_wps_format(struct wps_data *data); | 27 | void gui_wps_format(struct wps_data *data); |
29 | bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset, | 28 | bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset, |
diff --git a/apps/misc.c b/apps/misc.c index 8487da0d98..d072d4f881 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -186,6 +186,27 @@ char *create_numbered_filename(char *buffer, const char *path, | |||
186 | return buffer; | 186 | return buffer; |
187 | } | 187 | } |
188 | 188 | ||
189 | /* Format time into buf. | ||
190 | * | ||
191 | * buf - buffer to format to. | ||
192 | * buf_size - size of buffer. | ||
193 | * t - time to format, in milliseconds. | ||
194 | */ | ||
195 | void format_time(char* buf, int buf_size, long t) | ||
196 | { | ||
197 | if ( t < 3600000 ) | ||
198 | { | ||
199 | snprintf(buf, buf_size, "%d:%02d", | ||
200 | (int) (t / 60000), (int) (t % 60000 / 1000)); | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | snprintf(buf, buf_size, "%d:%02d:%02d", | ||
205 | (int) (t / 3600000), (int) (t % 3600000 / 60000), | ||
206 | (int) (t % 60000 / 1000)); | ||
207 | } | ||
208 | } | ||
209 | |||
189 | #ifdef CONFIG_RTC | 210 | #ifdef CONFIG_RTC |
190 | /* Create a filename with a date+time part. | 211 | /* Create a filename with a date+time part. |
191 | It is allowed that buffer and path point to the same memory location, | 212 | It is allowed that buffer and path point to the same memory location, |
diff --git a/apps/misc.h b/apps/misc.h index f273631030..f127d6acbf 100644 --- a/apps/misc.h +++ b/apps/misc.h | |||
@@ -49,6 +49,15 @@ char *output_dyn_value(char *buf, int buf_size, int value, | |||
49 | char *create_numbered_filename(char *buffer, const char *path, | 49 | char *create_numbered_filename(char *buffer, const char *path, |
50 | const char *prefix, const char *suffix, | 50 | const char *prefix, const char *suffix, |
51 | int numberlen IF_CNFN_NUM_(, int *num)); | 51 | int numberlen IF_CNFN_NUM_(, int *num)); |
52 | |||
53 | /* Format time into buf. | ||
54 | * | ||
55 | * buf - buffer to format to. | ||
56 | * buf_size - size of buffer. | ||
57 | * t - time to format, in milliseconds. | ||
58 | */ | ||
59 | void format_time(char* buf, int buf_size, long t); | ||
60 | |||
52 | #ifdef CONFIG_RTC | 61 | #ifdef CONFIG_RTC |
53 | /* Create a filename with a date+time part. | 62 | /* Create a filename with a date+time part. |
54 | It is allowed that buffer and path point to the same memory location, | 63 | It is allowed that buffer and path point to the same memory location, |
diff --git a/apps/screens.c b/apps/screens.c index 26f083da47..29b6f1dd76 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include "debug.h" | 49 | #include "debug.h" |
50 | #include "led.h" | 50 | #include "led.h" |
51 | #include "sound.h" | 51 | #include "sound.h" |
52 | #include "gwps-common.h" | ||
53 | #include "splash.h" | 52 | #include "splash.h" |
54 | #include "statusbar.h" | 53 | #include "statusbar.h" |
55 | #include "screen_access.h" | 54 | #include "screen_access.h" |
@@ -1197,7 +1196,7 @@ static char * id3_get_info(int selected_item, void* data, char *buffer) | |||
1197 | } | 1196 | } |
1198 | break; | 1197 | break; |
1199 | case 8:/*LANG_ID3_LENGTH*/ | 1198 | case 8:/*LANG_ID3_LENGTH*/ |
1200 | gui_wps_format_time(buffer, MAX_PATH, id3->length); | 1199 | format_time(buffer, MAX_PATH, id3->length); |
1201 | info=buffer; | 1200 | info=buffer; |
1202 | break; | 1201 | break; |
1203 | case 9:/*LANG_ID3_PLAYLIST*/ | 1202 | case 9:/*LANG_ID3_PLAYLIST*/ |