[gnome-music] Reduce size of album icons
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Reduce size of album icons
- Date: Wed, 8 May 2013 14:33:21 +0000 (UTC)
commit e2963dde305a1cea90167642cb1626a84699720b
Author: Guillaume Quintard <guillaume quintard gmail com>
Date: Wed May 8 15:02:36 2013 +0200
Reduce size of album icons
fixes bug 699769
Signed-off-by: Seif Lotfy <seif lotfy com>
src/view.js | 38 ++++++++++++++++++++++++++++++++------
1 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index 1312735..2287aff 100644
--- a/src/view.js
+++ b/src/view.js
@@ -40,6 +40,7 @@ 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;
@@ -146,8 +147,7 @@ const ViewContainer = new Lang.Class({
this._items = [];
this._loadMore.widget.hide();
this._connectView();
- let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
- this._symbolicIcon = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, this._iconHeight,
this._iconWidth, true)
+ this._symbolicIcon = this._createSymblolicIcon(symbolicMusicPath, this._iconHeight, this._iconWidth);
grilo.connect('ready', Lang.bind(this, this.populate));
this.header_bar.connect('state-changed', Lang.bind(this, this._onStateChanged))
},
@@ -213,11 +213,12 @@ const ViewContainer = new Lang.Class({
if ((item.get_title() == null) && (item.get_url() != null)) {
item.set_title (extractFileName(item.get_url()));
}
- var icon = albumArtCache.makeIconFrame(this._symbolicIcon)
+ 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, icon, item]
+ [toString(item.get_id()), "", item.get_title(), artist, this.icon, item]
);
GLib.idle_add(300, Lang.bind(this, this._updateAlbumArt, item, iter));
}
@@ -273,6 +274,32 @@ 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(0x00000000);
+
+ icon.copy_area(0, 0,
+ icon.get_width(),
+ icon.get_height(),
+ result,
+ icon.get_width()*3/2,
+ icon.get_height()*3/2);
+ return result;
+
}
});
@@ -328,8 +355,7 @@ const Songs = new Lang.Class({
this.view.set_view_type(Gd.MainViewType.LIST);
this._iconHeight = 32;
this._iconWidth = 32;
- let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
- this._symbolicIcon = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, this._iconHeight,
this._iconWidth, true)
+ this._symbolicIcon = this._createSymblolicIcon(symbolicMusicPath, this._iconHeight, this._iconWidth)
this._addListRenderers();
this.player = player;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]