[gnome-music] Fix missing album icon
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Fix missing album icon
- Date: Thu, 9 May 2013 00:01:12 +0000 (UTC)
commit a649868491c6c313130e4f650ddce928d51b1751
Author: Guillaume Quintard <guillaume quintard gmail com>
Date: Wed May 8 18:37:43 2013 +0200
Fix missing album icon
And clean up a bit
Fixes bug 699828
Conflicts:
src/view.js
Signed-off-by: Seif Lotfy <seif lotfy com>
src/albumArtCache.js | 30 +++++++++++++++++++++++++++---
src/view.js | 39 +++------------------------------------
src/widgets.js | 14 ++++----------
3 files changed, 34 insertions(+), 49 deletions(-)
---
diff --git a/src/albumArtCache.js b/src/albumArtCache.js
index eabd911..7070287 100644
--- a/src/albumArtCache.js
+++ b/src/albumArtCache.js
@@ -129,6 +129,33 @@ const AlbumArtCache = new Lang.Class({
});
},
+ makeDefaultIcon: function(w, h) {
+ let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
+ //get a small pixbuf with the given path
+ let icon = GdkPixbuf.Pixbuf.new_from_file_at_scale(path,
+ w < 0 ? -1 : w/4,
+ h < 0 ? -1 : h/4,
+ true);
+
+ //create an empty pixbuf with the requested size
+ let result = GdkPixbuf.Pixbuf.new(icon.get_colorspace(),
+ true,
+ icon.get_bits_per_sample(),
+ icon.get_width()*4,
+ icon.get_height()*4);
+ result.fill(0x00000000);
+ icon.composite(result,
+ icon.get_width()*3/2,
+ icon.get_height()*3/2,
+ icon.get_width(),
+ icon.get_height(),
+ icon.get_width()*3/2,
+ icon.get_height()*3/2,
+ 1, 1,
+ GdkPixbuf.InterpType.NEAREST, 0xff)
+ return this.makeIconFrame(result);
+ },
+
makeIconFrame: function (pixbuf) {
var border = 3;
var color = 0xffffffff;
@@ -159,9 +186,6 @@ const AlbumArtCache = new Lang.Class({
border, border);
return result2;
-
-
- return result;
},
_keybuilder_funcs: [
diff --git a/src/view.js b/src/view.js
index 6bfc75c..91c2ea0 100644
--- a/src/view.js
+++ b/src/view.js
@@ -40,7 +40,6 @@ const tracker = Tracker.SparqlConnection.get (null);
const AlbumArtCache = imports.albumArtCache;
const Grilo = imports.grilo;
const albumArtCache = AlbumArtCache.AlbumArtCache.getDefault();
-const symbolicMusicPath = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
function extractFileName(uri) {
var exp = /^.*[\\\/]|[.][^.]*$/g;
@@ -147,7 +146,7 @@ const ViewContainer = new Lang.Class({
this._items = [];
this._loadMore.widget.hide();
this._connectView();
- this._symbolicIcon = this._createSymblolicIcon(symbolicMusicPath, this._iconHeight, this._iconWidth);
+ this._symbolicIcon = albumArtCache.makeDefaultIcon(this._iconHeight, this._iconWidth);
grilo.connect('ready', Lang.bind(this, this.populate));
this.header_bar.connect('state-changed', Lang.bind(this, this._onStateChanged))
},
@@ -213,12 +212,10 @@ const ViewContainer = new Lang.Class({
if ((item.get_title() == null) && (item.get_url() != null)) {
item.set_title (extractFileName(item.get_url()));
}
- if (!this.icon)
- this.icon = albumArtCache.makeIconFrame(this._symbolicIcon);
this._model.set(
iter,
[0, 1, 2, 3, 4, 5],
- [toString(item.get_id()), "", item.get_title(), artist, this.icon, item]
+ [toString(item.get_id()), "", item.get_title(), artist, this._symbolicIcon, item]
);
GLib.idle_add(300, Lang.bind(this, this._updateAlbumArt, item, iter));
}
@@ -274,37 +271,7 @@ const ViewContainer = new Lang.Class({
},
_onItemActivated: function (widget, id, path) {
- },
- //TODO: this should probably be a helper as it will probably
- //be used by others
- _createSymblolicIcon: function(path, w, h) {
- //get a small pixbuf with the given path
- let icon = GdkPixbuf.Pixbuf.new_from_file_at_scale(path,
- w < 0 ? -1 : w/4,
- h < 0 ? -1 : h/4,
- true);
-
- //create an empty pixbuf with the requested size
- let result = GdkPixbuf.Pixbuf.new(icon.get_colorspace(),
- true,
- icon.get_bits_per_sample(),
- icon.get_width()*4,
- icon.get_height()*4);
- result.fill(0xffffffff);
-
- icon.composite(result,
- icon.get_width()*3/2,
- icon.get_height()*3/2,
- icon.get_width(),
- icon.get_height(),
- icon.get_width()*3/2,
- icon.get_height()*3/2,
- 1, 1,
- GdkPixbuf.InterpType.NEAREST, 0xff)
- return result;
-
}
-
});
Signals.addSignalMethods(ViewContainer.prototype);
@@ -358,7 +325,7 @@ const Songs = new Lang.Class({
this.view.set_view_type(Gd.MainViewType.LIST);
this._iconHeight = 32;
this._iconWidth = 32;
- this._symbolicIcon = this._createSymblolicIcon(symbolicMusicPath, this._iconHeight, this._iconWidth)
+ this._symbolicIcon = albumArtCache.makeDefaultIcon(this._iconHeight, this._iconWidth)
this._addListRenderers();
this.player = player;
},
diff --git a/src/widgets.js b/src/widgets.js
index e408bb0..30475b7 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -35,12 +35,6 @@ const grilo = Grilo.grilo;
const AlbumArtCache = imports.albumArtCache;
const albumArtCache = AlbumArtCache.AlbumArtCache.getDefault();
-const folderPixbuf_small = GdkPixbuf.Pixbuf.new_from_file_at_scale(
- "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg",
- -1, 128, true);
-const folderPixbuf_big = GdkPixbuf.Pixbuf.new_from_file_at_scale(
- "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg",
- -1, 128, true);
const nowPlayingPixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
"/usr/share/icons/gnome/scalable/actions/media-playback-start-symbolic.svg",
-1, 16, true);
@@ -184,7 +178,7 @@ const AlbumWidget = new Lang.Class({
this.view.set_model(this.model);
let pixbuf = albumArtCache.lookup (256, artist, item.get_string(Grl.METADATA_KEY_ALBUM));
if (pixbuf == null)
- pixbuf = folderPixbuf_big;
+ pixbuf = albumArtCache.makeDefaultIcon(256, 256);
this.ui.get_object("cover").set_from_pixbuf (pixbuf);
this.ui.get_object("artist_label").set_markup(artist);
@@ -337,9 +331,9 @@ const ArtistAlbumWidget = new Lang.Class({
this.ui = new Gtk.Builder();
this.ui.add_from_resource('/org/gnome/music/ArtistAlbumWidget.ui');
- var pixbuf = albumArtCache.lookup (128, artist, album.get_title());
+ let pixbuf = albumArtCache.lookup (128, artist, album.get_title());
if (pixbuf == null)
- pixbuf = folderPixbuf_small;
+ pixbuf = albumArtCache.makeDefaultIcon(128, 128);
this.ui.get_object("cover").set_from_pixbuf(pixbuf);
this.ui.get_object("title").set_label(album.get_title());
@@ -371,7 +365,7 @@ const ArtistAlbumWidget = new Lang.Class({
let iter = model.append();
model.set(iter,
[0, 1, 2, 3, 4, 5],
- [ track.get_title(), "", "", false, folderPixbuf_small, track]);
+ [ track.get_title(), "", "", false, pixbuf, track]);
songWidget.iter = iter;
songWidget.model = model;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]