[gtk+] Example for setting default action in gtk_drag_dest_set
- From: Robin Stocker <robinst src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+] Example for setting default action in gtk_drag_dest_set
- Date: Sun, 8 Nov 2009 00:37:04 +0000 (UTC)
commit 26e2c7f398e9376df4e67ca2d712b38a220b88f5
Author: Robin Stocker <robin nibor org>
Date: Sun Nov 8 01:27:05 2009 +0100
Example for setting default action in gtk_drag_dest_set
gtk/gtkdnd.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 8bbb4d2..c3a95d8 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -1239,6 +1239,28 @@ gtk_drag_dest_set_internal (GtkWidget *widget,
* and invokations of gtk_drag_finish() in #GtkWidget:drag-data-received.
* Especially the later is dramatic, when your own #GtkWidget:drag-motion
* handler calls gtk_drag_get_data() to inspect the dragged data.
+ *
+ * There's no way to set a default action here, you can use the
+ * #GtkWidget:drag-motion callback for that. Here's an example which selects
+ * the action to use depending on whether the control key is pressed or not:
+ * |[
+ * static void
+ * drag_motion (GtkWidget *widget,
+ * GdkDragContext *context,
+ * gint x,
+ * gint y,
+ * guint time)
+ * {
+ * GdkModifierType mask;
+ *
+ * gdk_window_get_pointer (gtk_widget_get_window (widget),
+ * NULL, NULL, &mask);
+ * if (mask & GDK_CONTROL_MASK)
+ * gdk_drag_status (context, GDK_ACTION_COPY, time);
+ * else
+ * gdk_drag_status (context, GDK_ACTION_MOVE, time);
+ * }
+ * ]|
*/
void
gtk_drag_dest_set (GtkWidget *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]