1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD 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
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module atk.Util;
26 
27 private import atk.ObjectAtk;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gtkc.atk;
31 public  import gtkc.atktypes;
32 
33 
34 /**
35  * A set of ATK utility functions which are used to support event
36  * registration of various types, and obtaining the 'root' accessible
37  * of a process and information about the current ATK implementation
38  * and toolkit version.
39  */
40 public struct Util
41 {
42 
43 	/** */
44 	public static GType getType()
45 	{
46 		return atk_util_get_type();
47 	}
48 
49 	/**
50 	 * Adds the specified function to the list of functions to be called
51 	 * when an object receives focus.
52 	 *
53 	 * Deprecated: Focus tracking has been dropped as a feature
54 	 * to be implemented by ATK itself. If you need focus tracking on your
55 	 * implementation, subscribe to the #AtkObject::state-change "focused" signal.
56 	 *
57 	 * Params:
58 	 *     focusTracker = Function to be added to the list of functions to be called
59 	 *         when an object receives focus.
60 	 *
61 	 * Returns: added focus tracker id, or 0 on failure.
62 	 */
63 	public static uint addFocusTracker(AtkEventListener focusTracker)
64 	{
65 		return atk_add_focus_tracker(focusTracker);
66 	}
67 
68 	/**
69 	 * Adds the specified function to the list of functions to be called
70 	 * when an ATK event of type event_type occurs.
71 	 *
72 	 * The format of event_type is the following:
73 	 * "ATK:<atk_type>:<atk_event>:<atk_event_detail>
74 	 *
75 	 * Where "ATK" works as the namespace, <atk_interface> is the name of
76 	 * the ATK type (interface or object), <atk_event> is the name of the
77 	 * signal defined on that interface and <atk_event_detail> is the
78 	 * gsignal detail of that signal. You can find more info about gsignal
79 	 * details here:
80 	 * http://developer.gnome.org/gobject/stable/gobject-Signals.html
81 	 *
82 	 * The first three parameters are mandatory. The last one is optional.
83 	 *
84 	 * For example:
85 	 * ATK:AtkObject:state-change
86 	 * ATK:AtkText:text-selection-changed
87 	 * ATK:AtkText:text-insert:system
88 	 *
89 	 * Toolkit implementor note: ATK provides a default implementation for
90 	 * this virtual method. ATK implementors are discouraged from
91 	 * reimplementing this method.
92 	 *
93 	 * Toolkit implementor note: this method is not intended to be used by
94 	 * ATK implementors but by ATK consumers.
95 	 *
96 	 * ATK consumers note: as this method adds a listener for a given ATK
97 	 * type, that type should be already registered on the GType system
98 	 * before calling this method. A simple way to do that is creating an
99 	 * instance of #AtkNoOpObject. This class implements all ATK
100 	 * interfaces, so creating the instance will register all ATK types as
101 	 * a collateral effect.
102 	 *
103 	 * Params:
104 	 *     listener = the listener to notify
105 	 *     eventType = the type of event for which notification is requested
106 	 *
107 	 * Returns: added event listener id, or 0 on failure.
108 	 */
109 	public static uint addGlobalEventListener(GSignalEmissionHook listener, string eventType)
110 	{
111 		return atk_add_global_event_listener(listener, Str.toStringz(eventType));
112 	}
113 
114 	/**
115 	 * Adds the specified function to the list of functions to be called
116 	 * when a key event occurs.  The @data element will be passed to the
117 	 * #AtkKeySnoopFunc (@listener) as the @func_data param, on notification.
118 	 *
119 	 * Params:
120 	 *     listener = the listener to notify
121 	 *     data = a #gpointer that points to a block of data that should be sent to the registered listeners,
122 	 *         along with the event notification, when it occurs.
123 	 *
124 	 * Returns: added event listener id, or 0 on failure.
125 	 */
126 	public static uint addKeyEventListener(AtkKeySnoopFunc listener, void* data)
127 	{
128 		return atk_add_key_event_listener(listener, data);
129 	}
130 
131 	/**
132 	 * Specifies the function to be called for focus tracker initialization.
133 	 * This function should be called by an implementation of the
134 	 * ATK interface if any specific work needs to be done to enable
135 	 * focus tracking.
136 	 *
137 	 * Deprecated: Focus tracking has been dropped as a feature
138 	 * to be implemented by ATK itself.
139 	 *
140 	 * Params:
141 	 *     init = Function to be called for focus tracker initialization
142 	 */
143 	public static void focusTrackerInit(AtkEventListenerInit init)
144 	{
145 		atk_focus_tracker_init(init);
146 	}
147 
148 	/**
149 	 * Cause the focus tracker functions which have been specified to be
150 	 * executed for the object.
151 	 *
152 	 * Deprecated: Focus tracking has been dropped as a feature
153 	 * to be implemented by ATK itself. As #AtkObject::focus-event was
154 	 * deprecated in favor of a #AtkObject::state-change signal, in order
155 	 * to notify a focus change on your implementation, you can use
156 	 * atk_object_notify_state_change() instead.
157 	 *
158 	 * Params:
159 	 *     object = an #AtkObject
160 	 */
161 	public static void focusTrackerNotify(ObjectAtk object)
162 	{
163 		atk_focus_tracker_notify((object is null) ? null : object.getObjectAtkStruct());
164 	}
165 
166 	/**
167 	 * Gets the currently focused object.
168 	 *
169 	 * Returns: the currently focused object for the current
170 	 *     application
171 	 *
172 	 * Since: 1.6
173 	 */
174 	public static ObjectAtk getFocusObject()
175 	{
176 		auto p = atk_get_focus_object();
177 		
178 		if(p is null)
179 		{
180 			return null;
181 		}
182 		
183 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p);
184 	}
185 
186 	/**
187 	 * Gets the root accessible container for the current application.
188 	 *
189 	 * Returns: the root accessible container for the current
190 	 *     application
191 	 */
192 	public static ObjectAtk getRoot()
193 	{
194 		auto p = atk_get_root();
195 		
196 		if(p is null)
197 		{
198 			return null;
199 		}
200 		
201 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p);
202 	}
203 
204 	/**
205 	 * Gets name string for the GUI toolkit implementing ATK for this application.
206 	 *
207 	 * Returns: name string for the GUI toolkit implementing ATK for this application
208 	 */
209 	public static string getToolkitName()
210 	{
211 		return Str.toString(atk_get_toolkit_name());
212 	}
213 
214 	/**
215 	 *
216 	 *
217 	 * Deprecated: Focus tracking has been dropped as a feature
218 	 * to be implemented by ATK itself. If you need focus tracking on your
219 	 * implementation, subscribe to the #AtkObject::state-change "focused" signal.
220 	 *
221 	 * Removes the specified focus tracker from the list of functions
222 	 * to be called when any object receives focus.
223 	 *
224 	 * Params:
225 	 *     trackerId = the id of the focus tracker to remove
226 	 */
227 	public static void removeFocusTracker(uint trackerId)
228 	{
229 		atk_remove_focus_tracker(trackerId);
230 	}
231 
232 	/**
233 	 * @listener_id is the value returned by #atk_add_global_event_listener
234 	 * when you registered that event listener.
235 	 *
236 	 * Toolkit implementor note: ATK provides a default implementation for
237 	 * this virtual method. ATK implementors are discouraged from
238 	 * reimplementing this method.
239 	 *
240 	 * Toolkit implementor note: this method is not intended to be used by
241 	 * ATK implementors but by ATK consumers.
242 	 *
243 	 * Removes the specified event listener
244 	 *
245 	 * Params:
246 	 *     listenerId = the id of the event listener to remove
247 	 */
248 	public static void removeGlobalEventListener(uint listenerId)
249 	{
250 		atk_remove_global_event_listener(listenerId);
251 	}
252 
253 	/**
254 	 * @listener_id is the value returned by #atk_add_key_event_listener
255 	 * when you registered that event listener.
256 	 *
257 	 * Removes the specified event listener.
258 	 *
259 	 * Params:
260 	 *     listenerId = the id of the event listener to remove
261 	 */
262 	public static void removeKeyEventListener(uint listenerId)
263 	{
264 		atk_remove_key_event_listener(listenerId);
265 	}
266 }