banshee r4537 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.PlayQueue src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4537 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui src/Extensions/Banshee.PlayQueue src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue
- Date: Fri, 12 Sep 2008 20:00:58 +0000 (UTC)
Author: gburt
Date: Fri Sep 12 20:00:58 2008
New Revision: 4537
URL: http://svn.gnome.org/viewvc/banshee?rev=4537&view=rev
Log:
2008-09-12 Gabriel Burt <gabriel burt gmail com>
* src/Extensions/Banshee.PlayQueue/Makefile.am:
* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj:
* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs:
Separate out the PlayQueue actions into their own subclass of
BansheeActionGroup, so they are disposed of properly when the plugin is,
etc (BGO #552005). Also, don't show Add to Play Queue action when in the
play queue iteslf (BGO #551672).
* src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs: Check
whether the action group is already registered before [un]registering.
Added:
trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui/BansheeActionGroup.cs Fri Sep 12 20:00:58 2008
@@ -68,12 +68,16 @@
public void Register ()
{
- Actions.AddActionGroup (this);
+ if (Actions.FindActionGroup (this.Name) == null) {
+ Actions.AddActionGroup (this);
+ }
}
public void UnRegister ()
{
- Actions.RemoveActionGroup (this);
+ if (Actions.FindActionGroup (this.Name) != null) {
+ Actions.RemoveActionGroup (this);
+ }
}
public override void Dispose ()
Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj (original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue.csproj Fri Sep 12 20:00:58 2008
@@ -39,6 +39,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Banshee.PlayQueue\PlayQueueSource.cs" />
+ <Compile Include="Banshee.PlayQueue\PlayQueueActions.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\ActiveSourceUI.xml">
Added: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueActions.cs Fri Sep 12 20:00:58 2008
@@ -0,0 +1,125 @@
+//
+// PlayQueueActions.cs
+//
+// Authors:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 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 Mono.Unix;
+
+using Gtk;
+
+using Banshee.ServiceStack;
+using Banshee.Sources;
+
+namespace Banshee.PlayQueue
+{
+ public class PlayQueueActions : Banshee.Gui.BansheeActionGroup
+ {
+ private PlayQueueSource playqueue;
+ public PlayQueueActions (PlayQueueSource playqueue) : base ("playqueue")
+ {
+ this.playqueue = playqueue;
+
+ Add (new ActionEntry [] {
+ new ActionEntry ("AddToPlayQueueAction", Stock.Add,
+ Catalog.GetString ("Add to Play Queue"), "q",
+ Catalog.GetString ("Append selected songs to the play queue"),
+ OnAddToPlayQueue)
+ });
+
+ AddImportant (
+ new ActionEntry ("ClearPlayQueueAction", Stock.Clear,
+ Catalog.GetString ("Clear"), null,
+ Catalog.GetString ("Remove all tracks from the play queue"),
+ OnClearPlayQueue)
+ );
+
+ Add (new ToggleActionEntry [] {
+ new ToggleActionEntry ("ClearPlayQueueOnQuitAction", null,
+ Catalog.GetString ("Clear on Quit"), null,
+ Catalog.GetString ("Clear the play queue when quitting"),
+ OnClearPlayQueueOnQuit, PlayQueueSource.ClearOnQuitSchema.Get ())
+ });
+
+ AddUiFromFile ("GlobalUI.xml");
+
+ playqueue.Updated += OnUpdated;
+ ServiceManager.SourceManager.ActiveSourceChanged += OnSourceUpdated;
+
+ OnUpdated (null, null);
+
+ Register ();
+ }
+
+ public override void Dispose ()
+ {
+ playqueue.Updated -= OnUpdated;
+ ServiceManager.SourceManager.ActiveSourceChanged -= OnSourceUpdated;
+ base.Dispose ();
+ }
+
+ #region Action Handlers
+
+ private void OnAddToPlayQueue (object o, EventArgs args)
+ {
+ playqueue.AddSelectedTracks (ServiceManager.SourceManager.ActiveSource);
+ }
+
+ private void OnClearPlayQueue (object o, EventArgs args)
+ {
+ playqueue.Clear ();
+ }
+
+ private void OnClearPlayQueueOnQuit (object o, EventArgs args)
+ {
+ ToggleAction action = this["ClearPlayQueueOnQuitAction"] as Gtk.ToggleAction;
+ PlayQueueSource.ClearOnQuitSchema.Set (action.Active);
+ }
+
+ #endregion
+
+ private void OnSourceUpdated (SourceEventArgs args)
+ {
+ OnUpdated (null, null);
+ }
+
+ private void OnUpdated (object o, EventArgs args)
+ {
+ Banshee.Base.ThreadAssist.ProxyToMain (UpdateActions);
+ }
+
+ private void UpdateActions ()
+ {
+ Source source = ServiceManager.SourceManager.ActiveSource;
+ if (source != null) {
+ DatabaseSource db_source = source as DatabaseSource ?? source.Parent as DatabaseSource;
+ UpdateAction ("ClearPlayQueueAction", true, playqueue.Count > 0);
+ UpdateAction ("AddToPlayQueueAction", db_source != null && db_source != playqueue, true);
+ }
+ }
+ }
+}
Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs Fri Sep 12 20:00:58 2008
@@ -29,7 +29,6 @@
using System;
using Mono.Unix;
-using Gtk;
using Hyena.Data.Sqlite;
@@ -53,8 +52,8 @@
private ITrackModelSource prior_playback_source;
private DatabaseTrackInfo playing_track;
- private bool actions_loaded = false;
-
+ private PlayQueueActions actions;
+
protected override bool HasArtistAlbum {
get { return false; }
}
@@ -70,7 +69,7 @@
Properties.SetString ("Icon.Name", "source-playlist");
Properties.SetString ("RemoveTracksActionLabel", Catalog.GetString ("Remove From Play Queue"));
- ((DatabaseTrackListModel)TrackModel).ForcedSortQuery = "CorePlaylistEntries.ViewOrder ASC, CorePlaylistEntries.EntryID ASC";
+ DatabaseTrackModel.ForcedSortQuery = "CorePlaylistEntries.ViewOrder ASC, CorePlaylistEntries.EntryID ASC";
ServiceManager.PlayerEngine.ConnectEvent (OnPlayerEvent);
ServiceManager.PlaybackController.Transition += OnCanonicalPlaybackControllerTransition;
@@ -79,37 +78,10 @@
// TODO change this Gtk.Action code so that the actions can be removed. And so this
// class doesn't depend on Gtk/ThickClient.
- InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();
- uia_service.TrackActions.Add (new ActionEntry [] {
- new ActionEntry ("AddToPlayQueueAction", Stock.Add,
- Catalog.GetString ("Add to Play Queue"), "q",
- Catalog.GetString ("Append selected songs to the play queue"),
- OnAddToPlayQueue)
- });
-
- uia_service.GlobalActions.AddImportant (
- new ActionEntry ("ClearPlayQueueAction", Stock.Clear,
- Catalog.GetString ("Clear"), null,
- Catalog.GetString ("Remove all tracks from the play queue"),
- OnClearPlayQueue)
- );
-
- uia_service.GlobalActions.Add (new ToggleActionEntry [] {
- new ToggleActionEntry ("ClearPlayQueueOnQuitAction", null,
- Catalog.GetString ("Clear on Quit"), null,
- Catalog.GetString ("Clear the play queue when quitting"),
- OnClearPlayQueueOnQuit, ClearOnQuitSchema.Get ())
- });
-
- uia_service.UIManager.AddUiFromResource ("GlobalUI.xml");
+ actions = new PlayQueueActions (this);
Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
Properties.SetString ("GtkActionPath", "/PlayQueueContextMenu");
-
- actions_loaded = true;
-
- UpdateActions ();
- ServiceManager.SourceManager.ActiveSourceChanged += delegate { Banshee.Base.ThreadAssist.ProxyToMain (UpdateActions); };
// TODO listen to all primary sources, and handle transient primary sources
ServiceManager.SourceManager.MusicLibrary.TracksChanged += HandleTracksChanged;
@@ -126,7 +98,6 @@
};
Reload ();
-
SetAsPlaybackSourceUnlessPlaying ();
}
@@ -138,12 +109,23 @@
}
}
+ public void Clear ()
+ {
+ playing_track = null;
+ RemoveTrackRange (DatabaseTrackModel, new Hyena.Collections.RangeCollection.Range (0, Count));
+ Reload ();
+ }
+
public void Dispose ()
{
ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
+ if (actions != null) {
+ actions.Dispose ();
+ }
+
if (ClearOnQuitSchema.Get ()) {
- OnClearPlayQueue (this, EventArgs.Empty);
+ Clear ();
}
}
@@ -169,15 +151,6 @@
SetAsPlaybackSourceUnlessPlaying ();
}
- protected override void OnUpdated ()
- {
- if (actions_loaded) {
- UpdateActions ();
- }
-
- base.OnUpdated ();
- }
-
private void OnCanonicalPlaybackControllerTransition (object o, EventArgs args)
{
if (Count > 0) {
@@ -198,44 +171,7 @@
}
}
}
-
- private void OnAddToPlayQueue (object o, EventArgs args)
- {
- AddSelectedTracks (ServiceManager.SourceManager.ActiveSource);
- }
-
- private void OnClearPlayQueue (object o, EventArgs args)
- {
- playing_track = null;
- RemoveTrackRange ((DatabaseTrackListModel)TrackModel, new Hyena.Collections.RangeCollection.Range (0, Count));
- Reload ();
- }
-
- private void OnClearPlayQueueOnQuit (object o, EventArgs args)
- {
- InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();
- if (uia_service == null) {
- return;
- }
-
- ToggleAction action = (ToggleAction)uia_service.GlobalActions["ClearPlayQueueOnQuitAction"];
- ClearOnQuitSchema.Set (action.Active);
- }
-
- private void UpdateActions ()
- {
- InterfaceActionService uia_service = ServiceManager.Get<InterfaceActionService> ();
- if (uia_service == null) {
- return;
- }
-
- Source source = ServiceManager.SourceManager.ActiveSource;
- bool in_db = (source != null && source.Parent is DatabaseSource) || source is DatabaseSource;
-
- uia_service.GlobalActions.UpdateAction ("ClearPlayQueueAction", true, Count > 0);
- uia_service.TrackActions.UpdateAction ("AddToPlayQueueAction", in_db, true);
- }
-
+
void IBasicPlaybackController.First ()
{
((IBasicPlaybackController)this).Next (false);
Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am (original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Makefile.am Fri Sep 12 20:00:58 2008
@@ -3,7 +3,9 @@
LINK = $(REF_EXTENSION_PLAYQUEUE)
INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
-SOURCES = Banshee.PlayQueue/PlayQueueSource.cs
+SOURCES = \
+ Banshee.PlayQueue/PlayQueueActions.cs \
+ Banshee.PlayQueue/PlayQueueSource.cs
RESOURCES = \
Banshee.PlayQueue.addin.xml \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]