FmDndDest

FmDndDest — Libfm support for drag&drop destination.

Synopsis

                    FmDndDest;
struct              FmDndDestClass;
enum                FmDndDestTargetType;
#define             fm_dnd_dest_add_targets             (widget,
                                                         targets,
                                                         n)
gboolean            fm_dnd_dest_drag_data_received      (FmDndDest *dd,
                                                         GdkDragContext *drag_context,
                                                         gint x,
                                                         gint y,
                                                         GtkSelectionData *sel_data,
                                                         guint info,
                                                         guint time);
gboolean            fm_dnd_dest_drag_drop               (FmDndDest *dd,
                                                         GdkDragContext *drag_context,
                                                         GdkAtom target,
                                                         int x,
                                                         int y,
                                                         guint time);
void                fm_dnd_dest_drag_leave              (FmDndDest *dd,
                                                         GdkDragContext *drag_context,
                                                         guint time);
GdkAtom             fm_dnd_dest_find_target             (FmDndDest *dd,
                                                         GdkDragContext *drag_context);
GdkDragAction       fm_dnd_dest_get_default_action      (FmDndDest *dd,
                                                         GdkDragContext *drag_context,
                                                         GdkAtom target);
FmFileInfo *        fm_dnd_dest_get_dest_file           (FmDndDest *dd);
FmPath *            fm_dnd_dest_get_dest_path           (FmDndDest *dd);
gboolean            fm_dnd_dest_is_target_supported     (FmDndDest *dd,
                                                         GdkAtom target);
FmDndDest *         fm_dnd_dest_new                     (GtkWidget *w);
FmDndDest *         fm_dnd_dest_new_with_handlers       (GtkWidget *w);
void                fm_dnd_dest_set_dest_file           (FmDndDest *dd,
                                                         FmFileInfo *dest_file);
void                fm_dnd_dest_set_widget              (FmDndDest *dd,
                                                         GtkWidget *w);
#define             fm_drag_context_has_target          (ctx,
                                                         target)
#define             fm_drag_context_has_target_name     (ctx,
                                                         name)

Object Hierarchy

  GObject
   +----FmDndDest

Signals

  "files-dropped"                                  : Run Last

Description

include: libfm/fm-dnd-dest.h

The FmDndDest can be used by some widget to provide support for Drop operations onto that widget.

To use FmDndDest the widget should create it - the simplest API for this is fm_dnd_dest_new_with_handlers(). When FmDndDest is created some drop data types ("targets") are set for the widget. The widget can extend the list by adding own targets to the list and connecting own handlers to the "drag-leave", "drag-drop", and "drag-data-received" signals.

The "drag-motion" signal should be always handled by the widget. The handler should check if drop can be performed. And if FmDndDest can accept the drop then widget should inform FmDndDest object about FmFileInfo object the mouse pointer targets at that moment by calling fm_dnd_dest_set_dest_file(). The FmDndDest uses a little different sequence for collecting dragged data - it queries data in time of drag motion and uses when data are dropped therefore widget should always call API fm_dnd_dest_get_default_action() from handler of the "drag-motion" signal for any target which FmDndDest supports.

Example 1. Sample Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36