Changeset 235


Ignore:
Timestamp:
06/06/06 18:49:28 (19 years ago)
Author:
Nicholas Riley
Message:

StreamVision.py: Pass through cmd-ctrl-\ in Emacs and X11 (C-M-\ is used in Emacs, and it doesn't handle being zoomed through the accessibility interface properly anyway); handle exceptions better when app doesn't respond to zooming Apple Events

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/StreamVision/StreamVision.py

    r234 r235  
    119119        self.hotKeys.append(hotKeyRef)
    120120        self.hotKeyActions[HotKey.HotKeyAddress(hotKeyRef)] = func
     121        return hotKeyRef
     122
     123    def unregisterHotKey(self, hotKeyRef):
     124        self.hotKeys.remove(hotKeyRef)
     125        del self.hotKeyActions[HotKey.HotKeyAddress(hotKeyRef)]
     126        hotKeyRef.UnregisterEventHotKey()
    121127
    122128    def incrementRatingBy(self, increment):
     
    145151            else:
    146152                XTensionApp().turnoff('Stereo')
    147                
     153
     154    def registerZoomWindowHotKey(self):
     155        self.zoomWindowHotKey = self.registerHotKey(self.zoomWindow, 42, cmdKey | controlKey) # cmd-ctrl-\
     156
     157    def unregisterZoomWindowHotKey(self):
     158        self.unregisterHotKey(self.zoomWindowHotKey)
     159        self.zoomWindowHotKey = None
     160
    148161    def zoomWindow(self):
    149162        systemEvents = app(id='com.apple.systemEvents')
     
    153166                menu_bar_items['Window'].menus.menu_items['Zoom'].click()
    154167            return
     168        elif frontName in ('X11', 'Emacs'): # preserve C-M-\
     169            self.unregisterZoomWindowHotKey()
     170            systemEvents.key_code(42, using=[k.command_down, k.control_down])
     171            self.registerZoomWindowHotKey()
     172            return
    155173        try:
    156174            zoomed = app(frontName).windows[1].zoomed
    157175            zoomed.set(not zoomed())
    158         except CommandError:
     176        except (CommandError, RuntimeError):
    159177            systemEvents.processes[frontName].windows. \
    160178                filter(its.subrole == 'AXStandardWindow').windows[1]. \
     
    170188        self.registerHotKey(lambda: self.incrementRatingBy(-20), 109, shiftKey) # shift-F10
    171189        self.registerHotKey(lambda: self.incrementRatingBy(20), 103, shiftKey) # shift-F11
    172         self.registerHotKey(self.zoomWindow, 42, cmdKey | controlKey) # cmd-ctrl-\
     190        self.registerZoomWindowHotKey()
    173191        NSDistributedNotificationCenter.defaultCenter().addObserver_selector_name_object_(self, self.displayTrackInfo, 'com.apple.iTunes.playerInfo', None)
    174192
Note: See TracChangeset for help on using the changeset viewer.