Merge lp:~alphapapa/pithos/908389-osdtext into lp:~kevin-mehall/pithos/trunk

Proposed by Adam Porter
Status: Needs review
Proposed branch: lp:~alphapapa/pithos/908389-osdtext
Merge into: lp:~kevin-mehall/pithos/trunk
Diff against target: 174 lines (+58/-15)
4 files modified
bin/pithos (+15/-7)
data/ui/PithosWindow.ui (+2/-2)
pithos/plugins/notification_icon.py (+11/-2)
pithos/plugins/notify.py (+30/-4)
To merge this branch: bzr merge lp:~alphapapa/pithos/908389-osdtext
Reviewer Review Type Date Requested Status
Kevin Mehall Pending
Review via email: mp+86855@code.launchpad.net
To post a comment you must log in.
lp:~alphapapa/pithos/908389-osdtext updated
183. By Adam Porter

Display album art icon in notification when unpausing. The icons display as question marks in KDE, anyway.

184. By Adam Porter

Adds heart and broken-heart icons (LGPL from Oxygen icons--need to add license somewhere?).
Puts icon at right side of notify OSD, but still experimenting.

185. By Adam Porter

I can't get the icon to align to the middle of the text, or vice-versa. Maybe someone else can.

186. By Adam Porter

Added 16px versions of icons.
Switched love/unlove to heart/broken-heart.
CellRendererAlbumArt.on_render() takes filenames or stock icons.

187. By Adam Porter

Use 'gtk' instead of 'stock' to determine stock icons--not all have 'stock' in their names.

188. By Adam Porter

Add unlove for loved songs.
Use cancel icon for ban, not heartbroken.

Unmerged revisions

188. By Adam Porter

Add unlove for loved songs.
Use cancel icon for ban, not heartbroken.

187. By Adam Porter

Use 'gtk' instead of 'stock' to determine stock icons--not all have 'stock' in their names.

186. By Adam Porter

Added 16px versions of icons.
Switched love/unlove to heart/broken-heart.
CellRendererAlbumArt.on_render() takes filenames or stock icons.

185. By Adam Porter

I can't get the icon to align to the middle of the text, or vice-versa. Maybe someone else can.

184. By Adam Porter

Adds heart and broken-heart icons (LGPL from Oxygen icons--need to add license somewhere?).
Puts icon at right side of notify OSD, but still experimenting.

183. By Adam Porter

Display album art icon in notification when unpausing. The icons display as question marks in KDE, anyway.

182. By Adam Porter

Make artist bold and album italic in OSD.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pithos'
2--- bin/pithos 2011-12-15 00:15:02 +0000
3+++ bin/pithos 2011-12-25 13:04:23 +0000
4@@ -76,13 +76,17 @@
5
6 ALBUM_ART_SIZE = 96
7 ALBUM_ART_X_PAD = 6
8+LOVE_ICON = 'media/heart.png'
9+UNLOVE_ICON = 'media/heart-broken.png'
10+BAN_ICON = gtk.STOCK_CANCEL
11+TIRED_ICON = gtk.STOCK_JUMP_TO
12
13 class CellRendererAlbumArt(gtk.GenericCellRenderer):
14 def __init__(self):
15 self.__gobject_init__()
16 self.icon = None
17 self.pixbuf = None
18- self.rate_bg = gtk.gdk.pixbuf_new_from_file(os.path.join(getdatapath(), 'media', 'rate_bg.png'))
19+ self.rate_bg = gtk.gdk.pixbuf_new_from_file(os.path.join(getdatapath(), 'media', 'rate_bg.png')) # FIXME: use get_data_file() ?
20
21 __gproperties__ = {
22 'icon': (str, 'icon', 'icon', '', gobject.PARAM_READWRITE),
23@@ -102,9 +106,13 @@
24 x = cell_area.x+(cell_area.width-self.rate_bg.get_width()) - ALBUM_ART_X_PAD # right
25 y = cell_area.y+(cell_area.height-self.rate_bg.get_height()) # bottom
26 window.draw_pixbuf(None, self.rate_bg, 0, 0, x, y, width=-1, height=-1, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
27-
28- icon = widget.style.lookup_icon_set(self.icon)
29- pixbuf = icon.render_icon(widget.style, widget.get_direction(), gtk.STATE_ACTIVE, gtk.ICON_SIZE_MENU, widget, detail=None)
30+
31+ if 'gtk' in self.icon:
32+ icon = widget.style.lookup_icon_set(self.icon)
33+ pixbuf = icon.render_icon(widget.style, widget.get_direction(), gtk.STATE_ACTIVE, gtk.ICON_SIZE_MENU, widget, detail=None)
34+ else:
35+ pixbuf = gtk.gdk.pixbuf_new_from_file(get_data_file(self.icon))
36+
37 x = cell_area.x+(cell_area.width-pixbuf.get_width())-5 - ALBUM_ART_X_PAD # right
38 y = cell_area.y+(cell_area.height-pixbuf.get_height())-5 # bottom
39 window.draw_pixbuf(None, pixbuf, 0, 0, x, y, width=-1, height=-1, dither=gtk.gdk.RGB_DITHER_NORMAL, x_dither=0, y_dither=0)
40@@ -574,11 +582,11 @@
41
42 def song_icon(self, song):
43 if song.tired:
44- return gtk.STOCK_JUMP_TO
45+ return TIRED_ICON
46 if song.rating == RATE_LOVE:
47- return gtk.STOCK_ABOUT
48+ return LOVE_ICON
49 if song.rating == RATE_BAN:
50- return gtk.STOCK_CANCEL
51+ return BAN_ICON
52
53 def update_song_row(self, song = None):
54 if song is None:
55
56=== added file 'data/media/heart-broken.png'
57Binary files data/media/heart-broken.png 1970-01-01 00:00:00 +0000 and data/media/heart-broken.png 2011-12-25 13:04:23 +0000 differ
58=== added file 'data/media/heart-broken16.png'
59Binary files data/media/heart-broken16.png 1970-01-01 00:00:00 +0000 and data/media/heart-broken16.png 2011-12-25 13:04:23 +0000 differ
60=== added file 'data/media/heart.png'
61Binary files data/media/heart.png 1970-01-01 00:00:00 +0000 and data/media/heart.png 2011-12-25 13:04:23 +0000 differ
62=== added file 'data/media/heart16.png'
63Binary files data/media/heart16.png 1970-01-01 00:00:00 +0000 and data/media/heart16.png 2011-12-25 13:04:23 +0000 differ
64=== modified file 'data/ui/PithosWindow.ui'
65--- data/ui/PithosWindow.ui 2011-11-09 15:44:39 +0000
66+++ data/ui/PithosWindow.ui 2011-12-25 13:04:23 +0000
67@@ -272,7 +272,7 @@
68 </object>
69 <object class="GtkImage" id="image2">
70 <property name="visible">True</property>
71- <property name="stock">gtk-about</property>
72+ <property name="file">data/media/heart16.png</property>
73 </object>
74 <object class="GtkImage" id="image3">
75 <property name="visible">True</property>
76@@ -462,7 +462,7 @@
77 </object>
78 <object class="GtkImage" id="image12">
79 <property name="visible">True</property>
80- <property name="stock">gtk-about</property>
81+ <property name="file">data/media/heart-broken16.png</property>
82 </object>
83 <object class="GtkImage" id="image13">
84 <property name="visible">True</property>
85
86=== modified file 'pithos/plugins/notification_icon.py'
87--- pithos/plugins/notification_icon.py 2010-09-08 18:36:53 +0000
88+++ pithos/plugins/notification_icon.py 2011-12-25 13:04:23 +0000
89@@ -59,7 +59,10 @@
90 item.set_active(True)
91 elif icon:
92 item = gtk.ImageMenuItem(text)
93- item.set_image(gtk.image_new_from_stock(icon, gtk.ICON_SIZE_MENU))
94+ if 'gtk' in icon:
95+ item.set_image(gtk.image_new_from_stock(icon, gtk.ICON_SIZE_MENU))
96+ else:
97+ item.set_image(gtk.image_new_from_file(icon))
98 else:
99 item = gtk.MenuItem(text)
100 item.connect('activate', action)
101@@ -71,9 +74,15 @@
102 # We have to add another entry for show / hide Pithos window
103 self.visible_check = button("Show Pithos", self._toggle_visible, 'check')
104
105+ # Make menu items
106 self.playpausebtn = button("Pause", self.window.playpause, gtk.STOCK_MEDIA_PAUSE)
107 button("Skip", self.window.next_song, gtk.STOCK_MEDIA_NEXT)
108- button("Love", (lambda *i: self.window.love_song()), gtk.STOCK_ABOUT)
109+
110+ if self.window.current_song.rating: # == None if not loved
111+ button("Unlove", (lambda *i: self.window.unrate_song()), get_data_file('media/heart-broken16.png'))
112+ else:
113+ button("Love", (lambda *i: self.window.love_song()), get_data_file('media/heart16.png'))
114+
115 button("Ban", (lambda *i: self.window.ban_song()), gtk.STOCK_CANCEL)
116 button("Tired", (lambda *i: self.window.tired_song()), gtk.STOCK_JUMP_TO)
117 button("Quit", self.window.quit, gtk.STOCK_QUIT )
118
119=== modified file 'pithos/plugins/notify.py'
120--- pithos/plugins/notify.py 2011-11-09 14:58:43 +0000
121+++ pithos/plugins/notify.py 2011-12-25 13:04:23 +0000
122@@ -26,14 +26,36 @@
123 pynotify.init('pithos')
124 self.notification = pynotify.Notification("Pithos","Pithos")
125
126+ # check notification capabilities for HTML use
127+ self.caps = pynotify.get_server_caps()
128+
129 def on_enable(self):
130 self.song_callback_handle = self.window.connect("song-changed", self.song_changed)
131 self.state_changed_handle = self.window.connect("user-changed-play-state", self.playstate_changed)
132+ # TODO: connect to song-rating-changed so the notification can have the heart added/removed if it's still on-screen when rating is changed?
133
134 def set_for_song(self, song):
135 self.notification.clear_hints()
136- msg = escape("by %s from %s"%(song.artist, song.album))
137- self.notification.update(song.title, msg, 'audio-x-generic')
138+
139+ # Escape special chars
140+ title = escape(song.title)
141+ artist = escape(song.artist)
142+ album = escape(song.album)
143+
144+ # Don't use HTML if by some chance the notification agent/daemon doesn't support it
145+ if self.caps and 'body-markup' in self.caps:
146+
147+ if song.rating: # == 'love' if loved, None if not
148+ heart = "<img src='%s'>&nbsp;" % get_data_file('media/heart16.png')
149+ else:
150+ heart = ''
151+
152+ title = ("%s<b>%s</b>" % (heart, title))
153+ msg = "&nbsp;<b>%s</b><br>&nbsp;<i>%s</i>" % (artist, album)
154+ else:
155+ msg = "by %s on %s" % (artist, album)
156+
157+ self.notification.update(title, msg, 'audio-x-generic')
158
159 def song_changed(self, window, song):
160 if not self.window.is_active():
161@@ -48,8 +70,12 @@
162 def playstate_changed(self, window, state):
163 if not self.window.is_active():
164 self.set_for_song(window.current_song)
165- if state:
166- self.notification.props.icon_name = 'gtk-media-play-ltr'
167+
168+ if state: # state means playing, apparently
169+ if window.current_song.art_pixbuf:
170+ self.notification.set_icon_from_pixbuf(window.current_song.art_pixbuf)
171+ else:
172+ self.notification.props.icon_name = 'gtk-media-play-ltr'
173 else:
174 self.notification.props.icon_name = 'gtk-media-pause'
175