From 59c2efbcd63835854ccd405a0151f6e4def01f2e Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 4 Jul 2018 00:52:21 +0200 Subject: [PATCH] Add a GdkDrag::actions property To go along the GdkDrop::actions property. --- gdk/gdkdrag.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/gdk/gdkdrag.c b/gdk/gdkdrag.c index c79f1ef0f3..63c76153f7 100644 --- a/gdk/gdkdrag.c +++ b/gdk/gdkdrag.c @@ -246,6 +246,13 @@ gdk_drag_set_property (GObject *gobject, } break; + case PROP_ACTIONS: + { + GdkDragAction actions = g_value_get_flags (value); + gdk_drag_set_actions (drag, actions, drag->suggested_action); + } + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -282,6 +289,10 @@ gdk_drag_get_property (GObject *gobject, g_value_set_flags (value, drag->selected_action); break; + case PROP_ACTIONS: + g_value_set_flags (value, drag->actions); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -382,6 +393,15 @@ gdk_drag_class_init (GdkDragClass *klass) G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); + properties[PROP_ACTIONS] = + g_param_spec_flags ("actions", + "Actions", + "The possible actions", + 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 @@ -593,8 +613,14 @@ gdk_drag_set_actions (GdkDrag *drag, GdkDragAction actions, GdkDragAction suggested_action) { - drag->actions = actions; drag->suggested_action = suggested_action; + + if (drag->actions == actions) + return; + + drag->actions = actions; + + g_object_notify_by_pspec (G_OBJECT (drag), properties[PROP_ACTIONS]); } void