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 gdk.Selection; 26 27 private import gdk.Display; 28 private import gdk.Window; 29 private import glib.Str; 30 private import gobject.ObjectG; 31 private import gtkc.gdk; 32 public import gtkc.gdktypes; 33 34 35 public struct Selection 36 { 37 /** 38 */ 39 40 /** 41 * Retrieves the contents of a selection in a given 42 * form. 43 * 44 * Params: 45 * requestor = a #GdkWindow. 46 * selection = an atom identifying the selection to get the 47 * contents of. 48 * target = the form in which to retrieve the selection. 49 * time = the timestamp to use when retrieving the 50 * selection. The selection owner may refuse the 51 * request if it did not own the selection at 52 * the time indicated by the timestamp. 53 */ 54 public static void convert(Window requestor, GdkAtom selection, GdkAtom target, uint time) 55 { 56 gdk_selection_convert((requestor is null) ? null : requestor.getWindowStruct(), selection, target, time); 57 } 58 59 /** 60 * Determines the owner of the given selection. 61 * 62 * Params: 63 * selection = an atom indentifying a selection. 64 * 65 * Return: if there is a selection owner 66 * for this window, and it is a window known to the current process, 67 * the #GdkWindow that owns the selection, otherwise %NULL. Note 68 * that the return value may be owned by a different process if a 69 * foreign window was previously created for that window, but a new 70 * foreign window will never be created by this call. 71 */ 72 public static Window ownerGet(GdkAtom selection) 73 { 74 auto p = gdk_selection_owner_get(selection); 75 76 if(p is null) 77 { 78 return null; 79 } 80 81 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 82 } 83 84 /** 85 * Determine the owner of the given selection. 86 * 87 * Note that the return value may be owned by a different 88 * process if a foreign window was previously created for that 89 * window, but a new foreign window will never be created by this call. 90 * 91 * Params: 92 * display = a #GdkDisplay 93 * selection = an atom indentifying a selection 94 * 95 * Return: if there is a selection owner 96 * for this window, and it is a window known to the current 97 * process, the #GdkWindow that owns the selection, otherwise 98 * %NULL. 99 * 100 * Since: 2.2 101 */ 102 public static Window ownerGetForDisplay(Display display, GdkAtom selection) 103 { 104 auto p = gdk_selection_owner_get_for_display((display is null) ? null : display.getDisplayStruct(), selection); 105 106 if(p is null) 107 { 108 return null; 109 } 110 111 return ObjectG.getDObject!(Window)(cast(GdkWindow*) p); 112 } 113 114 /** 115 * Sets the owner of the given selection. 116 * 117 * Params: 118 * owner = a #GdkWindow or %NULL to indicate that the 119 * the owner for the given should be unset. 120 * selection = an atom identifying a selection. 121 * time = timestamp to use when setting the selection. 122 * If this is older than the timestamp given last 123 * time the owner was set for the given selection, the 124 * request will be ignored. 125 * sendEvent = if %TRUE, and the new owner is different 126 * from the current owner, the current owner 127 * will be sent a SelectionClear event. 128 * 129 * Return: %TRUE if the selection owner was successfully 130 * changed to @owner, otherwise %FALSE. 131 */ 132 public static bool ownerSet(Window owner, GdkAtom selection, uint time, bool sendEvent) 133 { 134 return gdk_selection_owner_set((owner is null) ? null : owner.getWindowStruct(), selection, time, sendEvent) != 0; 135 } 136 137 /** 138 * Sets the #GdkWindow @owner as the current owner of the selection @selection. 139 * 140 * Params: 141 * display = the #GdkDisplay 142 * owner = a #GdkWindow or %NULL to indicate that the owner for 143 * the given should be unset 144 * selection = an atom identifying a selection 145 * time = timestamp to use when setting the selection 146 * If this is older than the timestamp given last time the owner was 147 * set for the given selection, the request will be ignored 148 * sendEvent = if %TRUE, and the new owner is different from the current 149 * owner, the current owner will be sent a SelectionClear event 150 * 151 * Return: %TRUE if the selection owner was successfully changed to owner, 152 * otherwise %FALSE. 153 * 154 * Since: 2.2 155 */ 156 public static bool ownerSetForDisplay(Display display, Window owner, GdkAtom selection, uint time, bool sendEvent) 157 { 158 return gdk_selection_owner_set_for_display((display is null) ? null : display.getDisplayStruct(), (owner is null) ? null : owner.getWindowStruct(), selection, time, sendEvent) != 0; 159 } 160 161 /** 162 * Retrieves selection data that was stored by the selection 163 * data in response to a call to gdk_selection_convert(). This function 164 * will not be used by applications, who should use the #GtkClipboard 165 * API instead. 166 * 167 * Params: 168 * requestor = the window on which the data is stored 169 * data = location to store a pointer to the retrieved data. 170 * If the retrieval failed, %NULL we be stored here, otherwise, it 171 * will be non-%NULL and the returned data should be freed with g_free() 172 * when you are finished using it. The length of the 173 * allocated memory is one more than the length 174 * of the returned data, and the final byte will always 175 * be zero, to ensure nul-termination of strings 176 * propType = location to store the type of the property 177 * propFormat = location to store the format of the property 178 * 179 * Return: the length of the retrieved data. 180 */ 181 public static int propertyGet(Window requestor, out string data, GdkAtom* propType, int* propFormat) 182 { 183 char* outdata = null; 184 185 auto p = gdk_selection_property_get((requestor is null) ? null : requestor.getWindowStruct(), &outdata, propType, propFormat); 186 187 data = Str.toString(outdata); 188 189 return p; 190 } 191 192 /** 193 * Sends a response to SelectionRequest event. 194 * 195 * Params: 196 * requestor = window to which to deliver response. 197 * selection = selection that was requested. 198 * target = target that was selected. 199 * property = property in which the selection owner stored the 200 * data, or %GDK_NONE to indicate that the request 201 * was rejected. 202 * time = timestamp. 203 */ 204 public static void sendNotify(Window requestor, GdkAtom selection, GdkAtom target, GdkAtom property, uint time) 205 { 206 gdk_selection_send_notify((requestor is null) ? null : requestor.getWindowStruct(), selection, target, property, time); 207 } 208 209 /** 210 * Send a response to SelectionRequest event. 211 * 212 * Params: 213 * display = the #GdkDisplay where @requestor is realized 214 * requestor = window to which to deliver response 215 * selection = selection that was requested 216 * target = target that was selected 217 * property = property in which the selection owner stored the data, 218 * or %GDK_NONE to indicate that the request was rejected 219 * time = timestamp 220 * 221 * Since: 2.2 222 */ 223 public static void sendNotifyForDisplay(Display display, Window requestor, GdkAtom selection, GdkAtom target, GdkAtom property, uint time) 224 { 225 gdk_selection_send_notify_for_display((display is null) ? null : display.getDisplayStruct(), (requestor is null) ? null : requestor.getWindowStruct(), selection, target, property, time); 226 } 227 }