[gnome-music] Improve initial startup time by lazy loading views
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Improve initial startup time by lazy loading views
- Date: Fri, 7 Jun 2013 09:05:21 +0000 (UTC)
commit 952588aec1cf7e6dd86552847c358db7aa99d444
Author: Seif Lotfy <seif lotfy com>
Date: Fri Jun 7 00:57:55 2013 +0200
Improve initial startup time by lazy loading views
Updated tests to create a stack and set visible child there. Removed duplicated function
https://bugzilla.gnome.org/show_bug.cgi?id=701764
src/view.js | 18 ++++++++++++++++--
tests/tests_albumPlayback.js | 7 ++++++-
tests/tests_artistsPlayback.js | 7 ++++++-
3 files changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/src/view.js b/src/view.js
index 3f4aff9..6959da6 100644
--- a/src/view.js
+++ b/src/view.js
@@ -106,7 +106,6 @@ const ViewContainer = new Lang.Class({
this._cursor = null;
this.header_bar = header_bar;
this.title = title;
-
this.add(this._grid)
this.show_all();
@@ -114,10 +113,25 @@ const ViewContainer = new Lang.Class({
this._loadMore.widget.hide();
this._connectView();
this._symbolicIcon = albumArtCache.makeDefaultIcon(this._iconHeight, this._iconWidth);
- grilo.connect('ready', Lang.bind(this, this.populate));
+
+ this._init = false;
+ grilo.connect('ready', Lang.bind(this, function() {
+ if (this.header_bar.get_stack().get_visible_child() == this && this._init == false)
+ this._populate();
+ this.header_bar.get_stack().connect('notify::visible-child',
+ Lang.bind(this, function(widget, param) {
+ if (this == widget.get_visible_child() && !this._init)
+ this._populate();
+ }));
+ }));
this.header_bar.connect('state-changed', Lang.bind(this, this._onStateChanged))
},
+ _populate: function() {
+ this._init = true;
+ this.populate();
+ },
+
_onStateChanged: function() {
},
diff --git a/tests/tests_albumPlayback.js b/tests/tests_albumPlayback.js
index 13e211a..7e6d89d 100644
--- a/tests/tests_albumPlayback.js
+++ b/tests/tests_albumPlayback.js
@@ -35,7 +35,12 @@ function getAlbumView() {
const Player = imports.player;
let toolbar = new Toolbar.Toolbar();
let player = new Player.Player();
- return new AlbumView(toolbar, player);
+ let stack = new Gtk.Stack();
+ toolbar.set_stack(stack);
+ view = new AlbumView(toolbar, player);
+ stack.add_titled(view, "Albums", "Albums");
+ stack.set_visible_child_name('Albums');
+ return view;
}
function testAlbumViewPlayback() {
diff --git a/tests/tests_artistsPlayback.js b/tests/tests_artistsPlayback.js
index 6f77b55..0deeb82 100644
--- a/tests/tests_artistsPlayback.js
+++ b/tests/tests_artistsPlayback.js
@@ -35,7 +35,12 @@ function getArtistView() {
const Player = imports.player;
let toolbar = new Toolbar.Toolbar();
let player = new Player.Player();
- return new ArtistView(toolbar, player);
+ let stack = new Gtk.Stack();
+ toolbar.set_stack(stack);
+ view = new ArtistView(toolbar, player);
+ stack.add_titled(view, "Artists", "Artists");
+ stack.set_visible_child_name('Artists');
+ return view;
}
function testArtistsViewPlayback() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]