Dest_No_Default : constant Dest_Defaults;
Dest_Default_Motion : constant Dest_Defaults;
Dest_Default_Highlight : constant Dest_Defaults;
Dest_Default_Drop : constant Dest_Defaults;
Dest_Default_All : constant Dest_Defaults;
procedure Dest_Set
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Flags | : Dest_Defaults := Dest_No_Default; | |
Targets | : Target_Entry_Array := Any_Target_Entry; | |
Actions | : Drag_Action := Action_Any); |
procedure Dest_Set_Proxy
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Proxy_Window | : Gdk.Window.Gdk_Window; | |
Protocol | : Drag_Protocol; | |
Use_Coordinates | : Boolean); |
procedure Dest_Unset
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Dest_Set_Target_List
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Target_List | : Gtk.Selection.Target_List); |
function Dest_Get_Target_List
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class) return Target_List; |
procedure Dest_Add_Image_Targets
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Dest_Add_Text_Targets
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Dest_Add_Uri_Targets
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
function Dest_Find_Target
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Context | : Gdk.Dnd.Drag_Context; | |
Target_List | : Gtk.Selection.Target_List) return Gdk.Types.Gdk_Atom; |
function Dest_Get_Track_Motion
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class) return Boolean; |
procedure Dest_Set_Track_Motion
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Track_Motion | : Boolean); |
procedure Source_Set
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Start_Button_Mask | : Gdk.Types.Gdk_Modifier_Type; | |
Targets | : Target_Entry_Array; | |
Actions | : Drag_Action); |
procedure Source_Unset
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Source_Set_Target_List
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Target_List | : Gtk.Selection.Target_List); |
function Source_Get_Target_List
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class) return Target_List; |
procedure Source_Add_Image_Targets
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Source_Add_Text_Targets
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Source_Add_Uri_Targets
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Source_Set_Icon
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Colormap | : Gdk.Color.Gdk_Colormap; | |
Pixmap | : Gdk.Pixmap.Gdk_Pixmap; | |
Mask | : Gdk.Bitmap.Gdk_Bitmap); |
procedure Source_Set_Icon_Pixbuf
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Pixbuf | : Gdk.Pixbuf.Gdk_Pixbuf); |
procedure Source_Set_Icon_Stock
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Stock_Id | : String); |
procedure Source_Set_Icon_Name
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Icon_Name | : String); |
procedure Finish
( | Context | : Drag_Context; |
Success | : Boolean; | |
Del | : Boolean; | |
Time | : Guint32 := 0); |
procedure Get_Data
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Context | : Drag_Context; | |
Target | : Gdk.Types.Gdk_Atom; | |
Time | : Guint32 := 0); |
function Get_Source_Widget
( | Context | : Drag_Context) return Gtk.Widget.Gtk_Widget; |
procedure Highlight
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
procedure Unhighlight
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class); |
function Drag_Begin
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Targets | : Target_List; | |
Actions | : Drag_Action; | |
Button | : Gint; | |
Event | : Gdk.Event.Gdk_Event) return Drag_Context; |
function Check_Threshold
( | Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; |
Start_X | : Gint; | |
Start_Y | : Gint; | |
Current_X | : Gint; | |
Current_Y | : Gint) return Boolean; |
procedure Set_Icon_Widget
( | Context | : Drag_Context; |
Widget | : access Gtk.Widget.Gtk_Widget_Record'Class; | |
Hot_X | : Gint; | |
Hot_Y | : Gint); |
procedure Set_Icon_Pixmap
( | Context | : Drag_Context; |
Colormap | : Gdk.Color.Gdk_Colormap; | |
Pixmap | : Gdk.Pixmap.Gdk_Pixmap; | |
Mask | : Gdk.Bitmap.Gdk_Bitmap; | |
Hot_X | : Gint; | |
Hot_Y | : Gint); |
procedure Set_Icon_Default
( | Context | : Drag_Context); |
procedure Set_Icon_Pixbuf
( | Context | : Drag_Context; |
Pixbuf | : Gdk.Pixbuf.Gdk_Pixbuf; | |
Hot_X | : Gint; | |
Hot_Y | : Gint); |
procedure Set_Icon_Stock
( | Context | : Drag_Context; |
Stock_Id | : String; | |
Hot_X | : Gint; | |
Hot_Y | : Gint); |
procedure Set_Icon_Name
( | Context | : Drag_Context; |
Icon_Name | : String; | |
Hot_X | : Gint; | |
Hot_Y | : Gint); |
procedure Set_Default_Icon
( | Colormap | : Gdk.Color.Gdk_Colormap; |
Pixmap | : Gdk.Pixmap.Gdk_Pixmap; | |
Mask | : Gdk.Bitmap.Gdk_Bitmap; | |
Hot_X | : Gint; | |
Hot_Y | : Gint); |
Like all modern GUI toolkits, GtkAda has a full support for drag-and-drop operations. This is a mechanism for interactively transferring data between two widgets, either in the same application or in two different applications. The user clicks on a widget (called a "drag source"), and, while keeping the mouse button pressed, moves it to another widget, where the mouse button is released (this other widget is called a "drop site").
As a result, and if both widgets can handle the same type of data, some data is either copied or moved to this new widget.
This is a very intuitive way, in some cases, to enhance the usability of your application, although you should carefully consider whether this should be used or not.
GtkAda supports several drag-and-drop protocols, so as to be able to communicate with the maximum number of applications. These protocols are Xdnd and Motif.
Below is a summary of what is needed to add drag-and-drop capabilities to your application. We highly recommend that you look at, and understand, the example in testgtk (create_dnd.adb), before using these features in your own application.
See also the package Gtk.Selection, that contains some lower subprograms and data types that are used when implementing drag-and-drop.
- Defining a widget as a possible drag source You need to call Source_Set, specifying which mouse buttons can activate the drag, which types of data will be given, and which kind of action will be performed.
You then need to connect to the signal "drag_data_get", that will be emitted when the user has dropped the item and GtkAda needs to find the data. You must call Selection_Data_Set in the handler to set the actual data.
You can also connect the widget to "drag_data_delete", which will be called whenever the data set for the selection is no longer required and should be deleted. The signal will be emitted only if the drop site requests it, or if the selected action for the drag-and-drop operation was Action_Move. It will not be called automatically for an Action_Copy.
Note that the callback might be called several times, if for instance this was an Action_Move, and the drop site requires explicitly to delete the data in its call to Finish.
- Defining a widget as a possible drop site You need to call Dest_Set, specifying which types of Data are accepted by the widget, which actions are recognized, and whether you accept drops from external applications.
You also need to connect to "drag_data_received", that will be emitted when the user has dropped some data on the widget. The handler should call Finish, to warn the source widget that the drag and drop operation is finished, and whether it was successful or not.
Binding from C File version 2.16.6
<testgtk>create_dnd.adb</testgtk>