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 atk.c.functions;
29 public  import atk.c.types;
30 private import glib.Str;
31 private import gobject.ObjectG;
32 public  import gtkc.atktypes;
33 
34 
35 /**
36  * A set of ATK utility functions which are used to support event
37  * registration of various types, and obtaining the 'root' accessible
38  * of a process and information about the current ATK implementation
39  * and toolkit version.
40  */
41 public struct Util
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: Focus tracking has been dropped as a feature
55 	 * to be implemented by ATK itself. If you need focus tracking on your
56 	 * implementation, subscribe to the #AtkObject::state-change "focused" signal.
57 	 *
58 	 * Params:
59 	 *     focusTracker = Function to be added to the list of functions to be called
60 	 *         when an object receives focus.
61 	 *
62 	 * Returns: added focus tracker id, or 0 on failure.
63 	 */
64 	public static uint addFocusTracker(AtkEventListener focusTracker)
65 	{
66 		return atk_add_focus_tracker(focusTracker);
67 	}
68 
69 	/**
70 	 * Adds the specified function to the list of functions to be called
71 	 * when an ATK event of type event_type occurs.
72 	 *
73 	 * The format of event_type is the following:
74 	 * "ATK:<atk_type>:<atk_event>:<atk_event_detail>
75 	 *
76 	 * Where "ATK" works as the namespace, <atk_interface> is the name of
77 	 * the ATK type (interface or object), <atk_event> is the name of the
78 	 * signal defined on that interface and <atk_event_detail> is the
79 	 * gsignal detail of that signal. You can find more info about gsignal
80 	 * details here:
81 	 * http://developer.gnome.org/gobject/stable/gobject-Signals.html
82 	 *
83 	 * The first three parameters are mandatory. The last one is optional.
84 	 *
85 	 * For example:
86 	 * ATK:AtkObject:state-change
87 	 * ATK:AtkText:text-selection-changed
88 	 * ATK:AtkText:text-insert:system
89 	 *
90 	 * Toolkit implementor note: ATK provides a default implementation for
91 	 * this virtual method. ATK implementors are discouraged from
92 	 * reimplementing this method.
93 	 *
94 	 * Toolkit implementor note: this method is not intended to be used by
95 	 * ATK implementors but by ATK consumers.
96 	 *
97 	 * ATK consumers note: as this method adds a listener for a given ATK
98 	 * type, that type should be already registered on the GType system
99 	 * before calling this method. A simple way to do that is creating an
100 	 * instance of #AtkNoOpObject. This class implements all ATK
101 	 * interfaces, so creating the instance will register all ATK types as
102 	 * a collateral effect.
103 	 *
104 	 * Params:
105 	 *     listener = the listener to notify
106 	 *     eventType = the type of event for which notification is requested
107 	 *
108 	 * Returns: added event listener id, or 0 on failure.
109 	 */
110 	public static uint addGlobalEventListener(GSignalEmissionHook listener, string eventType)
111 	{
112 		return atk_add_global_event_listener(listener, Str.toStringz(eventType));
113 	}
114 
115 	/**
116 	 * Adds the specified function to the list of functions to be called
117 	 * when a key event occurs.  The @data element will be passed to the
118 	 * #AtkKeySnoopFunc (@listener) as the @func_data param, on notification.
119 	 *
120 	 * Params:
121 	 *     listener = the listener to notify
122 	 *     data = a #gpointer that points to a block of data that should be sent to the registered listeners,
123 	 *         along with the event notification, when it occurs.
124 	 *
125 	 * Returns: added event listener id, or 0 on failure.
126 	 */
127 	public static uint addKeyEventListener(AtkKeySnoopFunc listener, void* data)
128 	{
129 		return atk_add_key_event_listener(listener, data);
130 	}
131 
132 	/**
133 	 * Specifies the function to be called for focus tracker initialization.
134 	 * This function should be called by an implementation of the
135 	 * ATK interface if any specific work needs to be done to enable
136 	 * focus tracking.
137 	 *
138 	 * Deprecated: Focus tracking has been dropped as a feature
139 	 * to be implemented by ATK itself.
140 	 *
141 	 * Params:
142 	 *     init = Function to be called for focus tracker initialization
143 	 */
144 	public static void focusTrackerInit(AtkEventListenerInit init)
145 	{
146 		atk_focus_tracker_init(init);
147 	}
148 
149 	/**
150 	 * Cause the focus tracker functions which have been specified to be
151 	 * executed for the object.
152 	 *
153 	 * Deprecated: Focus tracking has been dropped as a feature
154 	 * to be implemented by ATK itself. As #AtkObject::focus-event was
155 	 * deprecated in favor of a #AtkObject::state-change signal, in order
156 	 * to notify a focus change on your implementation, you can use
157 	 * atk_object_notify_state_change() instead.
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 	 * Returns: 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 	 * Returns: 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 	 * Returns: 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: Focus tracking has been dropped as a feature
219 	 * to be implemented by ATK itself. If you need focus tracking on your
220 	 * implementation, subscribe to the #AtkObject::state-change "focused" signal.
221 	 *
222 	 * Removes the specified focus tracker from the list of functions
223 	 * to be called when any object receives focus.
224 	 *
225 	 * Params:
226 	 *     trackerId = the id of the focus tracker to remove
227 	 */
228 	public static void removeFocusTracker(uint trackerId)
229 	{
230 		atk_remove_focus_tracker(trackerId);
231 	}
232 
233 	/**
234 	 * @listener_id is the value returned by #atk_add_global_event_listener
235 	 * when you registered that event listener.
236 	 *
237 	 * Toolkit implementor note: ATK provides a default implementation for
238 	 * this virtual method. ATK implementors are discouraged from
239 	 * reimplementing this method.
240 	 *
241 	 * Toolkit implementor note: this method is not intended to be used by
242 	 * ATK implementors but by ATK consumers.
243 	 *
244 	 * Removes the specified event listener
245 	 *
246 	 * Params:
247 	 *     listenerId = the id of the event listener to remove
248 	 */
249 	public static void removeGlobalEventListener(uint listenerId)
250 	{
251 		atk_remove_global_event_listener(listenerId);
252 	}
253 
254 	/**
255 	 * @listener_id is the value returned by #atk_add_key_event_listener
256 	 * when you registered that event listener.
257 	 *
258 	 * Removes the specified event listener.
259 	 *
260 	 * Params:
261 	 *     listenerId = the id of the event listener to remove
262 	 */
263 	public static void removeKeyEventListener(uint listenerId)
264 	{
265 		atk_remove_key_event_listener(listenerId);
266 	}
267 }