Create  Edit  FrontPage  Index  Search  Changes  History  RSS  Login

Gdk

module Gdk

The GDK initialization functions and miscellaneous utility functions.

Module Functions

Gdk.display_arg_name
Gets the display name specified in the command line arguments(--display command line option) passed to Gtk.init if any. Since 2.2
  • Returns: the display name, if specified explicitely, otherwise nil
Gdk.set_locale

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.

  • Returns: the resulting locale.
Gdk.sm_client_id=(id)
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.)
  • id: the client id assigned by the session manager when the connection was opened, or nil to remove the property. (String)
  • Returns: id
Gdk.set_sm_client_id(id)
Same as Gdk.sm_client_id=.
  • id: the client id assigned by the session manager when the connection was opened, or nil to remove the property. (String)
  • Returns: self
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.auto_startup_notification= is called to disable that feature. Since 2.2
  • Returns: self
Gdk.program_class
Gets the program class. Unless the program class has explicitly been set with Gdk.program_class= or with the --class commandline option, the default value is the program name (determined with GLib.prgname) with the first character converted to uppercase.
  • Returns: the program class. (String)
Gdk.program_class=(program_class)
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.
  • Returns: program_class
Gdk.set_program_class(program_class)
Same as Gdk.program_class=.
  • program_class: a string.
  • Returns: self
Gdk.display
Gets the name of the display, which usually comes from the DISPLAY environment variable or the --display command line option.
  • Returns: the name of the display.
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.
  • Returns: self
Gdk.screen_width
Returns the width of the default screen in pixels.
  • Returns: the width of the default screen in pixels.
Gdk.screen_height
Returns the height of the default screen in pixels.
  • Returns: the height of the default screen in pixels.
Gdk.screen_width_mm
Returns the width of the default screen in millimeters. Note that on many X servers this value will not be correct.
  • Returns: the width of the default screen in millimeters, though it is not always correct.
Gdk.screen_height_mm
Returns the height of the default screen in millimeters. Note that on many X servers this value will not be correct.
  • Returns: the height of the default screen in millimeters, though it is not always correct.
Gdk.pointer_grab(window, owner_events, event_mask, confine_to, cursor, time)
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. 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 true.
  • window: the Gdk::Window which will own the grab (the grab window).
  • owner_events: if false then all pointer events are reported with respect to window and are only reported if selected by event_mask. If true 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(GdkEventMask), 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-nil, 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 Gdk::Cursor to display while the grab is active. If this is nil 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::EventButton struct, though Gdk::Event::CURRENT_TIME can be used if the time isn't known.
  • Returns: Gdk::GRAB_SUCCESS if the grab was successful. (GdkGrabStatus)
Gdk.pointer_ungrab(time)
Ungrabs the pointer, if it is grabbed by this application.
Gdk.pointer_is_grabbed?
Returns true if the pointer is currently grabbed by this application. Note that this does not take the inmplicit pointer grab on button presses into account.
  • Returns: true if the pointer is currently grabbed by this application
Gdk.double_click_time=(msec)
Set the double click time for the default display. See Gdk::Display#double_click_time=. See also Gdk::Display#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)
  • Returns: msec
Gdk.set_double_click_time(msec)
Same as Gdk.double_click_time=.
  • msec: double click time in milliseconds (thousandths of a second)
  • Returns: self
Gdk.keyboard_grab(window, owner_events, time)
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.
  • window: the Gdk::Window which will own the grab (the grab window).
  • owner_events: if false then all keyboard events are reported with respect to window. If true 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::Event::CURRENT_TIME if no timestamp is available.
  • Returns: Gdk::GRAB_SUCCESS if the grab was successful. (GdkGrabStatus)
Gdk.keyboard_ungrab(time)
Ungrabs the keyboard, if it is grabbed by this application.
Gdk.beep
Emits a short beep.
  • Returns: self
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.

  • Returns: self
Example 1. Trapping an X error

 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 ... 
 end
Gdk.error_trap_pop
Removes the X error trap installed with Gdk.error_trap_push.
  • Returns: the X error code, or 0 if no error occurred.
Gdk.windowing_x11?
Returns true if GDK is configured to use the X backend, otherwise false.
  • Returns: true if GDK is configured to use the X backend, otherwise false
Gdk.windowing_win32?
Returns true if GDK is configured to use the Win32 backend.
  • Returns: true if GDK is configured to use the Win32 backend
Gdk.windowing_fb?
Returns true if GDK is configured to use the Linux framebuffer backend.
  • Returns: true if GDK is configured to use the Linux framebuffer backend
Gdk.target
Returns a String from pkg-config which backend GDK is configured to.
  • Returns: self
Gdk.cairo_available?
Returns true if Ruby/Cairo is supported.
  • Returns true if Ruby/Cairo is supported.
Gdk.set_x_error_handler{|serial, error_code, request_code, minor_code| ... }
Sets an global error handler caused by X. This function works on X backend only.
  • {|serial, error_code, request_code, minor_code| ... }: An error handler
    • serial: Serial number of failed request
    • error_code: Error code of failed request
    • request_code: Major op-code of failed request
    • minor_code: Minor op-code of failed request
  • Returns: self
Gdk.set_x_io_error_handler{|disp, errno, error| ... }
Sets an global fatal I/O error handler caused by X. This function works on X backend only.
  • {|disp, errno, error| ... }
    • disp: The display name which the error is occured
    • errno: The errno
    • error: The error message
  • Returns: self
Gdk.windowing_directfb?
  • Returns: self: FIXME
Gdk.windowing_quartz?
  • Returns: self: FIXME

Constants

GdkGrabStatus

Returned by Gdk.pointer_grab and Gdk.keyboard_grab to indicate success or the reason for the failure of the grab attempt.

GRAB_SUCCESS
= 0, the resource was successfully grabbed
GRAB_ALREADY_GRABBED
= 1, the resource is actively grabbed by another client
GRAB_INVALID_TIME
= 2, the resource was grabbed more recently than the specified time
GRAB_NOT_VIEWABLE
= 3, the grab window or the confine_to window are not viewable
GRAB_FROZEN
= 4, the resource is frozen by an active grab of another client

GdkStatus

OK
= 0
ERROR
= -1
ERROR_PARAM
= -2
ERROR_FILE
= -3
ERROR_MEM
= -4
LOG_DOMAIN

ChangeLog

  • 2005-05-07 Added. - Masao