[banshee] [Audiobook] Add Edit Track Info action
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Audiobook] Add Edit Track Info action
- Date: Fri, 14 May 2010 22:42:01 +0000 (UTC)
commit e08b28d97574ee483049a803cdf56738f5414ef4
Author: Gabriel Burt <gabriel burt gmail com>
Date: Thu May 13 10:51:11 2010 -0700
[Audiobook] Add Edit Track Info action
.../Banshee.Audiobook/Banshee.Audiobook/Actions.cs | 55 +++++++++++++++++---
.../Banshee.Audiobook/AudiobookLibrarySource.cs | 33 ++++++++++--
.../Banshee.Audiobook/Resources/GlobalUI.xml | 1 +
3 files changed, 75 insertions(+), 14 deletions(-)
---
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
index 9a9e47c..dd6a67c 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
@@ -33,19 +33,25 @@ using System.Linq;
using Mono.Unix;
using Gtk;
+using Hyena;
+
+using Banshee.ServiceStack;
+
namespace Banshee.Audiobook
{
public class Actions : Banshee.Gui.BansheeActionGroup
{
- public Actions () : base ("Audiobook")
+ private AudiobookLibrarySource library;
+
+ public Actions (AudiobookLibrarySource library) : base ("Audiobook")
{
+ this.library = library;
+
Add (
- new ActionEntry ("AudiobookBookPopup", null, null, null, null, (o, a) => {
- ShowContextMenu ("/AudiobookBookPopup");
- }),
- new ActionEntry ("AudiobookOpen", null, Catalog.GetString ("Open Book"), null, null, (o, a) => {
- Console.WriteLine ("open book!");
- })
+ new ActionEntry ("AudiobookBookPopup", null, null, null, null, (o, a) => ShowContextMenu ("/AudiobookBookPopup")),
+ new ActionEntry ("AudiobookOpen", null, Catalog.GetString ("Open Book"), null, null, OnOpen),
+ new ActionEntry ("AudiobookEdit", Stock.Edit,
+ Catalog.GetString ("_Edit Track Information"), "E", null, OnEdit)
);
/*AddImportant (
@@ -57,6 +63,39 @@ namespace Banshee.Audiobook
AddUiFromFile ("GlobalUI.xml");
Register ();
+
+ library.BooksModel.Selection.Changed += HandleSelectionChanged;
+ }
+
+ private void HandleSelectionChanged (object sender, EventArgs args)
+ {
+ ThreadAssist.ProxyToMain (UpdateActions);
+ }
+
+ private void UpdateActions ()
+ {
+ var selection = library.BooksModel.Selection;
+ bool has_selection = selection.Count > 0;
+ //bool has_single_selection = selection.Count == 1;
+
+ //UpdateAction ("AudiobookMerge", !has_single_selection, true);
+ UpdateAction ("AudiobookEdit", true, has_selection);
+ }
+
+ private void OnOpen (object o, EventArgs a)
+ {
+ var index = library.BooksModel.Selection.FocusedIndex;
+ if (index > -1) {
+ var book = library.BooksModel[index];
+ Console.WriteLine ("Asked to open {0}", book);
+ }
+ }
+
+ private void OnEdit (object o, EventArgs a)
+ {
+ //var books = library.BooksModel.SelectedItems;
+ library.TrackModel.Selection.SelectAll ();
+ Actions.TrackActions["TrackEditorAction"].Activate ();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
index 36f48f8..ec42371 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
@@ -49,8 +49,7 @@ namespace Banshee.Audiobook
{
private AudiobookModel books_model;
- private Actions actions;
- public Actions Actions { get { return actions; } }
+ public Actions Actions { get; private set; }
public AudiobookLibrarySource () : base (Catalog.GetString ("Audiobooks, etc"), "AudiobookLibrary", 49)
{
@@ -87,14 +86,36 @@ namespace Banshee.Audiobook
Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
Properties.Set<bool> ("ActiveSourceUIResourcePropagate", true);
- actions = new Actions ();
+ Actions = new Actions (this);
+
+ TracksAdded += (o, a) => {
+ if (!IsAdding) {
+ MergeBooksAddedSince (DateTime.Now - TimeSpan.FromHours (2));
+ }
+ };
+ TrackModel.Reloaded += delegate { Console.WriteLine ("Audiobooks track model reloaded"); };
+ }
+
+ private void MergeBooksAddedSince (DateTime since)
+ {
+ // TODO after import of files or move to audiobook:
+ // If for a given author, there are a set of 'albums' (books)
+ // whose names stripped of numbers are equal, merge them
+ // into one book:
+ // 1) If they already have sequential disc info, good to go
+ // 2) If they do not, need to extract that from album title
+ // -- or just generate it by incrementing a counter, assuming
+ // that as-is they sort lexically
+
+ //foreach (var book in BookModel.FetchMatching ("DateAdded > ? ORDER BY Title", since)) {
+ //}
}
public override void Dispose ()
{
- if (actions != null) {
- actions.Dispose ();
- actions = null;
+ if (Actions != null) {
+ Actions.Dispose ();
+ Actions = null;
}
base.Dispose ();
diff --git a/src/Extensions/Banshee.Audiobook/Resources/GlobalUI.xml b/src/Extensions/Banshee.Audiobook/Resources/GlobalUI.xml
index eddb50b..06f7783 100644
--- a/src/Extensions/Banshee.Audiobook/Resources/GlobalUI.xml
+++ b/src/Extensions/Banshee.Audiobook/Resources/GlobalUI.xml
@@ -1,6 +1,7 @@
<ui>
<popup name="AudiobookBookPopup">
<menuitem action="AudiobookOpen"/>
+ <menuitem action="AudiobookEdit"/>
<separator/>
</popup>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]