Gtk.SelectionData

Fields

None

Methods

  copy ()
  free ()
  get_data ()
  get_data_type ()
  get_display ()
  get_format ()
  get_length ()
  get_pixbuf ()
  get_selection ()
  get_target ()
  get_targets ()
  get_text ()
  get_uris ()
  set (type, format, data)
  set_pixbuf (pixbuf)
  set_text (str, len)
  set_uris (uris)
  targets_include_image (writable)
  targets_include_rich_text (buffer)
  targets_include_text ()
  targets_include_uri ()

Details

class Gtk.SelectionData
copy()[source]
Returns:a pointer to a copy of self.
Return type:Gtk.SelectionData

Makes a copy of a Gtk.SelectionData-struct and its data.

free()[source]

Frees a Gtk.SelectionData-struct returned from Gtk.SelectionData.copy().

get_data()[source]
Returns:the raw data of the selection
Return type:bytes

Retrieves the raw data of the selection along with its length.

New in version 3.0.

get_data_type()[source]
Returns:the data type of the selection.
Return type:Gdk.Atom

Retrieves the data type of the selection.

New in version 2.14.

get_display()[source]
Returns:the display of the selection.
Return type:Gdk.Display

Retrieves the display of the selection.

New in version 2.14.

get_format()[source]
Returns:the format of the selection.
Return type:int

Retrieves the format of the selection.

New in version 2.14.

get_length()[source]
Returns:the length of the data of the selection.
Return type:int

Retrieves the length of the raw data of the selection.

New in version 2.14.

get_pixbuf()[source]
Returns:if the selection data contained a recognized image type and it could be converted to a GdkPixbuf.Pixbuf, a newly allocated pixbuf is returned, otherwise None. If the result is non-None it must be freed with GObject.Object.unref().
Return type:GdkPixbuf.Pixbuf or None

Gets the contents of the selection data as a GdkPixbuf.Pixbuf.

New in version 2.6.

get_selection()[source]
Returns:the selection Gdk.Atom of the selection data.
Return type:Gdk.Atom

Retrieves the selection Gdk.Atom of the selection data.

New in version 2.16.

get_target()[source]
Returns:the target of the selection.
Return type:Gdk.Atom

Retrieves the target of the selection.

New in version 2.14.

get_targets()[source]
Returns:True if self contains a valid array of targets, otherwise False.
targets:location to store an array of targets. The result stored here must be freed with GLib.free().
Return type:(bool, targets: [Gdk.Atom])

Gets the contents of self as an array of targets. This can be used to interpret the results of getting the standard TARGETS target that is always supplied for any selection.

get_text()[source]
Returns:if the selection data contained a recognized text type and it could be converted to UTF-8, a newly allocated string containing the converted text, otherwise None. If the result is non-None it must be freed with GLib.free().
Return type:str or None

Gets the contents of the selection data as a UTF-8 string.

get_uris()[source]
Returns:if the selection data contains a list of URIs, a newly allocated None-terminated string array containing the URIs, otherwise None. If the result is non-None it must be freed with GLib.strfreev().
Return type:[str]

Gets the contents of the selection data as array of URIs.

New in version 2.6.

set(type, format, data)[source]
Parameters:
  • type (Gdk.Atom) – the type of selection data
  • format (int) – format (number of bits in a unit)
  • data (bytes) – pointer to the data (will be copied)

Stores new data into a Gtk.SelectionData object. Should only be called from a selection handler callback. Zero-terminates the stored data.

set_pixbuf(pixbuf)[source]
Parameters:pixbuf (GdkPixbuf.Pixbuf) – a GdkPixbuf.Pixbuf
Returns:True if the selection was successfully set, otherwise False.
Return type:bool

Sets the contents of the selection from a GdkPixbuf.Pixbuf The pixbuf is converted to the form determined by self->target.

New in version 2.6.

set_text(str, len)[source]
Parameters:
  • str (str) – a UTF-8 string
  • len (int) – the length of str, or -1 if str is nul-terminated.
Returns:

True if the selection was successfully set, otherwise False.

Return type:

bool

Sets the contents of the selection from a UTF-8 encoded string. The string is converted to the form determined by self->target.

set_uris(uris)[source]
Parameters:uris ([str]) – a None-terminated array of strings holding URIs
Returns:True if the selection was successfully set, otherwise False.
Return type:bool

Sets the contents of the selection from a list of URIs. The string is converted to the form determined by self->target.

New in version 2.6.

targets_include_image(writable)[source]
Parameters:writable (bool) – whether to accept only targets for which GTK+ knows how to convert a pixbuf into the format
Returns:True if self holds a list of targets, and a suitable target for images is included, otherwise False.
Return type:bool

Given a Gtk.SelectionData object holding a list of targets, determines if any of the targets in targets can be used to provide a GdkPixbuf.Pixbuf.

New in version 2.6.

targets_include_rich_text(buffer)[source]
Parameters:buffer (Gtk.TextBuffer) – a Gtk.TextBuffer
Returns:True if self holds a list of targets, and a suitable target for rich text is included, otherwise False.
Return type:bool

Given a Gtk.SelectionData object holding a list of targets, determines if any of the targets in targets can be used to provide rich text.

New in version 2.10.

targets_include_text()[source]
Returns:True if self holds a list of targets, and a suitable target for text is included, otherwise False.
Return type:bool

Given a Gtk.SelectionData object holding a list of targets, determines if any of the targets in targets can be used to provide text.

targets_include_uri()[source]
Returns:True if self holds a list of targets, and a suitable target for URI lists is included, otherwise False.
Return type:bool

Given a Gtk.SelectionData object holding a list of targets, determines if any of the targets in targets can be used to provide a list or URIs.

New in version 2.10.