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-Properties-and-Atoms.html 27 * outPack = gdk 28 * outFile = Atoms 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gdk_ 41 * omit structs: 42 * - GdkAtom 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gdk.Display 49 * - gdk.Window 50 * structWrap: 51 * - GdkDisplay* -> Display 52 * - GdkWindow* -> Window 53 * module aliases: 54 * local aliases: 55 * overrides: 56 */ 57 58 module gdk.Atoms; 59 60 public import gtkc.gdktypes; 61 62 private import gtkc.gdk; 63 private import glib.ConstructionException; 64 private import gobject.ObjectG; 65 66 67 private import glib.Str; 68 private import gdk.Display; 69 private import gdk.Window; 70 71 72 73 74 /** 75 */ 76 77 /** 78 * Converts a text property in the given encoding to 79 * a list of UTF-8 strings. 80 * Since 2.2 81 * Params: 82 * display = a GdkDisplay 83 * encoding = an atom representing the encoding of the text 84 * format = the format of the property 85 * text = the text to convert. [array length=length] 86 * length = the length of text, in bytes 87 * list = location to store the list 88 * of strings or NULL. The list should be freed with 89 * g_strfreev(). [out][array zero-terminated=1] 90 * Returns: the number of strings in the resulting list 91 */ 92 public static int textPropertyToUtf8_ListForDisplay(Display display, GdkAtom encoding, int format, char* text, int length, out char** list) 93 { 94 // gint gdk_text_property_to_utf8_list_for_display (GdkDisplay *display, GdkAtom encoding, gint format, const guchar *text, gint length, gchar ***list); 95 return gdk_text_property_to_utf8_list_for_display((display is null) ? null : display.getDisplayStruct(), encoding, format, text, length, &list); 96 } 97 98 /** 99 * Converts an UTF-8 string into the best possible representation 100 * as a STRING. The representation of characters not in STRING 101 * is not specified; it may be as pseudo-escape sequences 102 * \x{ABCD}, or it may be in some other form of approximation. 103 * Params: 104 * str = a UTF-8 string 105 * Returns: the newly-allocated string, or NULL if the conversion failed. (It should not fail for any properly formed UTF-8 string unless system limits like memory or file descriptors are exceeded.) 106 */ 107 public static string utf8_ToStringTarget(string str) 108 { 109 // gchar * gdk_utf8_to_string_target (const gchar *str); 110 return Str.toString(gdk_utf8_to_string_target(Str.toStringz(str))); 111 } 112 113 /** 114 * Finds or creates an atom corresponding to a given string. 115 * Params: 116 * atomName = a string. 117 * onlyIfExists = if TRUE, GDK is allowed to not create a new atom, but 118 * just return GDK_NONE if the requested atom doesn't already 119 * exists. Currently, the flag is ignored, since checking the 120 * existance of an atom is as expensive as creating it. 121 * Returns: the atom corresponding to atom_name. [transfer none] 122 */ 123 public static GdkAtom atomIntern(string atomName, int onlyIfExists) 124 { 125 // GdkAtom gdk_atom_intern (const gchar *atom_name, gboolean only_if_exists); 126 return gdk_atom_intern(Str.toStringz(atomName), onlyIfExists); 127 } 128 129 /** 130 * Finds or creates an atom corresponding to a given string. 131 * Note that this function is identical to gdk_atom_intern() except 132 * that if a new GdkAtom is created the string itself is used rather 133 * than a copy. This saves memory, but can only be used if the string 134 * will always exist. It can be used with statically 135 * allocated strings in the main program, but not with statically 136 * allocated memory in dynamically loaded modules, if you expect to 137 * ever unload the module again (e.g. do not use this function in 138 * GTK+ theme engines). 139 * Since 2.10 140 * Params: 141 * atomName = a static string 142 * Returns: the atom corresponding to atom_name. [transfer none] 143 */ 144 public static GdkAtom atomInternStaticString(string atomName) 145 { 146 // GdkAtom gdk_atom_intern_static_string (const gchar *atom_name); 147 return gdk_atom_intern_static_string(Str.toStringz(atomName)); 148 } 149 150 /** 151 * Determines the string corresponding to an atom. 152 * Params: 153 * atom = a GdkAtom. 154 * Returns: a newly-allocated string containing the string corresponding to atom. When you are done with the return value, you should free it using g_free(). 155 */ 156 public static string atomName(GdkAtom atom) 157 { 158 // gchar * gdk_atom_name (GdkAtom atom); 159 return Str.toString(gdk_atom_name(atom)); 160 } 161 162 /** 163 * Retrieves a portion of the contents of a property. If the 164 * property does not exist, then the function returns FALSE, 165 * and GDK_NONE will be stored in actual_property_type. 166 * Note 167 * The XGetWindowProperty() function that gdk_property_get() 168 * uses has a very confusing and complicated set of semantics. 169 * Unfortunately, gdk_property_get() makes the situation 170 * worse instead of better (the semantics should be considered 171 * undefined), and also prints warnings to stderr in cases where it 172 * should return a useful error to the program. You are advised to use 173 * XGetWindowProperty() directly until a replacement function for 174 * gdk_property_get() 175 * is provided. 176 * Params: 177 * window = a GdkWindow 178 * property = the property to retrieve 179 * type = the desired property type, or GDK_NONE, if any type of data 180 * is acceptable. If this does not match the actual 181 * type, then actual_format and actual_length will 182 * be filled in, a warning will be printed to stderr 183 * and no data will be returned. 184 * offset = the offset into the property at which to begin 185 * retrieving data, in 4 byte units. 186 * length = the length of the data to retrieve in bytes. Data is 187 * considered to be retrieved in 4 byte chunks, so length 188 * will be rounded up to the next highest 4 byte boundary 189 * (so be careful not to pass a value that might overflow 190 * when rounded up). 191 * pdelete = if TRUE, delete the property after retrieving the 192 * data. 193 * actualPropertyType = location to store the 194 * actual type of the property. [out][transfer none] 195 * actualFormat = location to store the actual return format of the 196 * data; either 8, 16 or 32 bits. [out] 197 * data = location 198 * to store a pointer to the data. The retrieved data should be 199 * freed with g_free() when you are finished using it. [out][array length=actual_length][transfer full] 200 * Returns: TRUE if data was successfully received and stored in data, otherwise FALSE. 201 */ 202 public static int propertyGet(Window window, GdkAtom property, GdkAtom type, gulong offset, gulong length, int pdelete, out GdkAtom actualPropertyType, out int actualFormat, out char[] data) 203 { 204 // gboolean gdk_property_get (GdkWindow *window, GdkAtom property, GdkAtom type, gulong offset, gulong length, gint pdelete, GdkAtom *actual_property_type, gint *actual_format, gint *actual_length, guchar **data); 205 guchar* outdata = null; 206 int actualLength; 207 208 auto p = gdk_property_get((window is null) ? null : window.getWindowStruct(), property, type, offset, length, pdelete, &actualPropertyType, &actualFormat, &actualLength, &outdata); 209 210 data = outdata[0 .. actualLength]; 211 return p; 212 } 213 214 /** 215 * Changes the contents of a property on a window. 216 * Params: 217 * window = a GdkWindow 218 * property = the property to change 219 * type = the new type for the property. If mode is 220 * GDK_PROP_MODE_PREPEND or GDK_PROP_MODE_APPEND, then this 221 * must match the existing type or an error will occur. 222 * format = the new format for the property. If mode is 223 * GDK_PROP_MODE_PREPEND or GDK_PROP_MODE_APPEND, then this 224 * must match the existing format or an error will occur. 225 * mode = a value describing how the new data is to be combined 226 * with the current data. 227 * data = the data (a guchar * 228 * gushort *, or gulong *, 229 * depending on format), cast to a guchar *. 230 */ 231 public static void propertyChange(Window window, GdkAtom property, GdkAtom type, int format, GdkPropMode mode, char[] data) 232 { 233 // void gdk_property_change (GdkWindow *window, GdkAtom property, GdkAtom type, gint format, GdkPropMode mode, const guchar *data, gint nelements); 234 gdk_property_change((window is null) ? null : window.getWindowStruct(), property, type, format, mode, data.ptr, cast(int) data.length); 235 } 236 237 /** 238 * Deletes a property from a window. 239 * Params: 240 * window = a GdkWindow 241 * property = the property to delete 242 */ 243 public static void propertyDelete(Window window, GdkAtom property) 244 { 245 // void gdk_property_delete (GdkWindow *window, GdkAtom property); 246 gdk_property_delete((window is null) ? null : window.getWindowStruct(), property); 247 } 248