1
0
mirror of https://github.com/gryf/wmdocklib.git synced 2025-12-19 04:20:17 +01:00

quick patch, to make this program fit in a swallowed gnome applet of

arbitrary height.  actually at the moment only works for 50 <= height <= 64
This commit is contained in:
mfrasca
2008-03-25 17:49:51 +00:00
parent dd1c8dd685
commit e70f75cda7

View File

@@ -87,6 +87,7 @@ class Application(wmoo.Application):
parser.add_option('-d', '--dateformat', default=dateDefaultFormat) parser.add_option('-d', '--dateformat', default=dateDefaultFormat)
parser.add_option('-y', '--weekdayformat', default=dayDefaultFormat) parser.add_option('-y', '--weekdayformat', default=dayDefaultFormat)
parser.add_option('-e', '--weekformat', default=weekDefaultFormat) parser.add_option('-e', '--weekformat', default=weekDefaultFormat)
parser.add_option('--height', type='int', default=64)
parser.add_option('-r', '--rgbfile') parser.add_option('-r', '--rgbfile')
#parser.add_option('-c', '--configfile', default=defaultConfigFile) #parser.add_option('-c', '--configfile', default=defaultConfigFile)
parser.add_option('--debug', action='store_true', default=False) parser.add_option('--debug', action='store_true', default=False)
@@ -102,11 +103,13 @@ class Application(wmoo.Application):
palette[0] = options.background palette[0] = options.background
palette[2] = options.foreground palette[2] = options.foreground
self.hpad = hpad = (64 - options.height) / 2
if options.antialiased: if options.antialiased:
background = [((6,3),(57,19)), background = [((6,3+hpad),(57,19+hpad)),
((3,22),(60,60))] ((3,22+hpad),(60,60-hpad))]
else: else:
background = [((3,3),(59,60))] background = [((3,3+hpad),(59,60-hpad))]
wmoo.Application.__init__(self, wmoo.Application.__init__(self,
patterns=patterns, patterns=patterns,
@@ -117,15 +120,17 @@ class Application(wmoo.Application):
if options.antialiased: if options.antialiased:
self.addWidget('date', wmoo.Label, orig=(4,24), size=(54,10), align=wmoo.CENTRE) self.addWidget('date', wmoo.Label, orig=(4,24+hpad), size=(54,10), align=wmoo.CENTRE)
self.addWidget('day', wmoo.Label, orig=(4,36), size=(54,10), align=wmoo.CENTRE) self.addWidget('day', wmoo.Label, orig=(4,36+hpad), size=(54,10), align=wmoo.CENTRE)
self.addWidget('week', wmoo.Label, orig=(4,48), size=(54,10), align=wmoo.CENTRE) if 48+hpad <= 50:
self.addWidget('week', wmoo.Label, orig=(4,48), size=(54,10), align=wmoo.CENTRE)
else: else:
self.addWidget('time', wmoo.Label, orig=(4, 5), size=(54,10), align=wmoo.CENTRE) self.addWidget('time', wmoo.Label, orig=(4, 5+hpad), size=(54,10), align=wmoo.CENTRE)
self.addWidget('time2', wmoo.Label, orig=(4,16), size=(54,10), align=wmoo.CENTRE) self.addWidget('time2', wmoo.Label, orig=(4,16+hpad), size=(54,10), align=wmoo.CENTRE)
self.addWidget('date', wmoo.Label, orig=(4,27), size=(54,10), align=wmoo.CENTRE) self.addWidget('date', wmoo.Label, orig=(4,27+hpad), size=(54,10), align=wmoo.CENTRE)
self.addWidget('day', wmoo.Label, orig=(4,38), size=(54,10), align=wmoo.CENTRE) self.addWidget('day', wmoo.Label, orig=(4,38+hpad), size=(54,10), align=wmoo.CENTRE)
self.addWidget('week', wmoo.Label, orig=(4,49), size=(54,10), align=wmoo.CENTRE) if 49+hpad <= 50:
self.addWidget('week', wmoo.Label, orig=(4,49+hpad), size=(54,10), align=wmoo.CENTRE)
self.timeFmt = options.timeformat self.timeFmt = options.timeformat
self.dateFmt = options.dateformat self.dateFmt = options.dateformat
@@ -155,7 +160,7 @@ class Application(wmoo.Application):
def updateTimeString(self, s): def updateTimeString(self, s):
if self.antialiased: if self.antialiased:
x, y = 8, 6 x, y = 8, 6+self.hpad
for c in s: for c in s:
charW = 7 charW = 7
charX = (ord(c) - ord('0')) * 7 charX = (ord(c) - ord('0')) * 7
@@ -192,7 +197,8 @@ class Application(wmoo.Application):
self['day'].setText(dayStr) self['day'].setText(dayStr)
self.lastStrs[2] = dayStr self.lastStrs[2] = dayStr
if self.lastStrs[3] != weekStr: if self.lastStrs[3] != weekStr:
self['week'].setText(weekStr) if 'week' in self._widgets:
self['week'].setText(weekStr)
self.lastStrs[3] = weekStr self.lastStrs[3] = weekStr
if __name__ == '__main__': if __name__ == '__main__':