Skip to content

Commit

Permalink
Merge branch 'other/lichray/fix-playlist-menu' into integration
Browse files Browse the repository at this point in the history
  • Loading branch information
multani committed Apr 6, 2012
2 parents 92449ef + f7233ee commit d575dc4
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
*.py[co]
*.swp
*~
mmkeys.so
sonata/sonata
mo/
Expand Down
7 changes: 7 additions & 0 deletions README.rst
Expand Up @@ -105,6 +105,13 @@ Currently, the following things have been changed since the Berlios's version:

This is the `refactor-consts` branch.

* Fix the population of the "Save to playlist" context menu, which didn't
contain the current playlist of MPD.
Fix also the name of the playlists in this menu, if their were containing an
underscore. There are now displayed correctly.

Thanks to Zhihao Yuan for the fixes!

Personal todo list
------------------

Expand Down
20 changes: 15 additions & 5 deletions sonata/main.py
Expand Up @@ -1046,12 +1046,22 @@ def populate_profiles_for_menu(self):

profile_names = [_("MPD_HOST/PORT")] if host \
or port else self.config.profile_names
actions = [(str(i), None,
"[%s] %s" % (i + 1, name.replace("_", "__")), None,
None, i)

actions = [
(str(i),
None,
"[%d] %s" % (i + 1, ui.quote_label(name)),
None,
None,
i)
for i, name in enumerate(profile_names)]
actions.append(('disconnect', None, _('Disconnect'), None, None,
len(self.config.profile_names)))
actions.append((
'disconnect',
None,
_('Disconnect'),
None,
None,
len(self.config.profile_names)))

active_radio = 0 if host or port else self.config.profile_num
if not self.conn:
Expand Down
2 changes: 1 addition & 1 deletion sonata/mpdhelper.py
Expand Up @@ -66,7 +66,7 @@ def version(self):
# after the initial client connection.
try:
version = getattr(self._client, "mpd_version", "0.0")
return version.split(".")
return tuple(int(x) for x in version.split("."))
except:
# XXX what exception are we expecting here!?
return (0, 0)
Expand Down
12 changes: 7 additions & 5 deletions sonata/playlists.py
Expand Up @@ -101,11 +101,13 @@ def populate_playlists_for_menu(self, playlistinfo):
self.actionGroupPlaylists = None
self.actionGroupPlaylists = gtk.ActionGroup('MPDPlaylists')
self.UIManager().ensure_update()
actions = [("Playlist: %s" % playlist.replace("&", ""),
gtk.STOCK_JUSTIFY_CENTER,
misc.unescape_html(playlist), None, None,
self.on_playlist_menu_click)
for playlist in playlistinfo]
actions = [
("Playlist: %s" % playlist.replace("&", ""),
gtk.STOCK_JUSTIFY_CENTER,
ui.quote_label(misc.unescape_html(playlist)),
None, None,
self.on_playlist_menu_click)
for playlist in playlistinfo]
self.actionGroupPlaylists.add_actions(actions)
uiDescription = """
<ui>
Expand Down
8 changes: 8 additions & 0 deletions sonata/ui.py
Expand Up @@ -231,6 +231,14 @@ def hide(widget):
def focus(widget):
widget.grab_focus()

def quote_label(label_value):
"""Quote the content of a label so that it's safe to display."""

# Don't inadvertently create accelerators if the value contains a "_"
result = label_value.replace("_", "__")

return result

def set_widths_equal(widgets):
# Assigns the same width to all passed widgets in the list, where
# the width is the maximum width across widgets.
Expand Down

0 comments on commit d575dc4

Please sign in to comment.