On Wednesday 08 September 2004 10:34, Dirk Meyer wrote:
> BTW, what about using an extra file for each plugin? I guess it would
> look much cleaner and having all the code in __init__.py is very bad.
>
>
> Dischi
Done, all IdleBarPlugins are now seperated into files.
Viggo
diff -Naur freevo/src/plugins/idlebar/__init__.py freevo_devel/src/plugins/idlebar/__init__.py
--- freevo/src/plugins/idlebar/__init__.py 2004-09-13 22:00:38.675851359 +0200
+++ freevo_devel/src/plugins/idlebar/__init__.py 2004-09-13 22:08:05.0 +0200
@@ -4,17 +4,6 @@
# ---
# $Id: __init__.py,v 1.29 2004/09/08 08:33:13 dischi Exp $
#
-# Documentation moved to the corresponding classes, so that the help
-# interface returns something usefull.
-# Available plugins:
-# idlebar
-# idlebar.clock
-# idlebar.cdstatus
-# idlebar.mail
-# idlebar.tv
-# idlebar.weather
-# idlebar.holidays
-#
# ---
# $Log: __init__.py,v $
# Revision 1.29 2004/09/08 08:33:13 dischi
@@ -84,22 +73,14 @@
#
# --- */
-
+# python modules
import time
-import os
-import sys
-import string
-import types
-import mailbox
-import re
import locale
+# freevo modules
import config
import plugin
-import util.tv_util as tv_util
-import util.pymetar as pymetar
import gui
-import gui.imagelib
import eventhandler
from event import *
@@ -308,418 +289,3 @@
for o in self.objects:
o.unparent()
self.objects = []
-
-
-
-
-class clock(IdleBarPlugin):
-"""
-Shows the current time.
-
-Activate with:
-plugin.activate('idlebar.clock', level=50)
-Note: The clock will always be displayed on the right side of
-the idlebar.
-"""
-def __init__(self, format=''):
-IdleBarPlugin.__init__(self)
- if format == '': # No overiding of the default value
- if time.strftime('%P') =='':
-format ='%a %H:%M'
-else:
-format ='%a %I:%M %P'
-self.format = format
-self.object = None
-self.align = 'right'
-self.width = 0
-self.text = ''
-
-def draw(self, width, height):
-clock = time.strftime(self.format)
-
-if self.objects and self.text == clock:
-return self.NO_CHANGE
-
-self.clear()
-
-font = gui.get_font('clock')
-width = min(width, font.stringsize(clock))
-
-txt = gui.Text(clock, (0, 0), (width, height), font,
- align_v='center', align_h='right')
-self.objects.append(txt)
-self.text = clock
-return width
-
-
-
-class cdstatus(IdleBarPlugin):
-"""
-Show the status of all rom drives.
-
-Activate with:
-plugin.activate('idlebar.cdstatus')
-"""
-def __init__(self):
-
-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 ['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')
-self.cdimages ['dvd'] = os.path.join(icondir, 'cd_video.png')
-self.cdimages ['burn']= os.path.join(icondir, 'cd_burn.png')
-self.cdimages ['cdrip'] = os.path.join(icondir, 'cd_rip.png')
-self.cdimages ['mixed'] = os.path.join(icondir, 'cd_mixed.png')
-
-def draw(self, width, height):
-image = self.cdimages['empty_cdrom']
-
-self.clear()
-
-w = 0
-for media in config.REMOVABLE_MEDIA:
-image = self.cdimages['empty_cdrom']
-if media.type == 'empty_cdrom':
-image = self.cdimages['empty_cdrom']
-if media.type and self.cdimages.has_key(media.type):
-image = self.cdimages[media.type]
-else:
-image = self.cdimages['mixed']
-i = gui.imagelib.load(image, (None, None))
-
-w += i.width + 10
-
-self.objects.append(gui.Image(i, (w, (height-i.height)/2)))
-
-
-if w:
-w -= 10
-return w
-
-
-class mail(IdleBarPlugin):
-"""
-Shows if new mail is in the mailbox.
-
-Activate with:
-plugin.activate('idlebar.mail',level=10, args=('path to mailbox', ))
-
-"""
-def __init__(self, mailbox):
-IdleBarPlugin.__init__(self)
-self.mails = -1
-self.NO_MAILIMAGE = os.path.join(config.ICON_DIR, 'status/newmail_dimmed.png')
-self.MAILIMAGE = os.path.join(config.ICON_DIR, 'status/newmail_active.png')
-self.MAILBOX = mailbox
-
-def checkmail(self):
-if no