~ciaran-liedeman/exaile/suspendplugin

« back to all changes in this revision

Viewing changes to xlgui/widgets/playback.py

  • Committer: Mathias Brodala
  • Date: 2011-02-08 20:48:57 UTC
  • Revision ID: info@noctus.net-20110208204857-4rdh79z15fprv8x3
* Add common idiom clamp() to, well, clamp a value

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
    settings,
38
38
    xdg
39
39
)
 
40
from xl.common import clamp
40
41
from xl.nls import gettext as _
41
42
from xlgui.widgets import menu
42
43
 
1238
1239
        tooltip = _('Muted')
1239
1240
 
1240
1241
        if volume > 0:
1241
 
            i = max(0, min(int(round(volume * 2), len(self.icon_names) - 1)))
 
1242
            i = clamp(int(round(volume * 2)), 0, len(self.icon_names) - 1)
1242
1243
            icon_name = 'audio-volume-%s' % self.icon_names[i]
1243
1244
            #TRANSLATORS: Volume percentage
1244
1245
            tooltip = _('%d%%') % (volume * 100)