1 |
|
# Orca |
2 |
|
# |
3 |
|
# Copyright 2006 Sun Microsystems Inc. |
4 |
|
# |
5 |
|
# This library is free software; you can redistribute it and/or |
6 |
|
# modify it under the terms of the GNU Library General Public |
7 |
|
# License as published by the Free Software Foundation; either |
8 |
|
# version 2 of the License, or (at your option) any later version. |
9 |
|
# |
10 |
|
# This library is distributed in the hope that it will be useful, |
11 |
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 |
|
# Library General Public License for more details. |
14 |
|
# |
15 |
|
# You should have received a copy of the GNU Library General Public |
16 |
|
# License along with this library; if not, write to the |
17 |
|
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 |
|
# Boston, MA 02111-1307, USA. |
19 |
|
|
20 |
1 |
"""Displays a GUI for the user to quit Orca.""" |
21 |
|
|
22 |
1 |
__id__ = "$Id: orca_quit.py 1515 2006-10-02 19:28:57Z richb $" |
23 |
1 |
__version__ = "$Revision: 1515 $" |
24 |
1 |
__date__ = "$Date: 2006-10-02 15:28:57 -0400 (Mon, 02 Oct 2006) $" |
25 |
1 |
__copyright__ = "Copyright (c) 2005-2006 Sun Microsystems Inc." |
26 |
1 |
__license__ = "LGPL" |
27 |
|
|
28 |
1 |
import os |
29 |
1 |
import sys |
30 |
1 |
import debug |
31 |
1 |
import gettext |
32 |
1 |
import gtk |
33 |
1 |
import gtk.glade |
34 |
1 |
import locale |
35 |
|
|
36 |
1 |
import orca |
37 |
1 |
import orca_glade |
38 |
1 |
import orca_state |
39 |
1 |
import platform |
40 |
1 |
import settings |
41 |
|
|
42 |
1 |
from orca_i18n import _ # for gettext support |
43 |
|
|
44 |
1 |
OS = None |
45 |
|
|
46 |
2 |
class orcaQuitGUI(orca_glade.GladeWrapper): |
47 |
|
|
48 |
1 |
def _init(self): |
49 |
1 |
pass |
50 |
|
|
51 |
1 |
def _showGUI(self): |
52 |
|
"""Show the Orca quit GUI dialog. This assumes that the GUI has |
53 |
|
already been created. |
54 |
|
""" |
55 |
|
|
56 |
|
# Set the current time on the quit GUI dialog so that it'll |
57 |
|
# get focus. set_user_time is a new call in pygtk 2.9.2 or later. |
58 |
|
# It's surronded by a try/except block here so that if it's not found, |
59 |
|
# then we can fail gracefully. |
60 |
|
# |
61 |
1 |
try: |
62 |
1 |
self.quitDialog.realize() |
63 |
1 |
self.quitDialog.window.set_user_time(\ |
64 |
1 |
orca_state.lastInputEventTimestamp) |
65 |
0 |
except AttributeError: |
66 |
0 |
debug.printException(debug.LEVEL_FINEST) |
67 |
|
|
68 |
1 |
self.quitDialog.show() |
69 |
|
|
70 |
1 |
def quitNoButtonClicked(self, widget): |
71 |
|
"""Signal handler for the "clicked" signal for the quitNoButton |
72 |
|
GtkButton widget. The user has clicked the No button. |
73 |
|
Don't quit Orca. Just hide the quit dialog and recreate the |
74 |
|
Orca main window. |
75 |
|
|
76 |
|
Arguments: |
77 |
|
- widget: the component that generated the signal. |
78 |
|
""" |
79 |
|
|
80 |
0 |
self.quitDialog.hide() |
81 |
0 |
if settings.showMainWindow: |
82 |
0 |
orca._showMainWindowGUI() |
83 |
|
|
84 |
1 |
def quitYesButtonClicked(self, widget): |
85 |
|
"""Signal handler for the "clicked" signal for the quitYesButton |
86 |
|
GtkButton widget. The user has clicked the Yes button. |
87 |
|
Call the orca.shutdown() method to gracefully terminate Orca. |
88 |
|
|
89 |
|
Arguments: |
90 |
|
- widget: the component that generated the signal. |
91 |
|
""" |
92 |
|
|
93 |
1 |
orca.shutdown() |
94 |
|
|
95 |
1 |
def quitDialogDestroyed(self, widget): |
96 |
|
"""Signal handler for the "destroyed" signal for the quitDialog |
97 |
|
GtkWindow widget. Reset OS to None, so that the GUI can be rebuilt |
98 |
|
from the Glade file the next time the user wants to display the |
99 |
|
quit dialog GUI. |
100 |
|
|
101 |
|
Arguments: |
102 |
|
- widget: the component that generated the signal. |
103 |
|
""" |
104 |
|
|
105 |
|
global OS |
106 |
|
|
107 |
0 |
OS = None |
108 |
|
|
109 |
1 |
def showQuitUI(): |
110 |
|
global OS |
111 |
|
|
112 |
1 |
if not OS: |
113 |
1 |
gladeFile = os.path.join(platform.prefix, |
114 |
1 |
platform.datadirname, |
115 |
1 |
platform.package, |
116 |
1 |
"glade", |
117 |
1 |
"orca-quit.glade") |
118 |
1 |
OS = orcaQuitGUI(gladeFile, "quitDialog") |
119 |
1 |
OS._init() |
120 |
|
|
121 |
1 |
OS._showGUI() |
122 |
|
|
123 |
1 |
def main(): |
124 |
0 |
locale.setlocale(locale.LC_ALL, '') |
125 |
|
|
126 |
0 |
showQuitUI() |
127 |
|
|
128 |
0 |
gtk.main() |
129 |
0 |
sys.exit(0) |
130 |
|
|
131 |
1 |
if __name__ == "__main__": |
132 |
0 |
main() |