aboutsummaryrefslogtreecommitdiffstats
path: root/equalize_sidebearings.py
diff options
context:
space:
mode:
authorTeddy Wing2015-12-24 18:26:03 -0800
committerTeddy Wing2015-12-24 18:26:03 -0800
commit8778928a0989ea938fb06f0dd4c6639a6f9148ca (patch)
treec74529b901ff2dcb9883f293218b81ee8bbcfd58 /equalize_sidebearings.py
parent78cb02c8b70c037eda31e5a40b33da71067c8435 (diff)
downloadRoboFont-Equalize-Sidebearings-Key-8778928a0989ea938fb06f0dd4c6639a6f9148ca.tar.bz2
Make hotkey preference work
Separate preference handling into a new class and have the previous preferences class handle only the preferences window. We rename the old file to `preferences_window.py` and adjust the `info.plist` key for the menu item accordingly. Our new `Preference` class can now be imported from both `equalize_sidebearings.py` and `preferences_window.py` without causing confusion. I extracted it because asking for the `DEFAULT_ACTIVATION_KEY` from `preferences_window.py` from `equalize_sidebearings.py` would open the preferences window (bad). We now save the preferred key using RoboFont's extension preferences API. When the text input in the preferences window is modified, the new key preference gets saved. BUG: There's an issue with this implementation where the preferred key doesn't become active until the next launch of RoboFont because `EqualizeSidebearings` has its own instance of `Preferences` which has a stale `activation_key`.
Diffstat (limited to 'equalize_sidebearings.py')
-rw-r--r--equalize_sidebearings.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/equalize_sidebearings.py b/equalize_sidebearings.py
index 18515ad..5660330 100644
--- a/equalize_sidebearings.py
+++ b/equalize_sidebearings.py
@@ -1,6 +1,8 @@
from mojo.events import addObserver
from lib.doodleMenus import SpaceCenterMenuForGlyph
+from preferences import Preferences
+
class CustomSpaceCenterMenuForGlyph(SpaceCenterMenuForGlyph):
@@ -10,13 +12,13 @@ class CustomSpaceCenterMenuForGlyph(SpaceCenterMenuForGlyph):
class EqualizeSidebearings(object):
- DEFAULT_ACTIVATION_KEY = 'e'
def __init__(self):
addObserver(self, 'equalize', 'spaceCenterKeyUp')
+ self.preferences = Preferences()
def equalize(self, info):
- if info['event'].characters() == self.DEFAULT_ACTIVATION_KEY:
+ if info['event'].characters() == self.preferences.activation_key:
space_center_menu = CustomSpaceCenterMenuForGlyph(
info['glyph'].naked())
space_center_menu.equalSideBearings_(self)