Synopsis#include <gtk/gtk.h> GtkTargetEntry; GtkTargetList; GtkTargetPair; GtkTargetList* gtk_target_list_new (const GtkTargetEntry *targets, guint ntargets); GtkTargetList* gtk_target_list_ref (GtkTargetList *list); void gtk_target_list_unref (GtkTargetList *list); void gtk_target_list_add (GtkTargetList *list, GdkAtom target, guint flags, guint info); void gtk_target_list_add_table (GtkTargetList *list, const GtkTargetEntry *targets, guint ntargets); void gtk_target_list_add_text_targets (GtkTargetList *list, guint info); void gtk_target_list_add_image_targets (GtkTargetList *list, guint info, gboolean writable); void gtk_target_list_add_uri_targets (GtkTargetList *list, guint info); void gtk_target_list_add_rich_text_targets (GtkTargetList *list, guint info, gboolean deserializable, GtkTextBuffer *buffer); void gtk_target_list_remove (GtkTargetList *list, GdkAtom target); gboolean gtk_target_list_find (GtkTargetList *list, GdkAtom target, guint *info); void gtk_target_table_free (GtkTargetEntry *targets, gint n_targets); GtkTargetEntry* gtk_target_table_new_from_list (GtkTargetList *list, gint *n_targets); gboolean gtk_selection_owner_set (GtkWidget *widget, GdkAtom selection, guint32 time_); gboolean gtk_selection_owner_set_for_display (GdkDisplay *display, GtkWidget *widget, GdkAtom selection, guint32 time_); void gtk_selection_add_target (GtkWidget *widget, GdkAtom selection, GdkAtom target, guint info); void gtk_selection_add_targets (GtkWidget *widget, GdkAtom selection, const GtkTargetEntry *targets, guint ntargets); void gtk_selection_clear_targets (GtkWidget *widget, GdkAtom selection); gboolean gtk_selection_convert (GtkWidget *widget, GdkAtom selection, GdkAtom target, guint32 time_); void gtk_selection_data_set (GtkSelectionData *selection_data, GdkAtom type, gint format, const guchar *data, gint length); gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data, const gchar *str, gint len); guchar* gtk_selection_data_get_text (GtkSelectionData *selection_data); gboolean gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data, GdkPixbuf *pixbuf); GdkPixbuf* gtk_selection_data_get_pixbuf (GtkSelectionData *selection_data); gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data, gchar **uris); gchar** gtk_selection_data_get_uris (GtkSelectionData *selection_data); gboolean gtk_selection_data_get_targets (GtkSelectionData *selection_data, GdkAtom **targets, gint *n_atoms); gboolean gtk_selection_data_targets_include_image (GtkSelectionData *selection_data, gboolean writable); gboolean gtk_selection_data_targets_include_text (GtkSelectionData *selection_data); gboolean gtk_selection_data_targets_include_uri (GtkSelectionData *selection_data); gboolean gtk_selection_data_targets_include_rich_text (GtkSelectionData *selection_data, GtkTextBuffer *buffer); const guchar* gtk_selection_data_get_data (GtkSelectionData *selection_data); gint gtk_selection_data_get_length (GtkSelectionData *selection_data); GdkAtom gtk_selection_data_get_data_type (GtkSelectionData *selection_data); GdkDisplay* gtk_selection_data_get_display (GtkSelectionData *selection_data); gint gtk_selection_data_get_format (GtkSelectionData *selection_data); GdkAtom gtk_selection_data_get_target (GtkSelectionData *selection_data); gboolean gtk_targets_include_image (GdkAtom *targets, gint n_targets, gboolean writable); gboolean gtk_targets_include_text (GdkAtom *targets, gint n_targets); gboolean gtk_targets_include_uri (GdkAtom *targets, gint n_targets); gboolean gtk_targets_include_rich_text (GdkAtom *targets, gint n_targets, GtkTextBuffer *buffer); void gtk_selection_remove_all (GtkWidget *widget); gboolean gtk_selection_clear (GtkWidget *widget, GdkEventSelection *event); GtkSelectionData* gtk_selection_data_copy (GtkSelectionData *data); void gtk_selection_data_free (GtkSelectionData *data); DescriptionThe selection mechanism provides the basis for different types of communication between processes. In particular, drag and drop and GtkClipboard work via selections. You will very seldom or never need to use most of the functions in this section directly; GtkClipboard provides a nicer interface to the same functionality. Some of the datatypes defined this section are used in the GtkClipboard and drag-and-drop API's as well. The GtkTargetEntry structure and GtkTargetList objects represent lists of data types that are supported when sending or receiving data. The GtkSelectionData object is used to store a chunk of data along with the data type and other associated information. DetailsGtkTargetEntrytypedef struct { gchar *target; guint flags; guint info; } GtkTargetEntry; A GtkTargetEntry structure represents a single type of data than can be supplied for by a widget for a selection or for supplied or received during drag-and-drop. It contains a string representing the drag type, a flags field (used only for drag and drop - see GtkTargetFlags), and an application assigned integer ID. The integer ID will later be passed as a signal parameter for signals like "selection_get". It allows the application to identify the target type without extensive string compares. GtkTargetListtypedef struct { GList *list; guint ref_count; } GtkTargetList; A GtkTargetList structure is a reference counted list of GtkTargetPair. It is used to represent the same information as a table of GtkTargetEntry, but in an efficient form. This structure should be treated as opaque. GtkTargetPairtypedef struct { GdkAtom target; guint flags; guint info; } GtkTargetPair; Internally used structure in the drag-and-drop and selection handling code. gtk_target_list_new ()GtkTargetList* gtk_target_list_new (const GtkTargetEntry *targets, guint ntargets); Creates a new GtkTargetList from an array of GtkTargetEntry.
gtk_target_list_ref ()GtkTargetList* gtk_target_list_ref (GtkTargetList *list); Increases the reference count of a GtkTargetList by one.
gtk_target_list_unref ()void gtk_target_list_unref (GtkTargetList *list); Decreases the reference count of a GtkTargetList by one. If the resulting reference count is zero, frees the list.
gtk_target_list_add ()void gtk_target_list_add (GtkTargetList *list, GdkAtom target, guint flags, guint info); Appends another target to a GtkTargetList.
gtk_target_list_add_table ()void gtk_target_list_add_table (GtkTargetList *list, const GtkTargetEntry *targets, guint ntargets); Prepends a table of GtkTargetEntry to a target list.
gtk_target_list_add_text_targets ()void gtk_target_list_add_text_targets (GtkTargetList *list, guint info);
Appends the text targets supported by GtkSelection to
the target list. All targets are added with the same
Since 2.6 gtk_target_list_add_image_targets ()void gtk_target_list_add_image_targets (GtkTargetList *list, guint info, gboolean writable);
Appends the image targets supported by GtkSelection to
the target list. All targets are added with the same
Since 2.6 gtk_target_list_add_uri_targets ()void gtk_target_list_add_uri_targets (GtkTargetList *list, guint info);
Appends the URI targets supported by GtkSelection to
the target list. All targets are added with the same
Since 2.6 gtk_target_list_add_rich_text_targets ()void gtk_target_list_add_rich_text_targets (GtkTargetList *list, guint info, gboolean deserializable, GtkTextBuffer *buffer);
Appends the rich text targets registered with
Since 2.10 gtk_target_list_remove ()void gtk_target_list_remove (GtkTargetList *list, GdkAtom target); Removes a target from a target list.
gtk_target_list_find ()gboolean gtk_target_list_find (GtkTargetList *list, GdkAtom target, guint *info); Looks up a given target in a GtkTargetList.
gtk_target_table_free ()void gtk_target_table_free (GtkTargetEntry *targets, gint n_targets);
This function frees a target table as returned by
Since 2.10 gtk_target_table_new_from_list ()GtkTargetEntry* gtk_target_table_new_from_list (GtkTargetList *list, gint *n_targets);
This function creates an GtkTargetEntry array that contains the
same targets as the passed
Since 2.10 gtk_selection_owner_set ()gboolean gtk_selection_owner_set (GtkWidget *widget, GdkAtom selection, guint32 time_);
Claims ownership of a given selection for a particular widget,
or, if
gtk_selection_owner_set_for_display ()gboolean gtk_selection_owner_set_for_display (GdkDisplay *display, GtkWidget *widget, GdkAtom selection, guint32 time_);
Claim ownership of a given selection for a particular widget, or,
if
Since 2.2 gtk_selection_add_target ()void gtk_selection_add_target (GtkWidget *widget, GdkAtom selection, GdkAtom target, guint info); Appends a specified target to the list of supported targets for a given widget and selection.
gtk_selection_add_targets ()void gtk_selection_add_targets (GtkWidget *widget, GdkAtom selection, const GtkTargetEntry *targets, guint ntargets); Prepends a table of targets to the list of supported targets for a given widget and selection.
gtk_selection_clear_targets ()void gtk_selection_clear_targets (GtkWidget *widget, GdkAtom selection); Remove all targets registered for the given selection for the widget.
gtk_selection_convert ()gboolean gtk_selection_convert (GtkWidget *widget, GdkAtom selection, GdkAtom target, guint32 time_); Requests the contents of a selection. When received, a "selection-received" signal will be generated.
gtk_selection_data_set ()void gtk_selection_data_set (GtkSelectionData *selection_data, GdkAtom type, gint format, const guchar *data, gint length); Stores new data into a GtkSelectionData object. Should only be called from a selection handler callback. Zero-terminates the stored data.
gtk_selection_data_set_text ()gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data, const gchar *str, gint len);
Sets the contents of the selection from a UTF-8 encoded string.
The string is converted to the form determined by
gtk_selection_data_get_text ()guchar* gtk_selection_data_get_text (GtkSelectionData *selection_data); Gets the contents of the selection data as a UTF-8 string.
gtk_selection_data_set_pixbuf ()gboolean gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data, GdkPixbuf *pixbuf);
Sets the contents of the selection from a GdkPixbuf
The pixbuf is converted to the form determined by
Since 2.6 gtk_selection_data_get_pixbuf ()GdkPixbuf* gtk_selection_data_get_pixbuf (GtkSelectionData *selection_data); Gets the contents of the selection data as a GdkPixbuf.
Since 2.6 gtk_selection_data_set_uris ()gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data, gchar **uris);
Sets the contents of the selection from a list of URIs.
The string is converted to the form determined by
Since 2.6 gtk_selection_data_get_uris ()gchar** gtk_selection_data_get_uris (GtkSelectionData *selection_data); Gets the contents of the selection data as array of URIs.
Since 2.6 gtk_selection_data_get_targets ()gboolean gtk_selection_data_get_targets (GtkSelectionData *selection_data, GdkAtom **targets, gint *n_atoms);
Gets the contents of
gtk_selection_data_targets_include_image ()gboolean gtk_selection_data_targets_include_image (GtkSelectionData *selection_data, gboolean writable);
Given a GtkSelectionData object holding a list of targets,
determines if any of the targets in
Since 2.6 gtk_selection_data_targets_include_text ()gboolean gtk_selection_data_targets_include_text (GtkSelectionData *selection_data);
Given a GtkSelectionData object holding a list of targets,
determines if any of the targets in
gtk_selection_data_targets_include_uri ()gboolean gtk_selection_data_targets_include_uri (GtkSelectionData *selection_data);
Given a GtkSelectionData object holding a list of targets,
determines if any of the targets in
Since 2.10 gtk_selection_data_targets_include_rich_text ()gboolean gtk_selection_data_targets_include_rich_text (GtkSelectionData *selection_data, GtkTextBuffer *buffer);
Given a GtkSelectionData object holding a list of targets,
determines if any of the targets in
Since 2.10 gtk_selection_data_get_data ()const guchar* gtk_selection_data_get_data (GtkSelectionData *selection_data); Retrieves the raw data of the selection.
Since 2.14 gtk_selection_data_get_length ()gint gtk_selection_data_get_length (GtkSelectionData *selection_data); Retrieves the length of the raw data of the selection.
Since 2.14 gtk_selection_data_get_data_type ()GdkAtom gtk_selection_data_get_data_type (GtkSelectionData *selection_data); Retrieves the data type of the selection.
Since 2.14 gtk_selection_data_get_display ()GdkDisplay* gtk_selection_data_get_display (GtkSelectionData *selection_data); Retrieves the display of the selection.
Since 2.14 gtk_selection_data_get_format ()gint gtk_selection_data_get_format (GtkSelectionData *selection_data); Retrieves the format of the selection.
Since 2.14 gtk_selection_data_get_target ()GdkAtom gtk_selection_data_get_target (GtkSelectionData *selection_data); Retrieves the target of the selection.
Since 2.14 gtk_targets_include_image ()gboolean gtk_targets_include_image (GdkAtom *targets, gint n_targets, gboolean writable);
Determines if any of the targets in
Since 2.10 gtk_targets_include_text ()gboolean gtk_targets_include_text (GdkAtom *targets, gint n_targets);
Determines if any of the targets in
Since 2.10 gtk_targets_include_uri ()gboolean gtk_targets_include_uri (GdkAtom *targets, gint n_targets);
Determines if any of the targets in
Since 2.10 gtk_targets_include_rich_text ()gboolean gtk_targets_include_rich_text (GdkAtom *targets, gint n_targets, GtkTextBuffer *buffer);
Determines if any of the targets in
Since 2.10 gtk_selection_remove_all ()void gtk_selection_remove_all (GtkWidget *widget); Removes all handlers and unsets ownership of all selections for a widget. Called when widget is being destroyed. This function will not generally be called by applications.
gtk_selection_clear ()gboolean gtk_selection_clear (GtkWidget *widget, GdkEventSelection *event); Warning
The default handler for the GtkWidget::selection_clear_event signal.
Since 2.2 gtk_selection_data_copy ()GtkSelectionData* gtk_selection_data_copy (GtkSelectionData *data); Makes a copy of a GtkSelectionData structure and its data.
gtk_selection_data_free ()void gtk_selection_data_free (GtkSelectionData *data);
Frees a GtkSelectionData structure returned from
|