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  = gdk-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  * Warning
79  * gdk_text_property_to_text_list is deprecated and should not be used in newly-written code.
80  * Converts a text string from the encoding as it is stored in
81  * a property into an array of strings in the encoding of
82  * the current local. (The elements of the array represent
83  * the nul-separated elements of the original text string.)
84  * Params:
85  * encoding = an atom representing the encoding. The most common
86  * values for this are STRING,
87  * or COMPOUND_TEXT. This is
88  * value used as the type for the property.
89  * format = the format of the property.
90  * text = the text data.
91  * list = location to store a terminated array of strings
92  * in the encoding of the current locale. This
93  * array should be freed using gdk_free_text_list().
94  * Returns: the number of strings stored in list, or 0, if the conversion failed.
95  */
96 public static int textPropertyToTextList(GdkAtom encoding, int format, char[] text, out string[] list)
97 {
98 	// gint gdk_text_property_to_text_list (GdkAtom encoding,  gint format,  const guchar *text,  gint length,  gchar ***list);
99 	char** outlist = null;
100 	int Return;
101 	
102 	auto p = gdk_text_property_to_text_list(encoding, format, text.ptr, cast(int) text.length, &outlist);
103 	
104 	list = null;
105 	foreach ( cstr; outlist[0 .. p] )
106 	{
107 		list ~= Str.toString(cstr);
108 	}
109 	return p;
110 }
111 
112 /**
113  * Warning
114  * gdk_text_property_to_text_list_for_display has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_x11_display_text_property_to_text_list()
115  * Convert a text string from the encoding as it is stored
116  * in a property into an array of strings in the encoding of
117  * the current locale. (The elements of the array represent the
118  * nul-separated elements of the original text string.)
119  * Since 2.2
120  * Params:
121  * display = The GdkDisplay where the encoding is defined.
122  * encoding = an atom representing the encoding. The most
123  * common values for this are STRING, or COMPOUND_TEXT.
124  * This is value used as the type for the property.
125  * format = the format of the property.
126  * text = The text data.
127  * list = location to store a terminated array of strings in
128  * the encoding of the current locale. This array should be
129  * freed using gdk_free_text_list().
130  * Returns: the number of strings stored in list, or 0, if the conversion failed.
131  */
132 public static int textPropertyToTextListForDisplay(Display display, GdkAtom encoding, int format, char[] text, out string[] list)
133 {
134 	// gint gdk_text_property_to_text_list_for_display  (GdkDisplay *display,  GdkAtom encoding,  gint format,  const guchar *text,  gint length,  gchar ***list);
135 	char** outlist = null;
136 	int Return;
137 	
138 	auto p = gdk_text_property_to_text_list_for_display((display is null) ? null : display.getDisplayStruct(), encoding, format, text.ptr, cast(int) text.length, &outlist);
139 	
140 	list = null;
141 	foreach ( cstr; outlist[0 .. p] )
142 	{
143 		list ~= Str.toString(cstr);
144 	}
145 	return p;
146 }
147 
148 /**
149  * Warning
150  * gdk_free_text_list is deprecated and should not be used in newly-written code.
151  * Frees the array of strings created by
152  * gdk_text_property_to_text_list().
153  * Params:
154  * list = the value stored in the list parameter by
155  * a call to gdk_text_property_to_text_list().
156  */
157 public static void freeTextList(string[] list)
158 {
159 	// void gdk_free_text_list (gchar **list);
160 	gdk_free_text_list(Str.toStringzArray(list));
161 }
162 
163 /**
164  * Warning
165  * gdk_text_property_to_utf8_list is deprecated and should not be used in newly-written code.
166  * Convert a text property in the giving encoding to
167  * a list of UTF-8 strings.
168  * Params:
169  * encoding = an atom representing the encoding of the text
170  * format = the format of the property
171  * text = the text to convert
172  * list = location to store the list of strings or NULL. The
173  * list should be freed with g_strfreev().
174  * Returns: the number of strings in the resulting list.
175  */
176 public static int textPropertyToUtf8_List(GdkAtom encoding, int format, char[] text, out string[] list)
177 {
178 	// gint gdk_text_property_to_utf8_list (GdkAtom encoding,  gint format,  const guchar *text,  gint length,  gchar ***list);
179 	char** outlist = null;
180 	int Return;
181 	
182 	auto p = gdk_text_property_to_utf8_list(encoding, format, text.ptr, cast(int) text.length, &outlist);
183 	
184 	list = null;
185 	foreach ( cstr; outlist[0 .. p] )
186 	{
187 		list ~= Str.toString(cstr);
188 	}
189 	return p;
190 }
191 
192 /**
193  * Converts a text property in the given encoding to
194  * a list of UTF-8 strings.
195  * Since 2.2
196  * Params:
197  * display = a GdkDisplay
198  * encoding = an atom representing the encoding of the text
199  * format = the format of the property
200  * text = the text to convert
201  * list = location to store the list of strings or NULL. The
202  * list should be freed with g_strfreev().
203  * Returns: the number of strings in the resulting list.
204  */
205 public static int textPropertyToUtf8_ListForDisplay(Display display, GdkAtom encoding, int format, char[] text, out string[] list)
206 {
207 	// gint gdk_text_property_to_utf8_list_for_display  (GdkDisplay *display,  GdkAtom encoding,  gint format,  const guchar *text,  gint length,  gchar ***list);
208 	char** outlist = null;
209 	int Return;
210 	
211 	auto p = gdk_text_property_to_utf8_list_for_display((display is null) ? null : display.getDisplayStruct(), encoding, format, text.ptr, cast(int) text.length, &outlist);
212 	
213 	list = null;
214 	foreach ( cstr; outlist[0 .. p] )
215 	{
216 		list ~= Str.toString(cstr);
217 	}
218 	return p;
219 }
220 
221 /**
222  * Warning
223  * gdk_string_to_compound_text is deprecated and should not be used in newly-written code.
224  * Converts a string from the encoding of the current locale
225  * into a form suitable for storing in a window property.
226  * Params:
227  * str = a nul-terminated string.
228  * encoding = location to store the encoding atom (to be used as the type for the property).
229  * format = location to store the format for the property.
230  * ctext = location to store newly allocated data for the property.
231  * Returns: 0 upon sucess, non-zero upon failure.
232  */
233 public static int stringToCompoundText(string str, out GdkAtom encoding, out int format, out char[] ctext)
234 {
235 	// gint gdk_string_to_compound_text (const gchar *str,  GdkAtom *encoding,  gint *format,  guchar **ctext,  gint *length);
236 	guchar* outctext = null;
237 	int length;
238 	
239 	auto p = gdk_string_to_compound_text(Str.toStringz(str), &encoding, &format, &outctext, &length);
240 	
241 	ctext = outctext[0 .. length];
242 	return p;
243 }
244 
245 /**
246  * Warning
247  * gdk_string_to_compound_text_for_display has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_x11_display_string_to_compound_text()
248  * Convert a string from the encoding of the current
249  * locale into a form suitable for storing in a window property.
250  * Since 2.2
251  * Params:
252  * display = the GdkDisplay where the encoding is defined.
253  * str = a nul-terminated string.
254  * encoding = location to store the encoding atom
255  * (to be used as the type for the property).
256  * format = location to store the format of the property
257  * ctext = location to store newly allocated data for the property.
258  * Returns: 0 upon success, non-zero upon failure.
259  */
260 public static int stringToCompoundTextForDisplay(Display display, string str, out GdkAtom encoding, out int format, out char[] ctext)
261 {
262 	// gint gdk_string_to_compound_text_for_display  (GdkDisplay *display,  const gchar *str,  GdkAtom *encoding,  gint *format,  guchar **ctext,  gint *length);
263 	guchar* outctext = null;
264 	int length;
265 	
266 	auto p = gdk_string_to_compound_text_for_display((display is null) ? null : display.getDisplayStruct(), Str.toStringz(str), &encoding, &format, &outctext, &length);
267 	
268 	ctext = outctext[0 .. length];
269 	return p;
270 }
271 
272 /**
273  * Warning
274  * gdk_free_compound_text is deprecated and should not be used in newly-written code.
275  * Frees the data returned from gdk_string_to_compound_text().
276  * Params:
277  * ctext = The pointer stored in ctext from a call to gdk_string_to_compound_text().
278  */
279 public static void freeCompoundText(char* ctext)
280 {
281 	// void gdk_free_compound_text (guchar *ctext);
282 	gdk_free_compound_text(ctext);
283 }
284 
285 /**
286  * Convert an UTF-8 string into the best possible representation
287  * as a STRING. The representation of characters not in STRING
288  * is not specified; it may be as pseudo-escape sequences
289  * \x{ABCD}, or it may be in some other form of approximation.
290  * Params:
291  * str = a UTF-8 string
292  * Returns: the newly allocated string, or NULL if the conversion failed. (It should not fail for any properly formed UTF-8 string.)
293  */
294 public static string utf8_ToStringTarget(string str)
295 {
296 	// gchar * gdk_utf8_to_string_target (const gchar *str);
297 	return Str.toString(gdk_utf8_to_string_target(Str.toStringz(str)));
298 }
299 
300 /**
301  * Warning
302  * gdk_utf8_to_compound_text is deprecated and should not be used in newly-written code.
303  * Convert from UTF-8 to compound text.
304  * Params:
305  * str = a UTF-8 string
306  * encoding = location to store resulting encoding
307  * format = location to store format of the result
308  * ctext = location to store the data of the result
309  * Returns: TRUE if the conversion succeeded, otherwise false.
310  */
311 public static int utf8_ToCompoundText(string str, out GdkAtom encoding, out int format, out char[] ctext)
312 {
313 	// gboolean gdk_utf8_to_compound_text (const gchar *str,  GdkAtom *encoding,  gint *format,  guchar **ctext,  gint *length);
314 	guchar* outctext = null;
315 	int length;
316 	
317 	auto p = gdk_utf8_to_compound_text(Str.toStringz(str), &encoding, &format, &outctext, &length);
318 	
319 	ctext = outctext[0 .. length];
320 	return p;
321 }
322 
323 /**
324  * Warning
325  * gdk_utf8_to_compound_text_for_display has been deprecated since version 2.24 and should not be used in newly-written code. Use gdk_x11_display_utf8_to_compound_text()
326  * Converts from UTF-8 to compound text.
327  * Since 2.2
328  * Params:
329  * display = a GdkDisplay
330  * str = a UTF-8 string
331  * encoding = location to store resulting encoding
332  * format = location to store format of the result
333  * ctext = location to store the data of the result
334  * Returns: TRUE if the conversion succeeded, otherwise FALSE.
335  */
336 public static int utf8_ToCompoundTextForDisplay(Display display, string str, out GdkAtom encoding, out int format, out char[] ctext)
337 {
338 	// gboolean gdk_utf8_to_compound_text_for_display  (GdkDisplay *display,  const gchar *str,  GdkAtom *encoding,  gint *format,  guchar **ctext,  gint *length);
339 	guchar* outctext = null;
340 	int length;
341 	
342 	auto p = gdk_utf8_to_compound_text_for_display((display is null) ? null : display.getDisplayStruct(), Str.toStringz(str), &encoding, &format, &outctext, &length);
343 	
344 	ctext = outctext[0 .. length];
345 	return p;
346 }
347 
348 /**
349  * Finds or creates an atom corresponding to a given string.
350  * Params:
351  * atomName = a string.
352  * onlyIfExists = if TRUE, GDK is allowed to not create a new atom, but
353  * just return GDK_NONE if the requested atom doesn't already
354  * exists. Currently, the flag is ignored, since checking the
355  * existance of an atom is as expensive as creating it.
356  * Returns: the atom corresponding to atom_name.
357  */
358 public static GdkAtom atomIntern(string atomName, int onlyIfExists)
359 {
360 	// GdkAtom gdk_atom_intern (const gchar *atom_name,  gboolean only_if_exists);
361 	return gdk_atom_intern(Str.toStringz(atomName), onlyIfExists);
362 }
363 
364 /**
365  * Finds or creates an atom corresponding to a given string.
366  * Note that this function is identical to gdk_atom_intern() except
367  * that if a new GdkAtom is created the string itself is used rather
368  * than a copy. This saves memory, but can only be used if the string
369  * will always exist. It can be used with statically
370  * allocated strings in the main program, but not with statically
371  * allocated memory in dynamically loaded modules, if you expect to
372  * ever unload the module again (e.g. do not use this function in
373  * GTK+ theme engines).
374  * Since 2.10
375  * Params:
376  * atomName = a static string
377  * Returns: the atom corresponding to atom_name
378  */
379 public static GdkAtom atomInternStaticString(string atomName)
380 {
381 	// GdkAtom gdk_atom_intern_static_string (const gchar *atom_name);
382 	return gdk_atom_intern_static_string(Str.toStringz(atomName));
383 }
384 
385 /**
386  * Determines the string corresponding to an atom.
387  * Params:
388  * atom = a GdkAtom.
389  * 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().
390  */
391 public static string atomName(GdkAtom atom)
392 {
393 	// gchar * gdk_atom_name (GdkAtom atom);
394 	return Str.toString(gdk_atom_name(atom));
395 }
396 
397 /**
398  * Retrieves a portion of the contents of a property. If the
399  * property does not exist, then the function returns FALSE,
400  * and GDK_NONE will be stored in actual_property_type.
401  * Note
402  * The XGetWindowProperty() function that gdk_property_get()
403  * uses has a very confusing and complicated set of semantics.
404  * Unfortunately, gdk_property_get() makes the situation
405  * worse instead of better (the semantics should be considered
406  * undefined), and also prints warnings to stderr in cases where it
407  * should return a useful error to the program. You are advised to use
408  * XGetWindowProperty() directly until a replacement function for
409  * gdk_property_get()
410  * is provided.
411  * Params:
412  * window = a GdkWindow.
413  * property = the property to retrieve.
414  * type = the desired property type, or GDK_NONE, if any type of data
415  * is acceptable. If this does not match the actual
416  * type, then actual_format and actual_length will
417  * be filled in, a warning will be printed to stderr
418  * and no data will be returned.
419  * offset = the offset into the property at which to begin
420  * retrieving data, in 4 byte units.
421  * length = the length of the data to retrieve in bytes. Data is
422  * considered to be retrieved in 4 byte chunks, so length
423  * will be rounded up to the next highest 4 byte boundary
424  * (so be careful not to pass a value that might overflow
425  * when rounded up).
426  * pdelete = if TRUE, delete the property after retrieving the
427  * data.
428  * actualPropertyType = location to store the actual type of
429  * the property.
430  * actualFormat = location to store the actual return format of the
431  * data; either 8, 16 or 32 bits.
432  * actualLength = location to store the length of the retrieved data, in
433  * bytes. Data returned in the 32 bit format is stored
434  * in a long variable, so the actual number of 32 bit
435  * elements should be be calculated via
436  * actual_length/sizeof(glong) to ensure portability to
437  * 64 bit systems.
438  * data = location to store a pointer to the data. The retrieved
439  * data should be freed with g_free() when you are finished
440  * using it.
441  * Returns: TRUE if data was successfully received and stored in data, otherwise FALSE.
442  */
443 public static int propertyGet(Window window, GdkAtom property, GdkAtom type, gulong offset, gulong length, int pdelete, out GdkAtom actualPropertyType, out int actualFormat, int* actualLength, char*[] data)
444 {
445 	// 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);
446 	return gdk_property_get((window is null) ? null : window.getWindowStruct(), property, type, offset, length, pdelete, &actualPropertyType, &actualFormat, actualLength, data.ptr);
447 }
448 
449 /**
450  * Changes the contents of a property on a window.
451  * Params:
452  * window = a GdkWindow.
453  * property = the property to change.
454  * type = the new type for the property. If mode is
455  * GDK_PROP_MODE_PREPEND or GDK_PROP_MODE_APPEND, then this
456  * must match the existing type or an error will occur.
457  * format = the new format for the property. If mode is
458  * GDK_PROP_MODE_PREPEND or GDK_PROP_MODE_APPEND, then this
459  * must match the existing format or an error will occur.
460  * mode = a value describing how the new data is to be combined
461  * with the current data.
462  * data = the data
463  * (a guchar *
464  * gushort *, or
465  * gulong *, depending on format), cast to a
466  * guchar *.
467  * nelements = the number of elements of size determined by the format,
468  * contained in data.
469  */
470 public static void propertyChange(Window window, GdkAtom property, GdkAtom type, int format, GdkPropMode mode, char* data, int nelements)
471 {
472 	// void gdk_property_change (GdkWindow *window,  GdkAtom property,  GdkAtom type,  gint format,  GdkPropMode mode,  const guchar *data,  gint nelements);
473 	gdk_property_change((window is null) ? null : window.getWindowStruct(), property, type, format, mode, data, nelements);
474 }
475 
476 /**
477  * Deletes a property from a window.
478  * Params:
479  * window = a GdkWindow.
480  * property = the property to delete.
481  */
482 public static void propertyDelete(Window window, GdkAtom property)
483 {
484 	// void gdk_property_delete (GdkWindow *window,  GdkAtom property);
485 	gdk_property_delete((window is null) ? null : window.getWindowStruct(), property);
486 }
487