From db1b823ac3ea524d80a83876c9c99593d29f3817 Mon Sep 17 00:00:00 2001 From: Torne Wuff Date: Mon, 5 Jul 2010 16:39:00 +0000 Subject: [PATCH] Provide the option to automatically update existing bookmark files on stop, without creating ones that don't already exist. Idea from FS#6272, but implemented differently. If you set "Update on stop" then it will check if the bookmark file exists on stop, and if so, write a new one without prompting. If the file doesn't exist, it will do whatever the "Bookmark on stop" setting tells it to do. This works quite well if you have an audiobook/podcast/etc folder/playlist: just bookmark it manually once and it will get bookmarked automatically after that, without creating bookmarks for regular music. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27294 a1c6a512-1295-4272-9138-f99709370657 --- apps/bookmark.c | 5 +++++ apps/lang/english.lang | 14 ++++++++++++++ apps/menus/settings_menu.c | 3 ++- apps/settings.h | 1 + apps/settings_list.c | 2 ++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/apps/bookmark.c b/apps/bookmark.c index 3d8df3ec0b..b8d41c7464 100644 --- a/apps/bookmark.c +++ b/apps/bookmark.c @@ -166,16 +166,21 @@ bool bookmark_mrb_load() bool bookmark_autobookmark(bool prompt_ok) { char* bookmark; + bool update = false; if (!system_check()) return false; audio_pause(); /* first pause playback */ + if (global_settings.autoupdatebookmark && bookmark_exist()) + update = true; bookmark = create_bookmark(); /* Workaround for inability to speak when paused: all callers will just do audio_stop() when we return, so we can do it right away. This makes it possible to speak the "Create a Bookmark?" prompt and the "Bookmark Created" splash. */ audio_stop(); + if (update) + return write_bookmark(true, bookmark); switch (global_settings.autocreatebookmark) { case BOOKMARK_YES: diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 2c09b594b2..653a0be3ed 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -12605,3 +12605,17 @@ touchscreen: "Cancel" + + id: LANG_BOOKMARK_SETTINGS_AUTOUPDATE + desc: prompt for user to decide whether to update bookmarks + user: core + + *: "Update on Stop" + + + *: "Update on Stop" + + + *: "Update on Stop" + + diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c index bcd49c942c..efd18b2204 100644 --- a/apps/menus/settings_menu.c +++ b/apps/menus/settings_menu.c @@ -347,11 +347,12 @@ static int bmark_callback(int action,const struct menu_item_ex *this_item) } MENUITEM_SETTING(autocreatebookmark, &global_settings.autocreatebookmark, bmark_callback); +MENUITEM_SETTING(autoupdatebookmark, &global_settings.autoupdatebookmark, NULL); MENUITEM_SETTING(autoloadbookmark, &global_settings.autoloadbookmark, NULL); MENUITEM_SETTING(usemrb, &global_settings.usemrb, NULL); MAKE_MENU(bookmark_settings_menu, ID2P(LANG_BOOKMARK_SETTINGS), 0, Icon_Bookmark, - &autocreatebookmark, &autoloadbookmark, &usemrb); + &autocreatebookmark, &autoupdatebookmark, &autoloadbookmark, &usemrb); /* BOOKMARK MENU */ /***********************************/ diff --git a/apps/settings.h b/apps/settings.h index a324ef2dd7..d9aec8fc92 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -604,6 +604,7 @@ struct user_settings /* auto bookmark settings */ int autoloadbookmark; /* auto load option: 0=off, 1=ask, 2=on */ int autocreatebookmark; /* auto create option: 0=off, 1=ask, 2=on */ + bool autoupdatebookmark;/* auto update option */ int usemrb; /* use MRB list: 0=No, 1=Yes*/ #ifdef HAVE_DIRCACHE diff --git a/apps/settings_list.c b/apps/settings_list.c index 9412ee4dd5..09eee6bb57 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -989,6 +989,8 @@ const struct settings_list settings[] = { ID2P(LANG_SET_BOOL_NO), ID2P(LANG_SET_BOOL_YES), ID2P(LANG_ASK), ID2P(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_YES), ID2P(LANG_BOOKMARK_SETTINGS_RECENT_ONLY_ASK)), + OFFON_SETTING(0, autoupdatebookmark, LANG_BOOKMARK_SETTINGS_AUTOUPDATE, + false, "autoupdate bookmarks", NULL), CHOICE_SETTING(0, autoloadbookmark, LANG_BOOKMARK_SETTINGS_AUTOLOAD, BOOKMARK_NO, "autoload bookmarks", off_on_ask, NULL, 3, ID2P(LANG_SET_BOOL_NO), ID2P(LANG_SET_BOOL_YES),