[gnome-music] Previous/Next buttons working.



commit 5e1a989b6e475460e75bac90b255b51933d82423
Author: CÃsar GarcÃa Tapia <cesar garcia tapia openshine com>
Date:   Tue Oct 30 14:40:49 2012 +0100

    Previous/Next buttons working.

 src/music-app.vala      |    3 +--
 src/music-player.vala   |   14 ++++++++++----
 src/music-playlist.vala |    7 +++++++
 3 files changed, 18 insertions(+), 6 deletions(-)
---
diff --git a/src/music-app.vala b/src/music-app.vala
index 68277f8..3de9ce9 100644
--- a/src/music-app.vala
+++ b/src/music-app.vala
@@ -235,12 +235,11 @@ private class Music.App {
     }
 
     private void on_player_need_next () {
-        debug ("NEED_NEXT");
         playlist.load_next();
     }
 
     private void on_player_need_previous () {
-
+        playlist.load_previous();
     }
 
     private void on_browse_history_changed () {
diff --git a/src/music-player.vala b/src/music-player.vala
index b855441..d42fc54 100644
--- a/src/music-player.vala
+++ b/src/music-player.vala
@@ -131,8 +131,7 @@ private class Music.Player: GLib.Object {
 
         prev_btn = new Gtk.Button ();
         prev_btn.set_image (new Gtk.Image.from_icon_name ("media-skip-backward-symbolic", IconSize.BUTTON));
-        prev_btn.clicked.connect ((button) => {
-        });
+        prev_btn.clicked.connect (on_prev_btn_clicked);
         toolbar_start.pack_start (prev_btn, false, false, 0);
 
         play_btn = new PlayPauseButton ();
@@ -141,8 +140,7 @@ private class Music.Player: GLib.Object {
 
         next_btn = new Gtk.Button ();
         next_btn.set_image (new Gtk.Image.from_icon_name ("media-skip-forward-symbolic", IconSize.BUTTON));
-        next_btn.clicked.connect ((button) => {
-        });
+        next_btn.clicked.connect (on_next_btn_clicked);
         toolbar_start.pack_start (next_btn, false, false, 0);
 
         var toolbar_song_info = new Gtk.Box (Orientation.HORIZONTAL, 0);
@@ -253,6 +251,14 @@ private class Music.Player: GLib.Object {
         }
     }
 
+    private void on_next_btn_clicked (Gtk.Button button) {
+        need_next ();
+    }
+
+    private void on_prev_btn_clicked (Gtk.Button button) {
+        need_previous ();
+    }
+
     private void set_duration (uint duration) {
         progress_scale.set_range (0.0, (double) (duration * Gst.SECOND));
         progress_scale.set_value (0.0);
diff --git a/src/music-playlist.vala b/src/music-playlist.vala
index 54f6a19..de2992f 100644
--- a/src/music-playlist.vala
+++ b/src/music-playlist.vala
@@ -43,6 +43,13 @@ private class Music.Playlist: Object, Gee.Iterable<Grl.Media> {
 		}
 	}
 
+	public void load_previous () {
+		if (current_index > 0) {
+			current_index--;
+			song_selected (list[current_index], current_index);	
+		}
+	}
+
 	public void load_album (Grl.Media media) {
 		if (media is Grl.MediaBox) {
 			list.clear();



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