Skip to content

Commit

Permalink
Merge branch 'consume-single' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Lashuk committed Aug 29, 2010
2 parents 1724133 + bf817ac commit e13db23
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
12 changes: 11 additions & 1 deletion sonata/cli.py
Expand Up @@ -7,7 +7,7 @@

# the mpd commands need a connection to server and exit without gui
mpd_cmds = ["play", "pause", "stop", "next", "prev", "pp", "info",
"status", "repeat", "random"]
"status", "repeat", "random", "single", "consume"]

class Args(object):
def __init__(self):
Expand All @@ -34,6 +34,8 @@ def parse(self, argv):
" pp %s" % _("toggle play/pause; plays if stopped"),
" repeat %s" % _("toggle repeat mode"),
" random %s" % _("toggle random mode"),
" single %s" % _("toggle single mode"),
" consume %s" % _("toggle consume mode"),
" info %s" % _("display current song info"),
" status %s" % _("display MPD status"),
))
Expand Down Expand Up @@ -168,6 +170,12 @@ def _execute_random(self):
def _execute_repeat(self):
self._execute_bool('repeat')

def _execute_single(self):
self._execute_bool('single')

def _execute_consume(self):
self._execute_bool('consume')

def _execute_pp(self):
if self.status['state'] in ['play']:
mpdh.call(self.client, 'pause', 1)
Expand Down Expand Up @@ -210,6 +218,8 @@ def _execute_status(self):

print "%s %s" % (_("Repeat:"), _("On") if self.status['repeat'] == '1' else _("Off"))
print "%s %s" % (_("Random:"), _("On") if self.status['random'] == '1' else _("Off"))
print "%s %s" % (_("Single:"), _("On") if self.status['single'] == '1' else _("Off"))
print "%s %s" % (_("Consume:"), _("On") if self.status['consume'] == '1' else _("Off"))
print "%s: %s/100" % (_("Volume"), self.status['volume'])
print "%s: %s %s" % (_('Crossfade'), self.status['xfade'],
gettext.ngettext('second', 'seconds',
Expand Down
27 changes: 26 additions & 1 deletion sonata/main.py
Expand Up @@ -160,6 +160,8 @@ def __init__(self, args, window=None, _sugar=False):
self.skip_on_profiles_click = False
self.last_repeat = None
self.last_random = None
self.last_single = None
self.last_consume = None
self.last_title = None
self.last_progress_frac = None
self.last_progress_text = None
Expand Down Expand Up @@ -299,6 +301,8 @@ def __init__(self, args, window=None, _sugar=False):
('showmenu', None, _('S_how Sonata'), None, None, self.on_withdraw_app_toggle, not self.config.withdrawn),
('repeatmenu', None, _('_Repeat'), None, None, self.on_repeat_clicked, False),
('randommenu', None, _('Rando_m'), None, None, self.on_random_clicked, False),
('singlemenu', None, _('S_ingle'), None, None, self.on_single_clicked, False),
('consumemenu', None, _('C_onsume'), None, None, self.on_consume_clicked, False),
]

toggle_tabactions = [
Expand Down Expand Up @@ -364,6 +368,8 @@ def __init__(self, args, window=None, _sugar=False):
<separator name="FM1"/>
<menuitem action="repeatmenu"/>
<menuitem action="randommenu"/>
<menuitem action="singlemenu"/>
<menuitem action="consumemenu"/>
<menu action="updatemenu">
<menuitem action="updateselectedmenu"/>
<menuitem action="updatefullmenu"/>
Expand Down Expand Up @@ -493,7 +499,9 @@ def __init__(self, args, window=None, _sugar=False):
self.window.add_accel_group(self.UIManager.get_accel_group())
self.mainmenu = self.UIManager.get_widget('/mainmenu')
self.randommenu = self.UIManager.get_widget('/mainmenu/randommenu')
self.consumemenu = self.UIManager.get_widget('/mainmenu/consumemenu')
self.repeatmenu = self.UIManager.get_widget('/mainmenu/repeatmenu')
self.singlemenu = self.UIManager.get_widget('/mainmenu/singlemenu')
self.imagemenu = self.UIManager.get_widget('/imagemenu')
self.traymenu = self.UIManager.get_widget('/traymenu')
self.librarymenu = self.UIManager.get_widget('/librarymenu')
Expand Down Expand Up @@ -1005,6 +1013,11 @@ def update_status(self):
self.repeatmenu.set_active(self.status['repeat'] == '1')
if not self.last_random or self.last_random != self.status['random']:
self.randommenu.set_active(self.status['random'] == '1')
if not self.last_single or self.last_single != self.status['single']:
self.singlemenu.set_active(self.status['single'] == '1')
if not self.last_consume or self.last_consume != self.status['consume']:
self.consumemenu.set_active(self.status['consume'] == '1')

if self.status['xfade'] == '0':
self.config.xfade_enabled = False
else:
Expand All @@ -1014,6 +1027,8 @@ def update_status(self):
self.config.xfade = 30
self.last_repeat = self.status['repeat']
self.last_random = self.status['random']
self.last_single = self.status['single']
self.last_consume = self.status['consume']
return
except:
pass
Expand Down Expand Up @@ -1399,7 +1414,7 @@ def menu_position(self, _menu):
def handle_change_status(self):
# Called when one of the following items are changed:
# 1. Current playlist (song added, removed, etc)
# 2. Repeat/random/xfade/volume
# 2. Repeat/random/single/consume/xfade/volume
# 3. Currently selected song in playlist
# 4. Status (playing/paused/stopped)
if self.status is None:
Expand Down Expand Up @@ -1819,6 +1834,8 @@ def update_infofile(self):
info_file.write('Volume: ' + self.status['volume'] + '\n')
info_file.write('Repeat: ' + self.status['repeat'] + '\n')
info_file.write('Random: ' + self.status['random'] + '\n')
info_file.write('Single: ' + self.status['single'] + '\n')
info_file.write('Consume: ' + self.status['consume'] + '\n')
info_file.close()
except:
pass
Expand Down Expand Up @@ -2774,6 +2791,14 @@ def on_random_clicked(self, widget):
if self.conn:
self._toggle_clicked('random', widget)

def on_single_clicked(self, widget):
if self.conn:
self._toggle_clicked('single', widget)

def on_consume_clicked(self, widget):
if self.conn:
self._toggle_clicked('consume', widget)

def setup_prefs_callbacks(self):
trayicon_available = HAVE_EGG or HAVE_STATUS_ICON
extras = preferences.Extras_cbs
Expand Down

0 comments on commit e13db23

Please sign in to comment.