[gnome-music] play button patch



commit 89b18738ef69ce91bc7e595b88906bd5df9d02bf
Author: Sai <suman sai14 gmail com>
Date:   Mon May 6 04:36:57 2013 +0530

    play button patch
    
    Signed-off-by: Seif Lotfy <seif lotfy com>

 data/PlayerToolbar.ui |    2 +-
 src/player.js         |   19 ++++++++++++-------
 src/widgets.js        |    1 +
 3 files changed, 14 insertions(+), 8 deletions(-)
---
diff --git a/data/PlayerToolbar.ui b/data/PlayerToolbar.ui
index e1845cc..187c429 100644
--- a/data/PlayerToolbar.ui
+++ b/data/PlayerToolbar.ui
@@ -71,7 +71,7 @@
                       </packing>
                     </child>
                     <child>
-                      <object class="GtkToggleButton" id="play_button">
+                      <object class="GtkButton" id="play_button">
                         <property name="width_request">55</property>
                         <property name="visible">True</property>
                         <property name="sensitive">False</property>
diff --git a/src/player.js b/src/player.js
index 9089bb4..227326e 100644
--- a/src/player.js
+++ b/src/player.js
@@ -52,6 +52,7 @@ const Player = new Lang.Class({
         this.playlistId = null;
         this.playlistField = null;
         this.currentTrack = null;
+        this._lastState = Gst.State.NULL;
         this.repeat = RepeatType.NONE;
         this.cache = AlbumArtCache.AlbumArtCache.getDefault();
 
@@ -84,13 +85,12 @@ const Player = new Lang.Class({
     },
 
     setPlaying: function(bool) {
-        this.playBtn.set_active(bool)
         if (bool) {
-            this.play()
+            this.play();
             this.playBtn.set_image(this._pauseImage);
         }
         else {
-            this.pause()
+            this.pause();
             this.playBtn.set_image(this._playImage);
         }
     },
@@ -241,7 +241,6 @@ const Player = new Lang.Class({
         this.eventBox = this._ui.get_object('eventBox');
         this.prevBtn = this._ui.get_object('previous_button');
         this.playBtn = this._ui.get_object('play_button');
-        this.playBtn.set_active(true)
         this.nextBtn = this._ui.get_object('next_button');
         this._playImage = this._ui.get_object('play_image');
         this._pauseImage = this._ui.get_object('pause_image');
@@ -264,10 +263,11 @@ const Player = new Lang.Class({
         replayMenu.show_all();
 
         this.prevBtn.connect("clicked", Lang.bind(this, this._onPrevBtnClicked));
-        this.playBtn.connect("toggled", Lang.bind(this, this._onPlayBtnToggled));
+        this.playBtn.connect("clicked", Lang.bind(this, this._onPlayBtnClicked));
         this.nextBtn.connect("clicked", Lang.bind(this, this._onNextBtnClicked));
         this.progressScale.connect("button-press-event", Lang.bind(this,
             function() {
+                this._lastState = this.player.get_state(1)[1];
                 this.player.set_state(Gst.State.PAUSED);
                 this._updatePositionCallback();
                 GLib.source_remove(this.timeout);
@@ -284,6 +284,7 @@ const Player = new Lang.Class({
                 this.onProgressScaleChangeValue(this.progressScale);
                 this.player.set_state(Gst.State.PLAYING);
                 this._updatePositionCallback();
+                this.player.set_state(this._lastState);
                 this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, Lang.bind(this, 
this._updatePositionCallback));
                 return false;
             }));
@@ -296,8 +297,12 @@ const Player = new Lang.Class({
         return (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds  < 10 ? "0" + seconds : seconds);
     },
 
-    _onPlayBtnToggled: function(btn) {
-       this.setPlaying(btn.get_active())
+    _onPlayBtnClicked: function(btn) {
+        if(this.player.get_state(1)[1] == Gst.State.PLAYING){
+            this.setPlaying(false);
+        }else{
+            this.setPlaying(true);
+        }
     },
 
     _onNextBtnClicked: function(btn) {
diff --git a/src/widgets.js b/src/widgets.js
index 9f33635..df6e162 100644
--- a/src/widgets.js
+++ b/src/widgets.js
@@ -64,6 +64,7 @@ const AlbumWidget = new Lang.Class({
         this.album=null;
         this.view.connect('item-activated', Lang.bind(this,
             function(widget, id, path) {
+                this.player.stop();
                 if (this.iterToClean && this.player.playlist_id == this.album){
                     let item = this.model.get_value(this.iterToClean, 5);
                     this.model.set_value(this.iterToClean, 0, item.get_title());


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]