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