1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
5 Functions for controlling drag and drop handling.
7 <!-- ##### SECTION Long_Description ##### -->
9 GTK+ has a rich set of functions for doing inter-process
10 communication via the drag-and-drop metaphore. GTK+
11 can do drag and drop (DND) via multiple protocols.
12 The currently supported protocols are the Xdnd and
15 As well as the functions listed here, applications
16 may need to use some facilities provided for
17 <link linkend="gtk-Selections">Selections</link>.
18 Also, the Drag and Drop API makes use of signals
19 in the #GtkWidget class.
22 <!-- ##### SECTION See_Also ##### -->
27 <!-- ##### ENUM GtkDestDefaults ##### -->
29 The #GtkDestfaults enumeration specifies the various
30 types of action that will be taken on behalf
31 of the user for a drag destination site.
33 <informaltable pgwide=1 frame="none" role="enum">
34 <tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*">
38 <entry><symbol>GTK_DEST_DEFAULT_MOTION</symbol></entry>
40 If set for a widget, GTK+, during a drag over this
41 widget will check if the drag matches this widget's
42 list of possible targets and actions.
43 GTK+ will then call gtk_drag_status() as appropriate.
48 <entry><symbol>GTK_DEST_DEFAULT_HIGHLIGHT</symbol></entry>
50 If set for a widget, GTK+ will draw a highlight on
51 this widget as long as a drag is over this widget
52 and the wiget drag format and action is accetable.</entry>
56 <entry><symbol>GTK_DEST_DEFAULT_DROP</symbol></entry>
58 If set for a widget, when a drop occurs, GTK+ will
59 will check if the drag matches this widget's
60 list of possible targets and actions. If so,
61 GTK+ will call gtk_drag_data_get() on behalf
62 of the widget. Whether or not the drop is succesful,
63 GTK+ will call gtk_drag_finish(). If the action
64 was a move, then if the drag was succesful, then
65 %TRUE will be passed for the @delete parameter
71 <entry><symbol>GTK_DEST_DEFAULT_ALL</symbol></entry>
73 If set, specifies that all default actions should
78 </tbody></tgroup></informaltable>
80 @GTK_DEST_DEFAULT_MOTION:
81 @GTK_DEST_DEFAULT_HIGHLIGHT:
82 @GTK_DEST_DEFAULT_DROP:
83 @GTK_DEST_DEFAULT_ALL:
85 <!-- ##### ENUM GtkTargetFlags ##### -->
87 The #GtkTargetFlags enumeration is used to specifies
88 constraints on an entry in a GtkTargetTable.
90 <varlistentry><term> %GTK_TARGET_SAME_APP </term>
93 If this is set, the target will only be selected
94 for drags within a single application.
98 <varlistentry><term> %GTK_TARGET_SAME_WIDGET </term>
101 If this is set, the target will only be selected
102 for drags within a single widget.
108 @GTK_TARGET_SAME_APP:
109 @GTK_TARGET_SAME_WIDGET:
111 <!-- ##### FUNCTION gtk_drag_dest_set ##### -->
113 Set a widget as a potential drop destination.
117 @flags: the flags that specify what actions GTK+ should take
118 on behalf of a widget for drops onto that widget. The @targets
119 and @actions fields only are used if %GTK_DEST_DEFAULT_MOTION
120 or %GTK_DEST_DEFAULT_DROP are given.
121 @targets: a pointer to an array of #GtkTargetEntry indicating
122 the drop types that this widget will accept.
123 @n_targets: the number of entries in @targets.
124 @actions: a bitmask of possible actions for a drop onto this
128 <!-- ##### FUNCTION gtk_drag_dest_set_proxy ##### -->
130 Set this widget as a proxy for drops to another window.
133 @widget: a #GtkWidget
134 @proxy_window: the window to which to forward drag events
135 @protocol: the drag protocol which the @proxy_window accepts
136 (You can use gdk_drag_get_protocol() to determine this)
137 @use_coordinates: If true, send the same coordinates to the
138 destination, because it is a embedded
142 <!-- ##### FUNCTION gtk_drag_dest_unset ##### -->
144 Clear information about a drop destination set with
145 gtk_drag_dest_set(). The widget will no longer receive
146 notification of drags.
149 @widget: a #GtkWidget
152 <!-- ##### FUNCTION gtk_drag_finish ##### -->
154 Inform the drag source that the drop is finished, and
155 that the data of the drag will no longer be required.
158 @context: the drag context.
159 @success: a flag indicating whether the drop was succesful
160 @del: a flag indicating whether the source should delete the
161 original data. (This should be %TRUE for a move)
162 @time: the timestamp from the "drag_data_drop" signal.
165 <!-- ##### FUNCTION gtk_drag_get_data ##### -->
167 Get the data associated with a drag. When the data
168 is received or the retrieval fails, GTK+ will emit a
169 "drag_data_received" signal. Failure of the retrieval
170 is indicated by the length field of the @selection_data
171 signal parameter being negative. However, when gtk_drag_get_data()
172 is called implicitely because the %GTK_DRAG_DEFAULT_DROP was set,
173 then the widget will not receive notification of failed
177 @widget: the widget that will receive the "drag_data_received"
179 @context: the drag context
180 @target: the target (form of the data) to retrieve.
181 @time: a timestamp for retrieving the data. This will
182 generally be the time received in a "drag_data_motion"
183 or "drag_data_drop" signal.
186 <!-- ##### FUNCTION gtk_drag_get_source_widget ##### -->
188 Determine the source widget for a drag.
191 @context: a (destination side) drag context.
192 @Returns: if the drag is occurring within a single application,
193 a pointer to the source widget. Otherwise, NULL.
196 <!-- ##### FUNCTION gtk_drag_highlight ##### -->
198 Draw a highlight around a widget. This will attach
199 handlers to "expose_event" and "draw", so the highlight
200 will continue to be displayed until gtk_drag_unhighlight
204 @widget: a widget to highlight
207 <!-- ##### FUNCTION gtk_drag_unhighlight ##### -->
209 Remove a highlight set by gtk_drag_highlight() from
214 @widget: a widget to remove the highlight from.
217 <!-- ##### FUNCTION gtk_drag_begin ##### -->
219 Initiate a drag on the source side. The function
220 only needs to be used when the application is
221 starting drags itself, and is not needed when
222 gtk_drag_source_set() is used.
225 @widget: the source widget.
226 @targets: The targets (data formats) in which the
227 source can provide the data.
228 @actions: A bitmask of the allowed drag actions for this
230 @button: The button the user clicked to start the drag.
231 @event: The event that triggered the start of the
233 @Returns: The context for this drag.
236 <!-- ##### FUNCTION gtk_drag_set_icon_widget ##### -->
238 Change the icon for a widget to a given widget. GTK+
239 will not destroy the icon, so if you don't want
240 it to persist, you should connect to the "drag_end"
241 signal and destroy it yourself.
244 @context: the context for a drag. (This must be called
245 with a context for the source side of a drag)
246 @widget: A toplevel window to use as an icon.
247 @hot_x: The X offset within @widget of the hotspot.
248 @hot_y: The Y offset within @widget of the hotspot.
251 <!-- ##### FUNCTION gtk_drag_set_icon_pixmap ##### -->
253 Sets a given pixmap as the icon for a given drag.
254 GTK+ retains a reference count for the arguments, and
255 will release them when they are no longer needed.
258 @context: the context for a drag. (This must be called
259 with a context for the source side of a drag)
260 @colormap: the colormap of the icon
261 @pixmap: the image data for the icon
262 @mask: the transparency mask for an image.
263 @hot_x: The X offset within @widget of the hotspot.
264 @hot_y: The Y offset within @widget of the hotspot.
267 <!-- ##### FUNCTION gtk_drag_set_icon_default ##### -->
269 Set the icon for a particular drag to the default
273 @context: the context for a drag. (This must be called
274 with a context for the source side of a drag)
277 <!-- ##### FUNCTION gtk_drag_set_default_icon ##### -->
279 Change the default drag icon. GTK+ retains a reference count for the
280 arguments, and will release them when they are no longer needed.
283 @colormap: the colormap of the icon
284 @pixmap: the image data for the icon
285 @mask: the transparency mask for an image.
286 @hot_x: The X offset within @widget of the hotspot.
287 @hot_y: The Y offset within @widget of the hotspot.
290 <!-- ##### FUNCTION gtk_drag_source_set ##### -->
292 Sets up a widget so that GTK+ will start a drag
293 operation when the user clicks and drags on the
294 widget. The widget must have a window.
297 @widget: a #GtkWidget
298 @start_button_mask: the bitmask of buttons that can start the drag
299 @targets: the table of targets that the drag will support
300 @n_targets: the number of items in @targets
301 @actions: the bitmask of possible actions for a drag from this
305 <!-- ##### FUNCTION gtk_drag_source_set_icon ##### -->
307 Sets the icon that will be used for drags from a
308 particular widget. GTK+ retains a reference count
309 for the arguments, and will release them when
310 they are no longer needed.
313 @widget: a #GtkWidget
314 @colormap: the colormap of the icon
315 @pixmap: the image data for the icon
316 @mask: the transparency mask for an image.
319 <!-- ##### FUNCTION gtk_drag_source_unset ##### -->
321 Undo the effects of gtk_drag_source_set().
324 @widget: a #GtkWidget
327 <!-- ##### FUNCTION gtk_drag_source_handle_event ##### -->
336 <!-- ##### FUNCTION gtk_drag_dest_handle_event ##### -->