[banshee: 40/61] [InternetArchive] set icons for DetailSources
- From: Gabriel Burt <gburt src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee: 40/61] [InternetArchive] set icons for DetailSources
- Date: Tue, 3 Nov 2009 06:31:12 +0000 (UTC)
commit faa15d7de77ecf2b8e17d26b4a6071ddc8a3622d
Author: Gabriel Burt <gabriel burt gmail com>
Date: Tue Oct 13 15:19:10 2009 -0700
[InternetArchive] set icons for DetailSources
.../Banshee.InternetArchive/Actions.cs | 2 +-
.../Banshee.InternetArchive/DetailsSource.cs | 28 +++++++++++++++++++-
.../Banshee.InternetArchive/Item.cs | 11 +++++--
.../InternetArchive/SearchResult.cs | 4 +++
4 files changed, 40 insertions(+), 5 deletions(-)
---
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
index 78a5d6d..071dca4 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Actions.cs
@@ -49,7 +49,7 @@ namespace Banshee.InternetArchive
var item = source.FocusedItem;
if (item != null && item.Id != null) {
string id = item.Id;
- var src = new DetailsSource (id, item.Title);
+ var src = new DetailsSource (id, item.Title, item.MediaType);
source.AddChildSource (src);
Banshee.ServiceStack.ServiceManager.SourceManager.SetActiveSource (src);
}
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
index 8e3f290..c225802 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/DetailsSource.cs
@@ -63,7 +63,7 @@ namespace Banshee.InternetArchive
get { return item; }
}
- public DetailsSource (string id, string title) : this (Item.LoadOrCreate (id, title)) {}
+ public DetailsSource (string id, string title, string mediaType) : this (Item.LoadOrCreate (id, title, mediaType)) {}
public DetailsSource (Item item) : base (item.Title, item.Title, 40, "internet-archive-" + item.Id)
{
@@ -75,6 +75,9 @@ namespace Banshee.InternetArchive
Properties.SetString ("GtkActionPath", "/IaDetailsSourcePopup");
Properties.SetString ("UnmapSourceActionLabel", Catalog.GetString ("Close Item"));
+ SetIcon ();
+
+
gui = new DetailsView (this, item);
Properties.Set<Gtk.Widget> ("Nereid.SourceContents", gui);
@@ -86,6 +89,29 @@ namespace Banshee.InternetArchive
}
}
+ private void SetIcon ()
+ {
+ if (item.MediaType == null)
+ return;
+
+ var media_type = IA.MediaType.Options.FirstOrDefault (mt =>
+ item.MediaType.Contains (mt.Id) || mt.Children.Any (c => item.MediaType.Contains (c.Id))
+ );
+
+ if (media_type == null)
+ return;
+
+ if (media_type.Id == "audio") {
+ Properties.SetStringList ("Icon.Name", "audio-x-generic", "audio");
+ } else if (media_type.Id == "movies") {
+ Properties.SetStringList ("Icon.Name", "video-x-generic", "video");
+ } else if (media_type.Id == "texts") {
+ Properties.SetStringList ("Icon.Name", "x-office-document", "document");
+ } else if (media_type.Id == "education") {
+ Properties.SetStringList ("Icon.Name", "video-x-generic", "video");
+ }
+ }
+
private void Load ()
{
ThreadAssist.SpawnFromMain (ThreadedLoad);
diff --git a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Item.cs b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Item.cs
index ebe58d7..24f1437 100644
--- a/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Item.cs
+++ b/src/Extensions/Banshee.InternetArchive/Banshee.InternetArchive/Item.cs
@@ -55,11 +55,11 @@ namespace Banshee.InternetArchive
{
public class Item
{
- public static Item LoadOrCreate (string id, string title)
+ public static Item LoadOrCreate (string id, string title, string mediaType)
{
var item = Provider.FetchFirstMatching ("ID = ?", id);
if (item == null) {
- item = new Item (id, title);
+ item = new Item (id, title, mediaType);
Provider.Save (item);
}
@@ -83,14 +83,18 @@ namespace Banshee.InternetArchive
[DatabaseColumn("Title")]
public string Title { get; private set; }
+ [DatabaseColumn("MediaType")]
+ public string MediaType { get; private set; }
+
public IA.Details Details { get; private set; }
public Item () {}
- private Item (string id, string title)
+ private Item (string id, string title, string mediaType)
{
Id = id;
Title = title;
+ MediaType = mediaType;
}
public void Delete ()
@@ -125,6 +129,7 @@ namespace Banshee.InternetArchive
ItemID INTEGER PRIMARY KEY,
ID TEXT UNIQUE NOT NULL,
Title TEXT NOT NULL,
+ MediaType TEXT,
DetailsJson TEXT)"
);
}
diff --git a/src/Extensions/Banshee.InternetArchive/InternetArchive/SearchResult.cs b/src/Extensions/Banshee.InternetArchive/InternetArchive/SearchResult.cs
index 5a5741a..649f648 100644
--- a/src/Extensions/Banshee.InternetArchive/InternetArchive/SearchResult.cs
+++ b/src/Extensions/Banshee.InternetArchive/InternetArchive/SearchResult.cs
@@ -87,6 +87,10 @@ namespace InternetArchive
get { return GetJoined (Field.Format, ", "); }
}
+ public string MediaType {
+ get { return Get<string> (Field.MediaType); }
+ }
+
public int Year {
get { return (int) Get<double> (Field.Year); }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]