summaryrefslogtreecommitdiff
path: root/gdk/gdkdrag.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2018-07-03 01:16:47 +0200
committerMatthias Clasen <mclasen@redhat.com>2018-07-12 13:02:42 +0200
commitdb0b9f61ae542fe0087c3df48f89b5367e708e5d (patch)
tree4a4d37d62a5b483157b9d07c987c5f4e65403ef9 /gdk/gdkdrag.c
parent63ab52314674c32f3aec228d97fd3c511e1bd448 (diff)
downloadgtk+-db0b9f61ae542fe0087c3df48f89b5367e708e5d.tar.gz
dnd: Add a GdkDrag::action property
This lets us drop the ::action-changed signal for the property change notification. But, can just as well move the signal class handers which just update the cursor to the ::action setter. No need to do this in the backends.
Diffstat (limited to 'gdk/gdkdrag.c')
-rw-r--r--gdk/gdkdrag.c56
1 files changed, 39 insertions, 17 deletions
diff --git a/gdk/gdkdrag.c b/gdk/gdkdrag.c
index 2e8efb8e71..ce8f7cfdc2 100644
--- a/gdk/gdkdrag.c
+++ b/gdk/gdkdrag.c
@@ -64,6 +64,7 @@ enum {
PROP_DEVICE,
PROP_DISPLAY,
PROP_FORMATS,
+ PROP_ACTION,
N_PROPERTIES
};
@@ -71,7 +72,6 @@ enum {
CANCEL,
DROP_PERFORMED,
DND_FINISHED,
- ACTION_CHANGED,
N_SIGNALS
};
@@ -260,6 +260,13 @@ gdk_drag_set_property (GObject *gobject,
}
break;
+ case PROP_ACTION:
+ {
+ GdkDragAction action = g_value_get_flags (value);
+ gdk_drag_set_action (drag, action);
+ }
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -293,6 +300,10 @@ gdk_drag_get_property (GObject *gobject,
g_value_set_boxed (value, priv->formats);
break;
+ case PROP_ACTION:
+ g_value_set_flags (value, drag->action);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
@@ -384,6 +395,16 @@ gdk_drag_class_init (GdkDragClass *klass)
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
+ properties[PROP_ACTION] =
+ g_param_spec_flags ("action",
+ "Action",
+ "The currently selected action",
+ GDK_TYPE_DRAG_ACTION,
+ 0,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS |
+ G_PARAM_EXPLICIT_NOTIFY);
+
/**
* GdkDrag::cancel:
* @drag: The object on which the signal is emitted
@@ -432,22 +453,6 @@ gdk_drag_class_init (GdkDragClass *klass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
- /**
- * GdkDrag::action-changed:
- * @drag: The object on which the signal is emitted
- * @action: The action currently chosen
- *
- * A new action is being chosen for the drag operation.
- */
- signals[ACTION_CHANGED] =
- g_signal_new (g_intern_static_string ("action-changed"),
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GdkDragClass, action_changed),
- NULL, NULL,
- g_cclosure_marshal_VOID__FLAGS,
- G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
-
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
}
@@ -617,6 +622,23 @@ gdk_drag_set_actions (GdkDrag *drag,
priv->suggested_action = suggested_action;
}
+void
+gdk_drag_set_action (GdkDrag *drag,
+ GdkDragAction action)
+{
+ GdkCursor *cursor;
+
+ if (drag->action == action)
+ return;
+
+ drag->action = action;
+
+ cursor = gdk_drag_get_cursor (drag, action);
+ gdk_drag_set_cursor (drag, cursor);
+
+ g_object_notify_by_pspec (G_OBJECT (drag), properties[PROP_ACTION]);
+}
+
/**
* gdk_drag_get_drag_surface:
* @drag: a #GdkDrag