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