1 '''
2 Defines a gtk dialog L{AEChooser} for searching for a given accessible in the
3 current view.
4
5 @author: Scott Haeger
6 @organization: IBM Corporation
7 @copyright: Copyright (c) 2005, 2007 IBM Corporation
8 @license: The BSD License
9
10 @author: Frank Zenker
11 @organization: IT Science Center Ruegen gGmbH, Germany
12 @copyright: Copyright (c) 2007, 2008 ITSC Ruegen
13 @license: The BSD License
14
15 All rights reserved. This program and the accompanying materials are made
16 available under the terms of the BSD license which accompanies
17 this distribution, and is available at
18 U{http://www.opensource.org/licenses/bsd-license.php}
19 '''
20
21 import pygtk
22 pygtk.require('2.0')
23 import gtk, gobject
24 import gtk.glade
25 from AccessEngine import AEChooser
26 from Tools.i18n import _
27 import gettext
28 from GTKUIEView import *
29
30 __uie__ = dict(kind='chooser')
31
33 '''
34 Dialog for searching current view for given accessible.
35
36 @ivar dialog: Dialog widget for choosing L{AccessEngine.AEScript}s
37 @type dialog: gtk.Dialog
38 @ivar query: Search query
39 @type query: string
40 @ivar matchcase: Make search case sensitive
41 @type matchcase: boolean
42 @ivar wrap: Make search wrap around
43 @type wrap: boolean
44 '''
45 START = 10
46 ALLOW_MULTI_APPS = True
47
48 - def init(self, app_name, timestamp, **kwargs):
49 '''
50 Creates and shows the chooser dialog and its components.
51
52 @param app_name: Name of application for current L{AETier}
53 @type app_name: string
54 @param timestamp: Time at which input was given indicating the start of
55 this chooser
56 @type timestamp: float
57 '''
58 self.query = ''
59 self.matchcase = False
60 self.wrap = False
61
62
63 self.source = gtk.glade.XML(self._getResource('search_chooser.glade'),
64 'main dialog',
65 gettext.textdomain())
66
67 self.dialog = self.source.get_widget('main dialog')
68 self.dialog.set_title(self.dialog.get_title() % app_name)
69
70
71 self.source.signal_autoconnect(self)
72
73
74 try:
75
76 self.dialog.window.set_user_time(timestamp)
77 except AttributeError:
78 pass
79 self._signal(self.START)
80
82 '''
83 Callback for search text entry. Updates query.
84
85 @param widget: source of GUI event
86 @type widget: gtk.Widget
87 '''
88 self.query = widget.get_text()
89
91 '''
92 Callback for 'match' checkbox. Sets instance variable according to
93 checkbox state.
94
95 @param widget: source of GUI event
96 @type widget: gtk.Widget
97 '''
98 self.matchcase = widget.get_active()
99
101 '''
102 Callback for 'wrap' checkbox. Sets instance variable according to
103 checkbox state.
104
105 @param widget: source of GUI event
106 @type widget: gtk.Widget
107 '''
108 self.wrap = widget.get_active()
109
111 '''
112 Notify the L{AccessEngine.AEScript} that the dialog is closing and destroy
113 it.
114
115 @param widget: Source of GUI event
116 @type widget: gtk.Widget
117 '''
118 self._signal(self.CANCEL)
119 self.close()
120
122 '''
123 Closes the chooser, preventing further chooser interaction with the user.
124 '''
125 self.dialog.destroy()
126
128 '''
129 Gets the name of the chooser.
130
131 @return: Human readable name of the chooser
132 @rtype: string
133 '''
134 return _('Search Chooser')
135
137 '''
138 Gets the search query.
139
140 @return: Search query
141 @rtype: string
142 '''
143 return self.query
144
146 '''
147 Should the search wrap to the top (or bottom) of the accessible tree ?
148
149 @return: Is search wrap set?
150 @rtype: boolean
151 '''
152 return self.wrap
153
155 '''
156 Should the search be case sensitive ?
157
158 @return: Is match case set?
159 @rtype: boolean
160 '''
161 return self.matchcase
162