mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-08 17:50:10 +00:00
dnd: Add gdk_drop_get_actions()
This uses the new method without GDK_ACTION_ASK: Either it is a single action (queryable via gdk_drag_action_is_unique()) or it is not and then the drop target has to make a decision (potentially by asking someone).
This commit is contained in:
parent
2e27967814
commit
b2dc303e5e
@ -785,6 +785,7 @@ gdk_drag_drop_done
|
||||
gdk_drag_begin
|
||||
gdk_drop_finish
|
||||
GdkDragAction
|
||||
GDK_ACTION_ALL
|
||||
gdk_drag_status
|
||||
|
||||
gdk_drag_context_get_display
|
||||
|
@ -722,6 +722,11 @@ gdk_drag_context_set_actions (GdkDragContext *context,
|
||||
|
||||
priv->actions = actions;
|
||||
priv->suggested_action = suggested_action;
|
||||
|
||||
if (suggested_action & GDK_ACTION_ASK)
|
||||
gdk_drop_set_actions (GDK_DROP (context), actions & GDK_ACTION_ALL);
|
||||
else
|
||||
gdk_drop_set_actions (GDK_DROP (context), suggested_action);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,6 +59,15 @@ typedef enum
|
||||
GDK_ACTION_ASK = 1 << 3
|
||||
} GdkDragAction;
|
||||
|
||||
/**
|
||||
* GDK_ACTION_ALL:
|
||||
*
|
||||
* Defines all possible DND actions. This can be used in gdk_drop_status()
|
||||
* messages when any drop can be accepted or a more specific drop method
|
||||
* is not yet known.
|
||||
*/
|
||||
#define GDK_ACTION_ALL (GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)
|
||||
|
||||
/**
|
||||
* GdkDragCancelReason:
|
||||
* @GDK_DRAG_CANCEL_NO_TARGET: There is no suitable drop target.
|
||||
|
@ -35,10 +35,12 @@ typedef struct _GdkDropPrivate GdkDropPrivate;
|
||||
struct _GdkDropPrivate {
|
||||
GdkDevice *device;
|
||||
GdkContentFormats *formats;
|
||||
GdkDragAction actions;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ACTIONS,
|
||||
PROP_DEVICE,
|
||||
PROP_DISPLAY,
|
||||
PROP_FORMATS,
|
||||
@ -101,6 +103,10 @@ gdk_drop_set_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACTIONS:
|
||||
gdk_drop_set_actions (self, g_value_get_flags (value));
|
||||
break;
|
||||
|
||||
case PROP_DEVICE:
|
||||
priv->device = g_value_dup_object (value);
|
||||
g_assert (priv->device != NULL);
|
||||
@ -130,6 +136,10 @@ gdk_drop_get_property (GObject *gobject,
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_ACTIONS:
|
||||
g_value_set_flags (value, priv->actions);
|
||||
break;
|
||||
|
||||
case PROP_DEVICE:
|
||||
g_value_set_object (value, priv->device);
|
||||
break;
|
||||
@ -168,6 +178,22 @@ gdk_drop_class_init (GdkDropClass *klass)
|
||||
object_class->set_property = gdk_drop_set_property;
|
||||
object_class->finalize = gdk_drop_finalize;
|
||||
|
||||
/**
|
||||
* GdkDrop:actions:
|
||||
*
|
||||
* The possible actions for this drop
|
||||
*/
|
||||
properties[PROP_ACTIONS] =
|
||||
g_param_spec_flags ("actions",
|
||||
"Actions",
|
||||
"The possible actions for this drop",
|
||||
GDK_TYPE_DRAG_ACTION,
|
||||
GDK_ACTION_ALL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS |
|
||||
G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GdkDrop:device:
|
||||
*
|
||||
@ -274,6 +300,49 @@ gdk_drop_get_formats (GdkDrop *self)
|
||||
return priv->formats;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drop_get_actions:
|
||||
* @self: a #GdkDrop
|
||||
*
|
||||
* Returns the possible actions for this #GdkDrop. If this value
|
||||
* contains multiple actions - ie gdk_drag_action_is_unique()
|
||||
* returns %FALSE for the result - gdk_drop_finish() must choose
|
||||
* the action to use when accepting the drop.
|
||||
*
|
||||
* This value may change over the lifetime of the #GdkDrop both
|
||||
* as a response to source side actions as well as to calls to
|
||||
* gdk_drop_status() or gdk_drop_finish(). The source side will
|
||||
* not change this value anymore once a drop has started.
|
||||
*
|
||||
* Returns: The possible #GdkDragActions
|
||||
**/
|
||||
GdkDragAction
|
||||
gdk_drop_get_actions (GdkDrop *self)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (GDK_IS_DROP (self), 0);
|
||||
|
||||
return priv->actions;
|
||||
}
|
||||
|
||||
void
|
||||
gdk_drop_set_actions (GdkDrop *self,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkDropPrivate *priv = gdk_drop_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (GDK_IS_DROP (self));
|
||||
g_return_if_fail ((actions & GDK_ACTION_ASK) == 0);
|
||||
|
||||
if (priv->actions == actions)
|
||||
return;
|
||||
|
||||
priv->actions = actions;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIONS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drop_read_async:
|
||||
* @self: a #GdkDrop
|
||||
|
@ -45,6 +45,8 @@ GDK_AVAILABLE_IN_ALL
|
||||
GdkDevice * gdk_drop_get_device (GdkDrop *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkContentFormats * gdk_drop_get_formats (GdkDrop *self);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drop_get_actions (GdkDrop *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_read_async (GdkDrop *self,
|
||||
|
@ -51,6 +51,8 @@ struct _GdkDropClass {
|
||||
GError **error);
|
||||
};
|
||||
|
||||
void gdk_drop_set_actions (GdkDrop *self,
|
||||
GdkDragAction actions);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user