[gnome-music/freeze-break: 88/107] view: Play first song when Play is selected in Playlists view menu



commit 235c95bd4ba957e302392b07a6f001c82fcd3c28
Author: Arnel A. Borja <arnelborja src gnome org>
Date:   Sun Sep 8 15:10:14 2013 +0800

    view: Play first song when Play is selected in Playlists view menu

 gnomemusic/view.py |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/gnomemusic/view.py b/gnomemusic/view.py
index c7eda20..ec46a19 100644
--- a/gnomemusic/view.py
+++ b/gnomemusic/view.py
@@ -641,6 +641,8 @@ class Playlist(ViewContainer):
         self.name_label = builder.get_object('playlist_name')
         self.songs_count_label = builder.get_object('songs_count')
         self.menubutton = builder.get_object('playlist_menubutton')
+        self.play_menuitem = builder.get_object('menuitem_play')
+        self.play_menuitem.connect('activate', self._on_play_activate)
         self._grid.insert_row(0)
         self._grid.attach(self.headerbar, 0, 0, 1, 1)
 
@@ -872,6 +874,16 @@ class Playlist(ViewContainer):
         self.playlists_sidebar.set_sensitive(not self.header_bar._selectionMode)
         self.menubutton.set_sensitive(not self.header_bar._selectionMode)
 
+    def _on_play_activate(self, menuitem, data=None):
+        _iter = self._model.get_iter_first()
+        if not _iter:
+            return
+
+        self.view.get_generic_view().get_selection().\
+            select_path(self._model.get_path(_iter))
+        self.view.emit('item-activated', '0',
+                       self._model.get_path(_iter))
+
     def populate(self):
         for item in self.playlists_list:
             self._add_item(item)


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