[orca] Part 2 of the fix for bgo#607990 - Orca should present the appearance of the icon for logged errors



commit 8fd095eeb57deb5375ae29c386ecf9f19def8ef1
Author: Joanmarie Diggs <joanmarie diggs gmail com>
Date:   Sun Jan 24 20:44:25 2010 -0500

    Part 2 of the fix for bgo#607990 - Orca should present the appearance of the icon for logged errors in packagemanager
    
    This implements the app-unique preference.

 src/orca/scripts/apps/packagemanager/Makefile.am   |    1 +
 src/orca/scripts/apps/packagemanager/script.py     |   55 ++++++++++++++++++-
 .../scripts/apps/packagemanager/script_settings.py |   28 ++++++++++
 3 files changed, 81 insertions(+), 3 deletions(-)
---
diff --git a/src/orca/scripts/apps/packagemanager/Makefile.am b/src/orca/scripts/apps/packagemanager/Makefile.am
index a294d4d..3daf180 100644
--- a/src/orca/scripts/apps/packagemanager/Makefile.am
+++ b/src/orca/scripts/apps/packagemanager/Makefile.am
@@ -4,6 +4,7 @@ orca_python_PYTHON = \
     __init__.py \
     braille_generator.py \
     script.py \
+    script_settings.py \
     speech_generator.py \
     tutorialgenerator.py
 
diff --git a/src/orca/scripts/apps/packagemanager/script.py b/src/orca/scripts/apps/packagemanager/script.py
index f18cb7f..86b62ab 100644
--- a/src/orca/scripts/apps/packagemanager/script.py
+++ b/src/orca/scripts/apps/packagemanager/script.py
@@ -1,6 +1,6 @@
 # Orca
 #
-# Copyright 2005-2009 Sun Microsystems Inc.
+# Copyright 2005-2010 Sun Microsystems Inc.
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Library General Public
@@ -22,9 +22,10 @@
 __id__        = "$Id$"
 __version__   = "$Revision$"
 __date__      = "$Date$"
-__copyright__ = "Copyright (c) 2005-2009 Sun Microsystems Inc."
+__copyright__ = "Copyright (c) 2005-2010 Sun Microsystems Inc."
 __license__   = "LGPL"
 
+import gtk
 import pyatspi
 
 import orca.braille as braille
@@ -40,6 +41,7 @@ from orca.orca_i18n import _
 from braille_generator import BrailleGenerator
 from speech_generator import SpeechGenerator
 from tutorialgenerator import TutorialGenerator
+import script_settings
 
 ########################################################################
 #                                                                      #
@@ -61,6 +63,10 @@ class Script(default.Script):
         self._lastObjectPresented = None
         self._presentedStatusBarIcon = False
 
+        # Initialize variable to None to make pylint happy.
+        #
+        self.presentLoggedErrorsCheckButton = None
+
     def getListeners(self):
         """Sets up the AT-SPI event listeners for this script."""
 
@@ -84,6 +90,48 @@ class Script(default.Script):
 
         return TutorialGenerator(self)
 
+    def getAppPreferencesGUI(self):
+        """Return a GtkVBox contain the application unique configuration
+        GUI items for the current application.
+        """
+
+        vbox = gtk.VBox(False, 0)
+        vbox.set_border_width(12)
+        gtk.Widget.show(vbox)
+
+        # Translators: The Package Manager application notifies the
+        # user of minor errors by displaying an icon in the status
+        # bar and adding them to an error log rather than displaying
+        # the error in a dialog box. This string is the label for a
+        # checkbox. If it is checked, Orca will inform the user when
+        # the notification icon has appeared.
+        #
+        label = _("Notify me when errors have been logged.")
+        self.presentLoggedErrorsCheckButton = gtk.CheckButton(label)
+        gtk.Widget.show(self.presentLoggedErrorsCheckButton)
+        gtk.Box.pack_start(vbox, self.presentLoggedErrorsCheckButton,
+                           False, False, 0)
+        gtk.ToggleButton.set_active(
+            self.presentLoggedErrorsCheckButton,
+            script_settings.presentLoggedErrors)
+
+        return vbox
+
+    def setAppPreferences(self, prefs):
+        """Write out the application specific preferences lines and set the
+        new values.
+
+        Arguments:
+        - prefs: file handle for application preferences.
+        """
+
+        prefs.writelines("\n")
+        script_settings.presentLoggedErrors = \
+                 self.presentLoggedErrorsCheckButton.get_active()
+        prefs.writelines("%s.presentLoggedErrors = %s\n" % \
+                         ("orca.scripts.apps.packagemanager.script_settings",
+                          script_settings.presentLoggedErrors))
+
     def locusOfFocusChanged(self, event, oldLocusOfFocus, newLocusOfFocus):
         """Called when the visual object with focus changes.
 
@@ -184,7 +232,8 @@ class Script(default.Script):
                 self._isBusy = False
             return
 
-        if not self._presentedStatusBarIcon \
+        if script_settings.presentLoggedErrors \
+           and not self._presentedStatusBarIcon \
            and event.source.getRole() == pyatspi.ROLE_PANEL \
            and event.type.startswith("object:state-changed:showing") \
            and event.detail1:
diff --git a/src/orca/scripts/apps/packagemanager/script_settings.py b/src/orca/scripts/apps/packagemanager/script_settings.py
new file mode 100644
index 0000000..bbacf8a
--- /dev/null
+++ b/src/orca/scripts/apps/packagemanager/script_settings.py
@@ -0,0 +1,28 @@
+# Orca
+#
+# Copyright 2005-2010 Sun Microsystems Inc.
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Library General Public
+# License as published by the Free Software Foundation; either
+# version 2 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
+# Boston MA  02110-1301 USA.
+
+__id__        = "$Id$"
+__version__   = "$Revision$"
+__date__      = "$Date$"
+__copyright__ = "Copyright (c) 2005-2010 Sun Microsystems Inc."
+__license__   = "LGPL"
+
+# Whether we present the indicator that an error has been logged
+#
+presentLoggedErrors = True



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]