accerciser r552 - in trunk: . plugins
- From: eitani svn gnome org
- To: svn-commits-list gnome org
- Subject: accerciser r552 - in trunk: . plugins
- Date: Wed, 26 Mar 2008 21:04:11 +0000 (GMT)
Author: eitani
Date: Wed Mar 26 21:04:11 2008
New Revision: 552
URL: http://svn.gnome.org/viewvc/accerciser?rev=552&view=rev
Log:
* plugins/validate.glade:
* plugins/validate.py: Implement save functionality,
thanks Brian Merrell! (bug #508665). Added an extra column
to the append in _exceptionError()'s append to model.
Modified:
trunk/ChangeLog
trunk/plugins/validate.glade
trunk/plugins/validate.py
Modified: trunk/plugins/validate.glade
==============================================================================
--- trunk/plugins/validate.glade (original)
+++ trunk/plugins/validate.glade Wed Mar 26 21:04:11 2008
@@ -1,145 +1,281 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--*- mode: xml -*-->
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
+
<glade-interface>
- <widget class="GtkWindow" id="window1">
- <child>
- <widget class="GtkVBox" id="main vbox">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="spacing">5</property>
- <child>
- <widget class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
- <child>
- <widget class="GtkTreeView" id="report table">
- <property name="visible">True</property>
- <property name="reorderable">True</property>
- <property name="rules_hint">True</property>
- <signal name="row_activated" handler="_onActivateRow"/>
- <signal name="cursor_changed" handler="_onCursorChanged"/>
- </widget>
- </child>
- </widget>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="spacing">3</property>
- <child>
- <widget class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Sche_ma:</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">schema combo</property>
- <accessibility>
- <atkrelation target="schema combo" type="label-for"/>
- </accessibility>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkComboBox" id="schema combo">
- <property name="visible">True</property>
- <accessibility>
- <atkrelation target="label1" type="labelled-by"/>
- </accessibility>
- </widget>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
- <property name="spacing">3</property>
- <child>
- <widget class="GtkToggleButton" id="validate button">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="response_id">0</property>
- <signal name="toggled" handler="_onValidate"/>
- <child>
- <widget class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="spacing">5</property>
- <child>
- <widget class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="stock">gtk-apply</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="button label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">V_alidate</property>
- <property name="use_underline">True</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <widget class="GtkButton" id="help button">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="label">gtk-help</property>
- <property name="use_stock">True</property>
- <property name="response_id">0</property>
- <signal name="clicked" handler="_onHelp"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">GTK_PACK_END</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkProgressBar" id="progress bar">
- <property name="visible">True</property>
- <property name="pulse_step">0.0099999997764800008</property>
- <property name="text" translatable="yes">Idle</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">3</property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
+
+<widget class="GtkWindow" id="window1">
+ <property name="title" translatable="yes"></property>
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
+ <property name="window_position">GTK_WIN_POS_NONE</property>
+ <property name="modal">False</property>
+ <property name="resizable">True</property>
+ <property name="destroy_with_parent">False</property>
+ <property name="decorated">True</property>
+ <property name="skip_taskbar_hint">False</property>
+ <property name="skip_pager_hint">False</property>
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+ <property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
+
+ <child>
+ <widget class="GtkVBox" id="main vbox">
+ <property name="border_width">5</property>
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">5</property>
+
+ <child>
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
+
+ <child>
+ <widget class="GtkTreeView" id="report table">
+ <property name="visible">True</property>
+ <property name="headers_visible">True</property>
+ <property name="rules_hint">True</property>
+ <property name="reorderable">True</property>
+ <property name="enable_search">True</property>
+ <property name="fixed_height_mode">False</property>
+ <property name="hover_selection">False</property>
+ <property name="hover_expand">False</property>
+ <signal name="row_activated" handler="_onActivateRow"/>
+ <signal name="cursor_changed" handler="_onCursorChanged"/>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">3</property>
+
+ <child>
+ <widget class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Sche_ma:</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="mnemonic_widget">schema combo</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ <accessibility>
+ <atkrelation target="schema combo" type="label-for"/>
+ </accessibility>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkComboBox" id="schema combo">
+ <property name="visible">True</property>
+ <property name="add_tearoffs">False</property>
+ <property name="focus_on_click">True</property>
+ <accessibility>
+ <atkrelation target="label1" type="labelled-by"/>
+ </accessibility>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">3</property>
+
+ <child>
+ <widget class="GtkToggleButton" id="validate button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">False</property>
+ <property name="inconsistent">False</property>
+ <signal name="toggled" handler="_onValidate"/>
+
+ <child>
+ <widget class="GtkHBox" id="hbox2">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">5</property>
+
+ <child>
+ <widget class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="stock">gtk-apply</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="button label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">V_alidate</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox4">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkButton" id="save button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-save</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="_onSave" last_modification_time="Mon, 11 Feb 2008 17:01:40 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="clear button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-clear</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="_onClear" last_modification_time="Mon, 11 Feb 2008 17:01:30 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkButton" id="help button">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="label">gtk-help</property>
+ <property name="use_stock">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <signal name="clicked" handler="_onHelp"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkProgressBar" id="progress bar">
+ <property name="visible">True</property>
+ <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
+ <property name="fraction">0</property>
+ <property name="pulse_step">0.00999999977648</property>
+ <property name="text" translatable="yes">Idle</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
Modified: trunk/plugins/validate.py
==============================================================================
--- trunk/plugins/validate.py (original)
+++ trunk/plugins/validate.py Wed Mar 26 21:04:11 2008
@@ -152,7 +152,10 @@
plugin_name = N_('AT-SPI Validator')
plugin_name_localized = _(plugin_name)
plugin_description = N_('Validates application accessibility')
-
+
+ # keep track of when a file is being written
+ write_in_progress = False
+
def init(self):
'''
Loads the glade UI definition and initializes it.
@@ -173,7 +176,10 @@
self.progress = self.main_xml.get_widget('progress bar')
self.validate = self.main_xml.get_widget('validate button')
self.help = self.main_xml.get_widget('help button')
+ self.save = self.main_xml.get_widget('save button')
+ self.clear = self.main_xml.get_widget('clear button')
self.schema = self.main_xml.get_widget('schema combo')
+ self.validator_buffer = gtk.TextBuffer()
# model for the combobox
model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
@@ -232,8 +238,83 @@
else:
self._stopValidate()
- def _onSaveAs(self, button):
- pass
+ 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 _onSave(self, button):
+ '''
+ Save the report from the report model to disk
+
+ @param button: Save button
+ '''
+ save_dialog = gtk.FileChooserDialog(
+ 'Save validator output',
+ action=gtk.FILE_CHOOSER_ACTION_SAVE,
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OK, gtk.RESPONSE_OK))
+ #save_dialog.connect("response", self._savedDiagResponse)
+ save_dialog.set_do_overwrite_confirmation(True)
+ save_dialog.set_default_response(gtk.RESPONSE_OK)
+ response = save_dialog.run()
+ if response == gtk.RESPONSE_OK:
+ self.save_to = open(save_dialog.get_filename(), 'w')
+ gobject.idle_add(self._writeFile)
+ save_dialog.destroy()
+
+ def _onClear(self, button):
+ '''
+ Clear the report from the report model
+
+ @param button: Clear button
+ '''
+ self.report.get_model().clear()
+ self.validator_buffer.set_text('')
+ self.save.set_sensitive(False)
+ self.clear.set_sensitive(False)
def _onHelp(self, button):
'''
@@ -243,6 +324,54 @@
'''
webbrowser.open(self.url)
+ def _onSaveIdle(self):
+ '''
+ Move the progress bar
+ '''
+ self.progress.pulse()
+ return True
+
+ 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)
+
+ 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
+
+ def _setDefaultSaveVars(self):
+ '''
+ Ready appropriate variables for a save
+ '''
+ self.curr_file_row = 0
+ self.n_report_rows = 0
+ self.row_values = []
+
def _startValidate(self):
'''
Starts a validation by settting up an idle callback after initializing the
@@ -259,11 +388,13 @@
# build our walk generator
self.walk = self._traverse(self.acc, state)
# register an idle callback
- self.idle_id = gobject.idle_add(self._onIdle)
+ 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 _stopValidate(self):
'''
@@ -271,7 +402,7 @@
various UI components to their enabled states.
'''
# stop callbacks
- gobject.source_remove(self.idle_id)
+ gobject.source_remove(self.idle_validate_id)
# destroy generator
self.walk = None
# reset progress
@@ -281,8 +412,11 @@
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)
- def _onIdle(self):
+ def _onValidateIdle(self):
'''
Tests one accessible at a time on each idle callback by advancing the
walk generator.
@@ -411,30 +545,46 @@
'''
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])
-
+ self.report.get_model().append([_('EXCEPT'), text, acc, ''])
+
def error(self, text, acc, url=''):
'''
Used by validators to log messages for accessibility problems that have to
be fixed.
'''
- self.report.get_model().append([_('ERROR'), text, acc, url])
+ level = _('ERROR')
+ self.report.get_model().append([level, text, acc, url])
def warn(self, text, acc, url=''):
'''
Used by validators to log warning messages for accessibility problems that
should be fixed, but are not critical.
'''
- self.report.get_model().append([_('WARN'), text, acc, url])
+ level = _('WARN')
+ self.report.get_model().append([level, text, acc, url])
def info(self, text, acc, url=''):
'''
Used by validators to log informational messages.
'''
- self.report.get_model().append([_('INFO'), text, acc, url])
+ level = _('INFO')
+ self.report.get_model().append([level, text, acc, url])
def debug(self, text, acc, url=''):
'''
Used by validators to log debug messages.
'''
- self.report.get_model().append([_('DEBUG'), text, acc, url])
+ level = _('DEBUG')
+ self.report.get_model().append([level, text, acc, url])
+
+ def close(self):
+ '''
+ Things to do before the plugin closes.
+ '''
+ # don't close the plugin until we have finished writing
+ while True:
+ if not self.write_in_progress:
+ break
+ gtk.main_iteration_do(True)
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]