orca r3912 - in trunk: . src/orca



Author: richb
Date: Wed May 21 16:57:40 2008
New Revision: 3912
URL: http://svn.gnome.org/viewvc/orca?rev=3912&view=rev

Log:
        * src/orca/settings.py:
          src/orca/orca-setup.glade:
          src/orca/orca_gui_prefs.py:
          Fix for bug #448817 - Being able to configure autostart from
          orca's settings.


Modified:
   trunk/ChangeLog
   trunk/src/orca/orca-setup.glade
   trunk/src/orca/orca_gui_prefs.py
   trunk/src/orca/settings.py

Modified: trunk/src/orca/orca-setup.glade
==============================================================================
--- trunk/src/orca/orca-setup.glade	(original)
+++ trunk/src/orca/orca-setup.glade	Wed May 21 16:57:40 2008
@@ -319,6 +319,26 @@
 		      <property name="fill">False</property>
 		    </packing>
 		  </child>
+
+		  <child>
+		    <widget class="GtkCheckButton" id="autostartOrcaCheckbutton">
+		      <property name="visible">True</property>
+		      <property name="can_focus">True</property>
+		      <property name="label" translatable="yes">Start Orca when you lo_gin</property>
+		      <property name="use_underline">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>
+		      <property name="draw_indicator">True</property>
+		      <signal name="toggled" handler="autostartOrcaChecked" last_modification_time="Tue, 13 May 2008 14:30:23 GMT"/>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">False</property>
+		    </packing>
+		  </child>
 		</widget>
 		<packing>
 		  <property name="tab_expand">False</property>
@@ -1272,8 +1292,8 @@
 				  <property name="wrap">False</property>
 				  <property name="adjustment">10 1 9999 1 10 10</property>
 				  <accessibility>
-				    <atkrelation target="speakProgressBarUnitsLabel" type="labelled-by"/>
 				    <atkrelation target="speakProgressBarLabel" type="labelled-by"/>
+				    <atkrelation target="speakProgressBarUnitsLabel" type="labelled-by"/>
 				  </accessibility>
 				  <signal name="value_changed" handler="speakProgressBarValueChanged" last_modification_time="Thu, 14 Jun 2007 15:09:00 GMT"/>
 				</widget>
@@ -3681,8 +3701,8 @@
 							  <property name="wrap">False</property>
 							  <property name="adjustment">1 24 256 1 10 10</property>
 							  <accessibility>
-							    <atkrelation target="magCursorSizeLabel" type="labelled-by"/>
 							    <atkrelation target="magCursorSizeUnitsLabel" type="labelled-by"/>
+							    <atkrelation target="magCursorSizeLabel" type="labelled-by"/>
 							  </accessibility>
 							  <signal name="value_changed" handler="magCursorSizeValueChanged" last_modification_time="Wed, 03 May 2006 15:31:48 GMT"/>
 							</widget>
@@ -4034,8 +4054,8 @@
 							  <property name="wrap">False</property>
 							  <property name="adjustment">1 1 256 1 10 10</property>
 							  <accessibility>
-							    <atkrelation target="magCrossHairSizeLabel" type="labelled-by"/>
 							    <atkrelation target="magCrossHairSizeUnitsLabel" type="labelled-by"/>
+							    <atkrelation target="magCrossHairSizeLabel" type="labelled-by"/>
 							  </accessibility>
 							  <signal name="value_changed" handler="magCrossHairSizeValueChanged" last_modification_time="Wed, 03 May 2006 15:39:23 GMT"/>
 							</widget>
@@ -4472,8 +4492,8 @@
 						  <property name="wrap">False</property>
 						  <property name="adjustment">0 0 100 1 10 10</property>
 						  <accessibility>
-						    <atkrelation target="magEdgeMarginUnitsLabel" type="labelled-by"/>
 						    <atkrelation target="magEdgeMarginLabel" type="labelled-by"/>
+						    <atkrelation target="magEdgeMarginUnitsLabel" type="labelled-by"/>
 						  </accessibility>
 						  <signal name="value_changed" handler="magEdgeMarginValueChanged" last_modification_time="Thu, 06 Dec 2007 22:57:50 GMT"/>
 						</widget>

Modified: trunk/src/orca/orca_gui_prefs.py
==============================================================================
--- trunk/src/orca/orca_gui_prefs.py	(original)
+++ trunk/src/orca/orca_gui_prefs.py	Wed May 21 16:57:40 2008
@@ -115,6 +115,7 @@
         self.defaultVoice = None
         self.defKeyBindings = None
         self.disableKeyGrabPref = None
+        self.enableAutostart = None
         self.getTextAttributesView = None
         self.hyperlinkVoice = None
         self.initializingSpeech = None
@@ -1841,6 +1842,10 @@
 
         self.enableLiveUpdating = liveUpdating
 
+        self.enableAutostart = settings.isOrcaAutostarted()
+        self.get_widget("autostartOrcaCheckbutton").set_active( \
+                         self.enableAutostart)
+
     def getComboBoxIndex(self, combobox, searchStr, col=0):
         """ For each of the entries in the given combo box, look for searchStr.
             Return the index of the entry if searchStr is found.
@@ -2790,6 +2795,20 @@
         enable = widget.get_active()
         self.prefsDict["enableMouseReview"] = enable
 
+    def autostartOrcaChecked(self, widget):
+        """Signal handler for the "toggled" signal for the
+           autoStartOrcaCheckbutton GtkCheckButton widget.
+           The user has [un]checked the 'Start Orca when you login'
+           checkbox. Remember the new setting so that it can be used
+           to create or remove ~/.config/autostart/orca.desktop, if 
+           the user presses the Apply or OK button.
+
+        Arguments:
+        - widget: the component that generated the signal.
+        """
+
+        self.enableAutostart = widget.get_active()
+
     def abbrevRolenamesChecked(self, widget):
         """Signal handler for the "toggled" signal for the abbrevRolenames
            GtkCheckButton widget. The user has [un]checked the 'Abbreviated
@@ -3834,6 +3853,9 @@
 
         settings.setGKSUGrabDisabled(self.disableKeyGrabPref)
 
+        status = settings.setOrcaAutostart(self.enableAutostart)
+        self.get_widget("autostartOrcaCheckbutton").set_active(status)
+
         self.writeUserPreferences()
 
         orca.loadUserSettings()

Modified: trunk/src/orca/settings.py
==============================================================================
--- trunk/src/orca/settings.py	(original)
+++ trunk/src/orca/settings.py	Wed May 21 16:57:40 2008
@@ -29,6 +29,9 @@
 
 import os
 import re
+import shutil
+
+import platform
 
 screenWidth = 640
 screenHeight = 480
@@ -738,6 +741,54 @@
     except:
         return False
 
+# Obtain/set information regarding whether Orca is autostarted for this 
+# user at login time.
+#
+def isOrcaAutostarted():
+    """Return an indication of whether Orca autostart at login time is enabled.
+    """
+
+    userDesktopFile = os.path.join(os.environ["HOME"], ".config", \
+                                   "autostart", "orca.desktop")
+    return os.path.exists(userDesktopFile)
+
+def setOrcaAutostart(enable):
+    """Enable or disable the autostart of Orca at login time.
+
+    Arguments:
+    - enable: if True, whether Orca autostart at login time is enabled.
+
+    Returns an indication of whether the operation was successful.
+    """
+
+    status = True
+    systemDesktopFile = os.path.join(platform.prefix, platform.datadirname, \
+                                     "applications", "orca.desktop")
+    autostartDir = os.path.join(os.environ["HOME"], ".config", "autostart")
+    userDesktopFile = os.path.join(os.environ["HOME"], ".config", \
+                                   "autostart", "orca.desktop")
+
+    try:
+        # If the user wants to enable Orca autostart, then copy the
+        # orca.desktop file from /usr/share/applications to
+        # ~/.config/autostart directory (creating the autostart directory
+        # if neccessary).
+        #
+        # If the user wants to disable this feature, then just remove 
+        # ~/.config/autostart/orca.desktop (if it exists).
+        #
+        if enable:
+            try:
+                os.chdir(autostartDir)
+            except:
+                os.mkdir(autostartDir)
+            shutil.copy(systemDesktopFile, userDesktopFile)
+        else:
+            os.remove(userDesktopFile)
+    except:
+        status = False
+    return status
+
 # Obtain/set information regarding whether the gksu keyboard grab is enabled
 # or not.
 #



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