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