Changeset 118

Show
Ignore:
Timestamp:
01/14/08 18:02:48
Author:
slee
Message:

turned on pyatspi queueing but left on mine as well

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • inapp/trunk/src/jambu/InAppSelection.py

    r115 r118  
    55import gtk 
    66import gobject 
     7import gconf 
     8import pyatspi 
    79 
    810import sys 
     
    1517                ,Switch.SWITCH_UP: 'switch-up' 
    1618                ,Switch.NO_EVENT: None} 
    17   
     19 
     20_ = lambda x: x 
     21 
    1822class App(object): 
    1923  '''The application''' 
    20   def onDeleteEvent(self, widget, event, data=None): 
    21     gtk.main_quit() 
    22     return False 
    23  
    2424  def _getArgs(self): 
    2525    show_tree = scan = False 
     
    7373      
    7474  def main(self): 
    75     gtk.main() 
     75    ''' 
     76    Runs the app. 
     77    ''' 
     78#    gtk.main() 
     79    # Tell user if desktop accessibility is disabled. 
     80    if not self._showNoA11yDialog(): 
     81      return 
     82     
     83    def _onIdle(): 
     84      pyatspi.Registry.onPumpQueuedEvents() 
     85      return True   # keep this function in idle processing 
     86    gobject.idle_add(_onIdle) 
     87 
     88    try: 
     89      pyatspi.Registry.start(async=True) 
     90    except KeyboardInterrupt: 
     91      self._stop() 
    7692 
    7793  def _onTimeout(self): 
     
    87103      target.emit(signal, p1, p2) 
    88104   
     105  def _showNoA11yDialog(self): 
     106    ''' 
     107    Shows a dialog with a relevant message when desktop accessibility seems to 
     108    be disabled. If desktop accessibility is disabled in gconf, prompts the 
     109    user to enable it. 
     110    ''' 
     111    cl = gconf.client_get_default() 
     112    if not cl.get_bool('/desktop/gnome/interface/accessibility'): 
     113      message = _('Accerciser could not see the applications on your desktop.' 
     114                  'You must enable desktop accessibility to fix this problem.' 
     115                  'Do you want to enable it now?') 
     116      dialog = gtk.MessageDialog(self.window,type=gtk.MESSAGE_ERROR, 
     117                                 buttons=gtk.BUTTONS_YES_NO,  
     118                                 message_format=message) 
     119      response_id = dialog.run() 
     120      dialog.destroy() 
     121      if response_id == gtk.RESPONSE_YES: 
     122        cl = gconf.client_get_default() 
     123        cl.set_bool('/desktop/gnome/interface/accessibility', True) 
     124        dialog = gtk.MessageDialog( 
     125          self.window, 
     126          type=gtk.MESSAGE_INFO, 
     127          buttons=gtk.BUTTONS_OK,  
     128          message_format=_('Note: Changes only take effect after logout.')) 
     129        dialog.run() 
     130        dialog.destroy() 
     131      return False 
     132    return True 
     133 
     134  def _shutDown(self): 
     135    ''' 
     136    Cleans up any object instances that need explicit shutdown. 
     137    ''' 
     138    pass 
     139   
     140  def _stop(self): 
     141    self._shutDown() 
     142    pyatspi.Registry.stop() 
     143     
     144  def onDeleteEvent(self, widget, event, data=None): 
     145    self._stop() 
     146    return False 
     147 
    89148if __name__ == '__main__': 
    90149  app = App()