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 
45 	public static GType getType()
46 	{
47 		return atk_util_get_type();
48 	}
49 
50 	/**
51 	 * Adds the specified function to the list of functions to be called
52 	 * when an object receives focus.
53 	 *
54 	 * Deprecated: This method is deprecated since ATK version
55 	 * 2.9.4. Focus tracking has been dropped as a feature to be
56 	 * implemented by ATK itself. If you need focus tracking on your
57 	 * implementation, subscribe to the state-changed:focused signal.
58 	 *
59 	 * Params:
60 	 *     focusTracker = Function to be added to the list of functions to be called
61 	 *         when an object receives focus.
62 	 *
63 	 * Return: added focus tracker id, or 0 on failure.
64 	 */
65 	public static uint addFocusTracker(AtkEventListener focusTracker)
66 	{
67 		return atk_add_focus_tracker(focusTracker);
68 	}
69 
70 	/**
71 	 * Adds the specified function to the list of functions to be called
72 	 * when an ATK event of type event_type occurs.
73 	 *
74 	 * The format of event_type is the following:
75 	 * "ATK:<atk_type>:<atk_event>:<atk_event_detail>
76 	 *
77 	 * Where "ATK" works as the namespace, <atk_interface> is the name of
78 	 * the ATK type (interface or object), <atk_event> is the name of the
79 	 * signal defined on that interface and <atk_event_detail> is the
80 	 * gsignal detail of that signal. You can find more info about gsignal
81 	 * details here:
82 	 * http://developer.gnome.org/gobject/stable/gobject-Signals.html
83 	 *
84 	 * The first three parameters are mandatory. The last one is optional.
85 	 *
86 	 * For example:
87 	 * ATK:AtkObject:state-change
88 	 * ATK:AtkText:text-selection-changed
89 	 * ATK:AtkText:text-insert:system
90 	 *
91 	 * Toolkit implementor note: ATK provides a default implementation for
92 	 * this virtual method. ATK implementors are discouraged from
93 	 * reimplementing this method.
94 	 *
95 	 * Toolkit implementor note: this method is not intended to be used by
96 	 * ATK implementors but by ATK consumers.
97 	 *
98 	 * ATK consumers note: as this method adds a listener for a given ATK
99 	 * type, that type should be already registered on the GType system
100 	 * before calling this method. A simple way to do that is creating an
101 	 * instance of #AtkNoOpObject. This class implements all ATK
102 	 * interfaces, so creating the instance will register all ATK types as
103 	 * a collateral effect.
104 	 *
105 	 * Params:
106 	 *     listener = the listener to notify
107 	 *     eventType = the type of event for which notification is requested
108 	 *
109 	 * Return: added event listener id, or 0 on failure.
110 	 */
111 	public static uint addGlobalEventListener(GSignalEmissionHook listener, string eventType)
112 	{
113 		return atk_add_global_event_listener(listener, Str.toStringz(eventType));
114 	}
115 
116 	/**
117 	 * Adds the specified function to the list of functions to be called
118 	 * when a key event occurs.  The @data element will be passed to the
119 	 * #AtkKeySnoopFunc (@listener) as the @func_data param, on notification.
120 	 *
121 	 * Params:
122 	 *     listener = the listener to notify
123 	 *     data = a #gpointer that points to a block of data that should be sent to the registered listeners,
124 	 *         along with the event notification, when it occurs.
125 	 *
126 	 * Return: added event listener id, or 0 on failure.
127 	 */
128 	public static uint addKeyEventListener(AtkKeySnoopFunc listener, void* data)
129 	{
130 		return atk_add_key_event_listener(listener, data);
131 	}
132 
133 	/**
134 	 * Specifies the function to be called for focus tracker initialization.
135 	 * This function should be called by an implementation of the
136 	 * ATK interface if any specific work needs to be done to enable
137 	 * focus tracking.
138 	 *
139 	 * Deprecated: This method is deprecated since ATK version
140 	 * 2.9.4. Focus tracking has been dropped as a feature to be
141 	 * implemented by ATK itself.
142 	 *
143 	 * Params:
144 	 *     init = Function to be called for focus tracker initialization
145 	 */
146 	public static void focusTrackerInit(AtkEventListenerInit init)
147 	{
148 		atk_focus_tracker_init(init);
149 	}
150 
151 	/**
152 	 * Cause the focus tracker functions which have been specified to be
153 	 * executed for the object.
154 	 *
155 	 * Deprecated: This method is deprecated since ATK version
156 	 * 2.9.4. Focus tracking has been dropped as a feature to be
157 	 * implemented by ATK itself.
158 	 *
159 	 * Params:
160 	 *     object = an #AtkObject
161 	 */
162 	public static void focusTrackerNotify(ObjectAtk object)
163 	{
164 		atk_focus_tracker_notify((object is null) ? null : object.getObjectAtkStruct());
165 	}
166 
167 	/**
168 	 * Gets the currently focused object.
169 	 *
170 	 * Return: the currently focused object for the current
171 	 *     application
172 	 *
173 	 * Since: 1.6
174 	 */
175 	public static ObjectAtk getFocusObject()
176 	{
177 		auto p = atk_get_focus_object();
178 		
179 		if(p is null)
180 		{
181 			return null;
182 		}
183 		
184 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p);
185 	}
186 
187 	/**
188 	 * Gets the root accessible container for the current application.
189 	 *
190 	 * Return: the root accessible container for the current
191 	 *     application
192 	 */
193 	public static ObjectAtk getRoot()
194 	{
195 		auto p = atk_get_root();
196 		
197 		if(p is null)
198 		{
199 			return null;
200 		}
201 		
202 		return ObjectG.getDObject!(ObjectAtk)(cast(AtkObject*) p);
203 	}
204 
205 	/**
206 	 * Gets name string for the GUI toolkit implementing ATK for this application.
207 	 *
208 	 * Return: name string for the GUI toolkit implementing ATK for this application
209 	 */
210 	public static string getToolkitName()
211 	{
212 		return Str.toString(atk_get_toolkit_name());
213 	}
214 
215 	/**
216 	 *
217 	 *
218 	 * Deprecated: This method is deprecated since ATK version
219 	 * 2.9.4. Focus tracking has been dropped as a feature to be
220 	 * implemented by ATK itself. If you need focus tracking on your
221 	 * implementation, subscribe to the state-changed:focused signal.
222 	 *
223 	 * Removes the specified focus tracker from the list of functions
224 	 * to be called when any object receives focus.
225 	 *
226 	 * Params:
227 	 *     trackerId = the id of the focus tracker to remove
228 	 */
229 	public static void removeFocusTracker(uint trackerId)
230 	{
231 		atk_remove_focus_tracker(trackerId);
232 	}
233 
234 	/**
235 	 * @listener_id is the value returned by #atk_add_global_event_listener
236 	 * when you registered that event listener.
237 	 *
238 	 * Toolkit implementor note: ATK provides a default implementation for
239 	 * this virtual method. ATK implementors are discouraged from
240 	 * reimplementing this method.
241 	 *
242 	 * Toolkit implementor note: this method is not intended to be used by
243 	 * ATK implementors but by ATK consumers.
244 	 *
245 	 * Removes the specified event listener
246 	 *
247 	 * Params:
248 	 *     listenerId = the id of the event listener to remove
249 	 */
250 	public static void removeGlobalEventListener(uint listenerId)
251 	{
252 		atk_remove_global_event_listener(listenerId);
253 	}
254 
255 	/**
256 	 * @listener_id is the value returned by #atk_add_key_event_listener
257 	 * when you registered that event listener.
258 	 *
259 	 * Removes the specified event listener.
260 	 *
261 	 * Params:
262 	 *     listenerId = the id of the event listener to remove
263 	 */
264 	public static void removeKeyEventListener(uint listenerId)
265 	{
266 		atk_remove_key_event_listener(listenerId);
267 	}
268 }