]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/general.sgml
Remove deprecated gdk_exit() function
[~andy/gtk] / docs / reference / gdk / tmpl / general.sgml
1 <!-- ##### SECTION Title ##### -->
2 General
3
4 <!-- ##### SECTION Short_Description ##### -->
5 Library initialization and miscellaneous functions
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 This section describes the GDK initialization functions and miscellaneous
10 utility functions.
11 </para>
12
13 <!-- ##### SECTION See_Also ##### -->
14 <para>
15
16 </para>
17
18 <!-- ##### SECTION Stability_Level ##### -->
19
20
21 <!-- ##### SECTION Image ##### -->
22
23
24 <!-- ##### FUNCTION gdk_init ##### -->
25 <para>
26 Initializes the GDK library and connects to the X server.
27 If initialization fails, a warning message is output and the application
28 terminates with a call to <literal>exit(1)</literal>.
29 </para>
30 <para>
31 Any arguments used by GDK are removed from the array and @argc and @argv are
32 updated accordingly.
33 </para>
34 <para>
35 GTK+ initializes GDK in gtk_init() and so this function is not usually needed
36 by GTK+ applications.
37 </para>
38
39 @argc: the number of command line arguments.
40 @argv: the array of command line arguments.
41
42
43 <!-- ##### FUNCTION gdk_init_check ##### -->
44 <para>
45 Initializes the GDK library and connects to the X server, returning %TRUE on
46 success.
47 </para>
48 <para>
49 Any arguments used by GDK are removed from the array and @argc and @argv are
50 updated accordingly.
51 </para>
52 <para>
53 GTK+ initializes GDK in gtk_init() and so this function is not usually needed
54 by GTK+ applications.
55 </para>
56
57 @argc: the number of command line arguments.
58 @argv: the array of command line arguments.
59 @Returns: %TRUE if initialization succeeded.
60
61
62 <!-- ##### FUNCTION gdk_parse_args ##### -->
63 <para>
64
65 </para>
66
67 @argc: 
68 @argv: 
69
70
71 <!-- ##### FUNCTION gdk_get_display_arg_name ##### -->
72 <para>
73
74 </para>
75
76 @void: 
77 @Returns: 
78
79
80 <!-- ##### FUNCTION gdk_set_locale ##### -->
81 <para>
82 Initializes the support for internationalization by calling the <function>setlocale()</function>
83 system call. This function is called by gtk_set_locale() and so GTK+
84 applications should use that instead.
85 </para>
86 <para>
87 The locale to use is determined by the <envar>LANG</envar> environment variable,
88 so to run an application in a certain locale you can do something like this:
89 <informalexample>
90 <programlisting>
91   export LANG="fr"
92   ... run application ...
93 </programlisting>
94 </informalexample>
95 </para>
96 <para>
97 If the locale is not supported by X then it is reset to the standard "C"
98 locale.
99 </para>
100
101 @void: 
102 @Returns: the resulting locale.
103
104
105 <!-- ##### FUNCTION gdk_set_sm_client_id ##### -->
106 <para>
107 </para>
108
109 @sm_client_id: 
110
111
112 <!-- ##### FUNCTION gdk_notify_startup_complete ##### -->
113 <para>
114
115 </para>
116
117 @void: 
118
119
120 <!-- ##### FUNCTION gdk_notify_startup_complete_with_id ##### -->
121 <para>
122
123 </para>
124
125 @startup_id: 
126
127
128 <!-- ##### FUNCTION gdk_get_program_class ##### -->
129 <para>
130 Gets the program class. Unless the program class has explicitly
131 been set with gdk_set_program_class() or with the <option>--class</option> 
132 commandline option, the default value is the program name (determined 
133 with g_get_prgname()) with the first character converted to uppercase. 
134 </para>
135
136 @void: 
137 @Returns: the program class.
138
139
140 <!-- ##### FUNCTION gdk_set_program_class ##### -->
141 <para>
142 Sets the program class. The X11 backend uses the program class to set
143 the class name part of the <literal>WM_CLASS</literal> property on
144 toplevel windows; see the ICCCM.
145 </para>
146
147 @program_class: a string.
148
149
150 <!-- ##### FUNCTION gdk_get_display ##### -->
151 <para>
152 Gets the name of the display, which usually comes from the <envar>DISPLAY</envar>
153 environment variable or the <option>--display</option> command line option.
154 </para>
155
156 @void: 
157 @Returns: the name of the display.
158
159
160 <!-- ##### FUNCTION gdk_flush ##### -->
161 <para>
162 Flushes the X output buffer and waits until all requests have been processed
163 by the server. This is rarely needed by applications. It's main use is for
164 trapping X errors with gdk_error_trap_push() and gdk_error_trap_pop().
165 </para>
166
167 @void: 
168
169
170 <!-- ##### FUNCTION gdk_screen_width ##### -->
171 <para>
172 </para>
173
174 @void: 
175 @Returns: 
176
177
178 <!-- ##### FUNCTION gdk_screen_height ##### -->
179 <para>
180 </para>
181
182 @void: 
183 @Returns: 
184
185
186 <!-- ##### FUNCTION gdk_screen_width_mm ##### -->
187 <para>
188 </para>
189
190 @void: 
191 @Returns: 
192
193
194 <!-- ##### FUNCTION gdk_screen_height_mm ##### -->
195 <para>
196 </para>
197
198 @void: 
199 @Returns: 
200
201
202 <!-- ##### FUNCTION gdk_pointer_grab ##### -->
203 <para>
204 Grabs the pointer (usually a mouse) so that all events are passed to this
205 application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
206 the grab window becomes unviewable.
207 This overrides any previous pointer grab by this client.
208 </para>
209 <para>
210 Pointer grabs are used for operations which need complete control over mouse
211 events, even if the mouse leaves the application.
212 For example in GTK+ it is used for Drag and Drop, for dragging the handle in
213 the #GtkHPaned and #GtkVPaned widgets, and for resizing columns in #GtkCList
214 widgets.
215 </para>
216 <para>
217 Note that if the event mask of an X window has selected both button press and
218 button release events, then a button press event will cause an automatic
219 pointer grab until the button is released.
220 X does this automatically since most applications expect to receive button
221 press and release events in pairs.
222 It is equivalent to a pointer grab on the window with @owner_events set to
223 %TRUE.
224 </para>
225 <para>
226 If you set up anything at the time you take the grab that needs to be cleaned
227 up when the grab ends, you should handle the #GdkEventGrabBroken events that
228 are emitted when the grab ends unvoluntarily.
229 </para>
230
231 @window: the #GdkWindow which will own the grab (the grab window).
232 @owner_events: if %FALSE then all pointer events are reported with respect to
233 @window and are only reported if selected by @event_mask. If %TRUE then pointer
234 events for this application are reported as normal, but pointer events outside
235 this application are reported with respect to @window and only if selected by
236 @event_mask. In either mode, unreported events are discarded.
237 @event_mask: specifies the event mask, which is used in accordance with
238 @owner_events. Note that only pointer events (i.e. button and motion events) 
239     may be selected.
240 @confine_to: If non-%NULL, the pointer will be confined to this
241 window during the grab. If the pointer is outside @confine_to, it will
242 automatically be moved to the closest edge of @confine_to and enter
243 and leave events will be generated as necessary.
244 @cursor: the cursor to display while the grab is active. If this is %NULL then
245 the normal cursors are used for @window and its descendants, and the cursor
246 for @window is used for all other windows.
247 @time_: the timestamp of the event which led to this pointer grab. This usually
248 comes from a #GdkEventButton struct, though %GDK_CURRENT_TIME can be used if
249 the time isn't known.
250 @Returns: %GDK_GRAB_SUCCESS if the grab was successful.
251
252
253 <!-- ##### ENUM GdkGrabStatus ##### -->
254 <para>
255 Returned by gdk_pointer_grab() and gdk_keyboard_grab() to indicate 
256 success or the reason for the failure of the grab attempt.
257 </para>
258
259 @GDK_GRAB_SUCCESS: the resource was successfully grabbed.
260 @GDK_GRAB_ALREADY_GRABBED: the resource is actively grabbed by another client.
261 @GDK_GRAB_INVALID_TIME: the resource was grabbed more recently than the 
262   specified time.
263 @GDK_GRAB_NOT_VIEWABLE: the grab window or the @confine_to window are not
264   viewable.
265 @GDK_GRAB_FROZEN: the resource is frozen by an active grab of another client.
266
267 <!-- ##### FUNCTION gdk_pointer_ungrab ##### -->
268 <para>
269
270 </para>
271
272 @time_: 
273
274
275 <!-- ##### FUNCTION gdk_pointer_is_grabbed ##### -->
276 <para>
277 </para>
278 <para>
279 </para>
280
281 @void: 
282 @Returns: 
283
284
285 <!-- ##### FUNCTION gdk_set_double_click_time ##### -->
286 <para>
287
288 </para>
289
290 @msec: 
291
292
293 <!-- ##### FUNCTION gdk_keyboard_grab ##### -->
294 <para>
295 Grabs the keyboard so that all events are passed to this
296 application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
297 This overrides any previous keyboard grab by this client.
298 </para>
299 <para>
300 If you set up anything at the time you take the grab that needs to be cleaned
301 up when the grab ends, you should handle the #GdkEventGrabBroken events that
302 are emitted when the grab ends unvoluntarily.
303 </para>
304
305 @window: the #GdkWindow which will own the grab (the grab window).
306 @owner_events: if %FALSE then all keyboard events are reported with respect to
307 @window. If %TRUE then keyboard events for this application are reported as
308 normal, but keyboard events outside this application are reported with respect
309 to @window. Both key press and key release events are always reported,
310 independant of the event mask set by the application.
311 @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no timestamp is
312 available.
313 @Returns: %GDK_GRAB_SUCCESS if the grab was successful.
314
315
316 <!-- ##### FUNCTION gdk_keyboard_ungrab ##### -->
317 <para>
318 </para>
319
320 @time_: 
321
322
323 <!-- ##### FUNCTION gdk_beep ##### -->
324 <para>
325 </para>
326
327 @void: 
328
329
330 <!-- ##### FUNCTION gdk_get_use_xshm ##### -->
331 <para>
332 Returns %TRUE if GDK will attempt to use the MIT-SHM shared memory extension.
333 </para>
334 <para>
335 The shared memory extension is used for #GdkImage, and consequently for
336 <link linkend="gdk-GdkRGB">GdkRGB</link>.
337 It enables much faster drawing by communicating with the X server through
338 SYSV shared memory calls. However, it can only be used if the X client and
339 server are on the same machine and the server supports it.
340 </para>
341
342 @void: 
343 @Returns: %TRUE if use of the MIT shared memory extension will be attempted.
344
345
346 <!-- ##### FUNCTION gdk_set_use_xshm ##### -->
347 <para>
348 Sets whether the use of the MIT shared memory extension should be attempted.
349 This function is mainly for internal use. It is only safe for an application
350 to set this to %FALSE, since if it is set to %TRUE and the server does not
351 support the extension it may cause warning messages to be output.
352 </para>
353
354 @use_xshm: %TRUE if use of the MIT shared memory extension should be attempted.
355
356
357 <!-- ##### FUNCTION gdk_error_trap_push ##### -->
358 <para>
359 This function allows X errors to be trapped instead of the normal behavior
360 of exiting the application. It should only be used if it is not possible to
361 avoid the X error in any other way.
362 </para>
363 <example>
364 <title>Trapping an X error</title>
365 <programlisting>
366   gdk_error_trap_push (<!-- -->);
367
368   /* ... Call the X function which may cause an error here ... */
369
370   /* Flush the X queue to catch errors now. */
371   gdk_flush (<!-- -->);
372
373   if (gdk_error_trap_pop (<!-- -->))
374     {
375       /* ... Handle the error here ... */
376     }
377 </programlisting>
378 </example>
379
380 @void: 
381
382
383 <!-- ##### FUNCTION gdk_error_trap_pop ##### -->
384 <para>
385 Removes the X error trap installed with gdk_error_trap_push().
386 </para>
387
388 @void: 
389 @Returns: the X error code, or 0 if no error occurred.
390
391
392 <!-- ##### MACRO GDK_WINDOWING_X11 ##### -->
393 <para>
394 This macro is defined if GDK is configured to use the X backend.
395 </para>
396
397
398