[banshee] [Banshee.Gui] Clean up TrackActions.UpdateActions
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Banshee.Gui] Clean up TrackActions.UpdateActions
- Date: Wed, 19 May 2010 00:17:43 +0000 (UTC)
commit 1f6f518f9a3cfccb23b500f9acb81fb7459be008
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue May 18 17:16:55 2010 -0700
[Banshee.Gui] Clean up TrackActions.UpdateActions
.../Banshee.Gui/TrackActions.cs | 59 ++++++++++----------
1 files changed, 29 insertions(+), 30 deletions(-)
---
diff --git a/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs b/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
index 1d0d779..f4a2884 100644
--- a/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
+++ b/src/Core/Banshee.ThickClient/Banshee.Gui/TrackActions.cs
@@ -207,50 +207,49 @@ namespace Banshee.Gui
private void UpdateActions ()
{
Source source = ServiceManager.SourceManager.ActiveSource;
+ if (source == null) {
+ Sensitive = Visible = false;
+ return;
+ }
+
bool in_database = source is DatabaseSource;
PrimarySource primary_source = (source as PrimarySource) ?? (source.Parent as PrimarySource);
- Hyena.Collections.Selection selection = (source is ITrackModelSource) ? (source as ITrackModelSource).TrackModel.Selection : null;
-
- if (selection != null) {
+ var track_source = source as ITrackModelSource;
+ if (track_source != null) {
+ var selection = track_source.TrackModel.Selection;
Sensitive = Visible = true;
bool has_selection = selection.Count > 0;
+ bool has_single_selection = selection.Count == 1;
+
foreach (string action in require_selection_actions) {
this[action].Sensitive = has_selection;
}
- bool has_single_selection = selection.Count == 1;
-
- this["SelectAllAction"].Sensitive = !selection.AllSelected;
-
- if (source != null) {
- ITrackModelSource track_source = source as ITrackModelSource;
- bool is_track_source = track_source != null;
-
- UpdateActions (is_track_source && source.CanSearch, has_single_selection,
- "SearchMenuAction", "SearchForSameArtistAction", "SearchForSameAlbumAction"
- );
+ UpdateActions (source.CanSearch, has_single_selection,
+ "SearchMenuAction", "SearchForSameArtistAction", "SearchForSameAlbumAction"
+ );
- UpdateAction ("RemoveTracksAction", is_track_source && track_source.CanRemoveTracks, has_selection, source);
- UpdateAction ("DeleteTracksFromDriveAction", is_track_source && track_source.CanDeleteTracks, has_selection, source);
+ this["SelectAllAction"].Sensitive = track_source.Count > 0 && !selection.AllSelected;
+ UpdateAction ("RemoveTracksAction", track_source.CanRemoveTracks, has_selection, source);
+ UpdateAction ("DeleteTracksFromDriveAction", track_source.CanDeleteTracks, has_selection, source);
- //if it can delete tracks, most likely it can open their folder
- UpdateAction ("OpenContainingFolderAction", is_track_source && track_source.CanDeleteTracks, has_single_selection, source);
+ //if it can delete tracks, most likely it can open their folder
+ UpdateAction ("OpenContainingFolderAction", track_source.CanDeleteTracks, has_single_selection, source);
- UpdateAction ("RemoveTracksFromLibraryAction", source.Parent is LibrarySource, has_selection, null);
+ UpdateAction ("RemoveTracksFromLibraryAction", source.Parent is LibrarySource, has_selection, null);
- UpdateAction ("TrackPropertiesAction", source.HasViewableTrackProperties, has_selection, source);
- UpdateAction ("TrackEditorAction", source.HasEditableTrackProperties, has_selection, source);
- UpdateAction ("RateTracksAction", in_database, has_selection, null);
- UpdateAction ("AddToPlaylistAction", in_database && primary_source != null &&
- primary_source.SupportsPlaylists && !primary_source.PlaylistsReadOnly, has_selection, null);
+ UpdateAction ("TrackPropertiesAction", source.HasViewableTrackProperties, has_selection, source);
+ UpdateAction ("TrackEditorAction", source.HasEditableTrackProperties, has_selection, source);
+ UpdateAction ("RateTracksAction", in_database, has_selection, null);
+ UpdateAction ("AddToPlaylistAction", in_database && primary_source != null &&
+ primary_source.SupportsPlaylists && !primary_source.PlaylistsReadOnly, has_selection, null);
- if (primary_source != null &&
- !(primary_source is LibrarySource) &&
- primary_source.StorageName != null) {
- this["DeleteTracksFromDriveAction"].Label = String.Format (
- Catalog.GetString ("_Delete From \"{0}\""), primary_source.StorageName);
- }
+ if (primary_source != null &&
+ !(primary_source is LibrarySource) &&
+ primary_source.StorageName != null) {
+ this["DeleteTracksFromDriveAction"].Label = String.Format (
+ Catalog.GetString ("_Delete From \"{0}\""), primary_source.StorageName);
}
} else {
Sensitive = Visible = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]