Methods
| Chapter 19. Drag and Drop |

## Methods

`Widget`s can be identified as sources or targets using `Gtk::DragSource` and `Gtk::DropTarget` event controllers.

    auto source = Gtk::DragSource::create();
    m_source_widget.add_controller(source);

Some `DragSource` methods:

- `void set_content(const Glib::RefPtr<Gdk::ContentProvider>& content)`: Sets a content provider on the drag source.

- `void set_actions(Gdk::DragAction actions)`: Sets the actions on the drag source. For instance `Gdk::DragAction::COPY | Gdk::DragAction::MOVE`.

- `void set_icon(const Glib::RefPtr<const Gdk::Paintable>& paintable, int hot_x, int hot_y)`: Sets a paintable to use as icon during DND operations.

    auto target = Gtk::DropTarget::create(gtype, actions);
    m_target_widget.add_controller(target);

Some `DropTarget` methods:

- `void set_gtypes(const std::vector<GType>& types)`: Sets the supported types for this drop target.

- `void set_actions(Gdk::DragAction actions)`: Sets the actions that this drop target supports.

- `Glib::ValueBase get_value() const`: Gets the current drop data, as a `Glib::Value`.

- `void reject()`: Rejects the ongoing drop operation. This function should be used when delaying the decision on whether to accept a drag or not until after reading the data.

Chapter 19. Drag and Drop |  | Signals