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