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.

Table 31-1. Widget support

Widget classAction taken
GtkEntryEntry value is replaced with first file
GtkLabelLabel text is replaced with first file
GtkButtonLabel text is replaced with first file if the first and only child is a GtkLabel
GtkToggleButtonLabel text is replaced with first file if the first and only child is a GtkLabel
GtkRadioButtonLabel text is replaced with first file if the first and only child is a GtkLabel
GtkCheckButtonLabel text is replaced with first file if the first and only child is a GtkLabel
GtkComboThe entry text is replaced with the first file. The list is not affected.
GtkFileSelectionFile 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.
GtkListEvery 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.