[gnome-music] Emit playlist-item-changed signal with correct parameters
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] Emit playlist-item-changed signal with correct parameters
- Date: Mon, 29 Apr 2013 11:05:32 +0000 (UTC)
commit f6ff766882aadb1a92bbecaa6336d4d5442649d1
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Mon Apr 29 13:03:25 2013 +0200
Emit playlist-item-changed signal with correct parameters
src/player.js | 11 +++++------
src/widgets.js | 47 ++++++++++++++++++++++-------------------------
2 files changed, 27 insertions(+), 31 deletions(-)
---
diff --git a/src/player.js b/src/player.js
index 4f2a7db..47c0983 100644
--- a/src/player.js
+++ b/src/player.js
@@ -85,7 +85,6 @@ const Player = new Lang.Class({
Name: "Player",
_init: function() {
- Signals.addSignalMethods(Player.prototype);
this.playlist = null;
this.playlist_type = null;
this.playlist_id = null;
@@ -102,7 +101,7 @@ const Player = new Lang.Class({
this.currentTrack=null;
else
this.load( this.playlist.get_value( this.currentTrack, this.playlist_field));
- return true;
+ return false;
}));
this.bus = this.player.get_bus();
this.bus.add_signal_watch()
@@ -126,8 +125,6 @@ const Player = new Lang.Class({
load: function(media) {
var pixbuf;
- this.emit("playlist-item-changed", this.playlist, this.currentTrack);
-
this._setDuration(media.get_duration());
this.song_total_time_lbl.set_label(this.seconds_to_string (media.get_duration()));
this.progress_scale.sensitive = true;
@@ -136,7 +133,7 @@ const Player = new Lang.Class({
this.next_btn.set_sensitive(true);
// FIXME: site contains the album's name. It's obviously a hack to remove
-
+
pixbuf = this.cache.lookup (ART_SIZE, media.get_artist (), media.get_string(Grl.METADATA_KEY_ALBUM));
this.cover_img.set_from_pixbuf (pixbuf);
@@ -161,6 +158,8 @@ const Player = new Lang.Class({
this.artist_lbl.set_label("Unknown artist");
}
this.player.set_property("uri", media.get_url());
+
+ this.emit("playlist-item-changed", this.playlist, this.currentTrack);
},
play: function() {
@@ -252,7 +251,6 @@ const Player = new Lang.Class({
this.playlist_id = id;
this.currentTrack = iter;
this.playlist_field = field;
- this.emit("playlist-item-changed", this.playlist, this.currentTrack);
},
runningPlaylist: function (type, id, force){
@@ -451,3 +449,4 @@ const Player = new Lang.Class({
return false;
}
});
+Signals.addSignalMethods(Player.prototype);
diff --git a/src/widgets.js b/src/widgets.js
index 5f97307..bf1e18e 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -145,7 +145,7 @@ const AlbumWidget = new Lang.Class({
let cachedPlaylist = this.player.runningPlaylist("Album", album);
if (cachedPlaylist){
this.model = cachedPlaylist;
- this.updateModel(cachedPlaylist, this.player.currentTrack);
+ this.updateModel(this.player, cachedPlaylist, this.player.currentTrack);
} else {
this.model = Gtk.ListStore.new([
GObject.TYPE_STRING, /*title*/
@@ -184,38 +184,37 @@ const AlbumWidget = new Lang.Class({
this.ui.get_object("released_label_info").set_text(item.get_creation_date().get_year().toString());
else
this.ui.get_object("released_label_info").set_text("----");
- this.player.connect('playlist-item-changed', Lang.bind(this,
- function(player, playlist, iter) { this.updateModel(playlist, iter);}
- ));
+ this.player.connect('playlist-item-changed', Lang.bind(this, this.updateModel));
},
- updateModel: function(playlist, iter){
+
+ updateModel: function(player, playlist, iter){
//this is not our playlist, return
if (playlist != this.model){
return true;}
if (this.iterToClean){
let next_iter = iter.copy();
do {
- let item = this.model.get_value(next_iter, 5);
- this.model.set_value(next_iter, 0, item.get_title());
+ let item = playlist.get_value(next_iter, 5);
+ playlist.set_value(next_iter, 0, item.get_title());
// Hide now playing icon
- this.model.set_value(next_iter, 3, false);
- } while (this.model.iter_next(next_iter))
+ playlist.set_value(next_iter, 3, false);
+ } while (!playlist.iter_next(next_iter))
}
this.iterToClean = iter.copy();
// Highlight currently played song as bold
- let item = this.model.get_value(iter, 5);
- this.model.set_value(iter, 0, "<b>" + item.get_title() + "</b>");
+ let item = playlist.get_value(iter, 5);
+ playlist.set_value(iter, 0, "<b>" + item.get_title() + "</b>");
// Display now playing icon
- this.model.set_value(iter, 3, true);
+ playlist.set_value(iter, 3, true);
// grey out previous items
let prev_iter = iter.copy();
- while(this.model.iter_previous(prev_iter)){
- let item = this.model.get_value(prev_iter, 5);
+ while(playlist.iter_previous(prev_iter)){
+ let item = playlist.get_value(prev_iter, 5);
let title = "<span color='grey'>" + item.get_title() + "</span>";
- this.model.set_value(prev_iter, 0, title);
- this.model.set_value(prev_iter, 3, false);
+ playlist.set_value(prev_iter, 0, title);
+ playlist.set_value(prev_iter, 3, false);
}
return true;
},
@@ -254,26 +253,24 @@ const ArtistAlbums = new Lang.Class({
widgets.push(widget);
}
this.show_all();
- this.player.connect('playlist-item-changed', Lang.bind(this,
- function(player, playlist, iter) { this.updateModel(playlist, iter);}
- ));
+ this.player.connect('playlist-item-changed', Lang.bind(this, this.updateModel));
},
- updateModel: function(playlist, currentIter){
+ updateModel: function(player, playlist, currentIter){
//this is not our playlist, return
if (playlist != this.model){
return true;}
- let currentSong = this.model.get_value(currentIter, 5);
- let [res, iter] = this.model.get_iter_first();
+ let currentSong = playlist.get_value(currentIter, 5);
+ let [res, iter] = playlist.get_iter_first();
if (!res)
return true;
let songPassed = false;
let i = 0;
do{
i++;
- let song = this.model.get_value(iter, 5);
+ let song = playlist.get_value(iter, 5);
let songWidget = song.songWidget;
-
+
if (song == currentSong){
songWidget.nowPlayingSign.show();
songWidget.title.set_markup("<b>" + song.get_title() + "</b>");
@@ -285,7 +282,7 @@ const ArtistAlbums = new Lang.Class({
songWidget.nowPlayingSign.hide();
songWidget.title.set_markup("<span color='grey'>" + song.get_title() + "</span>");
}
- } while(this.model.iter_next(iter));
+ } while(playlist.iter_next(iter));
return true;
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]