Ignore:
Timestamp:
05/12/12 11:52:03 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The hotkey handling works

Location:
src/mlx/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/gui.py

    r164 r168  
    152152        self._lastLoadedPIREP = None
    153153
     154        self._hotkeySetID = None
     155
    154156    @property
    155157    def mainWindow(self):
     
    320322            self._wizard.connected(fsType, descriptor)
    321323        self._reconnecting = False
     324        self._listenHotkeys()
    322325
    323326    def connectionFailed(self):
     
    402405        """Disconnect from the simulator if connected."""
    403406        self.stopMonitoring()
     407        self._clearHotkeys()
    404408
    405409        if self._connected:
     
    875879    def _editPreferences(self, menuItem):
    876880        """Callback for editing the preferences."""
     881        self._clearHotkeys()
    877882        self._preferences.run(self.config)
    878883        self._setupTimeSync()
     884        self._listenHotkeys()
    879885
    880886    def _setupTimeSync(self):
     
    11061112        if callback is not None:
    11071113            callback(returned, result)
     1114
     1115    def _listenHotkeys(self):
     1116        """Setup the hotkeys based on the configuration."""
     1117        if self._hotkeySetID is None and self._simulator is not None:
     1118            self._hotkeySetID = \
     1119                self._simulator.listenHotkeys([self.config.pilotHotkey,
     1120                                               self.config.checklistHotkey],
     1121                                              self._handleHotkeys)
     1122
     1123    def _clearHotkeys(self):
     1124        """Clear the hotkeys."""
     1125        if self._hotkeySetID is not None:
     1126            self._hotkeySetID=None
     1127            self._simulator.clearHotkeys()
     1128
     1129    def _handleHotkeys(self, id, hotkeys):
     1130        """Handle the hotkeys."""
     1131        if id==self._hotkeySetID:
     1132            print "gui.GUI._handleHotkeys", hotkeys
  • src/mlx/gui/prefs.py

    r167 r168  
    4040        labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
    4141                                       xscale = 0.0, yscale = 0.0)
     42        labelAlignment.set_padding(padding_top = 0, padding_bottom = 0,
     43                                   padding_left = 0, padding_right = 4)
    4244        labelAlignment.add(label)
    43         self.pack_start(labelAlignment, False, False, 8)
     45        self.pack_start(labelAlignment, False, False, 0)
    4446
    4547        self._ctrl = gtk.CheckButton("Ctrl")
     
    5456
    5557        self._hotkeyModel = gtk.ListStore(str)
    56         for keyCode in range(ord("0"), ord("9")) + range(ord("A"), ord("Z")):
     58        for keyCode in range(ord("0"), ord("9")+1) + range(ord("A"), ord("Z")+1):
    5759            self._hotkeyModel.append([chr(keyCode)])
    5860
Note: See TracChangeset for help on using the changeset viewer.