[banshee] [Audiobook] Improved Resume functionality
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Audiobook] Improved Resume functionality
- Date: Tue, 18 May 2010 23:07:55 +0000 (UTC)
commit 47bb27d6961db0c17af2dbf1913bd9781fd7851c
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue May 18 16:06:49 2010 -0700
[Audiobook] Improved Resume functionality
.../Banshee.Audiobook/Banshee.Audiobook/Actions.cs | 6 ++--
.../Banshee.Audiobook/AudiobookLibrarySource.cs | 17 +++++++---
.../Banshee.Audiobook/BookPlaylist.cs | 4 ++-
.../Banshee.Audiobook/BookView.cs | 34 ++++++++++++++++---
.../Banshee.Audiobook/Resources/ActiveSourceUI.xml | 1 -
5 files changed, 46 insertions(+), 16 deletions(-)
---
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
index 22f5e0c..57641e9 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
@@ -61,7 +61,7 @@ namespace Banshee.Audiobook
Catalog.GetString ("Resume"), null, Catalog.GetString ("Resume playback of this audiobook"), OnResume)
);
- AddImportant (new ActionEntry ("AudiobookResume", Stock.MediaPlay,
+ Add (new ActionEntry ("AudiobookResume", Stock.MediaPlay,
Catalog.GetString ("Resume"), null, Catalog.GetString ("Resume playback of this audiobook"), OnResume));
AddUiFromFile ("GlobalUI.xml");
@@ -94,7 +94,7 @@ namespace Banshee.Audiobook
}
}
}
- UpdateAction ("AudiobookResume", library.CurrentViewBook != null && can_resume, true);
+ UpdateAction ("AudiobookResume", library.CurrentViewBook != null, can_resume);
UpdateAction ("AudiobookResumeSelected", can_resume, true);
}
@@ -103,7 +103,7 @@ namespace Banshee.Audiobook
var book = library.ActiveBook;
var bookmark = library.GetLastPlayedBookmark (book.DbId);
if (bookmark != null) {
- Log.DebugFormat ("Audiobook Library jumpting to last-played position in active book: {0}", bookmark.Name);
+ Log.DebugFormat ("Audiobook Library jumping to last-played position in active book: {0}", bookmark.Name);
library.PlaybackSource.Book = book;
ServiceManager.PlaybackController.Source = library;
bookmark.JumpTo ();
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
index 8ee7958..8150604 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
@@ -95,9 +95,10 @@ namespace Banshee.Audiobook
pattern.FileSchema = CreateSchema<string> ("file_pattern", pattern.DefaultFile, "", "");
SetFileNamePattern (pattern);
+ Actions = new Actions (this);
+
grid_view = new LazyLoadSourceContents<AudiobookContent> ();
book_view = new LazyLoadSourceContents<BookView> ();
-
Properties.Set<ISourceContents> ("Nereid.SourceContents", grid_view);
Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
@@ -114,8 +115,6 @@ namespace Banshee.Audiobook
title_switcher.PackStart (book_label);
Properties.Set<Gtk.Widget> ("Nereid.SourceContents.TitleWidget", title_switcher);
- Actions = new Actions (this);
-
TracksAdded += (o, a) => {
if (!IsAdding) {
MergeBooksAddedSince (DateTime.Now - TimeSpan.FromHours (2));
@@ -143,6 +142,8 @@ namespace Banshee.Audiobook
{
if (ServiceManager.PlaybackController.Source == this) {
PlaybackSource.Book = PlaybackSource.Book ?? ActiveBook;
+ } else {
+ PlaybackSource.Book = null;
}
Actions.UpdateActions ();
@@ -262,7 +263,7 @@ namespace Banshee.Audiobook
private void StartTimeout ()
{
if (timeout_id == 0) {
- timeout_id = Application.RunTimeout (5000, delegate { UpdateLastPlayed (); return true; });
+ timeout_id = Application.RunTimeout (3000, delegate { UpdateLastPlayed (); return true; });
}
}
@@ -277,7 +278,9 @@ namespace Banshee.Audiobook
private Bookmark bookmark;
private void UpdateLastPlayed ()
{
- if (book_track != null) {
+ if (book_track != null && book_track.IsPlaying &&
+ ServiceManager.PlayerEngine.CurrentState == PlayerState.Playing)
+ {
bookmark = GetLastPlayedBookmark (book_track.AlbumId) ?? new Bookmark ();
bookmark.Type = LAST_PLAYED_BOOKMARK;
@@ -285,6 +288,10 @@ namespace Banshee.Audiobook
bookmark.Track = book_track;
bookmark.Position = TimeSpan.FromMilliseconds ((int)ServiceManager.PlayerEngine.Position);
bookmark.Save ();
+
+ if (CurrentViewBook != null && book_track.AlbumId == CurrentViewBook.DbId) {
+ book_view.Contents.UpdateResumeButton (bookmark);
+ }
}
}
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookPlaylist.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookPlaylist.cs
index 836f011..6a861fe 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookPlaylist.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookPlaylist.cs
@@ -48,8 +48,10 @@ namespace Banshee.Audiobook
public DatabaseAlbumInfo Book {
get { return book; }
set {
- if (value == null)
+ if (value == null) {
+ book = null;
return;
+ }
if (book != null && value.DbId == book.DbId) {
Reload ();
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
index f8e8706..244c8f6 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/BookView.cs
@@ -67,6 +67,7 @@ namespace Banshee.Audiobook
Label title_label;
BookCover cover;
+ ImageButton resume_button;
RatingEntry rating_entry;
BaseTrackListView track_list;
@@ -90,6 +91,9 @@ namespace Banshee.Audiobook
GLib.Markup.EscapeText (book.ArtistName)
);
+ var bookmark = library.GetLastPlayedBookmark (book.DbId);
+ UpdateResumeButton (bookmark);
+
UpdateCover ();
/*var bookmarks = Bookmark.Provider.FetchAllMatching (
@@ -102,6 +106,21 @@ namespace Banshee.Audiobook
));
}
+ internal void UpdateResumeButton (Bookmark bookmark)
+ {
+ if (bookmark != null) {
+ resume_button.LabelWidget.Markup = String.Format (
+ "<b>{0}</b>\n<small>{1}</small>",
+ GLib.Markup.EscapeText (Catalog.GetString ("Resume Playback")),
+ GLib.Markup.EscapeText (bookmark.Name)
+ );
+ } else {
+ resume_button.LabelWidget.Markup = String.Format (
+ "<b>{0}</b>\n<small>{1}</small>",
+ GLib.Markup.EscapeText (Catalog.GetString ("No Bookmark Set")), "");
+ }
+ }
+
private void UpdateCover ()
{
cover.LoadImage (
@@ -124,10 +143,13 @@ namespace Banshee.Audiobook
public bool SetSource (ISource source)
{
- library = source as AudiobookLibrarySource;
+ if (library != null)
+ return true;
+ library = source as AudiobookLibrarySource;
if (library != null) {
track_list.SetModel (library.TrackModel);
+ library.Actions["AudiobookResume"].ConnectProxy (resume_button);
}
return library != null;
@@ -168,10 +190,10 @@ namespace Banshee.Audiobook
Yalign = 0
};
- var continue_button = new ImageButton ("<b>Continue Playback</b>\n<small>Disc 3 - Track 3b (2:53)</small>", null, IconSize.Button);
- continue_button.ImageWidget.Stock = Stock.MediaPlay;
- continue_button.LabelWidget.Xalign = 0;
- continue_button.Spacing = 6;
+ resume_button = new ImageButton ("", null, IconSize.LargeToolbar);
+ resume_button.ImageWidget.Stock = Stock.MediaPlay;
+ resume_button.LabelWidget.Xalign = 0;
+ resume_button.Spacing = 6;
// FIXME the left padding on this is not right
rating_entry = new RatingEntry () {
@@ -184,7 +206,7 @@ namespace Banshee.Audiobook
// Packing
left_box.PackStart (editable_cover, false, false, 0);
left_box.PackStart (title_label, false, false, 0);
- //left_box.PackStart (continue_button, false, false, 0);
+ left_box.PackStart (resume_button, false, false, 0);
//left_box.PackStart (rating, false, false, 0);
hbox.PackStart (left_box, false, false, 0);
diff --git a/src/Extensions/Banshee.Audiobook/Resources/ActiveSourceUI.xml b/src/Extensions/Banshee.Audiobook/Resources/ActiveSourceUI.xml
index 1314a8c..0d11bd7 100644
--- a/src/Extensions/Banshee.Audiobook/Resources/ActiveSourceUI.xml
+++ b/src/Extensions/Banshee.Audiobook/Resources/ActiveSourceUI.xml
@@ -1,7 +1,6 @@
<ui>
<toolbar name="HeaderToolbar">
<placeholder name="SourceActions">
- <toolitem action="AudiobookResume"/>
</placeholder>
</toolbar>
<menubar name="MainMenu">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]