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 Orca main window.""" |
21 |
|
|
22 |
1 |
__id__ = "$Id: orca_gui_main.py 2232 2007-04-02 17:17:42Z richb $" |
23 |
1 |
__version__ = "$Revision: 2232 $" |
24 |
1 |
__date__ = "$Date: 2007-04-02 13:17:42 -0400 (Mon, 02 Apr 2007) $" |
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 |
|
|
41 |
1 |
from orca_i18n import _ # for gettext support |
42 |
|
|
43 |
1 |
OS = None |
44 |
|
|
45 |
2 |
class orcaMainGUI(orca_glade.GladeWrapper): |
46 |
|
|
47 |
1 |
def _init(self): |
48 |
1 |
pass |
49 |
|
|
50 |
1 |
def _setMainWindowIcon(self): |
51 |
|
"""Set the "orca.png" icon as the icon for the Orca main window.""" |
52 |
|
|
53 |
1 |
icon_theme = gtk.icon_theme_get_default() |
54 |
1 |
try: |
55 |
1 |
icon = icon_theme.load_icon("orca", 48, 0) |
56 |
0 |
except: |
57 |
0 |
return |
58 |
|
|
59 |
1 |
self.mainWindow.set_icon(icon) |
60 |
|
|
61 |
1 |
def _showGUI(self): |
62 |
|
"""Show the Orca main window GUI. This assumes that the GUI has |
63 |
|
already been created. |
64 |
|
""" |
65 |
|
|
66 |
1 |
self._setMainWindowIcon() |
67 |
1 |
self.mainWindow.show() |
68 |
|
|
69 |
1 |
def _hideGUI(self): |
70 |
|
"""Hide the Orca main window GUI. This assumes that the GUI has |
71 |
|
already been created. |
72 |
|
""" |
73 |
|
|
74 |
0 |
self.mainWindow.hide() |
75 |
|
|
76 |
1 |
def quitButtonClicked(self, widget): |
77 |
|
"""Signal handler for the "clicked" signal for the quitButton |
78 |
|
GtkButton widget. The user has clicked the Quit button. |
79 |
|
Call the method to bring up the Quit dialog. |
80 |
|
|
81 |
|
Arguments: |
82 |
|
- widget: the component that generated the signal. |
83 |
|
""" |
84 |
|
|
85 |
0 |
orca.quitOrca() |
86 |
|
|
87 |
1 |
def preferencesButtonClicked(self, widget): |
88 |
|
"""Signal handler for the "clicked" signal for the preferencesButton |
89 |
|
GtkButton widget. The user has clicked the Preferences button. |
90 |
|
Call the method to bring up the Preferences dialog. |
91 |
|
|
92 |
|
Arguments: |
93 |
|
- widget: the component that generated the signal. |
94 |
|
""" |
95 |
|
|
96 |
0 |
orca._showPreferencesGUI() |
97 |
|
|
98 |
1 |
def mainWindowDestroyed(self, widget): |
99 |
|
"""Signal handler for the "destroyed" signal for the mainWindow |
100 |
|
GtkWindow widget. Reset OS to None, then call the method to |
101 |
|
bring up the quit dialog. |
102 |
|
|
103 |
|
Arguments: |
104 |
|
- widget: the component that generated the signal. |
105 |
|
""" |
106 |
|
|
107 |
|
global OS |
108 |
|
|
109 |
0 |
OS = None |
110 |
0 |
orca.quitOrca() |
111 |
|
|
112 |
1 |
def showMainUI(): |
113 |
|
global OS |
114 |
|
|
115 |
1 |
if not OS: |
116 |
1 |
gladeFile = os.path.join(platform.prefix, |
117 |
1 |
platform.datadirname, |
118 |
1 |
platform.package, |
119 |
1 |
"glade", |
120 |
1 |
"orca-mainwin.glade") |
121 |
1 |
OS = orcaMainGUI(gladeFile, "mainWindow") |
122 |
1 |
OS._init() |
123 |
|
|
124 |
1 |
OS._showGUI() |
125 |
|
|
126 |
1 |
def hideMainUI(): |
127 |
|
global OS |
128 |
|
|
129 |
0 |
if OS: |
130 |
0 |
OS._hideGUI() |
131 |
|
|
132 |
1 |
def main(): |
133 |
0 |
locale.setlocale(locale.LC_ALL, '') |
134 |
|
|
135 |
0 |
showMainUI() |
136 |
|
|
137 |
0 |
gtk.main() |
138 |
0 |
sys.exit(0) |
139 |
|
|
140 |
1 |
if __name__ == "__main__": |
141 |
0 |
main() |