Widget support
Widget support –
Drops handled on different widget types
Natively supported widgets
By default, the dropped files are displayed in the widget,
e.g. if you drop a file over a GtkEntry
, the
text value of the widget will be overwritten to the filename.
As not all widgets have such simple values, Gtk_FileDrop has built-in support for a number of widget classes and acts different on different types.
Widget class | Action taken |
---|---|
GtkEntry | Entry value is replaced with first file |
GtkLabel | Label text is replaced with first file |
GtkButton | Label text is replaced with first file if the first and only child is a GtkLabel |
GtkToggleButton | Label text is replaced with first file if the first and only child is a GtkLabel |
GtkRadioButton | Label text is replaced with first file if the first and only child is a GtkLabel |
GtkCheckButton | Label text is replaced with first file if the first and only child is a GtkLabel |
GtkCombo | The entry text is replaced with the first file. The list is not affected. |
GtkFileSelection | File name of the file dialog is set to the first dropped file. The directory is changed to the directory name of the file, and the file name (without directory) is set in the file name entry. |
GtkList | Every accepted file is appended at the end of the list. |
Beside the automatic actions, you can specify a callback as the third
parameter of the attach
function which is called
with the widget itself and an array of accepted files as parameters.