[banshee] [Audiobook] Add a context menu



commit 08d4ef4473a441305b6a05a198320b0ec773840d
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Sun Dec 20 15:43:37 2009 -0800

    [Audiobook] Add a context menu

 .../Banshee.Audiobook/Banshee.Audiobook/Actions.cs |   62 ++++++++++++++++++++
 .../Banshee.Audiobook/AudiobookContent.cs          |    2 +-
 .../Banshee.Audiobook/AudiobookGrid.cs             |    9 +++-
 .../Banshee.Audiobook/AudiobookLibrarySource.cs    |   18 ++++++
 src/Extensions/Banshee.Audiobook/Makefile.am       |    6 ++-
 .../Banshee.Audiobook/Resources/ActiveSourceUI.xml |    6 ++
 .../Banshee.Audiobook/Resources/GlobalUI.xml       |    6 ++
 7 files changed, 106 insertions(+), 3 deletions(-)
---
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
new file mode 100644
index 0000000..6b833de
--- /dev/null
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/Actions.cs
@@ -0,0 +1,62 @@
+//
+// Actions.cs
+//
+// Authors:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2009 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using Mono.Unix;
+using Gtk;
+
+namespace Banshee.Audiobook
+{
+    public class Actions : Banshee.Gui.BansheeActionGroup
+    {
+        public Actions () : base ("Audiobook")
+        {
+            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!");
+                })
+            );
+
+            /*AddImportant (
+                new ActionEntry ("VisitInternetArchive", Stock.JumpTo, Catalog.GetString ("Visit Archive.org"), null, null, (o, a) => {
+                    Banshee.Web.Browser.Open ("http://archive.org";);
+                })
+            );*/
+
+            AddUiFromFile ("GlobalUI.xml");
+
+            Register ();
+        }
+    }
+}
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookContent.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookContent.cs
index 756cd6c..495f8b7 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookContent.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookContent.cs
@@ -69,7 +69,7 @@ namespace Banshee.Audiobook
                 return false;
             }
 
-            grid.SetModel (library.BooksModel);
+            grid.SetLibrary (library);
 
             // Not sure why this is needed
             library.BooksModel.Reloaded += delegate {
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookGrid.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookGrid.cs
index b52dacd..6f60243 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookGrid.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookGrid.cs
@@ -52,6 +52,7 @@ namespace Banshee.Audiobook
     public class AudiobookGrid : SearchableListView<AlbumInfo>
     {
         private ColumnCellAlbum renderer;
+        private AudiobookLibrarySource library;
 
         public AudiobookGrid ()
         {
@@ -67,6 +68,12 @@ namespace Banshee.Audiobook
             //RowActivated += OnRowActivated;
         }
 
+        public void SetLibrary (AudiobookLibrarySource library)
+        {
+            SetModel (library.BooksModel);
+            this.library = library;
+        }
+
         public override bool SelectOnRowFound {
             get { return true; }
         }
@@ -78,7 +85,7 @@ namespace Banshee.Audiobook
 
         protected override bool OnPopupMenu ()
         {
-            //ServiceManager.Get<InterfaceActionService> ().TrackActions["TrackContextMenuAction"].Activate ();
+            library.Actions["AudiobookBookPopup"].Activate ();
             return true;
         }
     }
diff --git a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
index 9714df9..36f48f8 100644
--- a/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
+++ b/src/Extensions/Banshee.Audiobook/Banshee.Audiobook/AudiobookLibrarySource.cs
@@ -49,6 +49,9 @@ namespace Banshee.Audiobook
     {
         private AudiobookModel books_model;
 
+        private Actions actions;
+        public Actions Actions { get { return actions; } }
+
         public AudiobookLibrarySource () : base (Catalog.GetString ("Audiobooks, etc"), "AudiobookLibrary", 49)
         {
             MediaTypes = TrackMediaAttributes.AudioBook;
@@ -80,6 +83,21 @@ namespace Banshee.Audiobook
             SetFileNamePattern (pattern);
 
             Properties.Set<ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents<AudiobookContent> ());
+            //Properties.SetString ("GtkActionPath", "/LastfmStationSourcePopup");
+            Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
+            Properties.Set<bool> ("ActiveSourceUIResourcePropagate", true);
+
+            actions = new Actions ();
+        }
+
+        public override void Dispose ()
+        {
+            if (actions != null) {
+                actions.Dispose ();
+                actions = null;
+            }
+
+            base.Dispose ();
         }
 
         protected override IEnumerable<IFilterListModel> CreateFiltersFor (DatabaseSource src)
diff --git a/src/Extensions/Banshee.Audiobook/Makefile.am b/src/Extensions/Banshee.Audiobook/Makefile.am
index 272ac22..1aa6711 100644
--- a/src/Extensions/Banshee.Audiobook/Makefile.am
+++ b/src/Extensions/Banshee.Audiobook/Makefile.am
@@ -4,12 +4,16 @@ LINK = $(REF_EXTENSION_AUDIOBOOK)
 INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
 
 SOURCES =  \
+	Banshee.Audiobook/Actions.cs \
 	Banshee.Audiobook/AudiobookFileNamePattern.cs \
 	Banshee.Audiobook/AudiobookLibrarySource.cs \
 	Banshee.Audiobook/AudiobookContent.cs \
 	Banshee.Audiobook/AudiobookGrid.cs \
 	Banshee.Audiobook/AudiobookModel.cs
 
-RESOURCES = Banshee.Audiobook.addin.xml
+RESOURCES =  \
+	Banshee.Audiobook.addin.xml \
+	Resources/GlobalUI.xml \
+	Resources/ActiveSourceUI.xml
 
 include $(top_srcdir)/build/build.mk
diff --git a/src/Extensions/Banshee.Audiobook/Resources/ActiveSourceUI.xml b/src/Extensions/Banshee.Audiobook/Resources/ActiveSourceUI.xml
new file mode 100644
index 0000000..43ed389
--- /dev/null
+++ b/src/Extensions/Banshee.Audiobook/Resources/ActiveSourceUI.xml
@@ -0,0 +1,6 @@
+<ui>
+    <toolbar name="HeaderToolbar">
+        <placeholder name="SourceActions">
+        </placeholder>
+    </toolbar>
+</ui>
diff --git a/src/Extensions/Banshee.Audiobook/Resources/GlobalUI.xml b/src/Extensions/Banshee.Audiobook/Resources/GlobalUI.xml
new file mode 100644
index 0000000..eddb50b
--- /dev/null
+++ b/src/Extensions/Banshee.Audiobook/Resources/GlobalUI.xml
@@ -0,0 +1,6 @@
+<ui>
+    <popup name="AudiobookBookPopup">
+        <menuitem action="AudiobookOpen"/>
+        <separator/>
+    </popup>
+</ui>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]