Update of /cvsroot/freevo/freevo/src/audio/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2058/plugins
Modified Files: detach.py detachbar.py Log Message: better detachbar plugin, does not need stuff in other files now Index: detach.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/audio/plugins/detach.py,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** detach.py 6 Feb 2004 18:33:06 -0000 1.13 --- detach.py 15 Feb 2004 11:18:47 -0000 1.14 *************** *** 10,13 **** --- 10,16 ---- # ----------------------------------------------------------------------- # $Log$ + # Revision 1.14 2004/02/15 11:18:47 dischi + # better detachbar plugin, does not need stuff in other files now + # # Revision 1.13 2004/02/06 18:33:06 dischi # fix mimetype handling *************** *** 74,86 **** self.show_item.type = 'detached_player' def detach(self): - # start detachbar - self.detachbar = plugin.getbyname('audio.detachbar') - if self.detachbar == None: - plugin.activate('audio.detachbar') - self.detachbar = plugin.getbyname('audio.detachbar') - gui = audio.player.get() - gui.detachbar = self.detachbar # hide the player and show the menu --- 77,83 ---- self.show_item.type = 'detached_player' + def detach(self): gui = audio.player.get() # hide the player and show the menu *************** *** 94,97 **** --- 91,95 ---- if gui.item.parent: gui.item.parent.menuw = None + rc.post_event(plugin.event('DETACH')) Index: detachbar.py =================================================================== RCS file: /cvsroot/freevo/freevo/src/audio/plugins/detachbar.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** detachbar.py 14 Feb 2004 13:05:04 -0000 1.5 --- detachbar.py 15 Feb 2004 11:18:47 -0000 1.6 *************** *** 29,43 **** # freevo specific ! import skin,audio.player,plugin from event import * # barstates ! BAR_HIDE=0 # timedout, reset and change poll interval ! BAR_SHOW=1 # show the bar ! BAR_IDLE=2 # wait for new track class PluginInterface(plugin.DaemonPlugin): """ ! detachbar plugin. """ def __init__(self): --- 29,51 ---- # freevo specific ! import skin ! import audio.player ! import plugin from event import * + # barstates ! BAR_HIDE=0 # timedout, reset and change poll interval ! BAR_SHOW=1 # show the bar ! BAR_IDLE=2 # wait for new track class PluginInterface(plugin.DaemonPlugin): """ ! This plugin enables a small bar showing information about audio being played ! when detached with the detach plugin. ! ! If the idlebar is loaded and there is enough space left there, this plugin ! will draw itself there, otherwise it will draw at the right bottom of the ! screen. """ def __init__(self): *************** *** 46,78 **** # tunables self.TimeOut = 3 # 3 seconds till we hide the bar ! self.reset() ! ! # register in list (is this necessery?) ! self.plugin_name = 'audio.detachbar' ! plugin.register(self, self.plugin_name) ! self.image = None ! ! def reset(self): ! self.status=BAR_HIDE ! self.render = [] ! self.player = None ! self.Timer = None ! self.bar = None ! self.setPoll(999999) - def eventhandler(self, event, menuw=None): - """ - Needed to catch the PLAY_START event, - since it now integrates with player.py, - this should probably be removed in the future - (don't have to many dependencies) - """ - print event - if self.player and event == PLAY_START: - if self.status == BAR_IDLE: - self.refresh() - else: - self.show() - return False def timer(self): --- 54,59 ---- # tunables self.TimeOut = 3 # 3 seconds till we hide the bar ! self.hide() def timer(self): *************** *** 88,112 **** return BAR_IDLE def hide(self): """ used when hiding the bar """ ! self.reset() def show(self): """ used when showing for the first time """ ! self.player = audio.player.get().player self.setPoll(10) - self.refresh() - - def refresh(self): - """ - used when updating new songinfo - """ self.getInfo() self.status = BAR_SHOW def stop(self): """ --- 69,105 ---- return BAR_IDLE + + def eventhandler(self, event, menuw=None): + """ + Needed to catch the plugin DETACH event + """ + if plugin.isevent(event) == 'DETACH': + self.show() + return True + return False + + def hide(self): """ used when hiding the bar """ ! self.status = BAR_HIDE ! self.render = [] ! self.player = None ! self.Timer = None ! self.bar = None ! self.setPoll(999999) + def show(self): """ used when showing for the first time """ ! self.player = audio.player.get() self.setPoll(10) self.getInfo() self.status = BAR_SHOW + def stop(self): """ *************** *** 114,118 **** """ self.status = BAR_IDLE ! self.Timer = time.time() def poll(self): --- 107,112 ---- """ self.status = BAR_IDLE ! self.Timer = time.time() ! def poll(self): *************** *** 122,139 **** if self.status == BAR_SHOW: skin.redraw() elif self.status == BAR_IDLE: self.status = self.timer() if self.status == BAR_HIDE: ! self.reset() skin.redraw() def draw(self, (type, object), osd): """ draws the bar """ if self.status == BAR_SHOW: font = osd.get_font('detachbar') ! if font==osd.get_font('default'): font = osd.get_font('info value') --- 116,153 ---- if self.status == BAR_SHOW: skin.redraw() + elif self.status == BAR_IDLE: self.status = self.timer() if self.status == BAR_HIDE: ! self.hide() skin.redraw() + def draw(self, (type, object), osd): """ draws the bar """ + if self.status == BAR_IDLE: + # when idle, wait for a new player + if audio.player.get(): + self.show() + if self.status == BAR_SHOW: + if not self.player.running: + # player stopped, we also stop + # and wait for a new one + self.player = None + self.stop() + return + + if type == 'player': + # Oops, showing the player again, stop me + self.stop() + self.hide() + return + font = osd.get_font('detachbar') ! if font == osd.get_font('default'): font = osd.get_font('info value') *************** *** 169,175 **** osd.write_text( progress, font, None, self.t_x, y, self.t_w, self.font_h , 'center', 'center') - return 0 def getInfo(self): """ --- 183,189 ---- osd.write_text( progress, font, None, self.t_x, y, self.t_w, self.font_h , 'center', 'center') return 0 + def getInfo(self): """ *************** *** 199,202 **** --- 213,217 ---- self.render += [ self.player.item.name ] + def calculatesizes(self,osd,font): """ *************** *** 230,234 **** for r in self.render: bar_height += self.font_h ! bar_width = self.longest(bar_width,font.font.stringsize(r)) self.y = (total_height - bar_height) - osd.y - pad - pad_internal --- 245,249 ---- for r in self.render: bar_height += self.font_h ! bar_width = max(bar_width,font.font.stringsize(r)) self.y = (total_height - bar_height) - osd.y - pad - pad_internal *************** *** 254,265 **** helper to set the poll_interval """ ! self.poll_counter = 0 self.poll_interval = interval ! def longest(self,a,b): ! if a>b: ! return a ! return b ! def formattime(self,seconds): """ --- 269,276 ---- helper to set the poll_interval """ ! self.poll_counter = 0 self.poll_interval = interval ! def formattime(self,seconds): """ ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ Freevo-cvslog mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog