Exemple #1
0
   def _buildMenu(self, context_plugin, transient_window):
       '''
 Build the menu according to the view managers model.
 
 @param context_plugin: Subject plugin of this menu.
 @type context_plugin: L{Plugin}
 @param transient_window: Transient parent window. Used for keeping the
 new view dialog modal.
 @type transient_window: gtk.Window
 '''
       menu_item = None
       for view in self.view_manager:
           menu_item = gtk.RadioMenuItem(label=_(view.view_name))
           menu_item.set_name(view.view_name)
           menu_item.connect('toggled', self._onItemToggled, view,
                             context_plugin)
           menu_item.set_active(view == context_plugin.get_parent())
           self.append(menu_item)
           menu_item.show()
       menu_item = gtk.SeparatorMenuItem()
       self.append(menu_item)
       menu_item.show()
       menu_item = gtk.MenuItem(label="<i>" + _('_New view…') + "</i>")
       menu_item.get_child().set_use_markup(True)
       menu_item.connect('activate', self._onItemActivated,
                         context_plugin, transient_window)
       self.append(menu_item)
       menu_item.show()
Exemple #2
0
 def _buildMenu(self, context_plugin, transient_window):
   '''
   Build the menu according to the view managers model.
   
   @param context_plugin: Subject plugin of this menu.
   @type context_plugin: L{Plugin}
   @param transient_window: Transient parent window. Used for keeping the
   new view dialog modal.
   @type transient_window: gtk.Window
   '''
   menu_item = None
   for view in self.view_manager:
     menu_item = gtk.RadioMenuItem(label = _(view.view_name))
     menu_item.set_name(view.view_name)
     menu_item.connect('toggled', self._onItemToggled, view, context_plugin)
     menu_item.set_active(view == context_plugin.get_parent())
     self.append(menu_item)
     menu_item.show()
   menu_item = gtk.SeparatorMenuItem()
   self.append(menu_item)
   menu_item.show()
   menu_item = gtk.MenuItem(label="<i>" + _('_New view...') + "</i>")
   menu_item.get_child().set_use_markup(True)
   menu_item.connect('activate', self._onItemActivated, 
                     context_plugin, transient_window)
   self.append(menu_item)
   menu_item.show()
    def _initTreeViews(self):
        '''
    Initialize the properties and methods tree views and models.
    '''
        # method view
        model = gtk.ListStore(str, str)
        self.method_tree.set_model(model)
        crt = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn(_('Method'))
        tvc.pack_start(crt, True)
        tvc.add_attribute(crt, 'text', 0)
        self.method_tree.append_column(tvc)

        # property view
        model = gtk.ListStore(str, str)
        self.property_tree.set_model(model)
        crt = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn(_('Property'))
        tvc.pack_start(crt, True)
        tvc.add_attribute(crt, 'text', 0)
        self.property_tree.append_column(tvc)
        crt = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn(_('Value'))
        tvc.pack_start(crt, True)
        tvc.add_attribute(crt, 'text', 1)
        self.property_tree.append_column(tvc)
 def _initTreeViews(self):
   '''
   Initialize the properties and methods tree views and models.
   '''
   # method view
   model = gtk.ListStore(str, str)
   self.method_tree.set_model(model)
   crt = gtk.CellRendererText()
   tvc = gtk.TreeViewColumn(_('Method'))
   tvc.pack_start(crt, True)
   tvc.set_attributes(crt, text=0)
   self.method_tree.append_column(tvc)
   
   # property view
   model = gtk.ListStore(str, str)
   self.property_tree.set_model(model)
   crt = gtk.CellRendererText()
   tvc = gtk.TreeViewColumn(_('Property'))
   tvc.pack_start(crt, True)
   tvc.set_attributes(crt, text=0)
   self.property_tree.append_column(tvc)
   crt = gtk.CellRendererText()
   tvc = gtk.TreeViewColumn(_('Value'))
   tvc.pack_start(crt, True)
   tvc.set_attributes(crt, text=1)
   self.property_tree.append_column(tvc)
    def _initTreeViews(self):
        """
    Initialize the properties and methods tree views and models.
    """
        # method view
        model = gtk.ListStore(str, str)
        self.method_tree.set_model(model)
        crt = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn(_("Method"))
        tvc.pack_start(crt, True)
        tvc.add_attribute(crt, "text", 0)
        self.method_tree.append_column(tvc)

        # property view
        model = gtk.ListStore(str, str)
        self.property_tree.set_model(model)
        crt = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn(_("Property"))
        tvc.pack_start(crt, True)
        tvc.add_attribute(crt, "text", 0)
        self.property_tree.append_column(tvc)
        crt = gtk.CellRendererText()
        tvc = gtk.TreeViewColumn(_("Value"))
        tvc.pack_start(crt, True)
        tvc.add_attribute(crt, "text", 1)
        self.property_tree.append_column(tvc)
Exemple #6
0
    def _writeFile(self):
        '''
    Save the report from the report model to disk in a temporary location.
    Close the file when finished.
    '''
        if self.write_in_progress:
            # if we have finished writing to the file
            if self.curr_file_row == self.n_report_rows:
                self.save_to.close()
                self._stopSave()
                return False
        else:
            # set up the file to be written
            self._startSave()
            self.save.set_sensitive(False)
            report_store = self.report.get_model()
            # create list of lists containing column values
            self.row_values = [[row[0], row[1], row[2], row[3]]
                               for row in report_store]
            self.n_report_rows = len(self.row_values)
            return True

        remaining_rows = self.n_report_rows - self.curr_file_row
        n_rows_to_write = 5
        if n_rows_to_write > remaining_rows:
            n_rows_to_write = remaining_rows

        file_str_list = []  # list to store strings to be written to file
        start = self.curr_file_row
        end = (self.curr_file_row + n_rows_to_write)
        for i in range(start, end):
            val = self.row_values[i]
            # add level to buffer
            file_str_list.append("%s: %s\n" % (_('Level'), val[0]))
            # add description to buffer
            file_str_list.append("%s: %s\n" % (_('Description'), val[1]))
            # add accessible's name to buffer
            file_str_list.append("%s: %s\n" % (_('Name'), val[2].name))
            # add accessible's role to buffer
            file_str_list.append("%s: %s\n" %
                                 (_('Role'), val[2].getRoleName()))
            # add url role to buffer
            file_str_list.append("%s: %s\n\n" % (_('Hyperlink'), val[3]))
            self.curr_file_row += 1

        self.save_to.write(''.join(file_str_list))

        return True
 def warn(self, text, acc, url=''):
   '''
   Used by validators to log warning messages for accessibility problems that
   should be fixed, but are not critical.
   '''
   level = _('WARN')
   self.report.get_model().append([level, text, acc, url])
Exemple #8
0
 def _buildUI(self):
     '''
 Manually build the plugin's UI.
 '''
     vbox = gtk.VBox()
     self.plugin_area.add(vbox)
     top_hbox = gtk.HBox()
     bottom_hbox = gtk.HBox()
     vbox.pack_start(top_hbox, False, True, 0)
     vbox.pack_start(bottom_hbox, True, True, 0)
     self.method_tree = gtk.TreeView()
     scrolled_window = gtk.ScrolledWindow()
     scrolled_window.add(self.method_tree)
     bottom_hbox.pack_start(scrolled_window, True, True, 0)
     self.property_tree = gtk.TreeView()
     scrolled_window = gtk.ScrolledWindow()
     scrolled_window.add(self.property_tree)
     bottom_hbox.pack_start(scrolled_window, True, True, 0)
     self.iface_combo = gtk.ComboBoxText.new()
     top_hbox.pack_start(self.iface_combo, False, True, 0)
     self.private_toggle = gtk.CheckButton.new_with_label(
         _('Hide private attributes'))
     self.private_toggle.set_active(True)
     top_hbox.pack_end(self.private_toggle, False, True, 0)
     self.show_all()
Exemple #9
0
     def __init__(self, view_manager, transient_window):
         '''
 
 
 @param view_manager: View manager to use as data model and controller.
 @type view_manager: L{ViewManager}
 @param transient_window: Transient parent window. Used for keeping the
 new view dialog modal.
 @type transient_window: gtk.Window
 '''
         self.view_manager = view_manager
         gtk.Dialog.__init__(self, _('New View…'), transient_window)
         self.add_buttons(gtk.STOCK_OK, gtk.ResponseType.OK,
                          gtk.STOCK_CLOSE, gtk.ResponseType.CLOSE)
         self.set_default_response(gtk.ResponseType.OK)
         completion = gtk.EntryCompletion()
         complete_model = gtk.ListStore(str)
         for view in self.view_manager:
             complete_model.append([view.view_name])
         completion.set_model(complete_model)
         completion.set_text_column(0)
         self.entry = gtk.Entry()
         self.entry.set_completion(completion)
         self.entry.connect('activate', self._onEntryActivate)
         self.box = self.get_children()[0]
         self.box.add(self.entry)
         self.entry.show()
Exemple #10
0
 def error(self, text, acc, url=""):
     """
 Used by validators to log messages for accessibility problems that have to
 be fixed.
 """
     level = _("ERROR")
     self.report.get_model().append([level, text, acc, url])
Exemple #11
0
 def error(self, text, acc, url=''):
     '''
 Used by validators to log messages for accessibility problems that have to
 be fixed.
 '''
     level = _('ERROR')
     self.report.get_model().append([level, text, acc, url])
Exemple #12
0
 def __init__(self, view_manager, transient_window):
   '''
   
   
   @param view_manager: View manager to use as data model and controller.
   @type view_manager: L{ViewManager}
   @param transient_window: Transient parent window. Used for keeping the
   new view dialog modal.
   @type transient_window: gtk.Window
   '''
   self.view_manager = view_manager
   gtk.Dialog.__init__(self, _('New View...'), transient_window)
   self.add_buttons(gtk.STOCK_OK, gtk.ResponseType.OK,
                    gtk.STOCK_CLOSE, gtk.ResponseType.CLOSE)
   self.set_default_response(gtk.ResponseType.OK)
   completion = gtk.EntryCompletion()
   complete_model = gtk.ListStore(str)
   for view in self.view_manager:
     complete_model.append([view.view_name])
   completion.set_model(complete_model)
   completion.set_text_column(0)
   self.entry = gtk.Entry()
   self.entry.set_completion(completion)
   self.entry.connect('activate', self._onEntryActivate)
   self.box = self.get_children()[0]
   self.box.add(self.entry)
   self.entry.show()
Exemple #13
0
 def before(self, acc, state, view):
   s = acc.getState()
   if s.contains(STATE_FOCUSED):
     if 'focus' not in state:
       state['focus'] = acc
     else:
       view.error(_('more than one focused widget'), acc, self.URL)
Exemple #14
0
 def before(self, acc, state, view):
     try:
         acc.querySelection()
     except NotImplementedError:
         view.error(
             _('focusable %s has a table interface, but not a selection interface'
               ) % acc.getLocalizedRoleName(), acc, self.URL)
Exemple #15
0
 def warn(self, text, acc, url=''):
     '''
 Used by validators to log warning messages for accessibility problems that
 should be fixed, but are not critical.
 '''
     level = _('WARN')
     self.report.get_model().append([level, text, acc, url])
 def error(self, text, acc, url=''):
   '''
   Used by validators to log messages for accessibility problems that have to
   be fixed.
   '''
   level = _('ERROR')
   self.report.get_model().append([level, text, acc, url])
Exemple #17
0
 def before(self, acc, state, view):
     try:
         acc.queryText()
     except NotImplementedError:
         view.error(
             _('%s has no text interface') % acc.getLocalizedRoleName(),
             acc, self.URL)
Exemple #18
0
 def _startValidate(self):
     '''
 Starts a validation by settting up an idle callback after initializing the
 report table and progress bar. Gets all validators for the selected schema.
 '''
     # clear the report
     self.report.get_model().clear()
     # get the validators
     index = self.schema.get_active()
     if index == -1:
         self.validate.set_active(False)
         return
     row = self.schema.get_model()[index]
     self.vals = ValidatorManager.getValidators(row[1])
     # build a new state dict
     state = {}
     # build our walk generator
     self.walk = self._traverse(self.acc, state)
     # register an idle callback
     self.idle_validate_id = GLib.idle_add(self._onValidateIdle)
     self.progress.set_text(_('Validating'))
     # disable controls
     self.schema.set_sensitive(False)
     self.help.set_sensitive(False)
     self.save.set_sensitive(False)
     self.clear.set_sensitive(False)
Exemple #19
0
 def before(self, acc, state, view):
     s = acc.getState()
     if s.contains(STATE_FOCUSED):
         if not state.has_key('focus'):
             state['focus'] = acc
         else:
             view.error(_('more than one focused widget'), acc, self.URL)
Exemple #20
0
 def before(self, acc, state, view):
     try:
         acc.queryAction()
     except NotImplementedError:
         view.error(
             _('interactive %s is not actionable') %
             acc.getLocalizedRoleName(), acc, self.URL)
  def _writeFile(self):
    '''
    Save the report from the report model to disk in a temporary location.
    Close the file when finished.
    '''
    if self.write_in_progress:
      # if we have finished writing to the file
      if self.curr_file_row == self.n_report_rows:
        self.save_to.close()
        self._stopSave()
        return False
    else:
      # set up the file to be written
      self._startSave()
      self.save.set_sensitive(False)
      report_store = self.report.get_model()
      # create list of lists containing column values
      self.row_values = [[row[0],row[1],row[2],row[3]] for row in report_store]
      self.n_report_rows = len(self.row_values)
      return True

    remaining_rows = self.n_report_rows - self.curr_file_row
    n_rows_to_write = 5
    if n_rows_to_write > remaining_rows:
      n_rows_to_write = remaining_rows
  
    file_str_list = [] # list to store strings to be written to file
    start = self.curr_file_row
    end = (self.curr_file_row + n_rows_to_write)
    for i in range(start, end):
      val = self.row_values[i]
      # add level to buffer
      file_str_list.append("%s: %s\n" % (_('Level'), val[0]))
      # add description to buffer
      file_str_list.append("%s: %s\n" % (_('Description'), val[1]))
      # add accessible's name to buffer
      file_str_list.append("%s: %s\n" % (_('Name'), val[2].name))
      # add accessible's role to buffer
      file_str_list.append("%s: %s\n" % (_('Role'), val[2].getRoleName()))
      # add url role to buffer
      file_str_list.append("%s: %s\n\n" % (_('Hyperlink'), val[3]))
      self.curr_file_row += 1
  
    self.save_to.write(''.join(file_str_list))

    return True
Exemple #22
0
 def before(self, acc, state, view):
   pi = acc.getIndexInParent()
   child = acc.parent.getChildAtIndex(pi)
   if acc != child:
     # Translators: The first variable is the role name of the object that has an
     # index mismatch.
     # 
     view.error(_('%s index in parent does not match child index') %
                acc.getLocalizedRoleName(), acc, self.URL)
Exemple #23
0
 def before(self, acc, state, view):
     pi = acc.getIndexInParent()
     child = acc.parent.getChildAtIndex(pi)
     if acc != child:
         # Translators: The first variable is the role name of the object that has an
         # index mismatch.
         #
         view.error(
             _('%s index in parent does not match child index') %
             acc.getLocalizedRoleName(), acc, self.URL)
Exemple #24
0
 def _exceptionError(self, acc, ex):
     '''
 Logs an unexpected exception that occurred during execution of a validator.
 
 @param acc: Accessible under test when the exception occurred
 @param ex: The exception
 '''
     info = traceback.extract_tb(sys.exc_info()[2])
     text = '%s (%d): %s' % (os.path.basename(info[-1][0]), info[-1][1], ex)
     self.report.get_model().append([_('EXCEPT'), text, acc, ''])
Exemple #25
0
 def __init__(self):
   '''
   Initialize tab.
   '''
   gtk.ScrolledWindow.__init__(self)
   self.set_name(_('Plugin Errors'))
   self._vbox = gtk.VBox()
   self._vbox.connect('remove', self._onMessageRemove)
   self.add_with_viewport(self._vbox)
   self.set_no_show_all(True)
   def __init__(self):
       '''
 Initialize tab.
 '''
       gtk.ScrolledWindow.__init__(self)
       self.set_name(_('Plugin Errors'))
       self._vbox = gtk.VBox()
       self._vbox.connect('remove', self._onMessageRemove)
       self.add_with_viewport(self._vbox)
       self.set_no_show_all(True)
 def _exceptionError(self, acc, ex):
   '''
   Logs an unexpected exception that occurred during execution of a validator.
   
   @param acc: Accessible under test when the exception occurred
   @param ex: The exception
   '''
   info = traceback.extract_tb(sys.exc_info()[2])
   text = '%s (%d): %s' % (os.path.basename(info[-1][0]), info[-1][1], ex)
   self.report.get_model().append([_('EXCEPT'), text, acc, ''])
Exemple #28
0
 def before(self, acc, state, view):
   s = acc.getRelationSet()
   for rel in s:
     kind = rel.getRelationType()
     for i in range(rel.getNTargets()):
       target = rel.getTarget(i)
       ts = target.getRelationSet()
       rec = self._getReciprocal(kind)
       if not self._hasRelationTarget(ts, rec, acc):
         view.error(_('Missing reciprocal for %s relation') %
                    rel.getRelationTypeName(), acc, self.URL)
Exemple #29
0
 def before(self, acc, state, view):
     s = acc.getRelationSet()
     for rel in s:
         kind = rel.getRelationType()
         for i in xrange(rel.getNTargets()):
             target = rel.getTarget(i)
             ts = target.getRelationSet()
             rec = self._getReciprocal(kind)
             if not self._hasRelationTarget(ts, rec, acc):
                 view.error(
                     _('Missing reciprocal for %s relation') %
                     rel.getRelationTypeName(), acc, self.URL)
Exemple #30
0
 def before(self, acc, state, view):
     ss = acc.getState()
     able_state = self.STATE_MAP[self.test_state]
     if not ss.contains(able_state):
         # Translators: First variable is an accessible role name, the next two
         # variables are accessible state names.
         # For example: "button has focused state without focusable state".
         #
         view.error(
             _('%s has %s state without %s state') %
             (acc.getLocalizedRoleName(), stateToString(self.test_state),
              stateToString(able_state)), acc, self.URL)
Exemple #31
0
 def before(self, acc, state, view):
   ss = acc.getState()
   able_state = self.STATE_MAP[self.test_state]
   if not ss.contains(able_state):
     # Translators: First variable is an accessible role name, the next two
     # variables are accessible state names.
     # For example: "button has focused state without focusable state".
     #
     view.error(_('%s has %s state without %s state') % (
       acc.getLocalizedRoleName(),
       stateToString(self.test_state),
       stateToString(able_state)), acc, self.URL)
Exemple #32
0
 def before(self, acc, state, view):
   if ((acc.name and acc.name.strip()) or
       (acc.description and acc.description.strip())):
     return
   ni = False
   try:
     im = acc.queryImage()
   except NotImplementedError:
     ni = True
   if ni or im.imageDescription is None or not im.imageDescription.strip():
     view.error(_('%s has no name or description') % 
                acc.getLocalizedRoleName(), acc, self.URL)
Exemple #33
0
 def _newView(self, view_name=None):
   '''
   Creates a new view.
   
   @param view_name: An optional view name. Gives a more mundane one if no
   name is provided.
   @type view_name: string
   
   @return: New view
   @rtype: L{PluginView}
   '''
   if not view_name:
     view_name = _('Plugin View')
     view_num = 2
     while view_name in self._getViewNames():
       view_name = _('Plugin View (%d)') % view_num
       view_num += 1
   w = PluginViewWindow(view_name)
   view = w.plugin_view
   self._connectSignals(view)
   self.append(view)
   return view
Exemple #34
0
 def _newView(self, view_name=None):
     '''
 Creates a new view.
 
 @param view_name: An optional view name. Gives a more mundane one if no
 name is provided.
 @type view_name: string
 
 @return: New view
 @rtype: L{PluginView}
 '''
     if not view_name:
         view_name = _('Plugin View')
         view_num = 2
         while view_name in self._getViewNames():
             view_name = _('Plugin View (%d)') % view_num
             view_num += 1
     w = PluginViewWindow(view_name)
     view = w.plugin_view
     self._connectSignals(view)
     self.append(view)
     return view
 def _startSave(self):
   '''
   Starts a save by settting up an idle callback after initializing progress
   bar.
   '''
   # set variables for writing report to file
   self.write_in_progress = True
   self._setDefaultSaveVars()
   # register an idle callback
   self.idle_save_id = GObject.idle_add(self._onSaveIdle)
   self.progress.set_text(_('Saving'))
   # disable controls
   self.validate.set_sensitive(False)
   self.save.set_sensitive(False)
Exemple #36
0
 def before(self, acc, state, view):
   attrs = acc.getAttributes()
   m = dict([attr.split(':', 1) for attr in attrs])
   if 'posinset' in m:
     return
   rels = acc.getRelationSet()
   for rel in rels:
     if rel.getRelationType() == RELATION_MEMBER_OF:
       return
   # Translators: The radio button does not belong to a set, thus it is useless.
   # The first variable is the object's role name.
   # 
   view.error(_('%s does not belong to a set') % acc.getLocalizedRoleName(),
              acc, self.URL)
Exemple #37
0
 def before(self, acc, state, view):
     if ((acc.name and acc.name.strip())
             or (acc.description and acc.description.strip())):
         return
     ni = False
     try:
         im = acc.queryImage()
     except NotImplementedError:
         ni = True
     if ni or im.imageDescription is None or not im.imageDescription.strip(
     ):
         view.error(
             _('%s has no name or description') %
             acc.getLocalizedRoleName(), acc, self.URL)
Exemple #38
0
 def _startSave(self):
     '''
 Starts a save by settting up an idle callback after initializing progress
 bar.
 '''
     # set variables for writing report to file
     self.write_in_progress = True
     self._setDefaultSaveVars()
     # register an idle callback
     self.idle_save_id = GObject.idle_add(self._onSaveIdle)
     self.progress.set_text(_('Saving'))
     # disable controls
     self.validate.set_sensitive(False)
     self.save.set_sensitive(False)
Exemple #39
0
 def before(self, acc, state, view):
   if self._checkForReadable(acc):
     return
   for rel in acc.getRelationSet():
     if rel.getRelationType() != RELATION_LABELLED_BY:
       continue
     for i in range(rel.getNTargets()):
       target = rel.getTarget(i)
       if self._checkForReadable(target):
         return
   # Translators: The first variable is the role name of the object that is missing
   # the name or label.
   # 
   view.error(_('%s missing name or label') % acc.getLocalizedRoleName(), acc,
              self.URL)
Exemple #40
0
 def before(self, acc, state, view):
     attrs = acc.getAttributes()
     m = dict([attr.split(':', 1) for attr in attrs])
     if m.has_key('posinset'):
         return
     rels = acc.getRelationSet()
     for rel in rels:
         if rel.getRelationType() == RELATION_MEMBER_OF:
             return
     # Translators: The radio button does not belong to a set, thus it is useless.
     # The first variable is the object's role name.
     #
     view.error(
         _('%s does not belong to a set') % acc.getLocalizedRoleName(), acc,
         self.URL)
Exemple #41
0
 def loadSchemas():
     """
 Loads all schema files from well known locations.
 """
     for path in [USER_SCHEMA_PATH, SYS_SCHEMA_PATH]:
         for fn in glob.glob(os.path.join(path, "*.py")):
             module = os.path.basename(fn)[:-3]
             params = imp.find_module(module, [path])
             schema = imp.load_module(module, *params)
             try:
                 # try to get descriptive fields from the module
                 SCHEMA_METADATA[module] = schema.__metadata__
             except AttributeError:
                 # default to usinf file name as description
                 SCHEMA_METADATA[module] = {"name": module, "description": _("No description")}
Exemple #42
0
 def before(self, acc, state, view):
     if self._checkForReadable(acc):
         return
     for rel in acc.getRelationSet():
         if rel.getRelationType() != RELATION_LABELLED_BY:
             continue
         for i in xrange(rel.getNTargets()):
             target = rel.getTarget(i)
             if self._checkForReadable(target):
                 return
     # Translators: The first variable is the role name of the object that is missing
     # the name or label.
     #
     view.error(
         _('%s missing name or label') % acc.getLocalizedRoleName(), acc,
         self.URL)
 def _stopSave(self):
   '''
   Stops a save by disabling the idle callback and restoring the various UI
   components to their enabled states.
   '''
   # stop callbacks
   GObject.source_remove(self.idle_save_id)
   # reset progress
   self.progress.set_fraction(0.0)
   self.progress.set_text(_('Idle'))
   # enable other controls
   self.validate.set_sensitive(True)
   self.save.set_sensitive(True)
   self.save.set_sensitive(True)
   # reset variables for writing report to file
   self._setDefaultSaveVars()
   self.write_in_progress = False
Exemple #44
0
 def _stopSave(self):
     '''
 Stops a save by disabling the idle callback and restoring the various UI
 components to their enabled states.
 '''
     # stop callbacks
     GObject.source_remove(self.idle_save_id)
     # reset progress
     self.progress.set_fraction(0.0)
     self.progress.set_text(_('Idle'))
     # enable other controls
     self.validate.set_sensitive(True)
     self.save.set_sensitive(True)
     self.save.set_sensitive(True)
     # reset variables for writing report to file
     self._setDefaultSaveVars()
     self.write_in_progress = False
Exemple #45
0
 def before(self, acc, state, view):
   t = acc.queryTable()
   samples = max(t.nRows * t.nColumns, self.MAX_SAMPLES)
   for i in range(samples):
     r, c = _randomRowCol(t)
     i = t.getIndexAt(r, c)
     ir = t.getRowAtIndex(i)
     ic = t.getColumnAtIndex(i)
     if r != ir or c != ic:
       # Translators: The row or column number retrieved from a table child's
       # object at a certain index is wrong.
       # The first variable is the role name of the object, the second is the
       # given index.
       # 
       view.error(_('%(rolename)s index %(num)d does not match row and column') %
                  {'rolename':acc.getLocalizedRoleName(), 'num':i}, acc, self.URL)
       return
Exemple #46
0
  def _setupActions(self):
    '''
    Sets up actions related to plugin layout.
    '''
    single = isinstance(self._view_model, SingleViewModel)
    layout_action_group = gtk.ActionGroup('PluginActions')
    ui_manager.uimanager.insert_action_group(layout_action_group, 0)
    layout_action_group.add_toggle_actions(
      [('SingleViewMode', None, _('_Single plugins view'), '<Control>t',
        None, self._onSingleViewToggled, single)])

    for action in layout_action_group.list_actions():
      merge_id = ui_manager.uimanager.new_merge_id()
      action_name = action.get_name()
      ui_manager.uimanager.add_ui(merge_id, ui_manager.PLUGIN_LAYOUT_PATH, 
                                  action_name, action_name, 
                                  gtk.UIManagerItemType.MENUITEM, True)
Exemple #47
0
 def before(self, acc, state, view):
   t = acc.queryTable()
   samples = max(t.nRows * t.nColumns, self.MAX_SAMPLES)
   for i in range(samples):
     r, c = _randomRowCol(t)
     child = t.getAccessibleAt(r, c)
     ip = child.getIndexInParent()
     i = t.getIndexAt(r, c)
     if i != ip:
       # Translators: The "parent index" is the order of the child in the parent.
       # the "row and column index" should be the same value retrieved by the
       # object's location in the table.
       # The first variable is the object's role name, the second and third variables
       # are index numbers.
       #
       view.error(_('%(rolename)s parent index %(num1)d does not match row and column index %(num2)d') %
                  {'rolename':acc.getLocalizedRoleName(), 'num1':ip, 'num2':i}, acc, self.URL)
       return
Exemple #48
0
 def loadSchemas():
     '''
 Loads all schema files from well known locations.
 '''
     for path in [USER_SCHEMA_PATH, SYS_SCHEMA_PATH]:
         for fn in glob.glob(os.path.join(path, '*.py')):
             module = os.path.basename(fn)[:-3]
             params = imp.find_module(module, [path])
             schema = imp.load_module(module, *params)
             try:
                 # try to get descriptive fields from the module
                 SCHEMA_METADATA[module] = schema.__metadata__
             except AttributeError:
                 # default to usinf file name as description
                 SCHEMA_METADATA[module] = {
                     'name': module,
                     'description': _('No description')
                 }
Exemple #49
0
    def _setupActions(self):
        '''
    Sets up actions related to plugin layout.
    '''
        single = isinstance(self._view_model, SingleViewModel)
        layout_action_group = gtk.ActionGroup.new('PluginActions')
        ui_manager.uimanager.insert_action_group(layout_action_group, 0)
        layout_action_group.add_toggle_actions([
            ('SingleViewMode', None, _('_Single plugins view'), '<Control>t',
             None, self._onSingleViewToggled, single)
        ])

        for action in layout_action_group.list_actions():
            merge_id = ui_manager.uimanager.new_merge_id()
            action_name = action.get_name()
            ui_manager.uimanager.add_ui(merge_id,
                                        ui_manager.PLUGIN_LAYOUT_PATH,
                                        action_name, action_name,
                                        gtk.UIManagerItemType.MENUITEM, True)
 def _stopValidate(self):
   '''
   Stops a validation run by disabling the idle callback and restoring the
   various UI components to their enabled states.
   '''
   # stop callbacks
   GObject.source_remove(self.idle_validate_id)
   # destroy generator
   self.walk = None
   # reset progress
   self.progress.set_fraction(0.0)
   self.progress.set_text(_('Idle'))
   # depress validate
   self.validate.set_active(False)
   # enable other controls
   self.schema.set_sensitive(True)
   self.help.set_sensitive(True)
   self.save.set_sensitive(True)
   self.clear.set_sensitive(True)
Exemple #51
0
 def _stopValidate(self):
     '''
 Stops a validation run by disabling the idle callback and restoring the
 various UI components to their enabled states.
 '''
     # stop callbacks
     GObject.source_remove(self.idle_validate_id)
     # destroy generator
     self.walk = None
     # reset progress
     self.progress.set_fraction(0.0)
     self.progress.set_text(_('Idle'))
     # depress validate
     self.validate.set_active(False)
     # enable other controls
     self.schema.set_sensitive(True)
     self.help.set_sensitive(True)
     self.save.set_sensitive(True)
     self.clear.set_sensitive(True)
class Console(ViewportPlugin):
  '''
  Plugin class for IPython console.
  '''
  plugin_name = N_('IPython Console')
  plugin_name_localized = _(plugin_name)
  plugin_description = \
      N_('Interactive console for manipulating currently selected accessible')
  def init(self):
    '''
    Initialize plugin.
    '''
    sw = gtk.ScrolledWindow()
    self.plugin_area.add(sw)
    self.ipython_view = ipython_view.IPythonView()
    self.ipython_view.updateNamespace({'acc': None})
    self.ipython_view.updateNamespace(pyatspi.__dict__)
    self.ipython_view.updateNamespace({'desktop': 
                                      pyatspi.Registry.getDesktop(0)})
    self.ipython_view.updateNamespace({'show': self._showAcc})
    sw.add(self.ipython_view)
  
  def onAccChanged(self, acc):
    '''
    Update 'acc' variable in console namespace with currently 
    selected accessible.
    
    @param acc: The currently selected accessible.
    @type acc: Accessibility.Accessible
    '''
    self.ipython_view.updateNamespace({'acc': acc})

  def _showAcc(self, acc):
    '''
    A method that is exposed in the console's namespace that allows the user 
    to show a given accessible in the main application.
    
    @param acc: Accessible to show.
    @type acc: Accessibility.Accessible
    '''
    self.node.update(acc)
Exemple #53
0
 def before(self, acc, state, view):
     t = acc.queryTable()
     samples = max(t.nRows * t.nColumns, self.MAX_SAMPLES)
     for i in xrange(samples):
         r, c = _randomRowCol(t)
         i = t.getIndexAt(r, c)
         ir = t.getRowAtIndex(i)
         ic = t.getColumnAtIndex(i)
         if r != ir or c != ic:
             # Translators: The row or column number retrieved from a table child's
             # object at a certain index is wrong.
             # The first variable is the role name of the object, the second is the
             # given index.
             #
             view.error(
                 _('%(rolename)s index %(num)d does not match row and column'
                   ) % {
                       'rolename': acc.getLocalizedRoleName(),
                       'num': i
                   }, acc, self.URL)
             return
Exemple #54
0
   def _viewNameDataFunc(self, column, cell, model, iter, foo=None):
       '''
 Function for determining the displayed data in the tree's view column.
 
 @param column: Column number.
 @type column: integer
 @param cell: Cellrender.
 @type cell: gtk.CellRendererText
 @param model: Tree's model
 @type model: gtk.ListStore
 @param iter: Tree iter of current row,
 @type iter: gtk.TreeIter
 '''
       plugin_class = model[iter][self.plugin_manager.COL_CLASS]
       if issubclass(plugin_class, gtk.Widget):
           view_name = \
               self.view_manager.getViewNameForPlugin(plugin_class.plugin_name)
           cell.set_property('sensitive', True)
       else:
           view_name = N_('No view')
           cell.set_property('sensitive', False)
       cell.set_property('text', _(view_name))
 def _viewNameDataFunc(self, column, cell, model, iter):
   '''
   Function for determining the displayed data in the tree's view column.
   
   @param column: Column number.
   @type column: integer
   @param cell: Cellrender.
   @type cell: gtk.CellRendererText
   @param model: Tree's model
   @type model: gtk.ListStore
   @param iter: Tree iter of current row,
   @type iter: gtk.TreeIter
   '''
   plugin_class = model[iter][self.plugin_manager.COL_CLASS]
   if issubclass(plugin_class, gtk.Widget):
     view_name = \
         self.view_manager.getViewNameForPlugin(plugin_class.plugin_name)
     cell.set_property('sensitive', True)
   else:
     view_name = N_('No view')
     cell.set_property('sensitive', False)
   cell.set_property('text', _(view_name))
Exemple #56
0
 def before(self, acc, state, view):
     t = acc.queryTable()
     samples = max(t.nRows * t.nColumns, self.MAX_SAMPLES)
     for i in xrange(samples):
         r, c = _randomRowCol(t)
         child = t.getAccessibleAt(r, c)
         ip = child.getIndexInParent()
         i = t.getIndexAt(r, c)
         if i != ip:
             # Translators: The "parent index" is the order of the child in the parent.
             # the "row and column index" should be the same value retrieved by the
             # object's location in the table.
             # The first variable is the object's role name, the second and third variables
             # are index numbers.
             #
             view.error(
                 _('%(rolename)s parent index %(num1)d does not match row and column index %(num2)d'
                   ) % {
                       'rolename': acc.getLocalizedRoleName(),
                       'num1': ip,
                       'num2': i
                   }, acc, self.URL)
             return
 def _startValidate(self):
   '''
   Starts a validation by settting up an idle callback after initializing the
   report table and progress bar. Gets all validators for the selected schema.
   '''
   # clear the report
   self.report.get_model().clear()
   # get the validators
   index = self.schema.get_active()
   row = self.schema.get_model()[index]
   self.vals = ValidatorManager.getValidators(row[1])
   # build a new state dict
   state = {}
   # build our walk generator
   self.walk = self._traverse(self.acc, state)
   # register an idle callback
   self.idle_validate_id = GObject.idle_add(self._onValidateIdle)
   self.progress.set_text(_('Validating'))
   # disable controls
   self.schema.set_sensitive(False)
   self.help.set_sensitive(False)
   self.save.set_sensitive(False)
   self.clear.set_sensitive(False)
    def __init__(self, plugin_manager):
      '''
      Initialize view.
      
      @param plugin_manager: Plugin manager to use as data model.
      @type plugin_manager: L{PluginManager}
      '''
      gtk.TreeView.__init__(self)
      self.plugin_manager = plugin_manager
      self.view_manager = plugin_manager.view_manager
      self.set_model(plugin_manager)
      self.connect('button-press-event', self._onButtonPress)
      self.connect('popup-menu', self._onPopupMenu)

      crc = gtk.CellRendererToggle()
      crc.connect('toggled', self._onPluginToggled)
      tvc = gtk.TreeViewColumn()
      tvc.pack_start(crc, True)
      tvc.set_cell_data_func(crc, self._pluginStateDataFunc)
      self.append_column(tvc)

      crt = gtk.CellRendererText()
      tvc = gtk.TreeViewColumn(_('Name'))
      tvc.pack_start(crt, True)
      tvc.set_cell_data_func(crt, self._pluginNameDataFunc)
      self.append_column(tvc)

      crc = gtk.CellRendererText()
      # Translators: This is the viewport in which the plugin appears,
      # it is a noun.
      # 
      tvc = gtk.TreeViewColumn(C_('viewport', 'View'))
      tvc.pack_start(crc, False)
      tvc.set_cell_data_func(crc, self._viewNameDataFunc)
      crc.set_property('editable', True)
      crc.connect('edited', self._onViewChanged)
      self.append_column(tvc)
Exemple #59
0
 def _buildUI(self):
   '''
   Manually build the plugin's UI.
   '''
   vbox = gtk.VBox()
   self.plugin_area.add(vbox)
   top_hbox = gtk.HBox()
   bottom_hbox = gtk.HBox()
   vbox.pack_start(top_hbox, False)
   vbox.pack_start(bottom_hbox)
   self.method_tree = gtk.TreeView()
   scrolled_window = gtk.ScrolledWindow()
   scrolled_window.add(self.method_tree)
   bottom_hbox.pack_start(scrolled_window)
   self.property_tree = gtk.TreeView()
   scrolled_window = gtk.ScrolledWindow()
   scrolled_window.add(self.property_tree)
   bottom_hbox.pack_start(scrolled_window)
   self.iface_combo = gtk.combo_box_new_text() 
   top_hbox.pack_start(self.iface_combo, False)
   self.private_toggle = gtk.CheckButton(_('Hide private attributes'))
   self.private_toggle.set_active(True)
   top_hbox.pack_end(self.private_toggle, False)
   self.show_all()
 def _buildUI(self):
     """
 Manually build the plugin's UI.
 """
     vbox = gtk.VBox()
     self.plugin_area.add(vbox)
     top_hbox = gtk.HBox()
     bottom_hbox = gtk.HBox()
     vbox.pack_start(top_hbox, False, True, 0)
     vbox.pack_start(bottom_hbox, True, True, 0)
     self.method_tree = gtk.TreeView()
     scrolled_window = gtk.ScrolledWindow()
     scrolled_window.add(self.method_tree)
     bottom_hbox.pack_start(scrolled_window, True, True, 0)
     self.property_tree = gtk.TreeView()
     scrolled_window = gtk.ScrolledWindow()
     scrolled_window.add(self.property_tree)
     bottom_hbox.pack_start(scrolled_window, True, True, 0)
     self.iface_combo = gtk.ComboBoxText.new()
     top_hbox.pack_start(self.iface_combo, False, True, 0)
     self.private_toggle = gtk.CheckButton(_("Hide private attributes"))
     self.private_toggle.set_active(True)
     top_hbox.pack_end(self.private_toggle, False, True, 0)
     self.show_all()