File: Atom.d

package info (click to toggle)
gtk-d 3.10.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 20,152 kB
  • sloc: javascript: 565; sh: 71; makefile: 25
file content (233 lines) | stat: -rw-r--r-- 8,341 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/*
 * This file is part of gtkD.
 *
 * gtkD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version, with
 * some exceptions, please read the COPYING file.
 *
 * gtkD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with gtkD; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage


module gdk.Atom;

private import gdk.Display;
private import gdk.Window;
private import gdk.c.functions;
public  import gdk.c.types;
private import glib.Str;
public  import gtkc.gdktypes;


/**
 * An opaque type representing a string as an index into a table
 * of strings on the X server.
 */

/**
 * Determines the string corresponding to an atom.
 *
 * 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().
 */
public string name(GdkAtom atom)
{
	auto retStr = gdk_atom_name(atom);

	scope(exit) Str.freeString(retStr);
	return Str.toString(retStr);
}

/**
 * Finds or creates an atom corresponding to a given string.
 *
 * Params:
 *     atomName = a string.
 *     onlyIfExists = if %TRUE, GDK is allowed to not create a new atom, but
 *         just return %GDK_NONE if the requested atom doesn’t already
 *         exists. Currently, the flag is ignored, since checking the
 *         existance of an atom is as expensive as creating it.
 *
 * Returns: the atom corresponding to @atom_name.
 */
public GdkAtom intern(string atomName, bool onlyIfExists)
{
	return gdk_atom_intern(Str.toStringz(atomName), onlyIfExists);
}

/**
 * Finds or creates an atom corresponding to a given string.
 *
 * Note that this function is identical to gdk_atom_intern() except
 * that if a new #GdkAtom is created the string itself is used rather
 * than a copy. This saves memory, but can only be used if the string
 * will always exist. It can be used with statically
 * allocated strings in the main program, but not with statically
 * allocated memory in dynamically loaded modules, if you expect to
 * ever unload the module again (e.g. do not use this function in
 * GTK+ theme engines).
 *
 * Params:
 *     atomName = a static string
 *
 * Returns: the atom corresponding to @atom_name
 *
 * Since: 2.10
 */
public GdkAtom internStaticString(string atomName)
{
	return gdk_atom_intern_static_string(Str.toStringz(atomName));
}

/**
 * Changes the contents of a property on a window.
 *
 * Params:
 *     window = a #GdkWindow
 *     property = the property to change
 *     type = the new type for the property. If @mode is
 *         %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
 *         must match the existing type or an error will occur.
 *     format = the new format for the property. If @mode is
 *         %GDK_PROP_MODE_PREPEND or %GDK_PROP_MODE_APPEND, then this
 *         must match the existing format or an error will occur.
 *     mode = a value describing how the new data is to be combined
 *         with the current data.
 *     data = the data (a `guchar *`
 *         `gushort *`, or `gulong *`,
 *         depending on @format), cast to a `guchar *`.
 */
public void propertyChange(Window window, GdkAtom property, GdkAtom type, int format, GdkPropMode mode, char[] data)
{
	gdk_property_change((window is null) ? null : window.getWindowStruct(), property, type, format, mode, data.ptr, cast(int)data.length);
}

/**
 * Deletes a property from a window.
 *
 * Params:
 *     window = a #GdkWindow
 *     property = the property to delete
 */
public void propertyDelete(Window window, GdkAtom property)
{
	gdk_property_delete((window is null) ? null : window.getWindowStruct(), property);
}

/**
 * Retrieves a portion of the contents of a property. If the
 * property does not exist, then the function returns %FALSE,
 * and %GDK_NONE will be stored in @actual_property_type.
 *
 * The XGetWindowProperty() function that gdk_property_get()
 * uses has a very confusing and complicated set of semantics.
 * Unfortunately, gdk_property_get() makes the situation
 * worse instead of better (the semantics should be considered
 * undefined), and also prints warnings to stderr in cases where it
 * should return a useful error to the program. You are advised to use
 * XGetWindowProperty() directly until a replacement function for
 * gdk_property_get() is provided.
 *
 * Params:
 *     window = a #GdkWindow
 *     property = the property to retrieve
 *     type = the desired property type, or %GDK_NONE, if any type of data
 *         is acceptable. If this does not match the actual
 *         type, then @actual_format and @actual_length will
 *         be filled in, a warning will be printed to stderr
 *         and no data will be returned.
 *     offset = the offset into the property at which to begin
 *         retrieving data, in 4 byte units.
 *     length = the length of the data to retrieve in bytes.  Data is
 *         considered to be retrieved in 4 byte chunks, so @length
 *         will be rounded up to the next highest 4 byte boundary
 *         (so be careful not to pass a value that might overflow
 *         when rounded up).
 *     pdelete = if %TRUE, delete the property after retrieving the
 *         data.
 *     actualPropertyType = location to store the
 *         actual type of the property.
 *     actualFormat = location to store the actual return format of the
 *         data; either 8, 16 or 32 bits.
 *     data = location
 *         to store a pointer to the data. The retrieved data should be
 *         freed with g_free() when you are finished using it.
 *
 * Returns: %TRUE if data was successfully received and stored
 *     in @data, otherwise %FALSE.
 */
public bool propertyGet(Window window, GdkAtom property, GdkAtom type, gulong offset, gulong length, int pdelete, out GdkAtom actualPropertyType, out int actualFormat, out char[] data)
{
	int actualLength;
	char* outdata = null;

	auto p = gdk_property_get((window is null) ? null : window.getWindowStruct(), property, type, offset, length, pdelete, &actualPropertyType, &actualFormat, &actualLength, &outdata) != 0;

	data = outdata[0 .. actualLength];

	return p;
}

/**
 * Converts a text property in the given encoding to
 * a list of UTF-8 strings.
 *
 * Params:
 *     display = a #GdkDisplay
 *     encoding = an atom representing the encoding of the text
 *     format = the format of the property
 *     text = the text to convert
 *     list = location to store the list
 *         of strings or %NULL. The list should be freed with
 *         g_strfreev().
 *
 * Returns: the number of strings in the resulting list
 *
 * Since: 2.2
 */
public int textPropertyToUtf8ListForDisplay(Display display, GdkAtom encoding, int format, char[] text, out string[] list)
{
	char** outlist = null;

	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);

	list = Str.toStringArray(outlist);

	return p;
}

/**
 * Converts an UTF-8 string into the best possible representation
 * as a STRING. The representation of characters not in STRING
 * is not specified; it may be as pseudo-escape sequences
 * \x{ABCD}, or it may be in some other form of approximation.
 *
 * Params:
 *     str = a UTF-8 string
 *
 * 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.)
 */
public string utf8ToStringTarget(string str)
{
	auto retStr = gdk_utf8_to_string_target(Str.toStringz(str));

	scope(exit) Str.freeString(retStr);
	return Str.toString(retStr);
}