[banshee/gio-hardware] [UI] Add Play menu item to tracks' context menu
- From: Alex Launi <alexlauni src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gio-hardware] [UI] Add Play menu item to tracks' context menu
- Date: Fri, 13 Aug 2010 15:27:14 +0000 (UTC)
commit f0ce4d99f0eaa059e09e3740161f5b36132ea243
Author: Gabriel Burt <gabriel burt gmail com>
Date: Thu Aug 12 17:01:50 2010 -0700
[UI] Add Play menu item to tracks' context menu
Fixes bgo#551671, making the first menu item the same as the
activation/double click action.
.../Banshee.Collection.Gui/BaseTrackListView.cs | 9 +------
.../Banshee.Gui/TrackActions.cs | 21 +++++++++++++++++++-
.../Resources/core-ui-actions-layout.xml | 2 +
3 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs
index 120c4f7..b3b041d 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/BaseTrackListView.cs
@@ -59,14 +59,9 @@ namespace Banshee.Collection.Gui
IsEverReorderable = true;
RowActivated += (o, a) => {
- ITrackModelSource source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource;
+ var source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource;
if (source != null && source.TrackModel == Model) {
- if ((a.RowValue.MediaAttributes & TrackMediaAttributes.ExternalResource) != 0) {
- System.Diagnostics.Process.Start (a.RowValue.Uri);
- } else {
- ServiceManager.PlaybackController.Source = source;
- ServiceManager.PlayerEngine.OpenPlay (a.RowValue);
- }
+ ServiceManager.Get<InterfaceActionService> ().TrackActions["PlayTrack"].Activate ();
}
};
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
index 06d385d..0f369d4 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
@@ -55,7 +55,7 @@ namespace Banshee.Gui
private static readonly string [] require_selection_actions = new string [] {
"TrackContextMenuAction", "TrackPropertiesAction", "AddToPlaylistAction",
"RemoveTracksAction", "RemoveTracksFromLibraryAction", "OpenContainingFolderAction",
- "DeleteTracksFromDriveAction", "RateTracksAction", "SelectNoneAction"
+ "DeleteTracksFromDriveAction", "RateTracksAction", "SelectNoneAction", "PlayTrack"
};
public event EventHandler SelectionChanged;
@@ -82,6 +82,10 @@ namespace Banshee.Gui
Catalog.GetString ("Properties"), null,
Catalog.GetString ("View information on selected tracks"), OnTrackProperties),
+ new ActionEntry ("PlayTrack", null,
+ Catalog.GetString ("_Play"), null,
+ Catalog.GetString ("Play the selected item"), OnPlayTrack),
+
new ActionEntry ("AddToPlaylistAction", null,
Catalog.GetString ("Add _to Playlist"), null,
Catalog.GetString ("Append selected items to playlist or create new playlist from selection"),
@@ -130,6 +134,7 @@ namespace Banshee.Gui
ServiceManager.SourceManager.ActiveSourceChanged += HandleActiveSourceChanged;
this["AddToPlaylistAction"].HideIfEmpty = false;
+ this["PlayTrack"].StockId = Gtk.Stock.MediaPlay;
}
#region State Event Handlers
@@ -326,6 +331,20 @@ namespace Banshee.Gui
}
}
+ private void OnPlayTrack (object o, EventArgs args)
+ {
+ var source = ServiceManager.SourceManager.ActiveSource as ITrackModelSource;
+ if (source != null) {
+ var track = source.TrackModel [source.TrackModel.Selection.FocusedIndex];
+ if (track.HasAttribute (TrackMediaAttributes.ExternalResource)) {
+ System.Diagnostics.Process.Start (track.Uri);
+ } else {
+ ServiceManager.PlaybackController.Source = source;
+ ServiceManager.PlayerEngine.OpenPlay (track);
+ }
+ }
+ }
+
// Called when the Add to Playlist action is highlighted.
// Generates the menu of playlists to which you can add the selected tracks.
private void OnAddToPlaylistMenu (object o, EventArgs args)
diff --git a/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml b/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
index 77ce3b9..7376552 100644
--- a/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
+++ b/src/Core/Banshee.ThickClient/Resources/core-ui-actions-layout.xml
@@ -170,6 +170,8 @@
</popup>
<popup name="TrackContextMenu" action="TrackContextMenuAction">
+ <menuitem action="PlayTrack"/>
+ <separator/>
<placeholder name="AboveAddToPlaylist"/>
<menu name="AddToPlaylist" action="AddToPlaylistAction"></menu>
<placeholder name="BelowAddToPlaylist"/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]