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