Hi, long time now see! These patches were submitted some time ago, (weeks) but somehow got lost on the way (atleast -- I did not receive them).
idlebar_fix_width.patch: - Replaced width with p.width when no changes has taken place. audio_detach_fix_position_and_codeingguidelines.patch: - Fix position when overscan is used. - Fix some coding guidelines inconcistencies. tiny_osd_consider_idlebar.patch: - Respect the idlebar when considering position of msgs. controlpanel_addkey_fix_placement.patch: - Add key for toggling the control (set to "T") in keymap. - Fix placement, centering didn't behave well with overscan. idlebar_cdstatus_fix_x0.patch: - Fixes some x0 alignment problem on the idlebar - Fixed drawing with several removable medias - Added option for not drawing empty removable medias on idlebar Regards Viggo Fredriksen -- Avoid cliches like the plague. They're a dime a dozen.
diff -Naur freevo/src/audio/plugins/detach.py freevo_viggo/src/audio/plugins/detach.py --- freevo/src/audio/plugins/detach.py 2005-01-11 16:07:29.714643597 +0100 +++ freevo_viggo/src/audio/plugins/detach.py 2005-01-11 16:16:33.894833415 +0100 @@ -92,7 +92,7 @@ # eventhandler.register(self, PLAY_END) eventhandler.register(self, PLAY_START) eventhandler.register(self, DETACH_AUDIO_STOP) - + self.visible = False self.detached = False self.animation = None @@ -108,7 +108,7 @@ def draw(self, width, height): """ Dummy method for the idlebar, only sets - our boundries for now + boundries for the detached bar to draw to. """ if self.max_width > width: self.max_width = width @@ -127,19 +127,27 @@ def detach(self,a=None): + """ + Shows or hides the detached view + according to its current status. + """ + p = audioplayer() - # hide the detached player show the player + if self.visible: + # hide the detached player show the player self.hide() p.show() self.detached = False - #p.item.parent.menuw.show() - - # hide the audioplayer and show the itemmenu else: + # hide the audioplayer and show the itemmenu p.hide() - #p.item.parent.menuw.show() + + # hack to make it work properly with overscan + # resets the self.__x and self.__y variables + self.clear() + self.detached = True # show the detachbar @@ -148,23 +156,27 @@ def show(self): + """ + Shows the detached view. + """ if self.visible: return - # set up a controlbar # XXX FIXME: Add config-var for this + a_handler = audioplayer().eventhandler path = os.path.join(config.ICON_DIR, 'misc','audio_') - handlers = [('Prev', '%sprev.png' % path, audioplayer().eventhandler, PLAYLIST_PREV), - ('Rew', '%srew.png' % path, audioplayer().eventhandler, Event(SEEK, arg=-10)), - ('Pause', '%spause.png'% path, audioplayer().eventhandler, PAUSE ), - ('Play', '%splay.png' % path, audioplayer().eventhandler, PLAY ), - ('Stop', '%sstop.png' % path, self.eventhandler, STOP ), - ('FFwd', '%sffwd.png' % path, audioplayer().eventhandler, Event(SEEK, arg=10)), - ('Next', '%snext.png' % path, audioplayer().eventhandler, PLAYLIST_NEXT), - ('Show Player', '%sshow.png' % path, self.detach, None) ] + handlers = [ + (_('Prev'), '%sprev.png' % path, a_handler, PLAYLIST_PREV), + (_('Rew'), '%srew.png' % path, a_handler, Event(SEEK, arg=-10)), + (_('Pause'), '%spause.png'% path, a_handler, PAUSE ), + (_('Play'), '%splay.png' % path, a_handler, PLAY ), + (_('Stop'), '%sstop.png' % path, self.eventhandler, STOP ), + (_('FFwd'), '%sffwd.png' % path, a_handler, Event(SEEK,arg=10)), + (_('Next'), '%snext.png' % path, a_handler, PLAYLIST_NEXT), + (_('Show Player'), '%sshow.png' % path, self.detach, None) ] self.controlbar = ButtonPanel(handlers, default_action=3) controlpanel().register(self.controlbar) @@ -176,11 +188,11 @@ if not self.show_detachbar: return - width = self.max_width - 4 - height = self.max_height - 4 + width = self.max_width - 10 + height = self.max_height - 10 y1 = self.y1 - x1 = 2 + x1 = 5 textinfo, image, item = self.format_info() @@ -193,28 +205,32 @@ # FIXME: Find a more suitable default image? if not image: image = os.path.join(config.IMAGE_DIR, 'gant', 'music.png') + cover = gui.Image(gui.imagelib.load(image, (None, height)),(x1, y1)) iw,ih = cover.get_size() self.objects.append(cover) # create a marquee for showing item info - info = mevas.image.CanvasImage((width-iw-6, fih)) - info.set_pos((x1+iw+4, y1+ih-fih-2)) + info = mevas.image.CanvasImage( (width - iw - 6, fih) ) + info.set_pos( (x1 + iw + 4, y1 + ih - fih - 2) ) # create text objects to be shown as # iteminfo on the detachbar tobjs = [] for string in textinfo: - tobjs.append(gui.Text(string, (0,0), - (fi.stringsize(string), fih), - fi, align_v='top', align_h='left')) + tobjs.append(gui.Text(string, + (0, 0), + (fi.stringsize(string), fih), + fi, + align_v='top', + align_h='left') ) self.objects.append(info) # create canvas for showing elapsed time - w = ft.stringsize('00:00') + w = ft.stringsize(u'00:00') elapsed = mevas.image.CanvasImage((w, fth)) - elapsed.set_pos((x1+width-w, y1)) + elapsed.set_pos( (x1 + width - w, y1) ) self.objects.append(elapsed) self.animation = DetachbarAnimation(tobjs, info, item, elapsed, ft) @@ -224,6 +240,10 @@ def hide(self): + """ + Hides the detached view. + """ + if not self.visible: return @@ -259,14 +279,15 @@ plugin.getbyname('idlebar').update() gui.get_display().update() return True - - elif event == PLAY_START and isinstance(event.arg, AudioItem) and self.detached: - # An audio item has started playing and we are in detached mode. This is our - # item and we should show ourself + + elif event == PLAY_START and isinstance(event.arg, AudioItem) and \ + self.detached: + # An audio item has started playing and we are in detached mode. + # This is our item and we should show ourself self.hide() self.show() return True - + return False @@ -284,22 +305,23 @@ # trackno - title if info['trackno'] and info['title']: - textinfo.append( 'Title: %s - %s' % (info['trackno'], info['title'] ) ) + textinfo.append( _('Title: %s - %s') % (info['trackno'], + info['title']) ) elif info['title']: - textinfo.append( 'Title: %s' % info['title'] ) + textinfo.append( _('Title: %s') % info['title'] ) else: - textinfo.append( 'Title: %s' % item.name) + textinfo.append( _('Title: %s') % item.name) # artist : album if info['artist']: - textinfo.append( 'Artist: %s' % info['artist'] ) + textinfo.append( _('Artist: %s') % info['artist'] ) if info['album']: - textinfo.append( 'Album: %s' % info['album'] ) - + textinfo.append( _('Album: %s') % info['album'] ) - textinfo.append('Duration: %02i:%02i' % (item.length/60, item.length%60) ) + textinfo.append(_('Duration: %02i:%02i') % (item.length / 60, + item.length % 60) ) self.item = item return textinfo, image, item @@ -310,9 +332,10 @@ """ Animation intended for the text on the detached audioplayer """ - def __init__(self, textobjects, textcanvas, item, itemcanvas, el_font, fps=15): - BaseAnimation.__init__(self, fps) + def __init__(self, textobjects, textcanvas, item, + itemcanvas, el_font, fps=15): + BaseAnimation.__init__(self, fps) self.fps = fps self.pobj = -1 @@ -334,7 +357,7 @@ """ if not audioplayer().running: eventhandler.post(DETACH_AUDIO_STOP) - + self.frame += 1 # goto next text object @@ -344,7 +367,8 @@ if self.pobj == len(self.objects): self.pobj = 0 - self.max_frames = self.objects[self.pobj].get_size()[0] + self.sleep_frames + self.max_frames = self.objects[self.pobj].get_size()[0] \ + + self.sleep_frames self.frame = 0 obj = self.objects[self.pobj] @@ -362,10 +386,15 @@ # update the time elapsed if self.item.elapsed != self.last_elapsed: self.last_elapsed = self.item.elapsed - elapsed = '%02i:%02i' % (self.item.elapsed / 60, self.item.elapsed % 60) - size = (self.elapsed_font.stringsize(elapsed), self.elapsed_font.height) + elapsed = u'%02i:%02i' % (self.item.elapsed / 60, + self.item.elapsed % 60) + + size = ( self.elapsed_font.stringsize(elapsed), + self.elapsed_font.height) # XXX FIXME!! Causes "Fatal python error: Deallocating None" # after a while! - self.itemcanvas.set_image(gui.Text(elapsed, (0,0), size, self.elapsed_font)) - + self.itemcanvas.set_image( gui.Text(elapsed, + (0, 0), + size, + self.elapsed_font) )
diff -Naur freevo/src/plugins/tiny_osd.py freevo_viggo/src/plugins/tiny_osd.py --- freevo/src/plugins/tiny_osd.py 2005-01-11 16:07:31.601016834 +0100 +++ freevo_viggo/src/plugins/tiny_osd.py 2005-01-11 16:36:40.795937795 +0100 @@ -37,7 +37,7 @@ # # ----------------------------------------------------------------------- # Freevo - A Home Theater PC framework -# Copyright (C) 2002 Krister Lagerstrom, et al. +# Copyright (C) 2002 Krister Lagerstrom, et al. # Please see the file freevo/Docs/CREDITS for a complete list of authors. # # This program is free software; you can redistribute it and/or modify @@ -88,7 +88,7 @@ self.gui_object = None self._timer_id = None - + def update(self): """ update the display @@ -108,12 +108,19 @@ # get the osd from from the settings font = gui.get_font('osd') + over_x = config.GUI_OVERSCAN_X + over_y = config.GUI_OVERSCAN_Y + # create the text object - # FIXME: do respect the idlebar if active + y = over_y + 10 + if plugin.getbyname('idlebar') != None: + y += 60 + + self.gui_object = gui.Text(self.message, - (config.GUI_OVERSCAN_X, config.GUI_OVERSCAN_Y + 10), - (display.width - 10 - 2 * config.GUI_OVERSCAN_X, - config.GUI_OVERSCAN_Y + 10 + font.height), + (over_x, y), + (display.width - 10 - 2 * over_x, + over_y + 10 + font.height), font, align_h='right') # make sure the object is on top of everything else
diff -Naur freevo/src/controlpanel.py freevo_viggo/src/controlpanel.py --- freevo/src/controlpanel.py 2005-01-11 16:07:28.530037192 +0100 +++ freevo_viggo/src/controlpanel.py 2005-01-11 16:54:31.224326969 +0100 @@ -113,11 +113,8 @@ self.container.add_child(o) # TODO: support different placements - tw = display.width - 2*config.GUI_OVERSCAN_X - th = display.height - 2*config.GUI_OVERSCAN_Y - - x = int(tw/2) - int(w/2) - y = th - h + x = config.GUI_OVERSCAN_X + 10 + y = display.height - config.GUI_OVERSCAN_Y - h self.container.set_pos((x,y)) diff -Naur freevo/src/input/keymap.py freevo_viggo/src/input/keymap.py --- freevo/src/input/keymap.py 2005-01-11 16:07:31.343102528 +0100 +++ freevo_viggo/src/input/keymap.py 2005-01-11 16:54:13.837103623 +0100 @@ -44,6 +44,7 @@ 'PERIOD' : 'EJECT', 'L' : 'SUBTITLE', 'A' : 'LANG', + 'T' : 'TOGGLE_CONTROL' } REMOTE_MAP = {
diff -Naur freevo/src/plugins/idlebar/__init__.py freevo_viggo/src/plugins/idlebar/__init__.py --- freevo/src/plugins/idlebar/__init__.py 2005-01-11 16:07:31.773959372 +0100 +++ freevo_viggo/src/plugins/idlebar/__init__.py 2005-01-11 16:14:49.912382998 +0100 @@ -173,9 +173,9 @@ p.set_pos((x1, y1)) x1 = x1 + p.width else: - if changed: - p.set_pos((x2 - width, y1)) x2 = x2 - p.width + if changed: + p.set_pos((x2, y1)) continue if width > x2 - x1: @@ -306,8 +306,8 @@ self.__x = 0 self.__y = 0 self.width = 0 - - + + def draw(self, width, height): return self.NO_CHANGE
diff -Naur freevo/src/plugins/idlebar/cdstatus.py freevo_viggo/src/plugins/idlebar/cdstatus.py --- freevo/src/plugins/idlebar/cdstatus.py 2004-09-14 16:00:39.000000000 +0200 +++ freevo_viggo/src/plugins/idlebar/cdstatus.py 2005-01-12 17:53:01.599455221 +0100 @@ -1,16 +1,16 @@ # -*- coding: iso-8859-1 -*- -# ----------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # cdstatus.py - IdleBarPlugin for showing cd status -# ----------------------------------------------------------------------- -# $Id: +# ----------------------------------------------------------------------------- +# $Id$ # -# ----------------------------------------------------------------------- -# $Log: +# ----------------------------------------------------------------------------- +# Freevo - A Home Theater PC framework +# Copyright (C) 2002-2004 Krister Lagerstrom, Dirk Meyer, et al. # +# First Edition: ? <[EMAIL PROTECTED]> +# Maintainer: Viggo Fredriksen <[EMAIL PROTECTED]> # -# ----------------------------------------------------------------------- -# Freevo - A Home Theater PC framework -# Copyright (C) 2002 Krister Lagerstrom, et al. # Please see the file freevo/Docs/CREDITS for a complete list of authors. # # This program is free software; you can redistribute it and/or modify @@ -27,12 +27,12 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# ----------------------------------------------------------------------- */ +# ----------------------------------------------------------------------------- import os - import gui import config + from plugins.idlebar import IdleBarPlugin class PluginInterface(IdleBarPlugin): @@ -41,13 +41,19 @@ Activate with: plugin.activate('idlebar.cdstatus') + or + plugin.activate('idlebar.cdstatus', args=(draw_empty_rom,) + + Where draw_empty_rom is either of + True : draw empty cdroms. (default) + False : do not draw empty cdroms. """ - def __init__(self): + def __init__(self, args=(True,)): IdleBarPlugin.__init__(self) icondir = os.path.join(config.ICON_DIR, 'status') self.cdimages ={} - self.cdimages ['audiocd'] = os.path.join(icondir, 'cd_audio.png') + self.cdimages ['audiocd'] = os.path.join(icondir, 'cd_audio.png') self.cdimages ['empty_cdrom'] = os.path.join(icondir, 'cd_inactive.png') self.cdimages ['images'] = os.path.join(icondir, 'cd_photo.png') self.cdimages ['video'] = os.path.join(icondir, 'cd_video.png') @@ -56,27 +62,61 @@ self.cdimages ['cdrip'] = os.path.join(icondir, 'cd_rip.png') self.cdimages ['mixed'] = os.path.join(icondir, 'cd_mixed.png') + self.draw_empty = args + self.init = True + self.rem_media = [] + + # collect all the media types + for media in config.REMOVABLE_MEDIA: + self.rem_media.append(media.type) + def draw(self, width, height): - image = self.cdimages['empty_cdrom'] + """ + Draws the removable media. + """ + changed = False + i = 0 + + for media in config.REMOVABLE_MEDIA: + # check if there has been any changes + if media.type != self.rem_media[i] or self.init: + self.rem_media[i] = media.type + changed = True + i += 1 + + if not changed: + # no changes registered + return self.NO_CHANGE + + # clear previous images self.clear() - w = 0 + self.init = False + w = 0 + x0 = 5 + + # iterate through the removable medias for media in config.REMOVABLE_MEDIA: - image = self.cdimages['empty_cdrom'] - if media.type == 'empty_cdrom': - image = self.cdimages['empty_cdrom'] + + if media.type == 'empty_cdrom' and not self.draw_empty: + # don't draw empty if configured + continue + if media.type and self.cdimages.has_key(media.type): - image = self.cdimages[media.type] + # search for a specific media type + image = gui.imagelib.load(self.cdimages[media.type],(None,None)) else: - image = self.cdimages['mixed'] - i = gui.imagelib.load(image, (None, None)) + # no specific type, use mixed icon + image = gui.imagelib.load(self.cdimages['mixed'], (None, None)) - w += i.width + 10 + y0 = int((height-image.height)/2) + self.objects.append(gui.Image(image, (x0, y0))) - self.objects.append(gui.Image(i, (w, (height-i.height)/2))) + w += image.width + 10 + x0 += image.width + 5 - - if w: + if w >= 10: w -= 10 + return w