The Old Screenlets updated bundle available from here, contains a number of very useful screenlets including a calculator and a conversion utility. However, some of these screenlets won’t work correctly with recent versions of screenlets because event handling has been changed (improved). Below are some simple patches to get Calc and Convert working properly with Screenlets >=0.0.10-3.
Calc
46d45
< self.window.connect("key-press-event", self.key_press)
417c416
< def key_press(self, widget, event):
---
> def on_key_down(self, code, key, event):
419,422c418
<
< key = gtk.gdk.keyval_name (event.keyval)
< KPCONVERT = {'KP_Add': 'plus', 'KP_Subtract': 'minus', 'KP_Multiply': 'asterisk',
< 'KP_Divide': 'slash', 'KP_Enter': 'Return'}
---
> KPCONVERT = {'+': 'plus', '-': 'minus', '*': 'asterisk', '/': 'slash', '\r': 'Return'}
Convert
73,74d72
< # connect additional event handlers
< self.window.connect('key-press-event', self.key_press)
110c108
< def key_press(self, widget, event):
---
> def on_key_down(self, code, key, event):
112c110
< if self.__converter.on_key_press(gtk.gdk.keyval_name(event.keyval)):
---
> if self.__converter.on_key_press(key):
Applying the patches
- Ensure that you have the
patchutility installed - Copy the the diff data under the Calc heading above into a file called Calc.diff
- Copy the data under the Convert heading to a file called Convert.diff
- Copy Calc.diff to the directory containing CalcScreenlet.py, e.g. /usr/local/share/screenlets/Calc
- Copy Convert.diff to the directory containing ConvertScreenlet.py
- In the Calc/ directory type
patch CalcScreenlet.py Calc.diff. - In the Convert/ directory type
patch ConvertScreenlet.py Convert.diff.
What this fixes
This fixes a bug where for each keypress, the application receives and prints two characters, i.e. if you press the ‘0’ key ‘00’ will displayed.