[戻る] | Crazy Unit |
void gtk_drag_dest_set ( GtkWidget *widget,
GtkDestDefaults flags,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions );
typedef enum {
GTK_DEST_DEFAULT_MOTION = 1 << 0,
GTK_DEST_DEFAULT_HIGHLIGHT = 1 << 1,
GTK_DEST_DEFAULT_DROP = 1 << 2,
GTK_DEST_DEFAULT_ALL = 0x07
} GtkDestDefaults;
GTK_DEST_DEFAULT_MOTIONはドロップ可否の判定を自動で行わせる場合に指定します。複雑な事をしないのであれば指定しておいた方が便利でしょう。
drag-motionシグナルハンドラを用意する必要が無くなります。struct GtkTargetEntry {
gchar *target;
guint flags;
guint info;
};
targetに受け入れ可能なmime型を設定します。typedef enum {
GDK_ACTION_DEFAULT = 1 << 0,
GDK_ACTION_COPY = 1 << 1,
GDK_ACTION_MOVE = 1 << 2,
GDK_ACTION_LINK = 1 << 3,
GDK_ACTION_PRIVATE = 1 << 4,
GDK_ACTION_ASK = 1 << 5
} GdkDragAction;
GDK_ACTION_PRIVATEはドロップ側で何をするかドラッグ側には判別不能な動作の場合に使用するらしいです。GTK_TARGET_SAME_APPやGTK_TARGET_SAME_WIDGETで何か特殊な動作をさせる場合に利用するんでしょうか?gboolean dest_drag_motion ( GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time_,
gpointer user_data );
void gdk_drag_status ( GdkDragContext *context,
GdkDragAction action,
guint32 time_ );
void dest_drag_leave ( GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time_,
gpointer user_data );
gboolean dest_drag_drop ( GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
guint time_,
gpointer user_data );
void gtk_drag_get_data ( GtkWidget *widget,
GdkDragContext *context,
GdkAtom target,
guint32 time_ );
GtkTargetList* gtk_drag_dest_get_target_list ( GtkWidget *widget );
GdkAtom gtk_drag_dest_find_target ( GtkWidget *widget,
GdkDragContext *context,
GtkTargetList *target_list );
void dest_drag_data_received ( GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint time_,
gpointer user_data );
struct GtkSelectionData {
GdkAtom selection;
GdkAtom target;
GdkAtom type;
gint format;
guchar *data;
gint length;
GdkDisplay *display;
};
gdk_atom_intern()やgdk_atom_name()を使用するとmime型の文字列からGdkAtom、GdkAtomからmime型の文字列を得ることができます。g_print("%s\n", gdk_atom_name(data->type));
if (data->type == gdk_atom_intern("text/uri-list",FALSE)) {
/* なにかする */
}
といった感じです。void gtk_drag_finish ( GdkDragContext *context,
gboolean success,
gboolean del,
guint32 time_);
void gtk_drag_source_set ( GtkWidget *widget,
GdkModifierType start_button_mask,
const GtkTargetEntry *targets,
gint n_targets,
GdkDragAction actions );
gboolean button_press_event ( GtkWidget *widget,
GdkEventButton *event,
gpointer user_data );
gboolean button_release_event ( GtkWidget *widget,
GdkEventButton *event,
gpointer user_data );
gboolean motion_notify_event ( GtkWidget *widget,
GdkEventMotion *event,
gpointer user_data );
gboolean leave_notify_event ( GtkWidget *widget,
GdkEventCrossing *event,
gpointer user_data );
gboolean gtk_drag_check_threshold ( GtkWidget *widget,
gint start_x,
gint start_y,
gint current_x,
gint current_y );
GdkDragContext* gtk_drag_begin ( GtkWidget *widget,
GtkTargetList *targets,
GdkDragAction actions,
gint button,
GdkEvent *event );
GtkTargetList* gtk_target_list_new ( const GtkTargetEntry *targets,
guint ntargets );
void gtk_target_list_unref ( GtkTargetList *list );
void source_drag_begin( GtkWidget *widget,
GdkDragContext *context,
gpointer user_data );
void source_drag_data_get ( GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *data,
guint info,
guint time_,
gpointer user_data );
void gtk_selection_data_set ( GtkSelectionData *selection_data,
GdkAtom type,
gint format,
const guchar *data,
gint length );
void source_drag_data_delete ( GtkWidget *widget,
GdkDragContext *context,
gpointer user_data );
void source_drag_end ( GtkWidget *widget,
GdkDragContext *context,
gpointer user_data );
ユーザ操作 | drag側 | drop側 |
---|---|---|
(1) ドラッグ開始 | ||
(2) drag-beginシグナル | ||
(3) マウスカーソルをdrop側に移動 | ||
(4) drag-motionシグナル | ||
(5) ドロップ | ||
(6) drag-leaveシグナル | ||
(7) drag-dropシグナル → gtk_drag_get_data()呼び出し | ||
(8) drag-data-getシグナル → gtk_selection_data_set()呼び出し | ||
(9) drag-data-receivedシグナル → gtk_drag_finish()呼び出し | ||
(10) drag-data-deleteシグナル (gtk_drag_finish()の第3パラメータがTRUEで呼び出された場合) | ||
(11) drag-endシグナル |