Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: DropTargetMeta

[773:14] static extends: object

Generated metadata helpers for DropTarget class surfaces.

Methods

  • properties ()

    Returns property metadata for DropTarget.

    • @r A list.
  • signals ()

    Returns signal metadata for DropTarget.

    • @r A list.

class: DropTargetEnterCallback

[563:7] extends: object

Generated low-level callback wrapper for GIR callback enter.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • DropTargetEnterCallback (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.

class: DropTarget

[44:7] extends: object

An event controller to receive Drag-and-Drop operations. The most basic way to use a GtkDropTarget to receive drops on a widget is to create it via [ctor@Gtk.DropTarget.new], passing in the GType of the data you want to receive and connect to the [signal@Gtk.DropTarget::drop] signal to receive the data: c static gboolean on_drop (GtkDropTarget *target, const GValue *value, double x, double y, gpointer data) { MyWidget *self = data; // Call the appropriate setter depending on the type of data // that we received if (G_VALUE_HOLDS (value, G_TYPE_FILE)) my_widget_set_file (self, g_value_get_object (value)); else if (G_VALUE_HOLDS (value, GDK_TYPE_PIXBUF)) my_widget_set_pixbuf (self, g_value_get_object (value)); else return FALSE; return TRUE; } static void my_widget_init (MyWidget *self) { GtkDropTarget *target = gtk_drop_target_new (G_TYPE_INVALID, GDK_ACTION_COPY); // This widget accepts two types of drop types: GFile objects // and GdkPixbuf objects gtk_drop_target_set_gtypes (target, (GType [2]) { G_TYPE_FILE, GDK_TYPE_PIXBUF, }, 2); g_signal_connect (target, "drop", G_CALLBACK (on_drop), self); gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (target)); } GtkDropTarget supports more options, such as: * rejecting potential drops via the [signal@Gtk.DropTarget::accept] signal and the [method@Gtk.DropTarget.reject] function to let other drop targets handle the drop * tracking an ongoing drag operation before the drop via the [signal@Gtk.DropTarget::enter], [signal@Gtk.DropTarget::motion] and [signal@Gtk.DropTarget::leave] signals * configuring how to receive data by setting the [property@Gtk.DropTarget:preload] property and listening for its availability via the [property@Gtk.DropTarget:value] property However, GtkDropTarget is ultimately modeled in a synchronous way and only supports data transferred via GType. If you want full control over an ongoing drop, the [class@Gtk.DropTargetAsync] object gives you this ability. While a pointer is dragged over the drop target's widget and the drop has not been rejected, that widget will receive the %GTK_STATE_FLAG_DROP_ACTIVE state, which can be used to style the widget. If you are not interested in receiving the drop, but just want to update UI state during a Drag-and-Drop operation (e.g. switching tabs), you can use [class@Gtk.DropControllerMotion].

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • DropTarget (Handle = null)

    Creates a new DropTarget by wrapping a native handle or another wrapper.

    • @p Handle is the native handle or another wrapper whose handle to adopt.
  • 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.
  • asEventController ()

    Wraps this handle as EventController.

    • @r A EventController 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.
  • setOnAccept (callback Fn, UserData = null)

    Emitted on the drop site when a drop operation is about to begin. If the drop is not accepted, %FALSE will be returned and the drop target will ignore the drop. If %TRUE is returned, the drop is accepted for now but may be rejected later via a call to [method@Gtk.DropTarget.reject] or ultimately by returning %FALSE from a [signal@Gtk.DropTarget::drop] handler. The default handler for this signal decides whether to accept the drop based on the formats provided by the @drop. If the decision whether the drop will be accepted or rejected depends on the data, this function should return %TRUE, the [property@Gtk.DropTarget:preload] property should be set and the value should be inspected via the ::notify:value signal, calling [method@Gtk.DropTarget.reject] if required.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (DropTarget Self, Drop Drop).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • setOnDrop (callback Fn, UserData = null)

    Emitted on the drop site when the user drops the data onto the widget. The signal handler must determine whether the pointer position is in a drop zone or not. If it is not in a drop zone, it returns %FALSE and no further processing is necessary. Otherwise, the handler returns %TRUE. In this case, this handler will accept the drop. The handler is responsible for using the given @value and performing the drop operation.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (DropTarget Self, Value Value, double X, double Y).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • setOnEnter (callback Fn, UserData = null)

    Emitted on the drop site when the pointer enters the widget. It can be used to set up custom highlighting.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (DropTarget Self, double X, double Y).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • setOnLeave (callback Fn, UserData = null)

    Emitted on the drop site when the pointer leaves the widget. Its main purpose it to undo things done in [signal@Gtk.DropTarget::enter].

    • @p Fn is the Aussom callback.
    • @p Fn is called with (DropTarget Self).
    • @p UserData is retained and passed through to the generated callback wrapper when provided.
    • @r The connected handler id.
  • setOnMotion (callback Fn, UserData = null)

    Emitted while the pointer is moving over the drop target.

    • @p Fn is the Aussom callback.
    • @p Fn is called with (DropTarget 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 GdkDragActions that this drop target supports.

    • @p Value is the new property value.
    • @r None.
  • setPreload (bool Value)

    Whether the drop data should be preloaded when the pointer is only hovering over the widget but has not been released. Setting this property allows finer grained reaction to an ongoing drop at the cost of loading more data. The default value for this property is %FALSE to avoid downloading huge amounts of data by accident. For example, if somebody drags a full document of gigabytes of text from a text editor across a widget with a preloading drop target, this data will be downloaded, even if the data is ultimately dropped elsewhere. For a lot of data formats, the amount of data is very small (like %GDK_TYPE_RGBA), so enabling this property does not hurt at all. And for local-only Drag-and-Drop operations, no data transfer is done, so enabling it there is free.

    • @p Value is the new property value.
    • @r None.
  • get_actions ()

    Gets the actions that this drop target supports.

  • get_current_drop ()

    Gets the currently handled drop operation. If no drop operation is going on, %NULL is returned.

  • get_drop ()

    Gets the currently handled drop operation. If no drop operation is going on, %NULL is returned.

  • get_formats ()

    Gets the data formats that this drop target accepts. If the result is %NULL, all formats are expected to be supported.

  • get_preload ()

    Gets whether data should be preloaded on hover.

  • get_value ()

    Gets the current drop data, as a GValue.

  • reject ()

    Rejects the ongoing drop operation. If no drop operation is ongoing, i.e when [property@Gtk.DropTarget:current-drop] is %NULL, this function does nothing. This function should be used when delaying the decision on whether to accept a drag or not until after reading the data.

    • @r None.
  • set_actions (string actions)

    Sets the actions that this drop target supports.

    • @p actions is the supported actions.
    • @r None.
  • set_preload (bool preload)

    Sets whether data should be preloaded on hover.

    • @p preload is %TRUE to preload drop data.
    • @r None.

class: DropTargetMotionCallback

[703:7] extends: object

Generated low-level callback wrapper for GIR callback motion.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • DropTargetMotionCallback (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.

class: DropTargetDropCallback

[492:7] extends: object

Generated low-level callback wrapper for GIR callback drop.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • DropTargetDropCallback (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, value, 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.

class: DropTargetAcceptCallback

[421:7] extends: object

Generated low-level callback wrapper for GIR callback accept.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • DropTargetAcceptCallback (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, drop, 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.

class: DropTargetLeaveCallback

[633:7] extends: object

Generated low-level callback wrapper for GIR callback leave.

Members

  • callbackObj
  • userFn
  • userData
  • hasUserData

Methods

  • DropTargetLeaveCallback (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, 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.