Merge lp:~sil/rhythmbox-ubuntuone/play-library-signal into lp:~sil/rhythmbox-ubuntuone/trunk

Proposed by Stuart Langridge
Status: Merged
Approved by: Stuart Langridge
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~sil/rhythmbox-ubuntuone/play-library-signal
Merge into: lp:~sil/rhythmbox-ubuntuone/trunk
Diff against target: 65 lines (+28/-0)
1 file modified
umusicstore/__init__.py (+28/-0)
To merge this branch: bzr merge lp:~sil/rhythmbox-ubuntuone/play-library-signal
Reviewer Review Type Date Requested Status
Rodrigo Moya (community) Approve
Stuart Langridge Pending
Review via email: mp+19481@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stuart Langridge (sil) wrote :

Receive play-library signal from music store widget; switch view to library, select the clicked song, and play it

Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Couldn't test because can't buy free songs from Spain when using the UK shop, so code looks good, and approving based on code review

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'umusicstore/__init__.py'
2--- umusicstore/__init__.py 2010-02-11 13:48:02 +0000
3+++ umusicstore/__init__.py 2010-02-17 13:01:16 +0000
4@@ -68,12 +68,34 @@
5 shell.append_source(self.source, None) # Add the source to the list
6 self.shell = shell
7 self.source.connect("preview-mp3", self.play_preview_mp3)
8+ self.source.connect("play-library", self.play_library)
9 self.add_u1_library()
10
11 def deactivate(self, shell):
12 """Plugin shutdown."""
13 pass
14
15+ def play_library(self, source, path):
16+ """Switch to and start playing a song from the library"""
17+ uri = U1LIBRARYPATH + "/" + urllib.quote(path)
18+ entry = self.shell.props.db.entry_lookup_by_location(uri)
19+ if not entry:
20+ print "couldn't find entry", uri
21+ return
22+ libsrc = self.shell.props.library_source
23+ genre_view, artist_view, album_view = libsrc.get_property_views()
24+ song_view = libsrc.get_entry_view()
25+ artist = self.shell.props.db.entry_get(entry, rhythmdb.PROP_ARTIST)
26+ album = self.shell.props.db.entry_get(entry, rhythmdb.PROP_ALBUM)
27+ self.shell.props.sourcelist.select(libsrc)
28+ artist_view.set_selection([artist])
29+ album_view.set_selection([album])
30+ song_view.scroll_to_entry(entry)
31+ player = self.shell.get_player()
32+ player.stop()
33+ player.play()
34+ player.play_entry(entry, libsrc)
35+
36 def play_preview_mp3(self, source, url, title):
37 """Play a passed mp3; signal handler for preview-mp3 signal."""
38 # create an entry, don't save it, and play it
39@@ -113,6 +135,7 @@
40 # it so that the plugin gets it, because the plugin actually plays the mp3
41 __gsignals__ = {
42 "preview-mp3": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (str, str)),
43+ "play-library": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (str,)),
44 }
45
46 def __init__(self):
47@@ -253,6 +276,7 @@
48 self.browser.set_no_show_all(True)
49 self.browser.set_property("visible", True)
50 self.browser.connect("preview-mp3", self.re_emit_preview)
51+ self.browser.connect("play-library", self.re_emit_playlibrary)
52
53 def do_impl_can_pause(self):
54 """Implementation can pause.
55@@ -263,6 +287,10 @@
56 """Handle the preview-mp3 signal and re-emit it to the rb.Plugin."""
57 self.emit("preview-mp3", url, title)
58
59+ def re_emit_playlibrary(self, widget, path):
60+ """Handle the play-library signal and re-emit it to the rb.Plugin."""
61+ self.emit("play-library", path)
62+
63 def do_set_property(self, property, value):
64 """Allow property settings to handle the plugin call."""
65 if property.name == 'plugin':

Subscribers

People subscribed via source and target branches

to all changes: