[gnome-music] The playlist songs titles are now clickable



commit ac84e3213f1cfdb3626b5e79cc5c19602642f933
Author: CÃsar GarcÃa Tapia <cesar garcia tapia openshine com>
Date:   Mon Oct 29 19:38:39 2012 +0100

    The playlist songs titles are now clickable

 src/Makefile.am                |    1 +
 src/music-album-info-box.vala  |    6 ++--
 src/music-clickable-label.vala |   61 ++++++++++++++++++++++++++++++++++++++++
 src/music-playlist-songs.vala  |   11 ++----
 4 files changed, 69 insertions(+), 10 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 62f55f2..5c016a8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,7 @@ vala_sources = \
 		music-album-info-box.vala	\
 		music-playlist-songs.vala	\
 		music-browse-history.vala	\
+		music-clickable-label.vala 	\
 		music-utils.vala			\
 		album-art-cache.vala		\
 		main.vala               	\
diff --git a/src/music-album-info-box.vala b/src/music-album-info-box.vala
index da1c190..18aa362 100644
--- a/src/music-album-info-box.vala
+++ b/src/music-album-info-box.vala
@@ -24,7 +24,7 @@ private class Music.AlbumInfoBox {
     private Gtk.Box box;
 
     private Gtk.Image art_image;
-    private Gtk.Label artist_label;
+    private Music.ClickableLabel artist_label;
     private Gtk.Label album_label;
     private Gtk.Label date_label;
     private Gtk.Label length_label;
@@ -41,8 +41,8 @@ private class Music.AlbumInfoBox {
         art_image = new Gtk.Image ();
         box.pack_start (art_image, false, false);
 
-        artist_label = new Gtk.Label ("Artist name");
-        artist_label.get_style_context ().add_class ("music-albuminfo-artist");
+        artist_label = new Music.ClickableLabel ("Artist name");
+        artist_label.set_style ("music-albuminfo-artist");
         box.pack_start (artist_label, false, false);
 
         album_label = new Gtk.Label ("Album name");
diff --git a/src/music-clickable-label.vala b/src/music-clickable-label.vala
new file mode 100644
index 0000000..e99fbaf
--- /dev/null
+++ b/src/music-clickable-label.vala
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2012 Cesar Garcia Tapia <tapia openshine com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using Gtk;
+using Gdk;
+
+private class Music.ClickableLabel : Gtk.EventBox {
+	public signal void clicked ();
+
+	private Gtk.Label label;
+
+ 	public ClickableLabel (string text) {
+ 		Gtk.HBox hbox = new Gtk.HBox (false, 0);
+ 		this.add (hbox);
+
+ 		label = new Gtk.Label (text);
+ 		hbox.add (label);
+
+ 		this.enter_notify_event.connect (() => {
+ 			Gdk.Cursor cursor = new Gdk.Cursor (Gdk.CursorType.HAND2);
+ 			this.get_window().set_cursor (cursor);
+ 			return false;
+ 		});
+
+ 		this.leave_notify_event.connect (() => {
+ 			Gdk.Cursor cursor = new Gdk.Cursor (Gdk.CursorType.ARROW);
+ 			this.get_window().set_cursor (cursor);
+ 			return false;
+ 		});
+ 		this.button_release_event.connect (() => {
+ 			clicked ();
+ 			return false;
+ 		});
+ 	}
+
+ 	public void set_label (string text) {
+ 		label.set_label (text);
+ 	}
+
+ 	public void set_style (string style) {
+ 		label.get_style_context ().add_class (style);
+ 	}
+
+ 	public void set_alignment (float xalign, float yalign) {
+ 		label.set_alignment (xalign, yalign);
+ 	}
+ }
\ No newline at end of file
diff --git a/src/music-playlist-songs.vala b/src/music-playlist-songs.vala
index 9e78e91..213f7ec 100644
--- a/src/music-playlist-songs.vala
+++ b/src/music-playlist-songs.vala
@@ -88,24 +88,21 @@ private class Music.PlaylistSongs {
     private void load_item_cb (Grl.Media? media,
                                uint remaining) {
         if (media != null) {
-            var title_string = media.get_title ();
-            var title = new Gtk.Label (null);
-            title.set_markup (@"<a href=''>$title_string</a>");
+            var title = new Music.ClickableLabel (media.get_title());
             title.set_alignment (0, (float)0.5);
-            title.activate_link.connect (() => {
+            title.clicked.connect (() => {
                 on_title_clicked (media);
-                return true;
             });
-            title.show();
 
             var duration = media.get_duration ();
             var length = new Gtk.Label (Music.seconds_to_string (duration));
             length.set_alignment (1, (float)0.5);
             length.get_style_context ().add_class ("dim-label");
-            length.show();
 
             grid.attach_next_to (title, null, Gtk.PositionType.BOTTOM, 1, 1);
             grid.attach_next_to (length, title, Gtk.PositionType.RIGHT, 1, 1);
+
+            grid.show_all ();
         }
     }
 



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