![]() |
![]() |
![]() |
GTK+ 3 Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
#include <gtk/gtk.h> enum GtkDestDefaults; enum GtkTargetFlags; void gtk_drag_dest_set (GtkWidget *widget
,GtkDestDefaults flags
,const GtkTargetEntry *targets
,gint n_targets
,GdkDragAction actions
); void gtk_drag_dest_set_proxy (GtkWidget *widget
,GdkWindow *proxy_window
,GdkDragProtocol protocol
,gboolean use_coordinates
); void gtk_drag_dest_unset (GtkWidget *widget
); GdkAtom gtk_drag_dest_find_target (GtkWidget *widget
,GdkDragContext *context
,GtkTargetList *target_list
); GtkTargetList * gtk_drag_dest_get_target_list (GtkWidget *widget
); void gtk_drag_dest_set_target_list (GtkWidget *widget
,GtkTargetList *target_list
); void gtk_drag_dest_add_text_targets (GtkWidget *widget
); void gtk_drag_dest_add_image_targets (GtkWidget *widget
); void gtk_drag_dest_add_uri_targets (GtkWidget *widget
); void gtk_drag_dest_set_track_motion (GtkWidget *widget
,gboolean track_motion
); gboolean gtk_drag_dest_get_track_motion (GtkWidget *widget
); void gtk_drag_finish (GdkDragContext *context
,gboolean success
,gboolean del
,guint32 time_
); void gtk_drag_get_data (GtkWidget *widget
,GdkDragContext *context
,GdkAtom target
,guint32 time_
); GtkWidget * gtk_drag_get_source_widget (GdkDragContext *context
); void gtk_drag_highlight (GtkWidget *widget
); void gtk_drag_unhighlight (GtkWidget *widget
); GdkDragContext * gtk_drag_begin (GtkWidget *widget
,GtkTargetList *targets
,GdkDragAction actions
,gint button
,GdkEvent *event
); void gtk_drag_set_icon_widget (GdkDragContext *context
,GtkWidget *widget
,gint hot_x
,gint hot_y
); void gtk_drag_set_icon_pixbuf (GdkDragContext *context
,GdkPixbuf *pixbuf
,gint hot_x
,gint hot_y
); void gtk_drag_set_icon_stock (GdkDragContext *context
,const gchar *stock_id
,gint hot_x
,gint hot_y
); void gtk_drag_set_icon_surface (GdkDragContext *context
,cairo_surface_t *surface
); void gtk_drag_set_icon_name (GdkDragContext *context
,const gchar *icon_name
,gint hot_x
,gint hot_y
); void gtk_drag_set_icon_gicon (GdkDragContext *context
,GIcon *icon
,gint hot_x
,gint hot_y
); void gtk_drag_set_icon_default (GdkDragContext *context
); gboolean gtk_drag_check_threshold (GtkWidget *widget
,gint start_x
,gint start_y
,gint current_x
,gint current_y
); void gtk_drag_source_set (GtkWidget *widget
,GdkModifierType start_button_mask
,const GtkTargetEntry *targets
,gint n_targets
,GdkDragAction actions
); void gtk_drag_source_set_icon_pixbuf (GtkWidget *widget
,GdkPixbuf *pixbuf
); void gtk_drag_source_set_icon_stock (GtkWidget *widget
,const gchar *stock_id
); void gtk_drag_source_set_icon_name (GtkWidget *widget
,const gchar *icon_name
); void gtk_drag_source_set_icon_gicon (GtkWidget *widget
,GIcon *icon
); void gtk_drag_source_unset (GtkWidget *widget
); void gtk_drag_source_set_target_list (GtkWidget *widget
,GtkTargetList *target_list
); GtkTargetList * gtk_drag_source_get_target_list (GtkWidget *widget
); void gtk_drag_source_add_text_targets (GtkWidget *widget
); void gtk_drag_source_add_image_targets (GtkWidget *widget
); void gtk_drag_source_add_uri_targets (GtkWidget *widget
);
GTK+ has a rich set of functions for doing inter-process communication via the drag-and-drop metaphor. GTK+ can do drag-and-drop (DND) via multiple protocols. The currently supported protocols are the Xdnd and Motif protocols.
As well as the functions listed here, applications may need to use some facilities provided for Selections. Also, the Drag and Drop API makes use of signals in the GtkWidget class.
typedef enum { GTK_DEST_DEFAULT_MOTION = 1 << 0, /* respond to "drag_motion" */ GTK_DEST_DEFAULT_HIGHLIGHT = 1 << 1, /* auto-highlight */ GTK_DEST_DEFAULT_DROP = 1 << 2, /* respond to "drag_drop" */ GTK_DEST_DEFAULT_ALL = 0x07 } GtkDestDefaults;
The GtkDestDefaults enumeration specifies the various types of action that will be taken on behalf of the user for a drag destination site.
If set for a widget, GTK+, during a drag over this
widget will check if the drag matches this widget's list of possible targets
and actions.
GTK+ will then call gdk_drag_status() as appropriate.
|
|
If set for a widget, GTK+ will draw a highlight on this widget as long as a drag is over this widget and the widget drag format and action are acceptable. | |
If set for a widget, when a drop occurs, GTK+ will
will check if the drag matches this widget's list of possible targets and
actions. If so, GTK+ will call gtk_drag_get_data() on behalf of the widget.
Whether or not the drop is successful, GTK+ will call gtk_drag_finish() . If
the action was a move, then if the drag was successful, then TRUE will be
passed for the delete parameter to gtk_drag_finish() .
|
|
If set, specifies that all default actions should be taken. |
typedef enum { GTK_TARGET_SAME_APP = 1 << 0, /*< nick=same-app >*/ GTK_TARGET_SAME_WIDGET = 1 << 1, /*< nick=same-widget >*/ GTK_TARGET_OTHER_APP = 1 << 2, /*< nick=other-app >*/ GTK_TARGET_OTHER_WIDGET = 1 << 3 /*< nick=other-widget >*/ } GtkTargetFlags;
The GtkTargetFlags enumeration is used to specify constraints on an entry in a GtkTargetTable.
If this is set, the target will only be selected for drags within a single application. | |
If this is set, the target will only be selected for drags within a single widget. | |
If this is set, the target will not be selected for drags within a single application. | |
If this is set, the target will not be selected for drags withing a single widget. |
void gtk_drag_dest_set (GtkWidget *widget
,GtkDestDefaults flags
,const GtkTargetEntry *targets
,gint n_targets
,GdkDragAction actions
);
|
a GtkWidget |
|
which types of default drag behavior to use |
|
a pointer to an array of GtkTargetEntrys
indicating the drop types that this widget will accept, or NULL .
Later you can access the list with gtk_drag_dest_get_target_list()
and gtk_drag_dest_find_target() . [allow-none][array length=n_targets]
|
|
the number of entries in targets
|
|
a bitmask of possible actions for a drop onto this widget . |
void gtk_drag_dest_set_proxy (GtkWidget *widget
,GdkWindow *proxy_window
,GdkDragProtocol protocol
,gboolean use_coordinates
);
|
a GtkWidget |
|
the window to which to forward drag events |
|
the drag protocol which the proxy_window accepts
(You can use gdk_drag_get_protocol() to determine this) |
|
If TRUE , send the same coordinates to the
destination, because it is an embedded
subwindow. |
GdkAtom gtk_drag_dest_find_target (GtkWidget *widget
,GdkDragContext *context
,GtkTargetList *target_list
);
|
drag destination widget |
|
drag context |
|
list of droppable targets, or NULL to use
gtk_drag_dest_get_target_list (widget ). [allow-none]
|
GtkTargetList * gtk_drag_dest_get_target_list (GtkWidget *widget
);
|
a GtkWidget |
void gtk_drag_dest_set_target_list (GtkWidget *widget
,GtkTargetList *target_list
);
void gtk_drag_dest_add_text_targets (GtkWidget *widget
);
|
a GtkWidget that's a drag destination |
Since 2.6
void gtk_drag_dest_add_image_targets (GtkWidget *widget
);
|
a GtkWidget that's a drag destination |
Since 2.6
void gtk_drag_dest_add_uri_targets (GtkWidget *widget
);
|
a GtkWidget that's a drag destination |
Since 2.6
void gtk_drag_dest_set_track_motion (GtkWidget *widget
,gboolean track_motion
);
|
a GtkWidget that's a drag destination |
|
whether to accept all targets |
Since 2.10
gboolean gtk_drag_dest_get_track_motion (GtkWidget *widget
);
|
a GtkWidget that's a drag destination |
Since 2.10
void gtk_drag_finish (GdkDragContext *context
,gboolean success
,gboolean del
,guint32 time_
);
|
the drag context. |
|
a flag indicating whether the drop was successful |
|
a flag indicating whether the source should delete the
original data. (This should be TRUE for a move) |
|
the timestamp from the "drag-drop" signal. |
void gtk_drag_get_data (GtkWidget *widget
,GdkDragContext *context
,GdkAtom target
,guint32 time_
);
|
the widget that will receive the "drag-data-received" signal. |
|
the drag context |
|
the target (form of the data) to retrieve. |
|
a timestamp for retrieving the data. This will generally be the time received in a "drag-motion"" or "drag-drop"" signal. |
GtkWidget * gtk_drag_get_source_widget (GdkDragContext *context
);
|
a (destination side) drag context |
void gtk_drag_unhighlight (GtkWidget *widget
);
|
a widget to remove the highlight from. |
GdkDragContext * gtk_drag_begin (GtkWidget *widget
,GtkTargetList *targets
,GdkDragAction actions
,gint button
,GdkEvent *event
);
|
the source widget. |
|
The targets (data formats) in which the source can provide the data. |
|
A bitmask of the allowed drag actions for this drag. |
|
The button the user clicked to start the drag. |
|
The event that triggered the start of the drag. |
void gtk_drag_set_icon_widget (GdkDragContext *context
,GtkWidget *widget
,gint hot_x
,gint hot_y
);
Changes the icon for a widget to a given widget. GTK+ will not destroy the icon, so if you don't want it to persist, you should connect to the "drag-end" signal and destroy it yourself.
|
the context for a drag. (This must be called with a context for the source side of a drag) |
|
a toplevel window to use as an icon. |
|
the X offset within widget of the hotspot. |
|
the Y offset within widget of the hotspot. |
void gtk_drag_set_icon_pixbuf (GdkDragContext *context
,GdkPixbuf *pixbuf
,gint hot_x
,gint hot_y
);
Sets pixbuf
as the icon for a given drag.
|
the context for a drag. (This must be called with a context for the source side of a drag) |
|
the GdkPixbuf to use as the drag icon. |
|
the X offset within widget of the hotspot. |
|
the Y offset within widget of the hotspot. |
void gtk_drag_set_icon_stock (GdkDragContext *context
,const gchar *stock_id
,gint hot_x
,gint hot_y
);
Sets the icon for a given drag from a stock ID.
|
the context for a drag. (This must be called with a context for the source side of a drag) |
|
the ID of the stock icon to use for the drag. |
|
the X offset within the icon of the hotspot. |
|
the Y offset within the icon of the hotspot. |
void gtk_drag_set_icon_surface (GdkDragContext *context
,cairo_surface_t *surface
);
Sets surface
as the icon for a given drag. GTK+ retains
references for the arguments, and will release them when
they are no longer needed.
To position the surface relative to the mouse, use
cairo_surface_set_device_offset()
on surface
. The mouse
cursor will be positioned at the (0,0) coordinate of the
surface.
|
the context for a drag. (This must be called with a context for the source side of a drag) |
|
the surface to use as icon |
void gtk_drag_set_icon_name (GdkDragContext *context
,const gchar *icon_name
,gint hot_x
,gint hot_y
);
Sets the icon for a given drag from a named themed icon. See
the docs for GtkIconTheme for more details. Note that the
size of the icon depends on the icon theme (the icon is
loaded at the symbolic size GTK_ICON_SIZE_DND), thus
hot_x
and hot_y
have to be used with care.
|
the context for a drag. (This must be called with a context for the source side of a drag) |
|
name of icon to use |
|
the X offset of the hotspot within the icon |
|
the Y offset of the hotspot within the icon |
Since 2.8
void gtk_drag_set_icon_gicon (GdkDragContext *context
,GIcon *icon
,gint hot_x
,gint hot_y
);
Sets the icon for a given drag from the given icon
. See the
documentation for gtk_drag_set_icon_name()
for more details about
using icons in drag and drop.
|
the context for a drag. (This must be called with a context for the source side of a drag) |
|
a GIcon |
|
the X offset of the hotspot within the icon |
|
the Y offset of the hotspot within the icon |
Since 3.2
void gtk_drag_set_icon_default (GdkDragContext *context
);
Sets the icon for a particular drag to the default icon.
|
the context for a drag. (This must be called with a context for the source side of a drag) |
gboolean gtk_drag_check_threshold (GtkWidget *widget
,gint start_x
,gint start_y
,gint current_x
,gint current_y
);
|
a GtkWidget |
|
X coordinate of start of drag |
|
Y coordinate of start of drag |
|
current X coordinate |
|
current Y coordinate |
void gtk_drag_source_set (GtkWidget *widget
,GdkModifierType start_button_mask
,const GtkTargetEntry *targets
,gint n_targets
,GdkDragAction actions
);
|
a GtkWidget |
|
the bitmask of buttons that can start the drag |
|
the table of targets that the drag will support,
may be NULL . [allow-none][array length=n_targets]
|
|
the number of items in targets
|
|
the bitmask of possible actions for a drag from this widget |
void gtk_drag_source_set_icon_pixbuf (GtkWidget *widget
,GdkPixbuf *pixbuf
);
|
a GtkWidget |
|
the GdkPixbuf for the drag icon |
void gtk_drag_source_set_icon_stock (GtkWidget *widget
,const gchar *stock_id
);
Sets the icon that will be used for drags from a particular source to a stock icon.
|
a GtkWidget |
|
the ID of the stock icon to use |
void gtk_drag_source_set_icon_name (GtkWidget *widget
,const gchar *icon_name
);
Sets the icon that will be used for drags from a particular source to a themed icon. See the docs for GtkIconTheme for more details.
|
a GtkWidget |
|
name of icon to use |
Since 2.8
void gtk_drag_source_set_icon_gicon (GtkWidget *widget
,GIcon *icon
);
Sets the icon that will be used for drags from a particular source
to icon
. See the docs for GtkIconTheme for more details.
Since 3.2
void gtk_drag_source_set_target_list (GtkWidget *widget
,GtkTargetList *target_list
);
|
a GtkWidget that's a drag source |
|
list of draggable targets, or NULL for none. [allow-none]
|
Since 2.4
GtkTargetList * gtk_drag_source_get_target_list (GtkWidget *widget
);
|
a GtkWidget |
Since 2.4
void gtk_drag_source_add_text_targets (GtkWidget *widget
);
Add the text targets supported by GtkSelection to
the target list of the drag source. The targets
are added with info
= 0. If you need another value,
use gtk_target_list_add_text_targets()
and
gtk_drag_source_set_target_list()
.
|
a GtkWidget that's is a drag source |
Since 2.6
void gtk_drag_source_add_image_targets (GtkWidget *widget
);
|
a GtkWidget that's is a drag source |
Since 2.6