gtkmm 4.16.0
|
Event controller to receive DND drops. More...
#include <gtkmm/droptarget.h>
Public Member Functions | |
DropTarget (DropTarget &&src) noexcept | |
DropTarget & | operator= (DropTarget &&src) noexcept |
~DropTarget () noexcept override | |
GtkDropTarget * | gobj () |
Provides access to the underlying C GObject. | |
const GtkDropTarget * | gobj () const |
Provides access to the underlying C GObject. | |
GtkDropTarget * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
void | set_gtypes (const std::vector< GType > & types) |
Sets the supported Types for this drop target. | |
std::vector< GType > | get_gtypes () const |
Gets a vector of supported Types. | |
Glib::RefPtr< Gdk::ContentFormats > | get_formats () |
Gets the data formats that this drop target accepts. | |
Glib::RefPtr< const Gdk::ContentFormats > | get_formats () const |
Gets the data formats that this drop target accepts. | |
void | set_actions (Gdk::DragAction actions) |
Sets the actions that this drop target supports. | |
Gdk::DragAction | get_actions () const |
Gets the actions that this drop target supports. | |
void | set_preload (bool preload=true) |
Sets whether data should be preloaded on hover. | |
bool | get_preload () const |
Gets whether data should be preloaded on hover. | |
Glib::RefPtr< Gdk::Drop > | get_drop () |
Gets the currently handled drop operation. | |
Glib::RefPtr< const Gdk::Drop > | get_drop () const |
Gets the currently handled drop operation. | |
Glib::RefPtr< Gdk::Drop > | get_current_drop () |
Gets the currently handled drop operation. | |
Glib::RefPtr< const Gdk::Drop > | get_current_drop () const |
Gets the currently handled drop operation. | |
Glib::ValueBase | get_value () const |
Gets the current drop data, as a Glib::Value . | |
void | reject () |
Rejects the ongoing drop operation. | |
Glib::PropertyProxy< Gdk::DragAction > | property_actions () |
The Gdk::DragActions that this drop target supports. | |
Glib::PropertyProxy_ReadOnly< Gdk::DragAction > | property_actions () const |
The Gdk::DragActions that this drop target supports. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::Drop > > | property_drop () const |
The Gdk::Drop that is currently being performed. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::Drop > > | property_current_drop () const |
The Gdk::Drop that is currently being performed. | |
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::ContentFormats > > | property_formats () const |
The Gdk::ContentFormats that determine the supported data formats. | |
Glib::PropertyProxy< bool > | property_preload () |
Whether the drop data should be preloaded when the pointer is only hovering over the widget but has not been released. | |
Glib::PropertyProxy_ReadOnly< bool > | property_preload () const |
Whether the drop data should be preloaded when the pointer is only hovering over the widget but has not been released. | |
Glib::PropertyProxy_ReadOnly< GValue * > | property_value () const |
The value for this drop operation. | |
Glib::SignalProxy< bool(const Glib::RefPtr< Gdk::Drop > &)> | signal_accept () |
Only one signal handler is called. | |
Glib::SignalProxy< Gdk::DragAction(double, double)> | signal_enter () |
Only one signal handler is called. | |
Glib::SignalProxy< Gdk::DragAction(double, double)> | signal_motion () |
Only one signal handler is called. | |
Glib::SignalProxy< void()> | signal_leave () |
Glib::SignalProxy< bool(const Glib::ValueBase &, double, double)> | signal_drop () |
Only one signal handler is called. | |
Public Member Functions inherited from Gtk::EventController | |
EventController (EventController &&src) noexcept | |
EventController & | operator= (EventController &&src) noexcept |
~EventController () noexcept override | |
GtkEventController * | gobj () |
Provides access to the underlying C GObject. | |
const GtkEventController * | gobj () const |
Provides access to the underlying C GObject. | |
GtkEventController * | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
Widget * | get_widget () |
Returns the Gtk::Widget this controller relates to. | |
const Widget * | get_widget () const |
Returns the Gtk::Widget this controller relates to. | |
void | reset () |
Resets the controller to a clean state. | |
PropagationPhase | get_propagation_phase () const |
Gets the propagation phase at which controller handles events. | |
void | set_propagation_phase (PropagationPhase phase) |
Sets the propagation phase at which a controller handles events. | |
PropagationLimit | get_propagation_limit () const |
Gets the propagation limit of the event controller. | |
void | set_propagation_limit (PropagationLimit limit) |
Sets the event propagation limit on the event controller. | |
Glib::ustring | get_name () const |
Gets the name of controller. | |
void | set_name (const Glib::ustring & name) |
Sets a name on the controller that can be used for debugging. | |
Glib::RefPtr< const Gdk::Event > | get_current_event () const |
Returns the event that is currently being handled by the controller. | |
guint32 | get_current_event_time () const |
Returns the timestamp of the event that is currently being handled by the controller. | |
Glib::RefPtr< Gdk::Device > | get_current_event_device () |
Returns the device of the event that is currently being handled by the controller. | |
Glib::RefPtr< const Gdk::Device > | get_current_event_device () const |
Returns the event that is currently being handled by the controller. | |
Gdk::ModifierType | get_current_event_state () const |
Returns the modifier state of the event that is currently being handled by the controller. | |
Glib::PropertyProxy_ReadOnly< Widget * > | property_widget () const |
The widget receiving the Gdk::Events that the controller will handle. | |
Glib::PropertyProxy< PropagationPhase > | property_propagation_phase () |
The propagation phase at which this controller will handle events. | |
Glib::PropertyProxy_ReadOnly< PropagationPhase > | property_propagation_phase () const |
The propagation phase at which this controller will handle events. | |
Glib::PropertyProxy< PropagationLimit > | property_propagation_limit () |
The limit for which events this controller will handle. | |
Glib::PropertyProxy_ReadOnly< PropagationLimit > | property_propagation_limit () const |
The limit for which events this controller will handle. | |
Glib::PropertyProxy< Glib::ustring > | property_name () |
The name for this controller, typically used for debugging purposes. | |
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_name () const |
The name for this controller, typically used for debugging purposes. | |
Static Public Member Functions | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
static Glib::RefPtr< DropTarget > | create (GType type, Gdk::DragAction actions) |
Creates a new Gtk::DropTarget object. | |
Static Public Member Functions inherited from Gtk::EventController | |
static GType | get_type () |
Get the GType for this class, for use with the underlying GObject type system. | |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Gtk::DropTarget > | wrap (GtkDropTarget *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Related Symbols inherited from Gtk::EventController | |
Glib::RefPtr< Gtk::EventController > | wrap (GtkEventController *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
Additional Inherited Members | |
Protected Member Functions inherited from Gtk::EventController | |
EventController () | |
There is no create() method that corresponds to this constructor, because only derived classes shall be created. | |
Event controller to receive DND drops.
Gtk::DropTarget is an event controller implementing a simple way to receive Drag-and-Drop operations.
The most basic way to use a Gtk::DropTarget to receive drops on a widget is to create it via create() passing in the GType of the data you want to receive and connect to signal_drop() to receive the data.
Gtk::DropTarget supports more options, such as:
However, Gtk::DropTarget is ultimately modeled in a synchronous way and only supports data transferred via GType.
If you want full control over an ongoing drop, the 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::StateFlags::DROP_ACTIVE state, which can be used to style the widget.
|
noexcept |
|
overridenoexcept |
|
static |
Creates a new Gtk::DropTarget
object.
If the drop target should support more than 1 type, pass G_TYPE_INVALID for type and then call set_gtypes().
type | The supported type or G_TYPE_INVALID. |
actions | The supported actions. |
Gtk::DropTarget
. Gdk::DragAction Gtk::DropTarget::get_actions | ( | ) | const |
Gets the actions that this drop target supports.
Glib::RefPtr< Gdk::Drop > Gtk::DropTarget::get_current_drop | ( | ) |
Gets the currently handled drop operation.
If no drop operation is going on, nullptr
is returned.
Gets the currently handled drop operation.
If no drop operation is going on, nullptr
is returned.
Glib::RefPtr< Gdk::Drop > Gtk::DropTarget::get_drop | ( | ) |
Gets the currently handled drop operation.
If no drop operation is going on, nullptr
is returned.
Deprecated: 4.4: Use get_current_drop() instead
Gets the currently handled drop operation.
If no drop operation is going on, nullptr
is returned.
Deprecated: 4.4: Use get_current_drop() instead
Glib::RefPtr< Gdk::ContentFormats > Gtk::DropTarget::get_formats | ( | ) |
Gets the data formats that this drop target accepts.
If the result is nullptr
, all formats are expected to be supported.
Glib::RefPtr< const Gdk::ContentFormats > Gtk::DropTarget::get_formats | ( | ) | const |
Gets the data formats that this drop target accepts.
If the result is nullptr
, all formats are expected to be supported.
std::vector< GType > Gtk::DropTarget::get_gtypes | ( | ) | const |
Gets a vector of supported Types.
If no type have been set, an empty vector will be returned.
bool Gtk::DropTarget::get_preload | ( | ) | const |
Gets whether data should be preloaded on hover.
true
if drop data should be preloaded.
|
static |
Get the GType for this class, for use with the underlying GObject type system.
Glib::ValueBase Gtk::DropTarget::get_value | ( | ) | const |
Gets the current drop data, as a Glib::Value
.
|
inline |
Provides access to the underlying C GObject.
|
inline |
Provides access to the underlying C GObject.
GtkDropTarget * Gtk::DropTarget::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
|
noexcept |
Glib::PropertyProxy< Gdk::DragAction > Gtk::DropTarget::property_actions | ( | ) |
The Gdk::DragActions
that this drop target supports.
Default value: 0
Glib::PropertyProxy_ReadOnly< Gdk::DragAction > Gtk::DropTarget::property_actions | ( | ) | const |
The Gdk::DragActions
that this drop target supports.
Default value: 0
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::Drop > > Gtk::DropTarget::property_current_drop | ( | ) | const |
The Gdk::Drop
that is currently being performed.
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::Drop > > Gtk::DropTarget::property_drop | ( | ) | const |
The Gdk::Drop
that is currently being performed.
Deprecated: 4.4: Use property_current_drop() instead
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Gdk::ContentFormats > > Gtk::DropTarget::property_formats | ( | ) | const |
The Gdk::ContentFormats
that determine the supported data formats.
Glib::PropertyProxy< bool > Gtk::DropTarget::property_preload | ( | ) |
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.
Default value: false
Glib::PropertyProxy_ReadOnly< bool > Gtk::DropTarget::property_preload | ( | ) | const |
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.
Default value: false
Glib::PropertyProxy_ReadOnly< GValue * > Gtk::DropTarget::property_value | ( | ) | const |
The value for this drop operation.
This is nullptr
if the data has not been loaded yet or no drop operation is going on.
Data may be available before the signal_drop() signal gets emitted - for example when the property_preload() property is set. You can use the signal_notify() signal to be notified of available data.
void Gtk::DropTarget::reject | ( | ) |
Rejects the ongoing drop operation.
If no drop operation is ongoing, i.e when property_current_drop() is nullptr
, 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.
void Gtk::DropTarget::set_actions | ( | Gdk::DragAction | actions | ) |
Sets the actions that this drop target supports.
actions | The supported actions. |
void Gtk::DropTarget::set_gtypes | ( | const std::vector< GType > & | types | ) |
Sets the supported Types for this drop target.
types | All supported Types that can be dropped. |
Sets whether data should be preloaded on hover.
preload | true to preload drop data. |
Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
bool on_my_accept(const Glib::RefPtr<Gdk::Drop>& drop)
Flags: Run Last
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 Gtk::DropTarget::reject() or ultimately by returning false
from a signal_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_preload() property should be set and the value should be inspected via the notify:value signal, calling Gtk::DropTarget::reject() if required.
drop | The Gdk::Drop . |
true
if drop is accepted. Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
bool on_my_drop(const Glib::ValueBase& value, double x, double y)
Flags: Run Last
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.
value | The Glib::Value being dropped. |
x | The x coordinate of the current pointer position. |
y | The y coordinate of the current pointer position. |
Glib::SignalProxy< Gdk::DragAction(double, double)> Gtk::DropTarget::signal_enter | ( | ) |
Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
Gdk::DragAction on_my_enter(double x, double y)
Flags: Run Last
Emitted on the drop site when the pointer enters the widget.
It can be used to set up custom highlighting.
x | The x coordinate of the current pointer position. |
y | The y coordinate of the current pointer position. |
Glib::SignalProxy< void()> Gtk::DropTarget::signal_leave | ( | ) |
void on_my_leave()
Flags: Run Last
Emitted on the drop site when the pointer leaves the widget.
Its main purpose it to undo things done in signal_enter().
Glib::SignalProxy< Gdk::DragAction(double, double)> Gtk::DropTarget::signal_motion | ( | ) |
Only one signal handler is called.
If you connect a handler, it must be called before (instead of) the default handler, otherwise it won't be called. Set the after parameter in connect() to false
.
Gdk::DragAction on_my_motion(double x, double y)
Flags: Run Last
Emitted while the pointer is moving over the drop target.
x | The x coordinate of the current pointer position. |
y | The y coordinate of the current pointer position. |
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |