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  * Conversion parameters:
26  * inFile  = gdk-Selections.html
27  * outPack = gdk
28  * outFile = Selection
29  * strct   = 
30  * realStrct=
31  * ctorStrct=
32  * clss    = Selection
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gdk_selection_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- gdk.Window
47  * 	- gdk.Display
48  * structWrap:
49  * 	- GdkDisplay* -> Display
50  * 	- GdkWindow* -> Window
51  * module aliases:
52  * local aliases:
53  * overrides:
54  */
55 
56 module gdk.Selection;
57 
58 public  import gtkc.gdktypes;
59 
60 private import gtkc.gdk;
61 private import glib.ConstructionException;
62 private import gobject.ObjectG;
63 
64 
65 private import gdk.Window;
66 private import gdk.Display;
67 
68 
69 
70 
71 /**
72  * Description
73  * The X selection mechanism provides a way to transfer
74  * arbitrary chunks of data between programs.
75  * A selection is a essentially
76  * a named clipboard, identified by a string interned
77  * as a GdkAtom. By claiming ownership of a selection,
78  * an application indicates that it will be responsible
79  * for supplying its contents. The most common
80  * selections are PRIMARY and
81  * CLIPBOARD.
82  * The contents of a selection can be represented in
83  * a number of formats, called targets.
84  * Each target is identified by an atom. A list of
85  * all possible targets supported by the selection owner
86  * can be retrieved by requesting the special target
87  * TARGETS. When a selection is
88  * retrieved, the data is accompanied by a type
89  * (an atom), and a format (an integer, representing
90  * the number of bits per item).
91  * See Properties and Atoms
92  * for more information.
93  * The functions in this section only contain the lowlevel
94  * parts of the selection protocol. A considerably more
95  * complicated implementation is needed on top of this.
96  * GTK+ contains such an implementation in the functions
97  * in gtkselection.h and programmers
98  * should use those functions instead of the ones presented
99  * here. If you plan to implement selection handling
100  * directly on top of the functions here, you should refer
101  * to the X Inter-client Communication Conventions Manual
102  * (ICCCM).
103  */
104 public class Selection
105 {
106 	
107 	/**
108 	 */
109 	
110 	/**
111 	 * Sets the owner of the given selection.
112 	 * Params:
113 	 * owner = a GdkWindow or NULL to indicate that the
114 	 * the owner for the given should be unset.
115 	 * selection = an atom identifying a selection.
116 	 * time = timestamp to use when setting the selection.
117 	 * If this is older than the timestamp given last
118 	 * time the owner was set for the given selection, the
119 	 * request will be ignored.
120 	 * sendEvent = if TRUE, and the new owner is different
121 	 * from the current owner, the current owner
122 	 * will be sent a SelectionClear event.
123 	 * Returns: TRUE if the selection owner was successfully changed to owner, otherwise FALSE.
124 	 */
125 	public static int ownerSet(Window owner, GdkAtom selection, uint time, int sendEvent)
126 	{
127 		// gboolean gdk_selection_owner_set (GdkWindow *owner,  GdkAtom selection,  guint32 time_,  gboolean send_event);
128 		return gdk_selection_owner_set((owner is null) ? null : owner.getWindowStruct(), selection, time, sendEvent);
129 	}
130 	
131 	/**
132 	 * Sets the GdkWindow owner as the current owner of the selection selection.
133 	 * Since 2.2
134 	 * Params:
135 	 * display = the GdkDisplay.
136 	 * owner = a GdkWindow or NULL to indicate that the owner for
137 	 * the given should be unset.
138 	 * selection = an atom identifying a selection.
139 	 * time = timestamp to use when setting the selection.
140 	 * If this is older than the timestamp given last time the owner was
141 	 * set for the given selection, the request will be ignored.
142 	 * sendEvent = if TRUE, and the new owner is different from the current
143 	 * owner, the current owner will be sent a SelectionClear event.
144 	 * Returns: TRUE if the selection owner was successfully changed to owner, otherwise FALSE.
145 	 */
146 	public static int ownerSetForDisplay(Display display, Window owner, GdkAtom selection, uint time, int sendEvent)
147 	{
148 		// gboolean gdk_selection_owner_set_for_display (GdkDisplay *display,  GdkWindow *owner,  GdkAtom selection,  guint32 time_,  gboolean send_event);
149 		return gdk_selection_owner_set_for_display((display is null) ? null : display.getDisplayStruct(), (owner is null) ? null : owner.getWindowStruct(), selection, time, sendEvent);
150 	}
151 	
152 	/**
153 	 * Determines the owner of the given selection.
154 	 * Params:
155 	 * selection = an atom indentifying a selection.
156 	 * Returns: if there is a selection owner for this window, and it is a window known to the current process, the GdkWindow that owns the selection, otherwise NULL. Note that the return value may be owned by a different process if a foreign window was previously created for that window, but a new foreign window will never be created by this call.
157 	 */
158 	public static Window ownerGet(GdkAtom selection)
159 	{
160 		// GdkWindow * gdk_selection_owner_get (GdkAtom selection);
161 		auto p = gdk_selection_owner_get(selection);
162 		
163 		if(p is null)
164 		{
165 			return null;
166 		}
167 		
168 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
169 	}
170 	
171 	/**
172 	 * Determine the owner of the given selection.
173 	 * Note that the return value may be owned by a different
174 	 * process if a foreign window was previously created for that
175 	 * window, but a new foreign window will never be created by this call.
176 	 * Since 2.2
177 	 * Params:
178 	 * display = a GdkDisplay.
179 	 * selection = an atom indentifying a selection.
180 	 * Returns: if there is a selection owner for this window, and it is a window known to the current process, the GdkWindow that owns the selection, otherwise NULL.
181 	 */
182 	public static Window ownerGetForDisplay(Display display, GdkAtom selection)
183 	{
184 		// GdkWindow * gdk_selection_owner_get_for_display (GdkDisplay *display,  GdkAtom selection);
185 		auto p = gdk_selection_owner_get_for_display((display is null) ? null : display.getDisplayStruct(), selection);
186 		
187 		if(p is null)
188 		{
189 			return null;
190 		}
191 		
192 		return ObjectG.getDObject!(Window)(cast(GdkWindow*) p);
193 	}
194 	
195 	/**
196 	 * Retrieves the contents of a selection in a given
197 	 * form.
198 	 * Params:
199 	 * requestor = a GdkWindow.
200 	 * selection = an atom identifying the selection to get the
201 	 * contents of.
202 	 * target = the form in which to retrieve the selection.
203 	 * time = the timestamp to use when retrieving the
204 	 * selection. The selection owner may refuse the
205 	 * request if it did not own the selection at
206 	 * the time indicated by the timestamp.
207 	 */
208 	public static void convert(Window requestor, GdkAtom selection, GdkAtom target, uint time)
209 	{
210 		// void gdk_selection_convert (GdkWindow *requestor,  GdkAtom selection,  GdkAtom target,  guint32 time_);
211 		gdk_selection_convert((requestor is null) ? null : requestor.getWindowStruct(), selection, target, time);
212 	}
213 	
214 	/**
215 	 * Retrieves selection data that was stored by the selection
216 	 * data in response to a call to gdk_selection_convert(). This function
217 	 * will not be used by applications, who should use the GtkClipboard
218 	 * API instead.
219 	 * Params:
220 	 * requestor = the window on which the data is stored
221 	 * data = location to store a pointer to the retrieved data.
222 	 * If the retrieval failed, NULL we be stored here, otherwise, it
223 	 * will be non-NULL and the returned data should be freed with g_free()
224 	 * when you are finished using it. The length of the
225 	 * allocated memory is one more than the length
226 	 * of the returned data, and the final byte will always
227 	 * be zero, to ensure nul-termination of strings.
228 	 * propType = location to store the type of the property.
229 	 * propFormat = location to store the format of the property.
230 	 * Returns: the length of the retrieved data.
231 	 */
232 	public static int propertyGet(Window requestor, char** data, GdkAtom* propType, int* propFormat)
233 	{
234 		// gint gdk_selection_property_get (GdkWindow *requestor,  guchar **data,  GdkAtom *prop_type,  gint *prop_format);
235 		return gdk_selection_property_get((requestor is null) ? null : requestor.getWindowStruct(), data, propType, propFormat);
236 	}
237 	
238 	/**
239 	 * Sends a response to SelectionRequest event.
240 	 * Params:
241 	 * requestor = window to which to deliver response.
242 	 * selection = selection that was requested.
243 	 * target = target that was selected.
244 	 * property = property in which the selection owner stored the
245 	 * data, or GDK_NONE to indicate that the request
246 	 * was rejected.
247 	 * time = timestamp.
248 	 */
249 	public static void sendNotify(GdkNativeWindow requestor, GdkAtom selection, GdkAtom target, GdkAtom property, uint time)
250 	{
251 		// void gdk_selection_send_notify (GdkNativeWindow requestor,  GdkAtom selection,  GdkAtom target,  GdkAtom property,  guint32 time_);
252 		gdk_selection_send_notify(requestor, selection, target, property, time);
253 	}
254 	
255 	/**
256 	 * Send a response to SelectionRequest event.
257 	 * Since 2.2
258 	 * Params:
259 	 * display = the GdkDisplay where requestor is realized
260 	 * requestor = window to which to deliver response.
261 	 * selection = selection that was requested.
262 	 * target = target that was selected.
263 	 * property = property in which the selection owner stored the data,
264 	 * or GDK_NONE to indicate that the request was rejected.
265 	 * time = timestamp.
266 	 */
267 	public static void sendNotifyForDisplay(Display display, GdkNativeWindow requestor, GdkAtom selection, GdkAtom target, GdkAtom property, uint time)
268 	{
269 		// void gdk_selection_send_notify_for_display  (GdkDisplay *display,  GdkNativeWindow requestor,  GdkAtom selection,  GdkAtom target,  GdkAtom property,  guint32 time_);
270 		gdk_selection_send_notify_for_display((display is null) ? null : display.getDisplayStruct(), requestor, selection, target, property, time);
271 	}
272 }