Skip to content

Instantly share code, notes, and snippets.

@gquintard
Last active December 16, 2015 13:09
Show Gist options
  • Save gquintard/5439636 to your computer and use it in GitHub Desktop.
Save gquintard/5439636 to your computer and use it in GitHub Desktop.
From 68616aa5c24f65e67169931e711e730cf126bfb6 Mon Sep 17 00:00:00 2001
From: Guillaume Quintard <guillaume.quintard@gmail.com>
Date: Tue, 23 Apr 2013 00:51:33 +0200
Subject: [PATCH 1/2] load symbolic icon only once for the albums view
---
src/view.js | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/view.js b/src/view.js
index 23ac10d..c460d13 100644
--- a/src/view.js
+++ b/src/view.js
@@ -147,7 +147,9 @@ const ViewContainer = new Lang.Class({
this._loadMore.widget.hide();
this._connectView();
grilo.connect('ready', Lang.bind(this, this.populate));
- this.header_bar.connect('state-changed', Lang.bind(this, this._onStateChanged))
+ this.header_bar.connect('state-changed', Lang.bind(this, this._onStateChanged));
+ 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);
},
_onStateChanged: function() {
@@ -202,8 +204,6 @@ const ViewContainer = new Lang.Class({
_addItem: function(source, param, item) {
if (item != null) {
this._offset += 1;
- let path = "/usr/share/icons/gnome/scalable/places/folder-music-symbolic.svg";
- let icon = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, this._iconHeight, this._iconWidth, true);
var iter = this._model.append();
var artist = "Unknown"
if (item.get_author() != null)
@@ -216,7 +216,7 @@ const ViewContainer = new Lang.Class({
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._symbolicIcon, item]
);
GLib.idle_add(300, Lang.bind(this, this._updateAlbumArt, item, iter));
}
--
1.8.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment