]> Pileus Git - ~andy/gtk/blob - docs/reference/gdk/tmpl/general.sgml
Make 3.0 parallel-installable to 2.x
[~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_exit ##### -->
113 <para>
114 Exits the application using the <function>exit()</function> system call.
115 </para>
116 <para>
117 This routine is provided mainly for backwards compatibility, since it used to
118 perform tasks necessary to exit the application cleanly. Those tasks are now
119 performed in a function which is automatically called on exit (via the use
120 of g_atexit()).
121 </para>
122
123 @error_code: the error code to pass to the <function>exit()</function> call.
124
125
126 <!-- ##### FUNCTION gdk_notify_startup_complete ##### -->
127 <para>
128
129 </para>
130
131 @void: 
132
133
134 <!-- ##### FUNCTION gdk_notify_startup_complete_with_id ##### -->
135 <para>
136
137 </para>
138
139 @startup_id: 
140
141
142 <!-- ##### FUNCTION gdk_get_program_class ##### -->
143 <para>
144 Gets the program class. Unless the program class has explicitly
145 been set with gdk_set_program_class() or with the <option>--class</option> 
146 commandline option, the default value is the program name (determined 
147 with g_get_prgname()) with the first character converted to uppercase. 
148 </para>
149
150 @void: 
151 @Returns: the program class.
152
153
154 <!-- ##### FUNCTION gdk_set_program_class ##### -->
155 <para>
156 Sets the program class. The X11 backend uses the program class to set
157 the class name part of the <literal>WM_CLASS</literal> property on
158 toplevel windows; see the ICCCM.
159 </para>
160
161 @program_class: a string.
162
163
164 <!-- ##### FUNCTION gdk_get_display ##### -->
165 <para>
166 Gets the name of the display, which usually comes from the <envar>DISPLAY</envar>
167 environment variable or the <option>--display</option> command line option.
168 </para>
169
170 @void: 
171 @Returns: the name of the display.
172
173
174 <!-- ##### FUNCTION gdk_flush ##### -->
175 <para>
176 Flushes the X output buffer and waits until all requests have been processed
177 by the server. This is rarely needed by applications. It's main use is for
178 trapping X errors with gdk_error_trap_push() and gdk_error_trap_pop().
179 </para>
180
181 @void: 
182
183
184 <!-- ##### FUNCTION gdk_screen_width ##### -->
185 <para>
186 </para>
187
188 @void: 
189 @Returns: 
190
191
192 <!-- ##### FUNCTION gdk_screen_height ##### -->
193 <para>
194 </para>
195
196 @void: 
197 @Returns: 
198
199
200 <!-- ##### FUNCTION gdk_screen_width_mm ##### -->
201 <para>
202 </para>
203
204 @void: 
205 @Returns: 
206
207
208 <!-- ##### FUNCTION gdk_screen_height_mm ##### -->
209 <para>
210 </para>
211
212 @void: 
213 @Returns: 
214
215
216 <!-- ##### FUNCTION gdk_pointer_grab ##### -->
217 <para>
218 Grabs the pointer (usually a mouse) so that all events are passed to this
219 application until the pointer is ungrabbed with gdk_pointer_ungrab(), or
220 the grab window becomes unviewable.
221 This overrides any previous pointer grab by this client.
222 </para>
223 <para>
224 Pointer grabs are used for operations which need complete control over mouse
225 events, even if the mouse leaves the application.
226 For example in GTK+ it is used for Drag and Drop, for dragging the handle in
227 the #GtkHPaned and #GtkVPaned widgets, and for resizing columns in #GtkCList
228 widgets.
229 </para>
230 <para>
231 Note that if the event mask of an X window has selected both button press and
232 button release events, then a button press event will cause an automatic
233 pointer grab until the button is released.
234 X does this automatically since most applications expect to receive button
235 press and release events in pairs.
236 It is equivalent to a pointer grab on the window with @owner_events set to
237 %TRUE.
238 </para>
239 <para>
240 If you set up anything at the time you take the grab that needs to be cleaned
241 up when the grab ends, you should handle the #GdkEventGrabBroken events that
242 are emitted when the grab ends unvoluntarily.
243 </para>
244
245 @window: the #GdkWindow which will own the grab (the grab window).
246 @owner_events: if %FALSE then all pointer events are reported with respect to
247 @window and are only reported if selected by @event_mask. If %TRUE then pointer
248 events for this application are reported as normal, but pointer events outside
249 this application are reported with respect to @window and only if selected by
250 @event_mask. In either mode, unreported events are discarded.
251 @event_mask: specifies the event mask, which is used in accordance with
252 @owner_events. Note that only pointer events (i.e. button and motion events) 
253     may be selected.
254 @confine_to: If non-%NULL, the pointer will be confined to this
255 window during the grab. If the pointer is outside @confine_to, it will
256 automatically be moved to the closest edge of @confine_to and enter
257 and leave events will be generated as necessary.
258 @cursor: the cursor to display while the grab is active. If this is %NULL then
259 the normal cursors are used for @window and its descendants, and the cursor
260 for @window is used for all other windows.
261 @time_: the timestamp of the event which led to this pointer grab. This usually
262 comes from a #GdkEventButton struct, though %GDK_CURRENT_TIME can be used if
263 the time isn't known.
264 @Returns: %GDK_GRAB_SUCCESS if the grab was successful.
265
266
267 <!-- ##### ENUM GdkGrabStatus ##### -->
268 <para>
269 Returned by gdk_pointer_grab() and gdk_keyboard_grab() to indicate 
270 success or the reason for the failure of the grab attempt.
271 </para>
272
273 @GDK_GRAB_SUCCESS: the resource was successfully grabbed.
274 @GDK_GRAB_ALREADY_GRABBED: the resource is actively grabbed by another client.
275 @GDK_GRAB_INVALID_TIME: the resource was grabbed more recently than the 
276   specified time.
277 @GDK_GRAB_NOT_VIEWABLE: the grab window or the @confine_to window are not
278   viewable.
279 @GDK_GRAB_FROZEN: the resource is frozen by an active grab of another client.
280
281 <!-- ##### FUNCTION gdk_pointer_ungrab ##### -->
282 <para>
283
284 </para>
285
286 @time_: 
287
288
289 <!-- ##### FUNCTION gdk_pointer_is_grabbed ##### -->
290 <para>
291 </para>
292 <para>
293 </para>
294
295 @void: 
296 @Returns: 
297
298
299 <!-- ##### FUNCTION gdk_set_double_click_time ##### -->
300 <para>
301
302 </para>
303
304 @msec: 
305
306
307 <!-- ##### FUNCTION gdk_keyboard_grab ##### -->
308 <para>
309 Grabs the keyboard so that all events are passed to this
310 application until the keyboard is ungrabbed with gdk_keyboard_ungrab().
311 This overrides any previous keyboard grab by this client.
312 </para>
313 <para>
314 If you set up anything at the time you take the grab that needs to be cleaned
315 up when the grab ends, you should handle the #GdkEventGrabBroken events that
316 are emitted when the grab ends unvoluntarily.
317 </para>
318
319 @window: the #GdkWindow which will own the grab (the grab window).
320 @owner_events: if %FALSE then all keyboard events are reported with respect to
321 @window. If %TRUE then keyboard events for this application are reported as
322 normal, but keyboard events outside this application are reported with respect
323 to @window. Both key press and key release events are always reported,
324 independant of the event mask set by the application.
325 @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no timestamp is
326 available.
327 @Returns: %GDK_GRAB_SUCCESS if the grab was successful.
328
329
330 <!-- ##### FUNCTION gdk_keyboard_ungrab ##### -->
331 <para>
332 </para>
333
334 @time_: 
335
336
337 <!-- ##### FUNCTION gdk_beep ##### -->
338 <para>
339 </para>
340
341 @void: 
342
343
344 <!-- ##### FUNCTION gdk_get_use_xshm ##### -->
345 <para>
346 Returns %TRUE if GDK will attempt to use the MIT-SHM shared memory extension.
347 </para>
348 <para>
349 The shared memory extension is used for #GdkImage, and consequently for
350 <link linkend="gdk-GdkRGB">GdkRGB</link>.
351 It enables much faster drawing by communicating with the X server through
352 SYSV shared memory calls. However, it can only be used if the X client and
353 server are on the same machine and the server supports it.
354 </para>
355
356 @void: 
357 @Returns: %TRUE if use of the MIT shared memory extension will be attempted.
358
359
360 <!-- ##### FUNCTION gdk_set_use_xshm ##### -->
361 <para>
362 Sets whether the use of the MIT shared memory extension should be attempted.
363 This function is mainly for internal use. It is only safe for an application
364 to set this to %FALSE, since if it is set to %TRUE and the server does not
365 support the extension it may cause warning messages to be output.
366 </para>
367
368 @use_xshm: %TRUE if use of the MIT shared memory extension should be attempted.
369
370
371 <!-- ##### FUNCTION gdk_error_trap_push ##### -->
372 <para>
373 This function allows X errors to be trapped instead of the normal behavior
374 of exiting the application. It should only be used if it is not possible to
375 avoid the X error in any other way.
376 </para>
377 <example>
378 <title>Trapping an X error</title>
379 <programlisting>
380   gdk_error_trap_push (<!-- -->);
381
382   /* ... Call the X function which may cause an error here ... */
383
384   /* Flush the X queue to catch errors now. */
385   gdk_flush (<!-- -->);
386
387   if (gdk_error_trap_pop (<!-- -->))
388     {
389       /* ... Handle the error here ... */
390     }
391 </programlisting>
392 </example>
393
394 @void: 
395
396
397 <!-- ##### FUNCTION gdk_error_trap_pop ##### -->
398 <para>
399 Removes the X error trap installed with gdk_error_trap_push().
400 </para>
401
402 @void: 
403 @Returns: the X error code, or 0 if no error occurred.
404
405
406 <!-- ##### MACRO GDK_WINDOWING_X11 ##### -->
407 <para>
408 This macro is defined if GDK is configured to use the X backend.
409 </para>
410
411
412
413 <!-- ##### MACRO GDK_WINDOWING_WIN32 ##### -->
414 <para>
415 This macro is defined if GDK is configured to use the Win32 backend.
416 </para>
417
418
419