banshee r4961 - in trunk/banshee: . src/Core/Banshee.Services/Banshee.Query src/Core/Banshee.ThickClient src/Core/Banshee.ThickClient/Banshee.Collection.Gui src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems



Author: gburt
Date: Mon Jan 26 02:09:07 2009
New Revision: 4961
URL: http://svn.gnome.org/viewvc/banshee?rev=4961&view=rev

Log:
2009-01-25  Gabriel Burt  <gabriel burt gmail com>

	* Banshee.Services/Banshee.Query/BansheeQuery.cs:
	* Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs:
	Add LicenseUri as a search and smart playlist field and as a column.

	* Banshee.ThickClient/Makefile.am:
	* Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-by.png:
	* Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nc.png:
	* Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nd.png:
	* Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-pd.png:
	* Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-sa.png:
	* Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellCreativeCommons.cs:
	New cell that detects Creative Commons licenses in the LicenseUri field
	and render them as images.

Added:
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellCreativeCommons.cs
   trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/
   trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-by.png
   trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nc.png
   trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nd.png
   trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-pd.png
   trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-sa.png
Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
   trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am

Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs	(original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Query/BansheeQuery.cs	Mon Jan 26 02:09:07 2009
@@ -218,6 +218,15 @@
             Catalog.GetString ("comment"), "comment"
         );
 
+        public static QueryField LicenseUriField = new QueryField (
+            "licenseuri", "LicenseUri",
+            // Translators: noun
+            Catalog.GetString ("License"), "CoreTracks.LicenseUri", false,
+            // Translators: These are unique search fields (and nouns).  Please, no spaces. Blank ok.
+            Catalog.GetString ("license"), Catalog.GetString ("licensed"), Catalog.GetString ("under"),
+            "license", "licensed", "under"
+        );
+
         public static QueryField RatingField = new QueryField (
             "rating", "SavedRating",
             Catalog.GetString ("Rating"), "CoreTracks.Rating", new Type [] {typeof(RatingQueryValue)},//, typeof(NullQueryValue)},
@@ -314,7 +323,7 @@
 
         public static QueryFieldSet FieldSet = new QueryFieldSet (
             ArtistField, AlbumField, AlbumArtistField, TitleField, TrackNumberField, TrackCountField, DiscNumberField, DiscCountField,
-            YearField, GenreField, ComposerField, ConductorField, GroupingField, CommentField, RatingField, PlayCountField,
+            YearField, GenreField, ComposerField, ConductorField, GroupingField, CommentField, LicenseUriField, RatingField, PlayCountField,
             SkipCountField, FileSizeField, UriField, DurationField, MimeTypeField, LastPlayedField, LastSkippedField,
             BpmField, BitRateField, DateAddedField, PlaylistField, SmartPlaylistField
         );
@@ -420,6 +429,7 @@
                 case "uri":
                 case "mimetype":
                 case "composer":
+                case "licenseuri":
                 case "comment":
                     sort_query = String.Format (
                         "CoreTracks.{0} {1}, {2}",

Added: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellCreativeCommons.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/ColumnCellCreativeCommons.cs	Mon Jan 26 02:09:07 2009
@@ -0,0 +1,110 @@
+// 
+// ColumnCellCreativeCommons.cs
+//
+// Author:
+//   Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Gtk;
+using Cairo;
+
+using Hyena.Gui;
+using Hyena.Data.Gui;
+using Hyena.Data.Gui;
+
+using Banshee.Gui;
+using Banshee.Streaming;
+using Banshee.MediaEngine;
+using Banshee.ServiceStack;
+
+namespace Banshee.Collection.Gui
+{
+    public class ColumnCellCreativeCommons : ColumnCell
+    {
+        private static Gdk.Pixbuf [] pixbufs;
+        private static string [] attributes = new string [] {"by", "nc", "nd", "sa", "pd"};
+        private const string CC_ID = "creativecommons.org/licenses/";
+        private static int CC_ID_LEN = CC_ID.Length;
+
+        public ColumnCellCreativeCommons (string property, bool expand) : base (property, expand)
+        {
+            LoadPixbufs ();
+        }
+
+        private void LoadPixbufs ()
+        {
+            if (pixbufs == null) {
+                pixbufs = new Gdk.Pixbuf[attributes.Length];
+            }
+            
+            for (int i = 0; i < attributes.Length; i++) {
+                pixbufs[i] = IconThemeUtils.LoadIcon (16, String.Format ("creative-commons-{0}", attributes[i]));
+            }
+        }
+
+        public override void Render (CellContext context, StateType state, double cellWidth, double cellHeight)
+        {
+            string license_uri = BoundObject as string;
+            if (String.IsNullOrEmpty (license_uri)) {
+                return;
+            }
+
+            int start_index = license_uri.IndexOf (CC_ID);
+            if (start_index == -1) {
+                return;
+            }
+
+            start_index += CC_ID_LEN;
+            context.Context.Translate (0, 0.5);
+
+            int draw_x = 0;
+            for (int i = 0; i < attributes.Length; i++) {
+                if (license_uri.IndexOf (attributes[i], start_index) != -1) {
+                    Gdk.Pixbuf render_pixbuf = pixbufs[i];
+
+                    Cairo.Rectangle pixbuf_area = new Cairo.Rectangle (draw_x,
+                        (cellHeight - render_pixbuf.Height) / 2, render_pixbuf.Width, render_pixbuf.Height);
+                    
+                    if (!context.Sensitive) {
+                        context.Context.Save ();
+                    }
+                    
+                    Gdk.CairoHelper.SetSourcePixbuf (context.Context, render_pixbuf, pixbuf_area.X, pixbuf_area.Y);
+                    context.Context.Rectangle (pixbuf_area);
+                    
+                    if (!context.Sensitive) {
+                        context.Context.Clip ();
+                        context.Context.PaintWithAlpha (0.5);
+                        context.Context.Restore ();
+                    } else {
+                        context.Context.Fill ();
+                    }
+
+                    draw_x += render_pixbuf.Width;
+                }
+            }
+        }
+    }
+}

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Collection.Gui/DefaultColumnController.cs	Mon Jan 26 02:09:07 2009
@@ -84,6 +84,7 @@
                 DateAddedColumn,
                 UriColumn,
                 MimeTypeColumn,
+                LicenseUriColumn,
                 AlbumArtistColumn,
                 TrackNumberAndCountColumn,
                 DiscNumberAndCountColumn,
@@ -144,6 +145,7 @@
             uri_column          = Create (BansheeQuery.UriField, 0.15, false, uri_cell);
             
             mime_type_column    = CreateText (BansheeQuery.MimeTypeField, 0.15);
+            license_uri_column  = Create (BansheeQuery.LicenseUriField, 0.15, false, new ColumnCellCreativeCommons (null, true));
 
             last_played_column  = Create (BansheeQuery.LastPlayedField, 0.15, false, new ColumnCellDateTime (null, true));
             last_skipped_column = Create (BansheeQuery.LastSkippedField, 0.15, false, new ColumnCellDateTime (null, true));
@@ -306,6 +308,11 @@
             get { return mime_type_column; }
         }
 
+        private SortableColumn license_uri_column;
+        public SortableColumn LicenseUriColumn {
+            get { return license_uri_column; }
+        }
+
 #endregion
 
     }

Modified: trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am	(original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Makefile.am	Mon Jan 26 02:09:07 2009
@@ -13,6 +13,7 @@
 	Banshee.Collection.Gui/ArtworkRenderer.cs \
 	Banshee.Collection.Gui/BaseTrackListView.cs \
 	Banshee.Collection.Gui/ColumnCellAlbum.cs \
+	Banshee.Collection.Gui/ColumnCellCreativeCommons.cs \
 	Banshee.Collection.Gui/ColumnCellDateTime.cs \
 	Banshee.Collection.Gui/ColumnCellDiscAndCount.cs \
 	Banshee.Collection.Gui/ColumnCellDuration.cs \

Added: trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-by.png
==============================================================================
Binary files (empty file) and trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-by.png	Mon Jan 26 02:09:07 2009 differ

Added: trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nc.png
==============================================================================
Binary files (empty file) and trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nc.png	Mon Jan 26 02:09:07 2009 differ

Added: trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nd.png
==============================================================================
Binary files (empty file) and trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-nd.png	Mon Jan 26 02:09:07 2009 differ

Added: trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-pd.png
==============================================================================
Binary files (empty file) and trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-pd.png	Mon Jan 26 02:09:07 2009 differ

Added: trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-sa.png
==============================================================================
Binary files (empty file) and trunk/banshee/src/Core/Banshee.ThickClient/ThemeIcons/16x16/emblems/creative-commons-sa.png	Mon Jan 26 02:09:07 2009 differ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]