![]() |
![]() |
![]() |
Libfm Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Signals |
struct FmDndSrc; struct FmDndSrcClass; enum FmDndSrcTarget; #define fm_dnd_src_add_targets (widget, targets, n) FmDndSrc * fm_dnd_src_new (GtkWidget *w
); void fm_dnd_src_set_file (FmDndSrc *ds
,FmFileInfo *file
); void fm_dnd_src_set_files (FmDndSrc *ds
,FmFileInfoList *files
); void fm_dnd_src_set_widget (FmDndSrc *ds
,GtkWidget *w
);
include
: libfm/fm-dnd-src.h
The FmDndSrc can be used by some widget to provide support for drag operations on FmFileInfo objects that are represented in that widget.
To use FmDndSrc the widget should create it with fm_dnd_src_new()
and
connect to the "data-get" signal of the created FmDndSrc
object.
Example 2. Sample Usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
{ widget->ds = fm_dnd_src_new(widget); g_signal_connect(widget->ds, "data-get", G_CALLBACK(on_data_get), widget); ... } static void on_object_finalize(MyWidget *widget) { ... g_signal_handlers_disconnect_by_data(widget->ds, widget); g_object_unref(G_OBJECT(widget->ds)); } static void on_data_get(FmDndSrc *ds, MyWidget *widget) { FmFileInfo *file = widget->selected_file; fm_dnd_src_set_file(ds, file); } |
The FmDndSrc will set drag activation for the widget by left mouse
button so if widget wants to use mouse movement with left button
pressed for something else (rubberbanding for example) then it should
disable Gtk drag handlers when needs (by blocking handlers that match
object data "gtk-site-data" usually).
If widget wants to handle some types of data other than FmFileInfo objects it should do it the usual way by connecting handlers for the "drag-data-get", "drag-begin", and "drag-end" signals and adding own targets to widget's drag source target list. To exclude conflicts the widget's specific handlers should use info indices starting from N_FM_DND_SRC_DEFAULT_TARGETS.
struct FmDndSrcClass { GObjectClass parent_class; void (*data_get)(FmDndSrc*); };
the parent class | |
the class closure for the "data-get" signal |
typedef enum { FM_DND_SRC_TARGET_FM_LIST = 1, FM_DND_SRC_TARGET_URI_LIST, FM_DND_SRC_TARGET_TEXT, N_FM_DND_SRC_DEFAULT_TARGETS } FmDndSrcTarget;
default targets of drag source
#define fm_dnd_src_add_targets(widget,targets,n)
Adds drag source targets to existing list for widget
. Convenience API.
|
GtkWidget to add targets |
|
pointer to array of GtkTargetEntry to add |
|
number of targets to add |
Since 1.0.1
FmDndSrc * fm_dnd_src_new (GtkWidget *w
);
Creates new drag source descriptor.
Before 1.0.1 this API didn't update drag source on widget so caller should set it itself. Since access to fm_default_dnd_src_targets outside of this API considered unsecure, that behavior was changed.
|
the widget where source files are selected. [allow-none] |
Returns : |
a new FmDndSrc object. [transfer full] |
Since 0.1.0
void fm_dnd_src_set_file (FmDndSrc *ds
,FmFileInfo *file
);
Sets file
as selection in the source descriptor.
|
the drag source descriptor |
|
files to set |
Since 0.1.0
void fm_dnd_src_set_files (FmDndSrc *ds
,FmFileInfoList *files
);
Sets files
as selection list in the source descriptor.
|
the drag source descriptor |
|
list of files to set |
Since 0.1.0
void fm_dnd_src_set_widget (FmDndSrc *ds
,GtkWidget *w
);
Resets drag source widget in ds
.
Before 1.0.1 this API didn't update drag source on widget so caller should set and unset it itself. Access to fm_default_dnd_src_targets outside of this API considered unsecure so that behavior was changed.
|
the drag source descriptor |
|
the widget where source files are selected. [allow-none] |
Since 0.1.0
"data-get"
signalvoid user_function (FmDndSrc *object,
gpointer user_data) : Run First
The "data-get" signal is emitted when information of
source files is needed. Handler of the signal should then call
fm_dnd_src_set_files()
to provide info of dragged source files.
|
the object which emitted the signal |
|
user data set when the signal handler was connected. |
Since 0.1.0