[378:7] extends: object
Generated low-level callback wrapper for GIR callback drag-begin.
DragSourceDragbeginCallback (callback Fn, UserData = null)
Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking
Fn.
Fn is the Aussom callback implementation.UserData is retained and passed through to Fn on each invocation when provided.trampoline (nativeSelf, drag, nativeUserData)
Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.
callback ()
Returns the wrapped NativeCallback.
handle ()
Returns the callback as a NativeHandle.
close ()
Closes the underlying NativeCallback.
isClosed ()
Returns true when the callback has been closed.
[449:7] extends: object
Generated low-level callback wrapper for GIR callback drag-cancel.
DragSourceDragcancelCallback (callback Fn, UserData = null)
Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking
Fn.
Fn is the Aussom callback implementation.UserData is retained and passed through to Fn on each invocation when provided.trampoline (nativeSelf, drag, reason, nativeUserData)
Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.
callback ()
Returns the wrapped NativeCallback.
handle ()
Returns the callback as a NativeHandle.
close ()
Closes the underlying NativeCallback.
isClosed ()
Returns true when the callback has been closed.
[663:14] static extends: object
Generated metadata helpers for DragSource class surfaces.
properties ()
Returns property metadata for
DragSource.
A list.signals ()
Returns signal metadata for
DragSource.
A list.[521:7] extends: object
Generated low-level callback wrapper for GIR callback drag-end.
DragSourceDragendCallback (callback Fn, UserData = null)
Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking
Fn.
Fn is the Aussom callback implementation.UserData is retained and passed through to Fn on each invocation when provided.trampoline (nativeSelf, drag, delete_data, nativeUserData)
Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.
callback ()
Returns the wrapped NativeCallback.
handle ()
Returns the callback as a NativeHandle.
close ()
Closes the underlying NativeCallback.
isClosed ()
Returns true when the callback has been closed.
[48:7] extends: object
An event controller to initiate Drag-And-Drop operations. GtkDragSource can
be set up with the necessary ingredients for a DND operation ahead of time.
This includes the source for the data that is being transferred, in the form
of a [class@Gdk.ContentProvider], the desired action, and the icon to use
during the drag operation. After setting it up, the drag source must be added
to a widget as an event controller, using [method@Gtk.Widget.add_controller].
= gtk_drag_source_new (); g_signal_connect (drag_source, "prepare",
G_CALLBACK (on_drag_prepare), self); g_signal_connect (drag_source,
"drag-begin", G_CALLBACK (on_drag_begin), self); gtk_widget_add_controller
(GTK_WIDGET (self), GTK_EVENT_CONTROLLER (drag_source)); } ``` Setting up the
content provider and icon ahead of time only makes sense when the data does
not change. More commonly, you will want to set them up just in time. To do
so, `GtkDragSource` has [signal@Gtk.DragSource::prepare] and
[signal@Gtk.DragSource::drag-begin] signals. The ::prepare signal is emitted
before a drag is started, and can be used to set the content provider and
actions that the drag should be started with. ```c static GdkContentProvider
* on_drag_prepare (GtkDragSource *source, double x, double y, MyWidget *self)
{ // This widget supports two types of content: GFile objects // and
GdkPixbuf objects; GTK will handle the serialization // of these types
automatically GFile *file = my_widget_get_file (self); GdkPixbuf *pixbuf =
my_widget_get_pixbuf (self); return gdk_content_provider_new_union
((GdkContentProvider *[2]) { gdk_content_provider_new_typed (G_TYPE_FILE,
file), gdk_content_provider_new_typed (GDK_TYPE_PIXBUF, pixbuf), }, 2); } ```
The ::drag-begin signal is emitted after the `GdkDrag` object has been
created, and can be used to set up the drag icon. ```c static void
on_drag_begin (GtkDragSource *source, GdkDrag *drag, MyWidget *self) { // Set
the widget as the drag icon GdkPaintable *paintable =
gtk_widget_paintable_new (GTK_WIDGET (self)); gtk_drag_source_set_icon
(source, paintable, 0, 0); g_object_unref (paintable); } ``` During the DND
operation, `GtkDragSource` emits signals that can be used to obtain updates
about the status of the operation, but it is not normally necessary to
connect to any signals, except for one case: when the supported actions
include %GDK_ACTION_MOVE, you need to listen for the
[signal@Gtk.DragSource::drag-end] signal and delete the data after it has
been transferred.
#### Members
- **handleObj**
- **lib**
- **retainedCallbacks**
- **signalHandlerNames**
- **signalSetterHandlers**
#### Methods
- **DragSource** ()
> Creates a new `GtkDragSource` object.
- **toNativeHandle** (`Source`)
> Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from `fn.call(...)`, another generated wrapper exposing `handle()`, or null. Returns null when the argument carries no pointer.
- **@p** `Source` is the raw handle, raw buffer, wrapper, or null.
- **@r** `A` raw pointer carrier or null when no pointer is present.
- **getLib** ()
> Returns the opened native library for this generated wrapper.
- **@r** `The` opened native library.
- **handle** ()
> Returns the wrapped NativeHandle.
- **@r** `The` wrapped NativeHandle.
- **isNull** ()
> Returns true when the wrapped handle is null.
- **@r** `A` bool.
- **describe** ()
> Returns a small string for debugging generated wrappers.
- **@r** `A` string.
- **asGestureSingle** ()
> Wraps this handle as `GestureSingle`.
- **@r** `A` `GestureSingle` object.
- **connectSignal** (`string Name, CallbackObj`)
> Connects one generated callback wrapper to a named signal.
- **@p** `Name` is the signal name.
- **@p** `CallbackObj` is the generated callback wrapper to connect.
- **@r** `The` connected handler id.
- **disconnectSignalHandler** (`int HandlerId`)
> Disconnects one retained signal handler id.
- **@p** `HandlerId` is the signal handler id to disconnect.
- **@r** `None.`
- **setOnDragbegin** (`callback Fn, UserData = null`)
> Emitted on the drag source when a drag is started. It can be used to e.g. set a custom drag icon with [method@Gtk.DragSource.set_icon].
- **@p** `Fn` is the Aussom callback.
- **@p** `Fn` is called with (DragSource Self, Drag Drag).
- **@p** `UserData` is retained and passed through to the generated callback wrapper when provided.
- **@r** `The` connected handler id.
- **setOnDragcancel** (`callback Fn, UserData = null`)
> Emitted on the drag source when a drag has failed. The signal handler may handle a failed drag operation based on the type of error. It should return %TRUE if the failure has been handled and the default "drag operation failed" animation should not be shown.
- **@p** `Fn` is the Aussom callback.
- **@p** `Fn` is called with (DragSource Self, Drag Drag, string Reason).
- **@p** `UserData` is retained and passed through to the generated callback wrapper when provided.
- **@r** `The` connected handler id.
- **setOnDragend** (`callback Fn, UserData = null`)
> Emitted on the drag source when a drag is finished. A typical reason to connect to this signal is to undo things done in [signal@Gtk.DragSource::prepare] or [signal@Gtk.DragSource::drag-begin] handlers.
- **@p** `Fn` is the Aussom callback.
- **@p** `Fn` is called with (DragSource Self, Drag Drag, bool Delete_data).
- **@p** `UserData` is retained and passed through to the generated callback wrapper when provided.
- **@r** `The` connected handler id.
- **setOnPrepare** (`callback Fn, UserData = null`)
> Emitted when a drag is about to be initiated. It returns the `GdkContentProvider` to use for the drag that is about to start. The default handler for this signal returns the value of the [property@Gtk.DragSource:content] property, so if you set up that property ahead of time, you don't need to connect to this signal.
- **@p** `Fn` is the Aussom callback.
- **@p** `Fn` is called with (DragSource Self, double X, double Y).
- **@p** `UserData` is retained and passed through to the generated callback wrapper when provided.
- **@r** `The` connected handler id.
- **getProperty** (`string Name`)
> Reads one generated property by name.
- **setProperty** (`string Name, Value`)
> Writes one generated property by name.
- **setActions** (`string Value`)
> The actions that are supported by drag operations from the source. Note that you must handle the [signal@Gtk.DragSource::drag-end] signal if the actions include %GDK_ACTION_MOVE.
- **@p** `Value` is the new property value.
- **@r** `None.`
- **setContent** (`object Value`)
> The data that is offered by drag operations from this source.
- **@p** `Value` is the new property value.
- **@r** `None.`
- **drag\_cancel** ()
> Cancels a currently ongoing drag operation.
- **@r** `None.`
- **get\_actions** ()
> Gets the actions that are currently set on the `GtkDragSource`.
- **get\_content** ()
> Gets the current content provider of a `GtkDragSource`.
- **get\_drag** ()
> Returns the underlying `GdkDrag` object for an ongoing drag.
- **set\_actions** (`string actions`)
> Sets the actions on the `GtkDragSource`. During a DND operation, the actions are offered to potential drop targets. If @actions include %GDK_ACTION_MOVE, you need to listen to the [signal@Gtk.DragSource::drag-end] signal and handle @delete_data being %TRUE. This function can be called before a drag is started, or in a handler for the [signal@Gtk.DragSource::prepare] signal.
- **@p** `actions` is the actions to offer.
- **@r** `None.`
- **set\_content** (`object content`)
> Sets a content provider on a `GtkDragSource`. When the data is requested in the cause of a DND operation, it will be obtained from the content provider. This function can be called before a drag is started, or in a handler for the [signal@Gtk.DragSource::prepare] signal. You may consider setting the content provider back to %NULL in a [signal@Gtk.DragSource::drag-end] signal handler.
- **@p** `content` is a `GdkContentProvider`.
- **@r** `None.`
- **set\_icon** (`object paintable, int hot_x, int hot_y`)
> Sets a paintable to use as icon during DND operations. The hotspot coordinates determine the point on the icon that gets aligned with the hotspot of the cursor. If @paintable is %NULL, a default icon is used. This function can be called before a drag is started, or in a [signal@Gtk.DragSource::prepare] or [signal@Gtk.DragSource::drag-begin] signal handler.
- **@p** `paintable` is the `GdkPaintable` to use as icon.
- **@p** `hot_x` is the hotspot X coordinate on the icon.
- **@p** `hot_y` is the hotspot Y coordinate on the icon.
- **@r** `None.`
## class: DragSourcePrepareCallback
[593:7] **extends: object**
Generated low-level callback wrapper for GIR callback `prepare`.
#### Members
- **callbackObj**
- **userFn**
- **userData**
- **hasUserData**
#### Methods
- **DragSourcePrepareCallback** (`callback Fn, UserData = null`)
> Creates one native callback wrapper. The wrapper owns a trampoline that converts native pointers into generated wrapper objects before invoking `Fn`.
- **@p** `Fn` is the Aussom callback implementation.
- **@p** `UserData` is retained and passed through to Fn on each invocation when provided.
- **trampoline** (`nativeSelf, x, y, nativeUserData`)
> Internal trampoline. Converts native pointer arguments into generated wrapper instances, then invokes the user's callback.
- **callback** ()
> Returns the wrapped NativeCallback.
- **handle** ()
> Returns the callback as a NativeHandle.
- **close** ()
> Closes the underlying NativeCallback.
- **isClosed** ()
> Returns true when the callback has been closed.