[banshee: 25/61] [InternetArchive] Add search entry menu
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee: 25/61] [InternetArchive] Add search entry menu
- Date: Tue, 3 Nov 2009 06:29:57 +0000 (UTC)
commit dded7e722b059aee050b31eb1fe70d56090879f0
Author: Gabriel Burt <gabriel burt gmail com>
Date: Sun Oct 11 16:07:56 2009 -0700
[InternetArchive] Add search entry menu
With an item for searchable fields that will entery "field:" into the
query entry. Rename some of the details table labels.
.../Banshee.InternetArchive/Actions.cs | 16 +++++-
.../Banshee.InternetArchive/DetailsSource.cs | 13 +++++-
.../DetailsSourceContents.cs | 22 ++++----
.../Banshee.InternetArchive/HeaderFilters.cs | 49 ++++++++++++++-----
.../Banshee.InternetArchive/Source.cs | 1 -
.../InternetArchive/Details.cs | 4 ++
.../InternetArchive/Field.cs | 11 ++++-
src/Extensions/Banshee.InternetArchive/Makefile.am | 3 +-
.../Resources/DetailsSourceActiveUI.xml | 18 +++++++
9 files changed, 106 insertions(+), 31 deletions(-)
---
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
index aa14124..198fa25 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
@@ -53,9 +53,19 @@ namespace Banshee.InternetArchive
}
}),
new ActionEntry ("OpenItemWebsite", Stock.JumpTo, Catalog.GetString ("Open Webpage"), null, null, (o, a) => {
- var item = source.TrackModel.FocusedItem;
- if (item != null && item.Uri != null) {
- Banshee.Web.Browser.Open (item.Uri.AbsoluteUri);
+ string uri = null;
+ var src = ActiveSource as DetailsSource;
+ if (src != null) {
+ uri = src.Item.WebpageUrl;
+ } else {
+ var item = source.TrackModel.FocusedItem;
+ if (item != null && item.Uri != null) {
+ uri = item.Uri.AbsoluteUri;
+ }
+ }
+
+ if (uri != null) {
+ Banshee.Web.Browser.Open (uri);
}
})
);
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
index dd55e45..fedb3c2 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
@@ -58,12 +58,19 @@ namespace Banshee.InternetArchive
private IA.Details item;
private MemoryTrackListModel track_model;
+ public IA.Details Item {
+ get { return item; }
+ }
+
public DetailsSource (string name, string id) : base (name, name, 40, "internet-archive-" + id)
{
item = IA.Details.LoadOrCreate (id, name);
track_model = new MemoryTrackListModel ();
track_model.Reloaded += delegate { OnUpdated (); };
+ Properties.SetString ("ActiveSourceUIResource", "DetailsSourceActiveUI.xml");
+ Properties.SetString ("GtkActionPath", "/InternetArchiveDetailsContextMenu");
+
Properties.Set<Gtk.Widget> ("Nereid.SourceContents", new DetailsSourceContents (this, item));
}
@@ -112,12 +119,16 @@ namespace Banshee.InternetArchive
get { return false; }
}
+ public bool CanPlay {
+ get { return true; }
+ }
+
public bool CanShuffle {
get { return false; }
}
public bool CanRepeat {
- get { return false; }
+ get { return true; }
}
public bool CanAddTracks {
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSourceContents.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSourceContents.cs
index 5dbe8aa..a49edbb 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSourceContents.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSourceContents.cs
@@ -141,9 +141,9 @@ namespace Banshee.InternetArchive
};
AddToTable (table, Catalog.GetString ("Venue:"), item.Venue);
- AddToTable (table, Catalog.GetString ("Coverage:"), item.Coverage);
+ AddToTable (table, Catalog.GetString ("Location:"), item.Coverage);
if (item.DateCreated != DateTime.MinValue) {
- AddToTable (table, Catalog.GetString ("Created:"), item.DateCreated);
+ AddToTable (table, Catalog.GetString ("Date:"), item.DateCreated);
} else {
AddToTable (table, Catalog.GetString ("Year:"), item.Year);
}
@@ -152,18 +152,18 @@ namespace Banshee.InternetArchive
table.AddSeparator ();
- AddToTable (table, Catalog.GetString ("Downloads (overall):"), item.DownloadsAllTime);
- AddToTable (table, Catalog.GetString ("Downloads (last month):"), item.DownloadsLastMonth);
- AddToTable (table, Catalog.GetString ("Downloads (last week):"), item.DownloadsLastWeek);
+ AddToTable (table, Catalog.GetString ("Downloads, overall:"), item.DownloadsAllTime);
+ AddToTable (table, Catalog.GetString ("Downloads, past month:"), item.DownloadsLastMonth);
+ AddToTable (table, Catalog.GetString ("Downloads, past week:"), item.DownloadsLastWeek);
table.AddSeparator ();
- AddToTable (table, Catalog.GetString ("Added:"), item.DateAdded);
- AddToTable (table, Catalog.GetString ("Added by:"), item.AddedBy);
- AddToTable (table, Catalog.GetString ("Source:"), item.Source);
- AddToTable (table, Catalog.GetString ("Taper:"), item.Taper);
- AddToTable (table, Catalog.GetString ("Lineage:"), item.Lineage);
- AddToTable (table, Catalog.GetString ("Transferer:"), item.Transferer);
+ AddToTable (table, Catalog.GetString ("Added:"), item.DateAdded);
+ AddToTable (table, Catalog.GetString ("Added by:"), item.AddedBy);
+ AddToTable (table, Catalog.GetString ("Source:"), item.Source);
+ AddToTable (table, Catalog.GetString ("Recorded by:"),item.Taper);
+ AddToTable (table, Catalog.GetString ("Lineage:"), item.Lineage);
+ AddToTable (table, Catalog.GetString ("Transferred by:"), item.Transferer);
expander.Child = table;
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HeaderFilters.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HeaderFilters.cs
index 5f566ec..db681b4 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HeaderFilters.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/HeaderFilters.cs
@@ -97,6 +97,34 @@ namespace Banshee.InternetArchive
EmptyMessage = String.Format (Catalog.GetString ("Optional Query"))
};
+ // Add 'filter' items
+ var filter_fields = new List<IA.Field> ();
+ int i = 0;
+ foreach (var field in IA.Field.Fields.Where (f => (f != IA.Field.Collection && f != IA.Field.Identifier))) {
+ filter_fields.Add (field);
+ entry.AddFilterOption (i++, field.Name);
+ }
+
+ // Add the Help item
+ entry.Menu.Append (new SeparatorMenuItem ());
+ var help_item = new ImageMenuItem (Catalog.GetString ("_Help")) {
+ Image = new Image ("gtk-help", IconSize.Menu)
+ };
+ help_item.Activated += delegate { Banshee.Web.Browser.Open ("http://www.archive.org/advancedsearch.php"); };
+ entry.Menu.Append (help_item);
+ entry.Menu.ShowAll ();
+
+ entry.FilterChanged += (o, a) => {
+ // Only prepend the filter: part if the query doesn't already end in a :
+ string prev_query = entry.Query.EndsWith (":") ? null : entry.Query;
+ entry.Query = String.Format ("{0}:{1}", filter_fields[entry.ActiveFilterID].Id, prev_query);
+
+ var editable = entry.InnerEntry as Editable;
+ if (editable != null) {
+ editable.Position = entry.Query.Length;
+ }
+ };
+
PackStart (entry, false, false, 0);
}
@@ -104,11 +132,11 @@ namespace Banshee.InternetArchive
{
var combo = sort_combo = ComboBox.NewText ();
- combo.AppendText (Catalog.GetString ("Popular"));
- combo.AppendText (Catalog.GetString ("Popular This Week"));
- combo.AppendText (Catalog.GetString ("Highly Rated"));
- combo.AppendText (Catalog.GetString ("Year"));
- combo.AppendText (Catalog.GetString ("Recently Added"));
+ combo.AppendText (Catalog.GetString ("Downloads"));
+ combo.AppendText (Catalog.GetString ("Downloads This Week"));
+ combo.AppendText (Catalog.GetString ("Rating"));
+ combo.AppendText (Catalog.GetString ("Year Created"));
+ combo.AppendText (Catalog.GetString ("Date Added"));
combo.Active = 0;
PackStart (new Label (Catalog.GetString ("Sort by:")), false, false, 0);
@@ -142,16 +170,11 @@ namespace Banshee.InternetArchive
var media_type = media_type_store.GetValue (iter, 0) as IA.FieldValue;
string query = media_type.ToString ();
- if (media_type is IA.Collection) {
- if ((media_type as IA.Collection).MediaType.Id == "music") {
- //query += " AND (format:mp3 OR format:ogg OR format:flac OR format:shorten)";
- }
- }
-
- query += " AND -mediatype:collection";//(format:mp3 OR format:ogg OR format:flac OR format:shorten)";
+ // Remove medialess 'collection' results
+ query += " AND -mediatype:collection";
if (!String.IsNullOrEmpty (search_entry.Query)) {
- query += String.Format (" AND (title:\"{0}\" OR description:\"{0}\" OR creator:\"{0}\")", search_entry.Query);
+ query += String.Format (" AND {0}", search_entry.Query);
}
source.Search.Query = query;
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Source.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Source.cs
index 2f0ee08..710f559 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Source.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Source.cs
@@ -115,7 +115,6 @@ namespace Banshee.InternetArchive
));
Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
- Properties.Set<bool> ("ActiveSourceUIResourcePropagate", true);
Properties.SetString ("GtkActionPath", "/InternetArchiveContextMenu");
actions = new Actions (this);
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
index 9134896..ff831b0 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Details.cs
@@ -194,6 +194,10 @@ namespace InternetArchive
get { return review_info.Get<int> ("num_reviews"); }
}
+ public string WebpageUrl {
+ get { return String.Format ("http://www.archive.org/details/{0}", Id); }
+ }
+
#endregion
private bool LoadDetails ()
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
index 19ef91e..82c0c75 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/Field.cs
@@ -25,6 +25,7 @@
// THE SOFTWARE.
using System;
+using System.Collections.Generic;
using Mono.Unix;
@@ -59,6 +60,7 @@ namespace InternetArchive
week
*/
+ private static List<Field> fields = new List<Field> ();
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"));
@@ -70,11 +72,15 @@ namespace InternetArchive
public static Field Language = new Field ("language", Catalog.GetString ("Language"));
public static Field LicenseUrl = new Field ("licenseurl", Catalog.GetString ("License"));
public static Field MediaType = new Field ("mediatype", Catalog.GetString ("Media Type"));
- public static Field NumReviews = new Field ("num_reviews",Catalog.GetString ("# Reviews"));
+ public static Field NumReviews = new Field ("num_reviews",Catalog.GetString ("Review Count"));
public static Field Publisher = new Field ("publisher", Catalog.GetString ("Publisher"));
public static Field Title = new Field ("title", Catalog.GetString ("Title"));
public static Field Year = new Field ("year", Catalog.GetString ("Year"));
+ public static IEnumerable<Field> Fields {
+ get { return fields; }
+ }
+
public string Name { get; private set; }
public string Id { get; private set; }
@@ -82,6 +88,9 @@ namespace InternetArchive
{
Id = id;
Name = name;
+
+ fields.Add (this);
+ fields.Sort ((a, b) => a.Name.CompareTo (b.Name));
}
}
}
diff --git a/src/Extensions/Banshee.InternetArchive/Makefile.am b/src/Extensions/Banshee.InternetArchive/Makefile.am
index cc1f7cb..7db34d2 100644
--- a/src/Extensions/Banshee.InternetArchive/Makefile.am
+++ b/src/Extensions/Banshee.InternetArchive/Makefile.am
@@ -24,6 +24,7 @@ SOURCES = \
RESOURCES = \
Banshee.InternetArchive.addin.xml \
- Resources/ActiveSourceUI.xml
+ Resources/ActiveSourceUI.xml \
+ Resources/DetailsSourceActiveUI.xml
include $(top_srcdir)/build/build.mk
diff --git a/src/Extensions/Banshee.InternetArchive/Resources/DetailsSourceActiveUI.xml b/src/Extensions/Banshee.InternetArchive/Resources/DetailsSourceActiveUI.xml
new file mode 100644
index 0000000..1e82ac8
--- /dev/null
+++ b/src/Extensions/Banshee.InternetArchive/Resources/DetailsSourceActiveUI.xml
@@ -0,0 +1,18 @@
+<ui>
+ <toolbar name="HeaderToolbar">
+ <placeholder name="SourceActions">
+ <toolitem action="OpenItemWebsite" />
+ </placeholder>
+ </toolbar>
+
+ <popup action="InternetArchiveDetailsContextMenu">
+ <menuitem action="VisitInternetArchive" />
+ </popup>
+
+ <popup name="TrackContextMenu" action="TrackContextMenuAction">
+ <placeholder name="BelowAddToPlaylist">
+ <separator />
+ <separator />
+ </placeholder>
+ </popup>
+</ui>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]