[banshee: 39/61] [InternetArchive] UI improvements
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee: 39/61] [InternetArchive] UI improvements
- Date: Tue, 3 Nov 2009 06:31:07 +0000 (UTC)
commit 74155cdd37d8e7afa5c1d7b321823e380fd9372f
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Oct 13 14:51:31 2009 -0700
[InternetArchive] UI improvements
Show a special message when requests timeout, with a Try Again button.
Show more details in the details table. Do a better job filling in
missing information on an item's files. Add the close button to the
Details source toolbar.
.../Banshee.InternetArchive/DetailsSource.cs | 18 ++++-
.../Banshee.InternetArchive/DetailsView.cs | 85 ++++++++++++++------
.../Banshee.InternetArchive/SearchSource.cs | 21 +++--
.../InternetArchive/Details.cs | 12 +++
.../InternetArchive/DetailsFile.cs | 13 +++-
.../InternetArchive/Field.cs | 5 +-
.../Resources/DetailsSourceActiveUI.xml | 1 +
7 files changed, 116 insertions(+), 39 deletions(-)
---
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
index b6d33f6..8e3f290 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
@@ -80,12 +80,17 @@ namespace Banshee.InternetArchive
if (item.Details == null) {
SetStatus (Catalog.GetString ("Getting item details from the Internet Archive"), false, true, null);
- ThreadAssist.SpawnFromMain (ThreadedLoad);
+ Load ();
} else {
gui.UpdateDetails ();
}
}
+ private void Load ()
+ {
+ ThreadAssist.SpawnFromMain (ThreadedLoad);
+ }
+
private void ThreadedLoad ()
{
try {
@@ -97,10 +102,17 @@ namespace Banshee.InternetArchive
}
});
} catch (Exception e) {
+ Hyena.Log.Exception ("Error loading IA item details", e);
+
ThreadAssist.ProxyToMain (delegate {
- SetStatus (Catalog.GetString ("Error getting item details from the Internet Archive"), true);
+ var web_e = e as System.Net.WebException;
+ if (web_e != null && web_e.Status == System.Net.WebExceptionStatus.Timeout) {
+ SetStatus (Catalog.GetString ("Timed out getting item details from the Internet Archive"), true);
+ CurrentMessage.AddAction (new MessageAction (Catalog.GetString ("Try Again"), (o, a) => Load ()));
+ } else {
+ SetStatus (Catalog.GetString ("Error getting item details from the Internet Archive"), true);
+ }
});
- Hyena.Log.Exception ("Error loading IA item details", e);
}
}
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs
index cd99db0..6a7f17d 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsView.cs
@@ -127,7 +127,7 @@ namespace Banshee.InternetArchive
var desc_exp = CreateExpander (Catalog.GetString ("Description"));
var desc = new Hyena.Widgets.WrapLabel () {
- Markup = String.Format ("<small>{0}</small>", GLib.Markup.EscapeText (details.Description))
+ Markup = String.Format ("<small>{0}</small>", GLib.Markup.EscapeText (Hyena.StringUtil.RemoveHtml (details.Description)))
};
desc_exp.Child = desc;
@@ -144,6 +144,7 @@ namespace Banshee.InternetArchive
table.SetSizeRequest (a.Requisition.Width, a.Requisition.Height);
};
+ AddToTable (table, Catalog.GetString ("Creator:"), details.Creator);
AddToTable (table, Catalog.GetString ("Venue:"), details.Venue);
AddToTable (table, Catalog.GetString ("Location:"), details.Coverage);
if (details.DateCreated != DateTime.MinValue) {
@@ -153,6 +154,8 @@ namespace Banshee.InternetArchive
}
AddToTable (table, Catalog.GetString ("Publisher:"), details.Publisher);
AddToTable (table, Catalog.GetString ("Subject:"), details.Subject);
+ AddToTable (table, Catalog.GetString ("License URL:"), details.LicenseUrl);
+ AddToTable (table, Catalog.GetString ("Language:"), details.Language);
table.AddSeparator ();
@@ -165,6 +168,7 @@ namespace Banshee.InternetArchive
AddToTable (table, Catalog.GetString ("Added:"), details.DateAdded);
AddToTable (table, Catalog.GetString ("Added by:"), details.AddedBy);
AddToTable (table, Catalog.GetString ("Source:"), details.Source);
+ AddToTable (table, Catalog.GetString ("Contributor:"), details.Contributor);
AddToTable (table, Catalog.GetString ("Recorded by:"),details.Taper);
AddToTable (table, Catalog.GetString ("Lineage:"), details.Lineage);
AddToTable (table, Catalog.GetString ("Transferred by:"), details.Transferer);
@@ -281,23 +285,49 @@ namespace Banshee.InternetArchive
var file_sw = new Gtk.ScrolledWindow ();
file_sw.Child = file_list;
- var files = new List<TrackInfo> ();
+ var tracks = new List<TrackInfo> ();
- string [] format_blacklist = new string [] { "zip", "m3u", "metadata", "fingerprint", "checksums", "text" };
+ var files = new List<IA.DetailsFile> (details.Files);
+
+ string [] format_blacklist = new string [] { "metadata", "fingerprint", "checksums", "xml", "m3u" };
var formats = new List<string> ();
- foreach (var f in details.Files) {
+ foreach (var f in files) {
var track = new TrackInfo () {
Uri = new SafeUri (f.Location),
FileSize = f.Size,
TrackNumber = f.Track,
- ArtistName = f.Creator,
+ ArtistName = f.Creator ?? details.Creator,
+ AlbumTitle = item.Title,
TrackTitle = f.Title,
BitRate = f.BitRate,
MimeType = f.Format,
Duration = f.Length
};
- files.Add (track);
+ // Fix up duration/track#/title
+ if ((f.Length == TimeSpan.Zero || f.Title == null || f.Track == 0) && !f.Location.Contains ("zip") && !f.Location.EndsWith ("m3u")) {
+ foreach (var b in files) {
+ if ((f.Title != null && f.Title == b.Title)
+ || (f.OriginalFile != null && b.Location != null && b.Location.EndsWith (f.OriginalFile))
+ || (f.OriginalFile != null && f.OriginalFile == b.OriginalFile)) {
+ if (track.Duration == TimeSpan.Zero)
+ track.Duration = b.Length;
+
+ if (track.TrackTitle == null)
+ track.TrackTitle = b.Title;
+
+ if (track.TrackNumber == 0)
+ track.TrackNumber = b.Track;
+
+ if (track.Duration != TimeSpan.Zero && track.TrackTitle != null && track.TrackNumber != 0)
+ break;
+ }
+ }
+ }
+
+ track.TrackTitle = track.TrackTitle ?? System.IO.Path.GetFileName (f.Location);
+
+ tracks.Add (track);
if (f.Format != null && !formats.Contains (f.Format)) {
if (!format_blacklist.Any (fmt => f.Format.ToLower ().Contains (fmt))) {
@@ -306,26 +336,25 @@ namespace Banshee.InternetArchive
}
}
- // HACK to fix up the times; sometimes the VBR MP3 file will have it but Ogg won't
- foreach (var a in files) {
- foreach (var b in files) {
- if (a.TrackTitle == b.TrackTitle) {
- a.Duration = b.Duration = a.Duration > b.Duration ? a.Duration : b.Duration;
- }
+ // Make these columns snugly fix their data
+ if (tracks.Count > 0) {
+ var max_track = tracks.Max (f => f.TrackNumber);
+ SetWidth (columns.TrackColumn, max_track);
+ if (max_track == 0) {
+ columns.TrackColumn.Visible = false;
}
+
+ SetWidth (columns.FileSizeColumn, tracks.Max (f => f.FileSize));
+ SetWidth (columns.DurationColumn, tracks.Max (f => f.Duration));
}
- // Make these columns snugly fix their data
- (columns.TrackColumn.GetCell (0) as ColumnCellText).SetMinMaxStrings (files.Max (f => f.TrackNumber));
- (columns.FileSizeColumn.GetCell (0) as ColumnCellText).SetMinMaxStrings (files.Max (f => f.FileSize));
- //(columns.FileSizeColumn.GetCell (0) as ColumnCellText).Expand = false;
- (columns.DurationColumn.GetCell (0) as ColumnCellText).SetMinMaxStrings (files.Max (f => f.Duration));
-
- string max_title = "";
- var sorted_by_title = files.OrderBy (f => f.TrackTitle == null ? 0 : f.TrackTitle.Length).ToList ();
- var nine_tenths = sorted_by_title[(int)Math.Floor (.90 * sorted_by_title.Count)].TrackTitle;
- var max = sorted_by_title[sorted_by_title.Count - 1].TrackTitle;
- max_title = ((double)max.Length >= (double)(2.0 * (double)nine_tenths.Length)) ? nine_tenths : max;
+ string max_title = " ";
+ if (tracks.Count > 0) {
+ var sorted_by_title = tracks.OrderBy (f => f.TrackTitle == null ? 0 : f.TrackTitle.Length).ToList ();
+ string nine_tenths = sorted_by_title[(int)Math.Floor (.90 * sorted_by_title.Count)].TrackTitle ?? "";
+ string max = sorted_by_title[sorted_by_title.Count - 1].TrackTitle ?? "";
+ max_title = ((double)max.Length >= (double)(2.0 * (double)nine_tenths.Length)) ? nine_tenths : max;
+ }
(columns.TitleColumn.GetCell (0) as ColumnCellText).SetMinMaxStrings (max_title);
file_list.ColumnController = file_columns;
@@ -340,7 +369,7 @@ namespace Banshee.InternetArchive
files_model.Clear ();
var selected_fmt = format_list.ActiveText;
- foreach (var track in files) {
+ foreach (var track in tracks) {
if (track.MimeType == selected_fmt) {
files_model.Add (track);
}
@@ -349,8 +378,11 @@ namespace Banshee.InternetArchive
files_model.Reload ();
};
+ // TODO replace this with a user-configurable format weighting preference
if (formats.IndexOf ("VBR MP3") != -1) {
format_list.Active = formats.IndexOf ("VBR MP3");
+ } else if (formats.Count > 0) {
+ format_list.Active = 0;
}
vbox.PackStart (file_sw, true, true, 0);
@@ -370,5 +402,10 @@ namespace Banshee.InternetArchive
//PackStart (vbox, true, true, 0);
PackStart (vbox, false, false, 0);
}
+
+ private void SetWidth<T> (Column col, T max)
+ {
+ (col.GetCell (0) as ColumnCellText).SetMinMaxStrings (max, max);
+ }
}
}
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs
index bdc3b30..0990941 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/SearchSource.cs
@@ -117,6 +117,7 @@ namespace Banshee.InternetArchive
bool success = false;
int total_results = 0;
status_text = "";
+ Exception err = null;
ThreadAssist.ProxyToMain (delegate {
SetStatus (Catalog.GetString ("Searching the Internet Archive"), false, true, "gtk-find");
@@ -130,9 +131,7 @@ namespace Banshee.InternetArchive
} catch (System.Net.WebException e) {
Hyena.Log.Exception ("Error searching the Internet Archive", e);
results = null;
- } catch (Exception e) {
- Hyena.Log.Exception ("Error searching the Internet Archive", e);
- results = null;
+ err = e;
}
if (results != null) {
@@ -149,6 +148,7 @@ namespace Banshee.InternetArchive
success = true;
} catch (Exception e) {
+ err = e;
Hyena.Log.Exception ("Error searching the Internet Archive", e);
}
}
@@ -167,14 +167,21 @@ namespace Banshee.InternetArchive
);
}
} else {
- // TODO differentiate between various errors types (network, invalid search, etc)
- //if (error.Status == WebExceptionStatus.Timeout)
ThreadAssist.ProxyToMain (delegate {
- SetStatus (Catalog.GetString ("Error searching the Internet Archive"), true);
+ var web_e = err as System.Net.WebException;
+ if (web_e != null && web_e.Status == System.Net.WebExceptionStatus.Timeout) {
+ SetStatus (Catalog.GetString ("Timed out searching the Internet Archive"), true);
+ CurrentMessage.AddAction (new MessageAction (Catalog.GetString ("Try Again"), (o, a) => Reload ()));
+ } else {
+ SetStatus (Catalog.GetString ("Error searching the Internet Archive"), true);
+ }
});
}
- model.Reload ();
+ ThreadAssist.ProxyToMain (delegate {
+ model.Reload ();
+ OnUpdated ();
+ });
}
public override int Count {
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
index abe6e89..58ea6d0 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
@@ -64,6 +64,18 @@ namespace InternetArchive
get { return metadata.GetJoined ("creator", ", "); }
}
+ public string LicenseUrl {
+ get { return metadata.GetJoined (Field.LicenseUrl.Id, ", "); }
+ }
+
+ public string Language {
+ get { return metadata.GetJoined (Field.Language.Id, ", "); }
+ }
+
+ public string Contributor {
+ get { return metadata.GetJoined (Field.Contributor.Id, ", "); }
+ }
+
public string Publisher {
get { return metadata.GetJoined ("publisher", ", "); }
}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs
index d8a41f9..ae842ba 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/DetailsFile.cs
@@ -56,13 +56,24 @@ namespace InternetArchive
}
public int Track {
- get { return file.Get<int> ("track"); }
+ get {
+ string track = file.Get<string> ("track");
+ if (track == null)
+ return 0;
+
+ var bits = track.Split ('/', '-');
+ return Int32.Parse (bits[0]);
+ }
}
public string Creator {
get { return file.Get<string> ("creator"); }
}
+ public string OriginalFile {
+ get { return file.Get<string> ("original"); }
+ }
+
public string Title {
get { return file.Get<string> ("title"); }
}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
index 82c0c75..f40c512 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
@@ -37,16 +37,12 @@ namespace InternetArchive
{
/*avg_rating
call_number
- collection
- contributor
coverage
- date
foldoutcount
headerImage
imagecount
- mediatype
month
oai_updatedate
publicdate
@@ -64,6 +60,7 @@ namespace InternetArchive
public static Field AvgRating = new Field ("avg_rating", Catalog.GetString ("Rating"));
public static Field Creator = new Field ("creator", Catalog.GetString ("Creator"));
public static Field Collection = new Field ("collection", Catalog.GetString ("Collection"));
+ public static Field Contributor= new Field ("contributor",Catalog.GetString ("Contributor"));
public static Field Date = new Field ("date", Catalog.GetString ("Created"));
public static Field Description= new Field ("description",Catalog.GetString ("Description"));
public static Field Downloads = new Field ("downloads", Catalog.GetString ("Downloads"));
diff --git a/src/Extensions/Banshee.InternetArchive/Resources/DetailsSourceActiveUI.xml b/src/Extensions/Banshee.InternetArchive/Resources/DetailsSourceActiveUI.xml
index f1206c5..4d86cb3 100644
--- a/src/Extensions/Banshee.InternetArchive/Resources/DetailsSourceActiveUI.xml
+++ b/src/Extensions/Banshee.InternetArchive/Resources/DetailsSourceActiveUI.xml
@@ -2,6 +2,7 @@
<toolbar name="HeaderToolbar">
<placeholder name="SourceActions">
<toolitem action="OpenItemWebsite" />
+ <toolitem action="UnmapSourceAction"/>
</placeholder>
</toolbar>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]