Drag and Drop

Name

Drag and Drop -- 

Synopsis


#include <history.h>


enum        TargetType;
GtkTargetList* dnd_get_file_target_list     (void);
GtkTargetList* dnd_get_dir_target_list      (void);
gint        dnd_init_destination            (GtkWidget *widget);
gboolean    on_main_widget_drag_motion      (GtkWidget *widget,
                                             GdkDragContext *drag_context,
                                             gint x,
                                             gint y,
                                             guint time,
                                             gpointer user_data);
void        on_main_widget_drag_data_get    (GtkWidget *widget,
                                             GdkDragContext *drag_context,
                                             GtkSelectionData *data,
                                             guint info,
                                             guint time,
                                             gpointer user_data);

Description

Details

enum TargetType

typedef enum {
	TargetTextUriList         = 0,
	TargetFileForInode        = 1, 
	TargetFileForMode         = 2, 
	TargetFileForOwner        = 3,
	TargetFileForGroupOwner   = 4,
	TargetFileForLinks        = 5,
	TargetUserName            = 6,
	TargetGroupName           = 7,
	TargetFileForSize         = 8,
	TargetFileForDate         = 9,
	TargetFileForName         = 10,
	TargetStringOption        = 11,
	TargetStringLongOption    = 12,
	TargetStringProgram       = 13,
	TargetUninitialized       = 100
} TargetType;

TargetTextUriList

TargetFileForInode

TargetFileForMode

TargetFileForOwner

TargetFileForGroupOwner

TargetFileForLinks

TargetUserName

TargetGroupName

TargetFileForSize

TargetFileForDate

TargetFileForName

TargetStringOption

TargetStringLongOption

TargetStringProgram

TargetUninitialized

the target type is not set


dnd_get_file_target_list ()

GtkTargetList* dnd_get_file_target_list     (void);

Returns a GtkTargetList usefull for DND target for regular files.

Returns :

a GtkTargetList list for file target sources


dnd_get_dir_target_list ()

GtkTargetList* dnd_get_dir_target_list      (void);

Returns a GtkTargetList usefull for DND target for regular directories.

Returns :

a GtkTargetList list for directory target sources


dnd_init_destination ()

gint        dnd_init_destination            (GtkWidget *widget);

widget :

Returns :


on_main_widget_drag_motion ()

gboolean    on_main_widget_drag_motion      (GtkWidget *widget,
                                             GdkDragContext *drag_context,
                                             gint x,
                                             gint y,
                                             guint time,
                                             gpointer user_data);

widget :

the GtkWidget where the motion has been found

drag_context :

the drag context of the operation

x :

the x coordinate of the mouse

y :

the y coordinate of the mouse

time :

the time when the motion was detected

user_data :

the data given by the signal connection

Returns :

TRUE if the motion could be handled (always returns TRUE)


on_main_widget_drag_data_get ()

void        on_main_widget_drag_data_get    (GtkWidget *widget,
                                             GdkDragContext *drag_context,
                                             GtkSelectionData *data,
                                             guint info,
                                             guint time,
                                             gpointer user_data);

Called when we initialized a DnD as a source widget and the target is asking the data. There are some problems with this function, namely:

(1) We store the DnD source CuiWidget with the main_widget object. This is not a nice solution IMHO.

widget :

the GtkTextView widget where the DnD was initiated

drag_context :

the GdkDragContext we created at the begin

data :

the GtkSelectionData we have to fill

info :

the size of the data units

time :

what was the time when the data was received

user_data :

pointer to the data gave by the signal connection command