[gnome-music] improve setPlaying and onPlayBtnToggled
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] improve setPlaying and onPlayBtnToggled
- Date: Thu, 2 May 2013 15:53:59 +0000 (UTC)
commit 303600f760a4a399385b3e8a700ea2e12f473f5c
Author: Eslam Mostafa <cseslam src gnome org>
Date: Thu May 2 03:54:15 2013 +0200
improve setPlaying and onPlayBtnToggled
Signed-off-by: Seif Lotfy <seif lotfy com>
src/player.js | 34 +++++++++++++++-------------------
src/view.js | 2 +-
src/widgets.js | 2 +-
3 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/src/player.js b/src/player.js
index 16a514b..d08ed49 100644
--- a/src/player.js
+++ b/src/player.js
@@ -98,12 +98,8 @@ const Player = new Lang.Class({
this._setupView();
},
- setPlaying: function(mode) {
- if( mode == true ) {
- this.play_btn.set_active(true);
- } else if ( mode == false ) {
- this.play_btn.set_active(false);
- }
+ setPlaying: function() {
+ this.play_btn.set_active(true);
},
load_next_track: function(){
@@ -194,7 +190,7 @@ const Player = new Lang.Class({
playNext: function () {
this.stop();
this.load_next_track();
- this.setPlaying(true);
+ this.setPlaying();
},
playPrevious: function () {
@@ -203,7 +199,7 @@ const Player = new Lang.Class({
let savedTrack;
if (RepeatType.SONG == this.repeat){
this.stop();
- this.setPlaying(true);
+ this.setPlaying();
return;
} else
savedTrack = this.currentTrack.copy()
@@ -223,7 +219,7 @@ const Player = new Lang.Class({
}
}
this.stop();
- this.setPlaying(true);
+ this.setPlaying();
},
setPlaylist: function (type, id, model, iter, field) {
@@ -305,18 +301,18 @@ const Player = new Lang.Class({
},
_onPlayBtnToggled: function(btn) {
- if(this.play_btn.get_active() == true ) {
- if (this.player.get_state(1)[1] != Gst.State.PAUSED) {
- this.play_btn.set_image(this._pause_image);
- this.pause();
- } else {
- this.play_btn.set_image(this._play_image);
+ if(btn.get_active() == true ) {
+ if (this.player.get_state(1)[1] == Gst.State.NULL) {
+ btn.set_image(this._pause_image);
this.play();
}
- } else {
- this.play_btn.set_image(this._pause_image);
- this.play_btn.show_all();
- this.pause();
+ else if (this.player.get_state(1)[1] == Gst.State.PAUSED) {
+ btn.set_image(this._pause_image);
+ this.play();
+ } else {
+ btn.set_image(this._play_image);
+ this.pause();
+ }
}
},
diff --git a/src/view.js b/src/view.js
index 1f6414d..b73e63f 100644
--- a/src/view.js
+++ b/src/view.js
@@ -331,7 +331,7 @@ const Songs = new Lang.Class({
_onItemActivated: function (widget, id, path) {
this.player.setPlaylist("Songs", null, this._model, this._model.get_iter(path)[1], 5);
- this.player.setPlaying(true);
+ this.player.setPlaying();
},
_addItem: function(source, param, item) {
diff --git a/src/widgets.js b/src/widgets.js
index b12a92e..1701127 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -71,7 +71,7 @@ const AlbumWidget = new Lang.Class({
this.model.set_value(this.iterToClean, 3, false);
}
this.player.setPlaylist("Album", this.album, this.model, this.model.get_iter(path)[1], 5);
- this.player.setPlaying(true);
+ this.player.setPlaying();
})
);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]