Next: , Previous: Overview, Up: Top


2 General

Library initialization and miscellaneous functions

2.1 Overview

This section describes the GDK initialization functions and miscellaneous utility functions.

2.2 Usage

— Function: gdk-get-display-arg-name ⇒  (ret mchars)

Gets the display name specified in the command line arguments passed to gdk-init or gdk-parse-args, if any.

ret
the display name, if specified explicitely, otherwise ‘#f’ this string is owned by GTK+ and must not be modified or freed.

Since 2.2

— Function: gdk-set-locale ⇒  (ret mchars)

Initializes the support for internationalization by calling the setlocale system call. This function is called by gtk-set-locale and so GTK+ applications should use that instead.

The locale to use is determined by the LANG environment variable, so to run an application in a certain locale you can do something like this:

          
            export LANG="fr"
            ... run application ...

If the locale is not supported by X then it is reset to the standard "C" locale.

ret
the resulting locale.
— Function: gdk-set-sm-client-id (sm_client_id mchars)

Sets the ‘SM_CLIENT_ID’ property on the application's leader window so that the window manager can save the application's state using the X11R6 ICCCM session management protocol.

See the X Session Management Library documentation for more information on session management and the Inter-Client Communication Conventions Manual (ICCCM) for information on the ‘WM_CLIENT_LEADER’ property. (Both documents are part of the X Window System distribution.)

sm-client-id
the client id assigned by the session manager when the connection was opened, or ‘#f’ to remove the property.
— Function: gdk-notify-startup-complete

Indicates to the GUI environment that the application has finished loading. If the applications opens windows, this function is normally called after opening the application's initial set of windows.

GTK+ will call this function automatically after opening the first <gtk-window> unless gtk-window-set-auto-startup-notification is called to disable that feature.

Since 2.2

— Function: gdk-get-program-class ⇒  (ret mchars)

Gets the program class. Unless the program class has explicitly been set with gdk-set-program-class or with the option, the default value is the program name (determined with g-get-prgname) with the first character converted to uppercase.

ret
the program class.
— Function: gdk-set-program-class (program_class mchars)

Sets the program class. The X11 backend uses the program class to set the class name part of the ‘WM_CLASS’ property on toplevel windows; see the ICCCM.

program-class
a string.
— Function: gdk-get-display ⇒  (ret mchars)

Gets the name of the display, which usually comes from the DISPLAY environment variable or the

ret
the name of the display.
— Function: gdk-flush

Flushes the X output buffer and waits until all requests have been processed by the server. This is rarely needed by applications. It's main use is for trapping X errors with gdk-error-trap-push and gdk-error-trap-pop.

— Function: gdk-screen-width ⇒  (ret int)

Returns the width of the default screen in pixels.

ret
the width of the default screen in pixels.
— Function: gdk-screen-height ⇒  (ret int)

Returns the height of the default screen in pixels.

ret
the height of the default screen in pixels.
— Function: gdk-screen-width-mm ⇒  (ret int)

Returns the width of the default screen in millimeters. Note that on many X servers this value will not be correct.

ret
the width of the default screen in millimeters, though it is not always correct.
— Function: gdk-screen-height-mm ⇒  (ret int)

Returns the height of the default screen in millimeters. Note that on many X servers this value will not be correct.

ret
the height of the default screen in millimeters, though it is not always correct.
— Function: gdk-pointer-grab (window <gdk-window>) (owner_events bool) (event_mask <gdk-event-mask>) (confine_to <gdk-window>) (cursor <gdk-cursor>) (time_ unsigned-int32) ⇒  (ret <gdk-grab-status>)

Grabs the pointer (usually a mouse) so that all events are passed to this application until the pointer is ungrabbed with gdk-pointer-ungrab, or the grab window becomes unviewable. This overrides any previous pointer grab by this client.

Pointer grabs are used for operations which need complete control over mouse events, even if the mouse leaves the application. For example in GTK+ it is used for Drag and Drop, for dragging the handle in the <gtk-hpaned> and <gtk-vpaned> widgets, and for resizing columns in <gtk-clist> widgets.

Note that if the event mask of an X window has selected both button press and button release events, then a button press event will cause an automatic pointer grab until the button is released. X does this automatically since most applications expect to receive button press and release events in pairs. It is equivalent to a pointer grab on the window with owner-events set to ‘#t’.

If you set up anything at the time you take the grab that needs to be cleaned up when the grab ends, you should handle the <gdk-event-grab-broken> events that are emitted when the grab ends unvoluntarily.

window
the <gdk-window> which will own the grab (the grab window).
owner-events
if ‘#f’ then all pointer events are reported with respect to window and are only reported if selected by event-mask. If ‘#t’ then pointer events for this application are reported as normal, but pointer events outside this application are reported with respect to window and only if selected by event-mask. In either mode, unreported events are discarded.
event-mask
specifies the event mask, which is used in accordance with owner-events. Note that only pointer events (i.e. button and motion events) may be selected.
confine-to
If non-‘#f’, the pointer will be confined to this window during the grab. If the pointer is outside confine-to, it will automatically be moved to the closest edge of confine-to and enter and leave events will be generated as necessary.
cursor
the cursor to display while the grab is active. If this is ‘#f’ then the normal cursors are used for window and its descendants, and the cursor for window is used for all other windows.
time
the timestamp of the event which led to this pointer grab. This usually comes from a <gdk-event-button> struct, though ‘GDK_CURRENT_TIME’ can be used if the time isn't known.
ret
GDK_GRAB_SUCCESS’ if the grab was successful.
— Function: gdk-pointer-ungrab (time_ unsigned-int32)

Ungrabs the pointer, if it is grabbed by this application.

time
a timestamp from a <gdk-event>, or ‘GDK_CURRENT_TIME’ if no timestamp is available.
— Function: gdk-pointer-is-grabbed ⇒  (ret bool)

Returns ‘#t’ if the pointer is currently grabbed by this application.

Note that this does not take the inmplicit pointer grab on button presses into account.

ret
#t’ if the pointer is currently grabbed by this application.*
— Function: gdk-set-double-click-time (msec unsigned-int)

Set the double click time for the default display. See gdk-display-set-double-click-time. See also gdk-display-set-double-click-distance. Applications should not set this, it is a global user-configured setting.

msec
double click time in milliseconds (thousandths of a second)
— Function: gdk-keyboard-grab (window <gdk-window>) (owner_events bool) (time_ unsigned-int32) ⇒  (ret <gdk-grab-status>)

Grabs the keyboard so that all events are passed to this application until the keyboard is ungrabbed with gdk-keyboard-ungrab. This overrides any previous keyboard grab by this client.

If you set up anything at the time you take the grab that needs to be cleaned up when the grab ends, you should handle the <gdk-event-grab-broken> events that are emitted when the grab ends unvoluntarily.

window
the <gdk-window> which will own the grab (the grab window).
owner-events
if ‘#f’ then all keyboard events are reported with respect to window. If ‘#t’ then keyboard events for this application are reported as normal, but keyboard events outside this application are reported with respect to window. Both key press and key release events are always reported, independant of the event mask set by the application.
time
a timestamp from a <gdk-event>, or ‘GDK_CURRENT_TIME’ if no timestamp is available.
ret
GDK_GRAB_SUCCESS’ if the grab was successful.
— Function: gdk-keyboard-ungrab (time_ unsigned-int32)

Ungrabs the keyboard, if it is grabbed by this application.

time
a timestamp from a <gdk-event>, or ‘GDK_CURRENT_TIME’ if no timestamp is available.
— Function: gdk-beep

Emits a short beep on the default display.

— Function: gdk-get-use-xshm ⇒  (ret bool)

gdk_get_use_xshm’ is deprecated and should not be used in newly-written code.

Returns ‘#t’ if GDK will attempt to use the MIT-SHM shared memory extension.

The shared memory extension is used for <gdk-image>, and consequently for GdkRGB. It enables much faster drawing by communicating with the X server through SYSV shared memory calls. However, it can only be used if the X client and server are on the same machine and the server supports it.

ret
#t’ if use of the MIT shared memory extension will be attempted.
— Function: gdk-set-use-xshm (use_xshm bool)

gdk_set_use_xshm’ is deprecated and should not be used in newly-written code.

Sets whether the use of the MIT shared memory extension should be attempted. This function is mainly for internal use. It is only safe for an application to set this to ‘#f’, since if it is set to ‘#t’ and the server does not support the extension it may cause warning messages to be output.

use-xshm
#t’ if use of the MIT shared memory extension should be attempted.
— Function: gdk-error-trap-push

This function allows X errors to be trapped instead of the normal behavior of exiting the application. It should only be used if it is not possible to avoid the X error in any other way.

          
            gdk_error_trap_push ();
          
            /* ... Call the X function which may cause an error here ... */
          
            /* Flush the X queue to catch errors now. */
            gdk_flush ();
          
            if (gdk_error_trap_pop ())
              {
                /* ... Handle the error here ... */
              }
— Function: gdk-error-trap-pop ⇒  (ret int)

Removes the X error trap installed with gdk-error-trap-push.

ret
the X error code, or 0 if no error occurred.