mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 20:38:03 +01:00
1579871: offer antialiasing as option
as required
This commit is contained in:
@@ -113,8 +113,8 @@ def calculateWeek(localTime):
|
|||||||
|
|
||||||
def parseCommandLine(argv):
|
def parseCommandLine(argv):
|
||||||
"""Parse the commandline. Return a dictionary with options and values."""
|
"""Parse the commandline. Return a dictionary with options and values."""
|
||||||
shorts = 'hf:b:t:d:e:y:r:c:F:'
|
shorts = 'hf:b:t:d:e:y:r:c:F:a'
|
||||||
longs = ['help', 'foreground=', 'background=', 'timeformat=', 'dateformat=',
|
longs = ['antialiased', 'help', 'foreground=', 'background=', 'timeformat=', 'dateformat=',
|
||||||
'weekdayformat=', 'weekformat=', 'rgbfile=', 'configfile=', 'font=']
|
'weekdayformat=', 'weekformat=', 'rgbfile=', 'configfile=', 'font=']
|
||||||
try:
|
try:
|
||||||
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
opts, nonOptArgs = getopt.getopt(argv[1:], shorts, longs)
|
||||||
@@ -123,10 +123,13 @@ def parseCommandLine(argv):
|
|||||||
sys.stderr.write(usage)
|
sys.stderr.write(usage)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
d = {}
|
d = {}
|
||||||
|
|
||||||
for o, a in opts:
|
for o, a in opts:
|
||||||
if o in ('-h', '--help'):
|
if o in ('-h', '--help'):
|
||||||
sys.stdout.write(usage)
|
sys.stdout.write(usage)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
if o in ('-a', '--antialiased'):
|
||||||
|
d['antialiased'] = True
|
||||||
if o in ('-f', '--foreground'):
|
if o in ('-f', '--foreground'):
|
||||||
d['foreground'] = a
|
d['foreground'] = a
|
||||||
if o in ('-F', '--font'):
|
if o in ('-F', '--font'):
|
||||||
@@ -164,12 +167,18 @@ def mainLoop(timeFmt, dateFmt, dayFmt, weekFmt):
|
|||||||
checkForEvents()
|
checkForEvents()
|
||||||
lt = time.localtime()
|
lt = time.localtime()
|
||||||
timeStr = time.strftime(timeFmt, lt)[:maxCharsPerLine]
|
timeStr = time.strftime(timeFmt, lt)[:maxCharsPerLine]
|
||||||
|
timeX = 3
|
||||||
|
if antialiased:
|
||||||
margin = 6
|
margin = 6
|
||||||
spacing = getVertSpacing(4, margin)
|
spacing = getVertSpacing(4, margin)
|
||||||
timeX = 3
|
|
||||||
if lastStrs[0] != timeStr:
|
if lastStrs[0] != timeStr:
|
||||||
addTimeString(timeStr, timeX, margin-4)
|
addTimeString(timeStr, timeX, margin-4)
|
||||||
margin = 8
|
margin += 1
|
||||||
|
else:
|
||||||
|
margin = 4
|
||||||
|
spacing = getVertSpacing(4, margin)
|
||||||
|
if lastStrs[0] != timeStr:
|
||||||
|
addString(timeStr, timeX, margin)
|
||||||
lastStrs[0] = timeStr
|
lastStrs[0] = timeStr
|
||||||
if counter % 100 == 0:
|
if counter % 100 == 0:
|
||||||
# We only perform the date/week checks/updates once every 100th
|
# We only perform the date/week checks/updates once every 100th
|
||||||
@@ -310,12 +319,15 @@ def main():
|
|||||||
|
|
||||||
font = clConfig.get('font', '6x8orig')
|
font = clConfig.get('font', '6x8orig')
|
||||||
|
|
||||||
global char_width, char_height, maxCharsPerLine
|
global char_width, char_height, maxCharsPerLine, antialiased
|
||||||
char_width, char_height = wmdocklib.initPixmap(background,
|
char_width, char_height = wmdocklib.initPixmap(background,
|
||||||
font_name=font,
|
font_name=font,
|
||||||
bg=0, fg=2, palette=palette)
|
bg=0, fg=2, palette=palette)
|
||||||
maxCharsPerLine = (width-2*xOffset) / char_width
|
maxCharsPerLine = (width-2*xOffset) / char_width
|
||||||
|
antialiased = clConfig.get('antialiased', False)
|
||||||
|
|
||||||
wmdocklib.openXwindow(sys.argv, width, height)
|
wmdocklib.openXwindow(sys.argv, width, height)
|
||||||
|
if antialiased:
|
||||||
wmdocklib.copyXPMArea(64+2*xOffset+1, 27, width - 2*xOffset, 17, xOffset, yOffset)
|
wmdocklib.copyXPMArea(64+2*xOffset+1, 27, width - 2*xOffset, 17, xOffset, yOffset)
|
||||||
mainLoop(timeFmt, dateFmt, dayFmt, weekFmt)
|
mainLoop(timeFmt, dateFmt, dayFmt, weekFmt)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user