Functions¶
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- Gdk.add_option_entries_libgtk_only(group)[source]¶
- Parameters:
group (
GLib.OptionGroup
) – An option group.
Appends gdk option entries to the passed in option group. This is not public API and must not be used by applications.
Deprecated since version 3.16: This symbol was never meant to be used outside of GTK+
- Gdk.atom_intern(atom_name, only_if_exists)[source]¶
- Parameters:
- Returns:
the atom corresponding to atom_name.
- Return type:
Finds or creates an atom corresponding to a given string.
- Gdk.atom_intern_static_string(atom_name)[source]¶
- Parameters:
atom_name (
str
) – a static string- Returns:
the atom corresponding to atom_name
- Return type:
Finds or creates an atom corresponding to a given string.
Note that this function is identical to
Gdk.Atom.intern
() except that if a newGdk.Atom
is created the string itself is used rather than a copy. This saves memory, but can only be used if the string will always exist. It can be used with statically allocated strings in the main program, but not with statically allocated memory in dynamically loaded modules, if you expect to ever unload the module again (e.g. do not use this function in GTK+ theme engines).New in version 2.10.
- Gdk.cairo_create(window)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
- Returns:
A newly created Cairo context. Free with cairo_destroy() when you are done drawing.
- Return type:
Creates a Cairo context for drawing to window.
Note that calling
cairo.Context.reset_clip
() on the resultingcairo.Context
will produce undefined results, so avoid it at all costs.Typically, this function is used to draw on a
Gdk.Window
out of the paint cycle of the toolkit; this should be avoided, as it breaks various assumptions and optimizations.If you are drawing on a native
Gdk.Window
in response to aGdk.EventType.EXPOSE
event you should useGdk.Window.begin_draw_frame
() andGdk.DrawingContext.get_cairo_context
() instead. GTK will automatically do this for you when drawing a widget.New in version 2.8.
Deprecated since version 3.22: Use
Gdk.Window.begin_draw_frame
() andGdk.DrawingContext.get_cairo_context
() instead
- Gdk.cairo_draw_from_gl(cr, window, source, source_type, buffer_scale, x, y, width, height)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextwindow (
Gdk.Window
) – The window we’re rendering for (not necessarily into)source (
int
) – The GL ID of the source buffersource_type (
int
) – The type of the sourcebuffer_scale (
int
) – The scale-factor that the source buffer is allocated forx (
int
) – The source x position in source to start copying from in GL coordinatesy (
int
) – The source y position in source to start copying from in GL coordinateswidth (
int
) – The width of the region to drawheight (
int
) – The height of the region to draw
This is the main way to draw GL content in GTK+. It takes a render buffer ID (source_type == #GL_RENDERBUFFER) or a texture id (source_type == #GL_TEXTURE) and draws it onto cr with an OVER operation, respecting the current clip. The top left corner of the rectangle specified by x, y, width and height will be drawn at the current (0,0) position of the
cairo.Context
.This will work for *all*
cairo.Context
, as long as window is realized, but the fallback implementation that reads back the pixels from the buffer may be used in the general case. In the case of direct drawing to a window with no special effects applied to cr it will however use a more efficient approach.For #GL_RENDERBUFFER the code will always fall back to software for buffers with alpha components, so make sure you use #GL_TEXTURE if using alpha.
Calling this may change the current GL context.
New in version 3.16.
- Gdk.cairo_get_clip_rectangle(cr)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo context- Returns:
True
if a clip rectangle exists,False
if all of cr is clipped and all drawing can be skipped- rect:
return location for the clip, or
None
- Return type:
(
bool
, rect:Gdk.Rectangle
)
This is a convenience function around
cairo.Context.clip_extents
(). It rounds the clip extents to integer coordinates and returns a boolean indicating if a clip area exists.
- Gdk.cairo_get_drawing_context(cr)[source]¶
- Parameters:
cr (
cairo.Context
) – a Cairo context- Returns:
a
Gdk.DrawingContext
, if any is set- Return type:
Retrieves the
Gdk.DrawingContext
that created the Cairo context cr.New in version 3.22.
- Gdk.cairo_rectangle(cr, rectangle)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextrectangle (
Gdk.Rectangle
) – aGdk.Rectangle
Adds the given rectangle to the current path of cr.
New in version 2.8.
- Gdk.cairo_region(cr, region)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextregion (
cairo.Region
) – acairo.Region
Adds the given region to the current path of cr.
New in version 2.8.
- Gdk.cairo_region_create_from_surface(surface)[source]¶
- Parameters:
surface (
cairo.Surface
) – a cairo surface- Returns:
A
cairo.Region
; must be freed with cairo_region_destroy()- Return type:
Creates region that describes covers the area where the given surface is more than 50% opaque.
This function takes into account device offsets that might be set with
cairo.Surface.set_device_offset
().
- Gdk.cairo_set_source_color(cr, color)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo context
Sets the specified
Gdk.Color
as the source color of cr.New in version 2.8.
Deprecated since version 3.4: Use
Gdk.cairo_set_source_rgba
() instead
- Gdk.cairo_set_source_pixbuf(cr, pixbuf, pixbuf_x, pixbuf_y)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextpixbuf (
GdkPixbuf.Pixbuf
) – aGdkPixbuf.Pixbuf
pixbuf_x (
float
) – X coordinate of location to place upper left corner of pixbufpixbuf_y (
float
) – Y coordinate of location to place upper left corner of pixbuf
Sets the given pixbuf as the source pattern for cr.
The pattern has an extend mode of
cairo.Extend.NONE
and is aligned so that the origin of pixbuf is pixbuf_x, pixbuf_y.New in version 2.8.
- Gdk.cairo_set_source_rgba(cr, rgba)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo context
Sets the specified
Gdk.RGBA
as the source color of cr.New in version 3.0.
- Gdk.cairo_set_source_window(cr, window, x, y)[source]¶
- Parameters:
cr (
cairo.Context
) – a cairo contextwindow (
Gdk.Window
) – aGdk.Window
x (
float
) – X coordinate of location to place upper left corner of windowy (
float
) – Y coordinate of location to place upper left corner of window
Sets the given window as the source pattern for cr.
The pattern has an extend mode of
cairo.Extend.NONE
and is aligned so that the origin of window is x, y. The window contains all its subwindows when rendering.Note that the contents of window are undefined outside of the visible part of window, so use this function with care.
New in version 2.24.
- Gdk.cairo_surface_create_from_pixbuf(pixbuf, scale, for_window)[source]¶
- Parameters:
pixbuf (
GdkPixbuf.Pixbuf
) – aGdkPixbuf.Pixbuf
scale (
int
) – the scale of the new surface, or 0 to use same as windowfor_window (
Gdk.Window
orNone
) – The window this will be drawn to, orNone
- Returns:
a new cairo surface, must be freed with cairo_surface_destroy()
- Return type:
Creates an image surface with the same contents as the pixbuf.
New in version 3.10.
- Gdk.color_parse(spec)[source]¶
- Parameters:
spec (
str
) – the string specifying the color- Returns:
- Return type:
Deprecated since version 3.14: Use
Gdk.RGBA
- Gdk.disable_multidevice()[source]¶
Disables multidevice support in GDK. This call must happen prior to
Gdk.Display.open
(), gtk_init(), gtk_init_with_args() or gtk_init_check() in order to take effect.Most common GTK+ applications won’t ever need to call this. Only applications that do mixed GDK/Xlib calls could want to disable multidevice support if such Xlib code deals with input devices in any way and doesn’t observe the presence of XInput 2.
New in version 3.0.
- Gdk.drag_abort(context, time_)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
time (
int
) – the timestamp for this operation
Aborts a drag without dropping.
This function is called by the drag source.
This function does not need to be called in managed drag and drop operations. See
Gdk.DragContext.manage_dnd
() for more information.
- Gdk.drag_begin(window, targets)[source]¶
- Parameters:
window (
Gdk.Window
) – the source window for this drag.targets ([
Gdk.Atom
]) – the offered targets, as list ofGdk.Atoms
- Returns:
a newly created
Gdk.DragContext
- Return type:
Starts a drag and creates a new drag context for it. This function assumes that the drag is controlled by the client pointer device, use
Gdk.drag_begin_for_device
() to begin a drag with a different device.This function is called by the drag source.
- Gdk.drag_begin_for_device(window, device, targets)[source]¶
- Parameters:
window (
Gdk.Window
) – the source window for this dragdevice (
Gdk.Device
) – the device that controls this dragtargets ([
Gdk.Atom
]) – the offered targets, as list ofGdk.Atoms
- Returns:
a newly created
Gdk.DragContext
- Return type:
Starts a drag and creates a new drag context for it.
This function is called by the drag source.
- Gdk.drag_begin_from_point(window, device, targets, x_root, y_root)[source]¶
- Parameters:
window (
Gdk.Window
) – the source window for this dragdevice (
Gdk.Device
) – the device that controls this dragtargets ([
Gdk.Atom
]) – the offered targets, as list ofGdk.Atoms
x_root (
int
) – the x coordinate where the drag nominally startedy_root (
int
) – the y coordinate where the drag nominally started
- Returns:
a newly created
Gdk.DragContext
- Return type:
Starts a drag and creates a new drag context for it.
This function is called by the drag source.
New in version 3.20.
- Gdk.drag_drop(context, time_)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
time (
int
) – the timestamp for this operation
Drops on the current destination.
This function is called by the drag source.
This function does not need to be called in managed drag and drop operations. See
Gdk.DragContext.manage_dnd
() for more information.
- Gdk.drag_drop_done(context, success)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
success (
bool
) – whether the drag was ultimatively successful
Inform GDK if the drop ended successfully. Passing
False
for success may trigger a drag cancellation animation.This function is called by the drag source, and should be the last call before dropping the reference to the context.
The
Gdk.DragContext
will only take the firstGdk.drag_drop_done
() call as effective, if this function is called multiple times, all subsequent calls will be ignored.New in version 3.20.
- Gdk.drag_drop_succeeded(context)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
- Returns:
True
if the drop was successful.- Return type:
Returns whether the dropped data has been successfully transferred. This function is intended to be used while handling a
Gdk.EventType.DROP_FINISHED
event, its return value is meaningless at other times.New in version 2.6.
- Gdk.drag_find_window_for_screen(context, drag_window, screen, x_root, y_root)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
drag_window (
Gdk.Window
) – a window which may be at the pointer position, but should be ignored, since it is put up by the drag source as an iconscreen (
Gdk.Screen
) – the screen where the destination window is soughtx_root (
int
) – the x position of the pointer in root coordinatesy_root (
int
) – the y position of the pointer in root coordinates
- Returns:
- dest_window:
location to store the destination window in
- protocol:
location to store the DND protocol in
- Return type:
(dest_window:
Gdk.Window
, protocol:Gdk.DragProtocol
)
Finds the destination window and DND protocol to use at the given pointer position.
This function is called by the drag source to obtain the dest_window and protocol parameters for
Gdk.drag_motion
().New in version 2.2.
- Gdk.drag_get_selection(context)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
.- Returns:
the selection atom, or %GDK_NONE
- Return type:
Returns the selection atom for the current source window.
- Gdk.drag_motion(context, dest_window, protocol, x_root, y_root, suggested_action, possible_actions, time_)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
dest_window (
Gdk.Window
) – the new destination window, obtained by gdk_drag_find_window()protocol (
Gdk.DragProtocol
) – the DND protocol in use, obtained by gdk_drag_find_window()x_root (
int
) – the x position of the pointer in root coordinatesy_root (
int
) – the y position of the pointer in root coordinatessuggested_action (
Gdk.DragAction
) – the suggested actionpossible_actions (
Gdk.DragAction
) – the possible actionstime (
int
) – the timestamp for this operation
- Return type:
Updates the drag context when the pointer moves or the set of actions changes.
This function is called by the drag source.
This function does not need to be called in managed drag and drop operations. See
Gdk.DragContext.manage_dnd
() for more information.
- Gdk.drag_status(context, action, time_)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
action (
Gdk.DragAction
) – the selected action which will be taken when a drop happens, or 0 to indicate that a drop will not be acceptedtime (
int
) – the timestamp for this operation
Selects one of the actions offered by the drag source.
This function is called by the drag destination in response to
Gdk.drag_motion
() called by the drag source.
- Gdk.drop_finish(context, success, time_)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
time (
int
) – the timestamp for this operation
Ends the drag operation after a drop.
This function is called by the drag destination.
- Gdk.drop_reply(context, accepted, time_)[source]¶
- Parameters:
context (
Gdk.DragContext
) – aGdk.DragContext
time (
int
) – the timestamp for this operation
Accepts or rejects a drop.
This function is called by the drag destination in response to a drop initiated by the drag source.
- Gdk.error_trap_pop()[source]¶
- Returns:
X error code or 0 on success
- Return type:
Removes an error trap pushed with
Gdk.error_trap_push
(). May block until an error has been definitively received or not received from the X server.Gdk.error_trap_pop_ignored
() is preferred if you don’t need to know whether an error occurred, because it never has to block. If you don’t need the return value ofGdk.error_trap_pop
(), useGdk.error_trap_pop_ignored
().Prior to GDK 3.0, this function would not automatically sync for you, so you had to
Gdk.flush
() if your last call to Xlib was not a blocking round trip.
- Gdk.error_trap_pop_ignored()[source]¶
Removes an error trap pushed with
Gdk.error_trap_push
(), but without bothering to wait and see whether an error occurred. If an error arrives later asynchronously that was triggered while the trap was pushed, that error will be ignored.New in version 3.0.
- Gdk.error_trap_push()[source]¶
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. Errors are ignored on all
Gdk.Display
currently known to theGdk.DisplayManager
. If you don’t care which error happens and just want to ignore everything, pop withGdk.error_trap_pop_ignored
(). If you need the error code, useGdk.error_trap_pop
() which may have to block and wait for the error to arrive from the X server.This API exists on all platforms but only does anything on X.
You can use gdk_x11_display_error_trap_push() to ignore errors on only a single display.
- Trapping an X error
gdk_error_trap_push (); // ... Call the X function which may cause an error here ... if (gdk_error_trap_pop ()) { // ... Handle the error here ... }
- Gdk.event_get()[source]¶
- Returns:
the next
Gdk.Event
to be processed, orNone
if no events are pending. The returnedGdk.Event
should be freed withGdk.Event.free
().- Return type:
Checks all open displays for a
Gdk.Event
to process,to be processed on, fetching events from the windowing system if necessary. SeeGdk.Display.get_event
().
- Gdk.event_handler_set(func, *data)[source]¶
- Parameters:
func (
Gdk.EventFunc
) – the function to call to handle events from GDK.
Sets the function to call to handle all events from GDK.
Note that GTK+ uses this to install its own event handler, so it is usually not useful for GTK+ applications. (Although an application can call this function then call gtk_main_do_event() to pass events to GTK+.)
- Gdk.event_peek()[source]¶
- Returns:
a copy of the first
Gdk.Event
on some event queue, orNone
if no events are in any queues. The returnedGdk.Event
should be freed withGdk.Event.free
().- Return type:
If there is an event waiting in the event queue of some open display, returns a copy of it. See
Gdk.Display.peek_event
().
- Gdk.event_request_motions(event)[source]¶
- Parameters:
event (
Gdk.EventMotion
) – a validGdk.Event
Request more motion notifies if event is a motion notify hint event.
This function should be used instead of
Gdk.Window.get_pointer
() to request further motion notifies, because it also works for extension events where motion notifies are provided for devices other than the core pointer. Coordinate extraction, processing and requesting more motion events from aGdk.EventType.MOTION_NOTIFY
event usually works like this:{ // motion_event handler x = motion_event->x; y = motion_event->y; // handle (x,y) motion gdk_event_request_motions (motion_event); // handles is_hint events }
New in version 2.12.
- Gdk.events_get_angle(event1, event2)[source]¶
- Parameters:
- Returns:
True
if the angle could be calculated.- angle:
return location for the relative angle between both events
- Return type:
If both events contain X/Y information, this function will return
True
and return in angle the relative angle from event1 to event2. The rotation direction for positive angles is from the positive X axis towards the positive Y axis.New in version 3.0.
- Gdk.events_get_center(event1, event2)[source]¶
- Parameters:
- Returns:
True
if the center could be calculated.- x:
return location for the X coordinate of the center
- y:
return location for the Y coordinate of the center
- Return type:
If both events contain X/Y information, the center of both coordinates will be returned in x and y.
New in version 3.0.
- Gdk.events_get_distance(event1, event2)[source]¶
- Parameters:
- Returns:
True
if the distance could be calculated.- distance:
return location for the distance
- Return type:
If both events have X/Y information, the distance between both coordinates (as in a straight line going from event1 to event2) will be returned.
New in version 3.0.
- Gdk.flush()[source]¶
Flushes the output buffers of all display connections and waits until all requests have been processed. This is rarely needed by applications.
- Gdk.get_default_root_window()[source]¶
- Returns:
the default root window
- Return type:
Obtains the root window (parent all other windows are inside) for the default display and screen.
- Gdk.get_display()[source]¶
- Returns:
the name of the display.
- Return type:
Gets the name of the display, which usually comes from the
DISPLAY
environment variable or the--display
command line option.Deprecated since version 3.8: Call
Gdk.Display.get_name
(Gdk.Display.get_default
())) instead.
- Gdk.get_display_arg_name()[source]¶
- Returns:
the display name, if specified explicitly, otherwise
None
this string is owned by GTK+ and must not be modified or freed.- Return type:
Gets the display name specified in the command line arguments passed to
Gdk.init
() orGdk.parse_args
(), if any.New in version 2.2.
- Gdk.get_program_class()[source]¶
- Returns:
the program class.
- Return type:
Gets the program class. Unless the program class has explicitly been set with
Gdk.set_program_class
() or with the--class
commandline option, the default value is the program name (determined withGLib.get_prgname
()) with the first character converted to uppercase.
- Gdk.init(argv)[source]¶
- Parameters:
argv ([
str
]) – the array of command line arguments.- Returns:
the array of command line arguments.
- Return type:
argv: [
str
]
Initializes the GDK library and connects to the windowing system. If initialization fails, a warning message is output and the application terminates with a call to
exit(1)
.Any arguments used by GDK are removed from the array and argc and argv are updated accordingly.
GTK+ initializes GDK in gtk_init() and so this function is not usually needed by GTK+ applications.
- Gdk.init_check(argv)[source]¶
- Parameters:
argv ([
str
]) – the array of command line arguments.- Returns:
True
if initialization succeeded.- argv:
the array of command line arguments.
- Return type:
Initializes the GDK library and connects to the windowing system, returning
True
on success.Any arguments used by GDK are removed from the array and argc and argv are updated accordingly.
GTK+ initializes GDK in gtk_init() and so this function is not usually needed by GTK+ applications.
- Gdk.keyboard_grab(window, owner_events, time_)[source]¶
- Parameters:
window (
Gdk.Window
) – theGdk.Window
which will own the grab (the grab window).owner_events (
bool
) – ifFalse
then all keyboard events are reported with respect to window. IfTrue
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 (
int
) – a timestamp from aGdk.Event
, orGdk.CURRENT_TIME
if no timestamp is available.
- Returns:
Gdk.GrabStatus.SUCCESS
if the grab was successful.- Return type:
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.EventGrabBroken
events that are emitted when the grab ends unvoluntarily.Deprecated since version 3.0: Use
Gdk.Device.grab
() instead.
- Gdk.keyboard_ungrab(time_)[source]¶
- Parameters:
time (
int
) – a timestamp from aGdk.Event
, orGdk.CURRENT_TIME
if no timestamp is available.
Ungrabs the keyboard on the default display, if it is grabbed by this application.
Deprecated since version 3.0: Use
Gdk.Device.ungrab
(), together withGdk.Device.grab
() instead.
- Gdk.keyval_convert_case(symbol)[source]¶
- Parameters:
symbol (
int
) – a keyval- Returns:
- lower:
return location for lowercase version of symbol
- upper:
return location for uppercase version of symbol
- Return type:
Obtains the upper- and lower-case versions of the keyval symbol. Examples of keyvals are
Gdk.KEY_a
, #GDK_KEY_Enter,Gdk.KEY_F1
, etc.
- Gdk.keyval_from_name(keyval_name)[source]¶
- Parameters:
keyval_name (
str
) – a key name- Returns:
the corresponding key value, or
Gdk.KEY_VoidSymbol
if the key name is not a valid key- Return type:
Converts a key name to a key value.
The names are the same as those in the
gdk/gdkkeysyms.h
header file but without the leading “GDK_KEY_”.
- Gdk.keyval_is_lower(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value.- Returns:
True
if keyval is in lower case, or if keyval is not subject to case conversion.- Return type:
Returns
True
if the given key value is in lower case.
- Gdk.keyval_is_upper(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value.- Returns:
True
if keyval is in upper case, or if keyval is not subject to case conversion.- Return type:
Returns
True
if the given key value is in upper case.
- Gdk.keyval_name(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value- Returns:
a string containing the name of the key, or
None
if keyval is not a valid key. The string should not be modified.- Return type:
Converts a key value into a symbolic name.
The names are the same as those in the
gdk/gdkkeysyms.h
header file but without the leading “GDK_KEY_”.
- Gdk.keyval_to_lower(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value.- Returns:
the lower case form of keyval, or keyval itself if it is already in lower case or it is not subject to case conversion.
- Return type:
Converts a key value to lower case, if applicable.
- Gdk.keyval_to_unicode(keyval)[source]¶
- Parameters:
keyval (
int
) – a GDK key symbol- Returns:
the corresponding unicode character, or 0 if there is no corresponding character.
- Return type:
Convert from a GDK key symbol to the corresponding ISO10646 (Unicode) character.
- Gdk.keyval_to_upper(keyval)[source]¶
- Parameters:
keyval (
int
) – a key value.- Returns:
the upper case form of keyval, or keyval itself if it is already in upper case or it is not subject to case conversion.
- Return type:
Converts a key value to upper case, if applicable.
- Gdk.list_visuals()[source]¶
- Returns:
a list of visuals; the list must be freed, but not its contents
- Return type:
Lists the available visuals for the default screen. (See
Gdk.Screen.list_visuals
()) A visual describes a hardware image data format. For example, a visual might support 24-bit color, or 8-bit color, and might expect pixels to be in a certain format.Call g_list_free() on the return value when you’re finished with it.
Deprecated since version 3.22: Use
Gdk.Screen.list_visuals
(Gdk.Screen.get_default
()).
- Gdk.notify_startup_complete()[source]¶
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 #GtkWindow unless gtk_window_set_auto_startup_notification() is called to disable that feature.
New in version 2.2.
- Gdk.notify_startup_complete_with_id(startup_id)[source]¶
- Parameters:
startup_id (
str
) – a startup-notification identifier, for which notification process should be completed
Indicates to the GUI environment that the application has finished loading, using a given identifier.
GTK+ will call this function automatically for #GtkWindow with custom startup-notification identifier unless gtk_window_set_auto_startup_notification() is called to disable that feature.
New in version 2.12.
- Gdk.offscreen_window_get_embedder(window)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
- Returns:
the embedding
Gdk.Window
, orNone
if window is not an mbedded offscreen window- Return type:
Gdk.Window
orNone
Gets the window that window is embedded in.
New in version 2.18.
- Gdk.offscreen_window_get_surface(window)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
- Returns:
The offscreen surface, or
None
if not offscreen- Return type:
Gets the offscreen surface that an offscreen window renders into. If you need to keep this around over window resizes, you need to add a reference to it.
- Gdk.offscreen_window_set_embedder(window, embedder)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
embedder (
Gdk.Window
) – theGdk.Window
that window gets embedded in
Sets window to be embedded in embedder.
To fully embed an offscreen window, in addition to calling this function, it is also necessary to handle the
Gdk.Window
::pick-embedded-child
signal on the embedder and theGdk.Window
::to-embedder
andGdk.Window
::from-embedder
signals on window.New in version 2.18.
- Gdk.pango_context_get()[source]¶
- Returns:
a new
Pango.Context
for the default display- Return type:
Creates a
Pango.Context
for the default GDK screen.The context must be freed when you’re finished with it.
When using GTK+, normally you should use gtk_widget_get_pango_context() instead of this function, to get the appropriate context for the widget you intend to render text onto.
The newly created context will have the default font options (see
cairo.FontOptions
) for the default screen; if these options change it will not be updated. Using gtk_widget_get_pango_context() is more convenient if you want to keep a context around and track changes to the screen’s font rendering settings.
- Gdk.pango_context_get_for_display(display)[source]¶
- Parameters:
display (
Gdk.Display
) – theGdk.Display
for which the context is to be created- Returns:
a new
Pango.Context
for display- Return type:
Creates a
Pango.Context
for display.The context must be freed when you’re finished with it.
When using GTK+, normally you should use gtk_widget_get_pango_context() instead of this function, to get the appropriate context for the widget you intend to render text onto.
The newly created context will have the default font options (see
cairo.FontOptions
) for the display; if these options change it will not be updated. Using gtk_widget_get_pango_context() is more convenient if you want to keep a context around and track changes to the font rendering settings.New in version 3.22.
- Gdk.pango_context_get_for_screen(screen)[source]¶
- Parameters:
screen (
Gdk.Screen
) – theGdk.Screen
for which the context is to be created.- Returns:
a new
Pango.Context
for screen- Return type:
Creates a
Pango.Context
for screen.The context must be freed when you’re finished with it.
When using GTK+, normally you should use gtk_widget_get_pango_context() instead of this function, to get the appropriate context for the widget you intend to render text onto.
The newly created context will have the default font options (see
cairo.FontOptions
) for the screen; if these options change it will not be updated. Using gtk_widget_get_pango_context() is more convenient if you want to keep a context around and track changes to the screen’s font rendering settings.New in version 2.2.
- Gdk.parse_args(argv)[source]¶
- Parameters:
argv ([
str
]) – the array of command line arguments.- Returns:
the array of command line arguments.
- Return type:
argv: [
str
]
Parse command line arguments, and store for future use by calls to
Gdk.Display.open
().Any arguments used by GDK are removed from the array and argc and argv are updated accordingly.
You shouldn’t call this function explicitly if you are using gtk_init(), gtk_init_check(),
Gdk.init
(), orGdk.init_check
().New in version 2.2.
- Gdk.pixbuf_get_from_surface(surface, src_x, src_y, width, height)[source]¶
- Parameters:
surface (
cairo.Surface
) – surface to copy fromsrc_x (
int
) – Source X coordinate within surfacesrc_y (
int
) – Source Y coordinate within surfacewidth (
int
) – Width in pixels of region to getheight (
int
) – Height in pixels of region to get
- Returns:
A newly-created pixbuf with a reference count of 1, or
None
on error- Return type:
Transfers image data from a
cairo.Surface
and converts it to an RGB(A) representation inside aGdkPixbuf.Pixbuf
. This allows you to efficiently read individual pixels from cairo surfaces. ForGdk.Windows
, useGdk.pixbuf_get_from_window
() instead.This function will create an RGB pixbuf with 8 bits per channel. The pixbuf will contain an alpha channel if the surface contains one.
- Gdk.pixbuf_get_from_window(window, src_x, src_y, width, height)[source]¶
- Parameters:
window (
Gdk.Window
) – Source windowsrc_x (
int
) – Source X coordinate within windowsrc_y (
int
) – Source Y coordinate within windowwidth (
int
) – Width in pixels of region to getheight (
int
) – Height in pixels of region to get
- Returns:
A newly-created pixbuf with a reference count of 1, or
None
on error- Return type:
Transfers image data from a
Gdk.Window
and converts it to an RGB(A) representation inside aGdkPixbuf.Pixbuf
.In other words, copies image data from a server-side drawable to a client-side RGB(A) buffer. This allows you to efficiently read individual pixels on the client side.
This function will create an RGB pixbuf with 8 bits per channel with the size specified by the width and height arguments scaled by the scale factor of window. The pixbuf will contain an alpha channel if the window contains one.
If the window is off the screen, then there is no image data in the obscured/offscreen regions to be placed in the pixbuf. The contents of portions of the pixbuf corresponding to the offscreen region are undefined.
If the window you’re obtaining data from is partially obscured by other windows, then the contents of the pixbuf areas corresponding to the obscured regions are undefined.
If the window is not mapped (typically because it’s iconified/minimized or not on the current workspace), then
None
will be returned.If memory can’t be allocated for the return value,
None
will be returned instead.In short, there are several ways this function can fail, and if it fails it returns
None
; so check the return value.You should rarely, if ever, need to call this function.
- Gdk.pointer_grab(window, owner_events, event_mask, confine_to, cursor, time_)[source]¶
- Parameters:
window (
Gdk.Window
) – theGdk.Window
which will own the grab (the grab window).owner_events (
bool
) – ifFalse
then all pointer events are reported with respect to window and are only reported if selected by event_mask. IfTrue
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 (
Gdk.EventMask
) – 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 (
Gdk.Window
orNone
) – If non-None
, 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 (
Gdk.Cursor
orNone
) – the cursor to display while the grab is active. If this isNone
then the normal cursors are used for window and its descendants, and the cursor for window is used for all other windows.time (
int
) – the timestamp of the event which led to this pointer grab. This usually comes from aGdk.EventButton
struct, thoughGdk.CURRENT_TIME
can be used if the time isn’t known.
- Returns:
Gdk.GrabStatus.SUCCESS
if the grab was successful.- Return type:
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 #GtkHPaned and #GtkVPaned 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
.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.EventGrabBroken
events that are emitted when the grab ends unvoluntarily.Deprecated since version 3.0: Use
Gdk.Device.grab
() instead.
- Gdk.pointer_is_grabbed()[source]¶
-
Returns
True
if the pointer on the default display is currently grabbed by this application.Note that this does not take the inmplicit pointer grab on button presses into account.
Deprecated since version 3.0: Use
Gdk.Display.device_is_grabbed
() instead.
- Gdk.pointer_ungrab(time_)[source]¶
- Parameters:
time (
int
) – a timestamp from aGdk.Event
, orGdk.CURRENT_TIME
if no timestamp is available.
Ungrabs the pointer on the default display, if it is grabbed by this application.
Deprecated since version 3.0: Use
Gdk.Device.ungrab
(), together withGdk.Device.grab
() instead.
- Gdk.pre_parse_libgtk_only()[source]¶
Prepare for parsing command line arguments for GDK. This is not public API and should not be used in application code.
Deprecated since version 3.16: This symbol was never meant to be used outside of GTK+
- Gdk.property_delete(window, property)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
property (
Gdk.Atom
) – the property to delete
Deletes a property from a window.
- Gdk.property_get(window, property, type, offset, length, pdelete)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
property (
Gdk.Atom
) – the property to retrievetype (
Gdk.Atom
) – the desired property type, or %GDK_NONE, if any type of data is acceptable. If this does not match the actual type, then actual_format and actual_length will be filled in, a warning will be printed to stderr and no data will be returned.offset (
int
) – the offset into the property at which to begin retrieving data, in 4 byte units.length (
int
) – the length of the data to retrieve in bytes. Data is considered to be retrieved in 4 byte chunks, so length will be rounded up to the next highest 4 byte boundary (so be careful not to pass a value that might overflow when rounded up).pdelete (
int
) – ifTrue
, delete the property after retrieving the data.
- Returns:
True
if data was successfully received and stored in data, otherwiseFalse
.- actual_property_type:
location to store the actual type of the property.
- actual_format:
location to store the actual return format of the data; either 8, 16 or 32 bits.
- data:
location to store a pointer to the data. The retrieved data should be freed with
GLib.free
() when you are finished using it.
- Return type:
(
bool
, actual_property_type:Gdk.Atom
, actual_format:int
, data:bytes
)
Retrieves a portion of the contents of a property. If the property does not exist, then the function returns
False
, and %GDK_NONE will be stored in actual_property_type.The XGetWindowProperty() function that
Gdk.property_get
() uses has a very confusing and complicated set of semantics. Unfortunately,Gdk.property_get
() makes the situation worse instead of better (the semantics should be considered undefined), and also prints warnings to stderr in cases where it should return a useful error to the program. You are advised to use XGetWindowProperty() directly until a replacement function forGdk.property_get
() is provided.
- Gdk.query_depths()[source]¶
- Returns:
return location for available depths
- Return type:
depths: [
int
]
This function returns the available bit depths for the default screen. It’s equivalent to listing the visuals (
Gdk.list_visuals
()) and then looking at the depth field in each visual, removing duplicates.The array returned by this function should not be freed.
Deprecated since version 3.22: Visual selection should be done using
Gdk.Screen.get_system_visual
() andGdk.Screen.get_rgba_visual
()
- Gdk.query_visual_types()[source]¶
- Returns:
return location for the available visual types
- Return type:
visual_types: [
Gdk.VisualType
]
This function returns the available visual types for the default screen. It’s equivalent to listing the visuals (
Gdk.list_visuals
()) and then looking at the type field in each visual, removing duplicates.The array returned by this function should not be freed.
Deprecated since version 3.22: Visual selection should be done using
Gdk.Screen.get_system_visual
() andGdk.Screen.get_rgba_visual
()
- Gdk.rectangle_intersect(src2)¶
intersect(src2: Gdk.Rectangle) -> (bool, dest: Gdk.Rectangle)
- Gdk.rectangle_union(src2)¶
union(src2: Gdk.Rectangle) -> dest: Gdk.Rectangle
- Gdk.selection_convert(requestor, selection, target, time_)[source]¶
- Parameters:
requestor (
Gdk.Window
) – aGdk.Window
.selection (
Gdk.Atom
) – an atom identifying the selection to get the contents of.target (
Gdk.Atom
) – the form in which to retrieve the selection.time (
int
) – the timestamp to use when retrieving the selection. The selection owner may refuse the request if it did not own the selection at the time indicated by the timestamp.
Retrieves the contents of a selection in a given form.
- Gdk.selection_owner_get(selection)[source]¶
- Parameters:
selection (
Gdk.Atom
) – an atom indentifying a selection.- Returns:
if there is a selection owner for this window, and it is a window known to the current process, the
Gdk.Window
that owns the selection, otherwiseNone
. Note that the return value may be owned by a different process if a foreign window was previously created for that window, but a new foreign window will never be created by this call.- Return type:
Gdk.Window
orNone
Determines the owner of the given selection.
- Gdk.selection_owner_get_for_display(display, selection)[source]¶
- Parameters:
display (
Gdk.Display
) – aGdk.Display
selection (
Gdk.Atom
) – an atom indentifying a selection
- Returns:
if there is a selection owner for this window, and it is a window known to the current process, the
Gdk.Window
that owns the selection, otherwiseNone
.- Return type:
Gdk.Window
orNone
Determine the owner of the given selection.
Note that the return value may be owned by a different process if a foreign window was previously created for that window, but a new foreign window will never be created by this call.
New in version 2.2.
- Gdk.selection_owner_set(owner, selection, time_, send_event)[source]¶
- Parameters:
owner (
Gdk.Window
orNone
) – aGdk.Window
orNone
to indicate that the the owner for the given should be unset.selection (
Gdk.Atom
) – an atom identifying a selection.time (
int
) – timestamp to use when setting the selection. If this is older than the timestamp given last time the owner was set for the given selection, the request will be ignored.send_event (
bool
) – ifTrue
, and the new owner is different from the current owner, the current owner will be sent a SelectionClear event.
- Returns:
True
if the selection owner was successfully changed to owner, otherwiseFalse
.- Return type:
Sets the owner of the given selection.
- Gdk.selection_owner_set_for_display(display, owner, selection, time_, send_event)[source]¶
- Parameters:
display (
Gdk.Display
) – theGdk.Display
owner (
Gdk.Window
orNone
) – aGdk.Window
orNone
to indicate that the owner for the given should be unsetselection (
Gdk.Atom
) – an atom identifying a selectiontime (
int
) – timestamp to use when setting the selection If this is older than the timestamp given last time the owner was set for the given selection, the request will be ignoredsend_event (
bool
) – ifTrue
, and the new owner is different from the current owner, the current owner will be sent a SelectionClear event
- Returns:
True
if the selection owner was successfully changed to owner, otherwiseFalse
.- Return type:
Sets the
Gdk.Window
owner as the current owner of the selection selection.New in version 2.2.
- Gdk.selection_send_notify(requestor, selection, target, property, time_)[source]¶
- Parameters:
requestor (
Gdk.Window
) – window to which to deliver response.selection (
Gdk.Atom
) – selection that was requested.target (
Gdk.Atom
) – target that was selected.property (
Gdk.Atom
) – property in which the selection owner stored the data, or %GDK_NONE to indicate that the request was rejected.time (
int
) – timestamp.
Sends a response to SelectionRequest event.
- Gdk.selection_send_notify_for_display(display, requestor, selection, target, property, time_)[source]¶
- Parameters:
display (
Gdk.Display
) – theGdk.Display
where requestor is realizedrequestor (
Gdk.Window
) – window to which to deliver responseselection (
Gdk.Atom
) – selection that was requestedtarget (
Gdk.Atom
) – target that was selectedproperty (
Gdk.Atom
) – property in which the selection owner stored the data, or %GDK_NONE to indicate that the request was rejectedtime (
int
) – timestamp
Send a response to SelectionRequest event.
New in version 2.2.
- Gdk.set_allowed_backends(backends)[source]¶
- Parameters:
backends (
str
) – a comma-separated list of backends
Sets a list of backends that GDK should try to use.
This can be be useful if your application does not work with certain GDK backends.
By default, GDK tries all included backends.
For example,
gdk_set_allowed_backends ("wayland,quartz,*");
instructs GDK to try the Wayland backend first, followed by the Quartz backend, and then all others.
If the
GDK_BACKEND
environment variable is set, it determines what backends are tried in what order, while still respecting the set of allowed backends that are specified by this function.The possible backend names are x11, win32, quartz, broadway, wayland. You can also include a * in the list to try all remaining backends.
This call must happen prior to
Gdk.Display.open
(), gtk_init(), gtk_init_with_args() or gtk_init_check() in order to take effect.New in version 3.10.
- Gdk.set_double_click_time(msec)[source]¶
- Parameters:
msec (
int
) – double click time in milliseconds (thousandths of a second)
Set the double click time for the default display. See
Gdk.Display.set_double_click_time
(). See alsoGdk.Display.set_double_click_distance
(). Applications should not set this, it is a global user-configured setting.
- Gdk.set_program_class(program_class)[source]¶
- Parameters:
program_class (
str
) – a string.
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.The program class can still be overridden with the –class command line option.
- Gdk.set_show_events(show_events)[source]¶
-
Sets whether a trace of received events is output. Note that GTK+ must be compiled with debugging (that is, configured using the
--enable-debug
option) to use this option.
- Gdk.setting_get(name, value)[source]¶
- Parameters:
name (
str
) – the name of the setting.value (
GObject.Value
) – location to store the value of the setting.
- Returns:
True
if the setting existed and a value was stored in value,False
otherwise.- Return type:
Obtains a desktop-wide setting, such as the double-click time, for the default screen. See
Gdk.Screen.get_setting
().
- Gdk.synthesize_window_state(window, unset_flags, set_flags)[source]¶
- Parameters:
window (
Gdk.Window
) –unset_flags (
Gdk.WindowState
) –set_flags (
Gdk.WindowState
) –
- Gdk.test_render_sync(window)[source]¶
- Parameters:
window (
Gdk.Window
) – a mappedGdk.Window
Retrieves a pixel from window to force the windowing system to carry out any pending rendering commands.
This function is intended to be used to synchronize with rendering pipelines, to benchmark windowing system rendering operations.
New in version 2.14.
- Gdk.test_simulate_button(window, x, y, button, modifiers, button_pressrelease)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
to simulate a button event forx (
int
) – x coordinate within window for the button eventy (
int
) – y coordinate within window for the button eventbutton (
int
) – Number of the pointer button for the event, usually 1, 2 or 3modifiers (
Gdk.ModifierType
) – Keyboard modifiers the event is setup withbutton_pressrelease (
Gdk.EventType
) – eitherGdk.EventType.BUTTON_PRESS
orGdk.EventType.BUTTON_RELEASE
- Returns:
whether all actions necessary for a button event simulation were carried out successfully
- Return type:
This function is intended to be used in GTK+ test programs. It will warp the mouse pointer to the given (x,`y`) coordinates within window and simulate a button press or release event. Because the mouse pointer needs to be warped to the target location, use of this function outside of test programs that run in their own virtual windowing system (e.g. Xvfb) is not recommended.
Also,
Gdk.test_simulate_button
() is a fairly low level function, for most testing purposes, gtk_test_widget_click() is the right function to call which will generate a button press event followed by its accompanying button release event.New in version 2.14.
- Gdk.test_simulate_key(window, x, y, keyval, modifiers, key_pressrelease)[source]¶
- Parameters:
window (
Gdk.Window
) – aGdk.Window
to simulate a key event forx (
int
) – x coordinate within window for the key eventy (
int
) – y coordinate within window for the key eventkeyval (
int
) – A GDK keyboard valuemodifiers (
Gdk.ModifierType
) – Keyboard modifiers the event is setup withkey_pressrelease (
Gdk.EventType
) – eitherGdk.EventType.KEY_PRESS
orGdk.EventType.KEY_RELEASE
- Returns:
whether all actions necessary for a key event simulation were carried out successfully
- Return type:
This function is intended to be used in GTK+ test programs. If (x,`y`) are > (-1,-1), it will warp the mouse pointer to the given (x,`y`) coordinates within window and simulate a key press or release event.
When the mouse pointer is warped to the target location, use of this function outside of test programs that run in their own virtual windowing system (e.g. Xvfb) is not recommended. If (x,`y`) are passed as (-1,-1), the mouse pointer will not be warped and window origin will be used as mouse pointer location for the event.
Also,
Gdk.test_simulate_key
() is a fairly low level function, for most testing purposes, gtk_test_widget_send_key() is the right function to call which will generate a key press event followed by its accompanying key release event.New in version 2.14.
- Gdk.text_property_to_utf8_list_for_display(display, encoding, format, text)[source]¶
- Parameters:
display (
Gdk.Display
) – aGdk.Display
encoding (
Gdk.Atom
) – an atom representing the encoding of the textformat (
int
) – the format of the propertytext (
bytes
) – the text to convert
- Returns:
the number of strings in the resulting list
- list:
location to store the list of strings or
None
. The list should be freed withGLib.strfreev
().
- Return type:
Converts a text property in the given encoding to a list of UTF-8 strings.
New in version 2.2.
- Gdk.threads_add_idle(priority, function, *data)[source]¶
- Parameters:
priority (
int
) – the priority of the idle source. Typically this will be in the range betweenGLib.PRIORITY_DEFAULT_IDLE
andGLib.PRIORITY_HIGH_IDLE
function (
GLib.SourceFunc
) – function to call
- Returns:
the ID (greater than 0) of the event source.
- Return type:
Adds a function to be called whenever there are no higher priority events pending. If the function returns
False
it is automatically removed from the list of event sources and will not be called again.This variant of
GLib.idle_add
() calls function with the GDK lock held. It can be thought of a MT-safe version for GTK+ widgets for the following use case, where you have to worry about idle_callback() running in thread A and accessing self after it has been finalized in thread B:static gboolean idle_callback (gpointer data) { // gdk_threads_enter(); would be needed for g_idle_add() SomeWidget *self = data; // do stuff with self self->idle_id = 0; // gdk_threads_leave(); would be needed for g_idle_add() return FALSE; } static void some_widget_do_stuff_later (SomeWidget *self) { self->idle_id = gdk_threads_add_idle (idle_callback, self) // using g_idle_add() here would require thread protection in the callback } static void some_widget_finalize (GObject *object) { SomeWidget *self = SOME_WIDGET (object); if (self->idle_id) g_source_remove (self->idle_id); G_OBJECT_CLASS (parent_class)->finalize (object); }
New in version 2.12.
- Gdk.threads_add_timeout(priority, interval, function, *data)[source]¶
- Parameters:
priority (
int
) – the priority of the timeout source. Typically this will be in the range betweenGLib.PRIORITY_DEFAULT_IDLE
andGLib.PRIORITY_HIGH_IDLE
.interval (
int
) – the time between calls to the function, in milliseconds (1/1000ths of a second)function (
GLib.SourceFunc
) – function to call
- Returns:
the ID (greater than 0) of the event source.
- Return type:
Sets a function to be called at regular intervals holding the GDK lock, with the given priority. The function is called repeatedly until it returns
False
, at which point the timeout is automatically destroyed and the function will not be called again. The notify function is called when the timeout is destroyed. The first call to the function will be at the end of the first interval.Note that timeout functions may be delayed, due to the processing of other event sources. Thus they should not be relied on for precise timing. After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to “catch up” time lost in delays).
This variant of
GLib.timeout_add
() can be thought of a MT-safe version for GTK+ widgets for the following use case:static gboolean timeout_callback (gpointer data) { SomeWidget *self = data; // do stuff with self self->timeout_id = 0; return G_SOURCE_REMOVE; } static void some_widget_do_stuff_later (SomeWidget *self) { self->timeout_id = g_timeout_add (timeout_callback, self) } static void some_widget_finalize (GObject *object) { SomeWidget *self = SOME_WIDGET (object); if (self->timeout_id) g_source_remove (self->timeout_id); G_OBJECT_CLASS (parent_class)->finalize (object); }
New in version 2.12.
- Gdk.threads_add_timeout_seconds(priority, interval, function, *data)[source]¶
- Parameters:
priority (
int
) – the priority of the timeout source. Typically this will be in the range betweenGLib.PRIORITY_DEFAULT_IDLE
andGLib.PRIORITY_HIGH_IDLE
.interval (
int
) – the time between calls to the function, in secondsfunction (
GLib.SourceFunc
) – function to call
- Returns:
the ID (greater than 0) of the event source.
- Return type:
A variant of
Gdk.threads_add_timeout
() with second-granularity. SeeGLib.timeout_add_seconds
() for a discussion of why it is a good idea to use this function if you don’t need finer granularity.New in version 2.14.
- Gdk.threads_enter()[source]¶
This function marks the beginning of a critical section in which GDK and GTK+ functions can be called safely and without causing race conditions. Only one thread at a time can be in such a critial section.
Deprecated since version 3.6: All GDK and GTK+ calls should be made from the main thread
- Gdk.threads_init()[source]¶
Initializes GDK so that it can be used from multiple threads in conjunction with
Gdk.threads_enter
() andGdk.threads_leave
().This call must be made before any use of the main loop from GTK+; to be safe, call it before gtk_init().
Deprecated since version 3.6: All GDK and GTK+ calls should be made from the main thread
- Gdk.threads_leave()[source]¶
Leaves a critical region begun with
Gdk.threads_enter
().Deprecated since version 3.6: All GDK and GTK+ calls should be made from the main thread
- Gdk.unicode_to_keyval(wc)[source]¶
- Parameters:
wc (
int
) – a ISO10646 encoded character- Returns:
the corresponding GDK key symbol, if one exists. or, if there is no corresponding symbol, wc | 0x01000000
- Return type:
Convert from a ISO10646 character to a key symbol.
- Gdk.utf8_to_string_target(str)[source]¶
- Parameters:
str (
str
) – a UTF-8 string- Returns:
the newly-allocated string, or
None
if the conversion failed. (It should not fail for any properly formed UTF-8 string unless system limits like memory or file descriptors are exceeded.)- Return type:
Converts an UTF-8 string into the best possible representation as a STRING. The representation of characters not in STRING is not specified; it may be as pseudo-escape sequences \x{ABCD}, or it may be in some other form of approximation.