Top | ![]() |
![]() |
![]() |
![]() |
#define | fm_dnd_src_add_targets() |
FmDndSrc * | fm_dnd_src_new () |
void | fm_dnd_src_set_file () |
void | fm_dnd_src_set_files () |
void | fm_dnd_src_set_widget () |
include
: libfm/fm-gtk.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 5. 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.
#define fm_dnd_src_add_targets(widget,targets,n)
Adds drag source targets to existing list for widget
. Convenience API.
widget |
GtkWidget to add targets |
|
targets |
pointer to array of GtkTargetEntry to add |
|
n |
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.
Since: 0.1.0
void fm_dnd_src_set_file (FmDndSrc *ds
,FmFileInfo *file
);
Sets file
as selection in the source descriptor.
Since: 0.1.0
void fm_dnd_src_set_files (FmDndSrc *ds
,FmFileInfoList *files
);
Sets files
as selection list in the source descriptor.
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.
Since: 0.1.0
struct FmDndSrcClass { GObjectClass parent_class; void (*data_get)(FmDndSrc*); };
“data-get”
signalvoid user_function (FmDndSrc *object, gpointer user_data)
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.
object |
the object which emitted the signal |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run First
Since: 0.1.0