]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/properties.sgml
ran make templates.
[~andy/gtk] / docs / reference / gdk / tmpl / properties.sgml
1 <!-- ##### SECTION Title ##### -->
2 Properties and Atoms
3
4 <!-- ##### SECTION Short_Description ##### -->
5 functions to manipulate properties on windows.
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 Each window under X can have any number of associated
10 <firstterm>properties</firstterm> attached to it.
11 Properties are arbitrary chunks of data identified by
12 <firstterm>atom</firstterm>s. (An <firstterm>atom</firstterm>
13 is a numeric index into a string table on the X server. They are used
14 to transfer strings efficiently between clients without
15 having to transfer the entire string.) A property
16 has an associated type, which is also identified
17 using an atom.
18 </para>
19 <para>
20 A property has an associated <firstterm>format</firstterm>,
21 an integer describing how many bits are in each unit
22 of data inside the property. It must be 8, 16, or 32.
23 When data is transfered between the server and client,
24 if they are of different endianesses it will be byteswapped
25 as necessary according to the format of the property.
26 Note that on the client side, properties of format 32
27 will be stored with one unit per <emphasis>long</emphasis>,
28 even if a long integer has more than 32 bits on the platform.
29 (This decision was apparently made for Xlib to maintain
30 compatibility with programs that assumed longs were 32
31 bits, at the expense of programs that knew better.)
32 </para>
33 <para>
34 The functions in this section are used to add, remove
35 and change properties on windows, to convert atoms
36 to and from strings and to manipulate some types of
37 data commonly stored in X window properties.
38 </para>
39
40 <!-- ##### SECTION See_Also ##### -->
41 <para>
42
43 </para>
44
45 <!-- ##### TYPEDEF GdkAtom ##### -->
46 <para>
47 A numeric type representing a string as an index into a table
48 of strings on the X server.
49 </para>
50
51
52 <!-- ##### MACRO GDK_NONE ##### -->
53 <para>
54
55 </para>
56
57
58
59 <!-- ##### FUNCTION gdk_text_property_to_text_list ##### -->
60 <para>
61 Convert a text string from the encoding as it is stored in
62 a property into an array of strings in the encoding of
63 the current local. (The elements of the array represent
64 the null-separated elements of the original text string.)
65 </para>
66
67 @encoding: an atom representing the encoding. The most common
68            values for this are <literal>STRING</literal>,
69            or <literal>COMPOUND_TEXT</literal>. This is
70            value used as the type for the property.
71 @format: the format of the property.
72 @text: the text data.
73 @length: the length of the property, in item.s
74 @list: location to store a terminated array of strings
75        in the encoding of the current locale. This
76        array should be freed using gdk_free_text_list().
77 @Returns: the number of strings stored in @list, or 0,
78           if the conversion failed.
79
80
81 <!-- ##### FUNCTION gdk_free_text_list ##### -->
82 <para>
83 Free the array of strings created by
84 gdk_text_property_to_text_list().
85 </para>
86
87 @list: the value stored in the @list parameter by
88        a call to gdk_text_property_to_text_list().
89
90
91 <!-- ##### FUNCTION gdk_string_to_compound_text ##### -->
92 <para>
93 Convert a string from the encoding of the current locale 
94 into a form suitable for storing in a window property.
95 </para>
96
97 @str: a null-terminated string.
98 @encoding: location to store the encoding atom (to be used as the type for the property).
99 @format: location to store the format for the property.
100 @ctext: location to store newly allocated data for the property.
101 @length: location to store the length of @ctext in items.
102 @Returns: 0 upon sucess, non-zero upon failure.
103
104
105 <!-- ##### FUNCTION gdk_free_compound_text ##### -->
106 <para>
107 Free the data returned from gdk_string_to_compound_text().
108 </para>
109
110 @ctext: The pointer stored in @ctext from a call to gdk_string_to_compound_text().
111
112
113 <!-- ##### FUNCTION gdk_atom_intern ##### -->
114 <para>
115 Find or create an atom corresponding to a given string.
116 </para>
117
118 @atom_name: a string.
119 @only_if_exists: if %TRUE, do not create a new atom, but
120                  just return the atom if it already exists.
121 @Returns: the atom corresponding to @atom_name, or, if
122           @only_if_exists is false, and an atom does not
123           already exists for the string, %GDK_NONE.
124
125
126 <!-- ##### FUNCTION gdk_atom_name ##### -->
127 <para>
128 Determine the string corresponding to an atom.
129 </para>
130
131 @atom: a #GdkAtom.
132 @Returns: a newly allocated string containing the string
133           corresponding to @atom. When you are done
134           with the return value, you should free it 
135           using g_free().
136
137
138 <!-- ##### FUNCTION gdk_property_get ##### -->
139 <para>
140 Retrieves a portion of the contents of a property. If the
141 property does not exist, then the function returns FALSE,
142 and %GDK_NONE will be stored in @actual_property_type.
143
144 Note: the <function>XGetWindowProperty()</function>
145 function that gdk_property_get()
146 uses has a very confusing and complicated set of semantics.
147 Unfortunately, gdk_property_get() makes the situation
148 worse instead of better (the semantics should be considered
149 undefined), and also prints warnings to stderr in cases where it
150 should return a useful error to the program. You are advised to use 
151 <function>XGetWindowProperty()</function>
152 directly until a replacement function for gdk_property_get()
153 is provided. 
154 </para>
155
156 @window: a #GdkWindow.
157 @property: the property to retrieve.
158 @type: the desired property type, or 0, if any type of data
159        is acceptable. If this does not match the actual
160        type, then @actual_format and @actual_length will
161        be filled in, a warning will be printed to stderr
162        and no data will be returned.
163 @offset: the offset into the property at which to begin
164          retrieving data. (in 4 byte units!)
165 @length: the length of the data to delete. (in bytes, but
166          the actual retrieved length will be the next
167          integer multiple multiple of four greater than 
168          this!)
169 @pdelete: if %TRUE, delete the property after retrieving the
170           data.
171 @actual_property_type: location to store the actual type of 
172                        the property.
173 @actual_format: location to store the actual format of the data.
174 @actual_length: location to store the length of the retrieved
175                 data, in bytes.
176 @data: location to store a pointer to the data. The retrieved
177        data should be freed with g_free() when you are finished
178        using it.
179 @Returns: %TRUE if data was sucessfully received and stored
180           in @data, otherwise %FALSE.
181
182
183 <!-- ##### FUNCTION gdk_property_change ##### -->
184 <para>
185 Change the contents of a property on a window.
186 </para>
187
188 @window: a #GdkWindow.
189 @property: the property to change.
190 @type: the new type for the property. If @mode is
191        %GDK_PROP_MODE_REPLACE or %GDK_PROP_MODE_APPEND, then this 
192        must match the existing type or an error will occur.
193 @format: the new format for the property. If @mode is
194          %GDK_PROP_MODE_REPLACE or %GDK_PROP_MODE_APPEND, then this 
195          must match the existing format or an error will occur.
196 @mode: a value describing how the new data is to be combined
197        with the current data.
198 @data: the data
199        (a <literal>guchar *</literal>
200         <literal>gushort *</literal>, or 
201         <literal>gulong *</literal>, depending on @format), cast to a 
202         <literal>guchar *</literal>.
203 @nelements: the number of elements of size determined by the format,
204             contained in @data.
205
206
207 <!-- ##### ENUM GdkPropMode ##### -->
208 <para>
209 Describes how existing data is combined with new data when
210 using gdk_property_change().
211 </para>
212
213 @GDK_PROP_MODE_REPLACE: the new data replaces the existing data.
214 @GDK_PROP_MODE_PREPEND: the new data is prepended to the existing data.
215 @GDK_PROP_MODE_APPEND: the new data is appended to the existing data.
216
217 <!-- ##### FUNCTION gdk_property_delete ##### -->
218 <para>
219 Delete a property from a window.
220 </para>
221
222 @window: a #GdkWindow.
223 @property: the property to delete.
224
225