[banshee] [Podcasting] Fix action sensitivity/visibility
- From: Gabriel Burt <gburt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [Podcasting] Fix action sensitivity/visibility
- Date: Tue, 26 Oct 2010 23:30:51 +0000 (UTC)
commit 8099a4b21826405c6c76500fd380b28c2c7f316d
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Oct 26 17:49:57 2010 -0500
[Podcasting] Fix action sensitivity/visibility
Use the new selection-aggregate ability to determine which actions (mark
new/archive, download/remove) are relevant. Fixes lazy use of (s) for
pluralization, too (bgo#545998).
.../PodcastTrackListModel.cs | 11 ++++++++
.../Banshee.Podcasting.Gui/PodcastActions.cs | 26 +++++++++++++++----
.../Resources/ActiveSourceUI.xml | 14 ++++++----
3 files changed, 39 insertions(+), 12 deletions(-)
---
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
index 73ee484..ba57431 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Data/PodcastTrackListModel.cs
@@ -65,8 +65,19 @@ namespace Banshee.Podcasting.Gui
"CoreTracks.PrimarySourceID = {3} AND {0}.FeedID = {1}.FeedID AND CoreTracks.ExternalID = {1}.ItemID AND {1}.ItemID = {2}.ItemID",
Feed.Provider.TableName, FeedItem.Provider.TableName, FeedEnclosure.Provider.TableName, podcast_library_dbid
));
+
+ SelectAggregates += ",COUNT(NULLIF(CoreTracks.Uri LIKE 'file:%', 0)), COUNT(NULLIF(CoreTracks.PlayCount = 0, 0)), COUNT(DISTINCT(CoreTracks.AlbumID))";
+ SelectionAggregatesHandler = (reader) => {
+ SelectionDownloadedCount = Convert.ToInt32 (reader[3]);
+ SelectionUnheardCount = Convert.ToInt32 (reader[4]);
+ SelectionPodcastCount = Convert.ToInt32 (reader[5]);
+ };
}
+ public int SelectionDownloadedCount { get; private set; }
+ public int SelectionUnheardCount { get; private set; }
+ public int SelectionPodcastCount { get; private set; }
+
protected override void GenerateSortQueryPart ()
{
SortQuery = (SortColumn == null)
diff --git a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
index ab116aa..1b24771 100644
--- a/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
+++ b/src/Extensions/Banshee.Podcasting/Banshee.Podcasting.Gui/PodcastActions.cs
@@ -132,7 +132,7 @@ namespace Banshee.Podcasting.Gui
new ActionEntry (
"PodcastItemDownloadAction", Stock.Save,
/* Translators: this is a verb used as a button name, not a noun*/
- Catalog.GetString ("Download Podcast(s)"),
+ Catalog.GetString ("Download"),
"<control><shift>D", String.Empty,
OnPodcastItemDownload
),
@@ -144,7 +144,7 @@ namespace Banshee.Podcasting.Gui
),
new ActionEntry (
"PodcastItemDeleteFileAction", Stock.Remove,
- Catalog.GetString ("Remove Downloaded File(s)"),
+ "",
null, String.Empty,
OnPodcastItemDeleteFile
),
@@ -248,10 +248,24 @@ namespace Banshee.Podcasting.Gui
private void UpdateItemActions ()
{
if (IsPodcastSource) {
- bool has_single_selection = ActiveDbSource.TrackModel.Selection.Count == 1;
- UpdateActions (true, has_single_selection,
- "PodcastItemLinkAction"
- );
+ int count = ActiveDbSource.TrackModel.Selection.Count;
+
+ //bool has_single_podcast = podcast_source.PodcastTrackModel.SelectionPodcastCount == 1;
+
+ UpdateAction ("PodcastItemLinkAction", true, count == 1);
+
+ int downloaded = podcast_source.PodcastTrackModel.SelectionDownloadedCount;
+ UpdateAction ("PodcastItemDownloadAction", downloaded != count, true);
+ UpdateAction ("PodcastItemDeleteFileAction", downloaded > 0, true);
+ // Translators: {0} is available for your use, containing the number of files to delete
+ this["PodcastItemDeleteFileAction"].Label = String.Format (Catalog.GetPluralString (
+ "Delete File", "Delete Files", downloaded), downloaded);
+
+ int unheard = podcast_source.PodcastTrackModel.SelectionUnheardCount;
+ UpdateAction ("PodcastItemMarkNewAction", unheard != count, true);
+ UpdateAction ("PodcastItemMarkOldAction", unheard > 0, true);
+
+ Actions["Track.SearchMenuAction"].Visible = false;
}
}
diff --git a/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml b/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml
index c9ad56d..8037c88 100644
--- a/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml
+++ b/src/Extensions/Banshee.Podcasting/Resources/ActiveSourceUI.xml
@@ -29,8 +29,16 @@
</menubar>
<popup name="TrackContextMenu" action="TrackContextMenuAction">
+ <placeholder name="AboveAddToPlaylist">
+ </placeholder>
<placeholder name="BelowAddToPlaylist">
<separator />
+ <menuitem name="PodcastItemMarkOld" action="PodcastItemMarkOldAction" />
+ <menuitem name="PodcastItemMarkNew" action="PodcastItemMarkNewAction" />
+ <menuitem name="PodcastItemDownload" action="PodcastItemDownloadAction" />
+ <menuitem name="PodcastItemDeleteFile" action="PodcastItemDeleteFileAction" />
+ <separator />
+ <menuitem name="PodcastItemLink" action="PodcastItemLinkAction" />
<menu action="EpisodePodcastMenu">
<menuitem name="PodcastUpdateFeed" action="PodcastUpdateFeedAction" />
<menuitem name="PodcastDownloadAll" action="PodcastDownloadAllAction"/>
@@ -39,14 +47,8 @@
<separator />
<menuitem name="PodcastProperties" action="PodcastPropertiesAction" />
</menu>
- <menuitem name="PodcastItemLink" action="PodcastItemLinkAction" />
- <menuitem name="PodcastItemDownload" action="PodcastItemDownloadAction" />
- <menuitem name="PodcastItemDeleteFile" action="PodcastItemDeleteFileAction" />
<!--
<menuitem name="PodcastItemCancel" action="PodcastItemCancelAction" />-->
- <separator />
- <menuitem name="PodcastItemMarkNew" action="PodcastItemMarkNewAction" />
- <menuitem name="PodcastItemMarkOld" action="PodcastItemMarkOldAction" />
</placeholder>
</popup>
</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]