3
# Copyright 2006-2008 Sun Microsystems Inc.
5
# This library is free software; you can redistribute it and/or
6
# modify it under the terms of the GNU Lesser General Public
7
# License as published by the Free Software Foundation; either
8
# version 2.1 of the License, or (at your option) any later version.
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
# Lesser General Public License for more details.
15
# You should have received a copy of the GNU Lesser General Public
16
# License along with this library; if not, write to the
17
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
18
# Boston MA 02110-1301 USA.
20
"""Displays a GUI for the user to quit Orca."""
23
__version__ = "$Revision$"
25
__copyright__ = "Copyright (c) 2005-2008 Sun Microsystems Inc."
35
import orca_gtkbuilder
42
class OrcaQuitGUI(orca_gtkbuilder.GtkBuilderWrapper):
48
"""Show the Orca quit GUI dialog. This assumes that the GUI has
52
quitDialog = self.get_widget("quitDialog")
53
quitDialog.connect('delete_event', self.quitDialogClosed)
55
# Set the current time on the quit GUI dialog so that it'll
56
# get focus. set_user_time is a new call in pygtk 2.9.2 or later.
57
# It's surronded by a try/except block here so that if it's not found,
58
# then we can fail gracefully.
62
ts = orca_state.lastInputEventTimestamp
64
ts = gtk.get_current_event_time()
65
quitDialog.window.set_user_time(ts)
66
except AttributeError:
67
debug.printException(debug.LEVEL_FINEST)
72
def quitNoButtonClicked(self, widget):
73
"""Signal handler for the "clicked" signal for the quitNoButton
74
GtkButton widget. The user has clicked the No button.
75
Don't quit Orca. Just hide the quit dialog and recreate the
79
- widget: the component that generated the signal.
82
self.get_widget("quitDialog").hide()
83
if settings.showMainWindow:
84
orca.showMainWindowGUI()
86
def quitYesButtonClicked(self, widget):
87
"""Signal handler for the "clicked" signal for the quitYesButton
88
GtkButton widget. The user has clicked the Yes button.
89
Call the orca.shutdown() method to gracefully terminate Orca.
92
- widget: the component that generated the signal.
97
def quitDialogClosed(self, widget, data):
98
"""Signal handler for the 'delete' signal. This is the equivalent
99
of the 'no' button being pressed."""
101
self.quitNoButtonClicked(None)
103
def quitDialogDestroyed(self, widget):
104
"""Signal handler for the "destroyed" signal for the quitDialog
105
GtkWindow widget. Reset OS to None, so that the GUI can be rebuilt
106
from the GtkBuilder file the next time the user wants to display
110
- widget: the component that generated the signal.
121
uiFile = os.path.join(orca_platform.prefix,
122
orca_platform.datadirname,
123
orca_platform.package,
126
OS = OrcaQuitGUI(uiFile, "quitDialog")
132
locale.setlocale(locale.LC_ALL, '')
139
if __name__ == "__main__":