forked from AuroraMiddleware/gtk
dnd: Move the gdk_drag_status() function
It's now gdk_drop_status(). Also clarify the intended semantics.
This commit is contained in:
parent
b2dc303e5e
commit
a05af1f0f3
@ -120,14 +120,6 @@ gdk_broadway_drag_context_drag_abort (GdkDragContext *context,
|
||||
|
||||
/* Destination side */
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time)
|
||||
{
|
||||
g_return_if_fail (context != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_broadway_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
@ -154,7 +146,6 @@ gdk_broadway_drag_context_class_init (GdkBroadwayDragContextClass *klass)
|
||||
|
||||
object_class->finalize = gdk_broadway_drag_context_finalize;
|
||||
|
||||
context_class->drag_status = gdk_broadway_drag_context_drag_status;
|
||||
context_class->drag_abort = gdk_broadway_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_broadway_drag_context_drag_drop;
|
||||
context_class->drop_finish = gdk_broadway_drag_context_drop_finish;
|
||||
|
@ -533,9 +533,7 @@ gdk_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time_)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
|
||||
|
||||
GDK_DRAG_CONTEXT_GET_CLASS (context)->drag_status (context, action, time_);
|
||||
gdk_drop_status (GDK_DROP (context), action);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -35,9 +35,6 @@ typedef struct _GdkDragContextClass GdkDragContextClass;
|
||||
struct _GdkDragContextClass {
|
||||
GdkDropClass parent_class;
|
||||
|
||||
void (*drag_status) (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time_);
|
||||
void (*drag_abort) (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
void (*drag_drop) (GdkDragContext *context,
|
||||
|
@ -58,6 +58,12 @@ G_DEFINE_TYPE_WITH_PRIVATE (GdkDrop, gdk_drop, G_TYPE_OBJECT)
|
||||
* should not be accessed directly.
|
||||
*/
|
||||
|
||||
static void
|
||||
gdk_drop_default_status (GdkDrop *self,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_drop_read_local_async (GdkDrop *self,
|
||||
GdkContentFormats *formats,
|
||||
@ -174,6 +180,8 @@ gdk_drop_class_init (GdkDropClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
klass->status = gdk_drop_default_status;
|
||||
|
||||
object_class->get_property = gdk_drop_get_property;
|
||||
object_class->set_property = gdk_drop_set_property;
|
||||
object_class->finalize = gdk_drop_finalize;
|
||||
@ -343,6 +351,32 @@ gdk_drop_set_actions (GdkDrop *self,
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIONS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drop_status:
|
||||
* @self: a #GdkDrop
|
||||
* @actions: Supported actions of the destination, or 0 to indicate
|
||||
* that a drop will not be accepted
|
||||
*
|
||||
* Selects all actions that are potentially supported by the destination.
|
||||
*
|
||||
* When calling this function, do not restrict the passed in actions to
|
||||
* the ones provided by gdk_drop_get_actions(). Those actions may
|
||||
* change in the future, even depending on the actions you provide here.
|
||||
*
|
||||
* This function should be called by drag destinations in response to
|
||||
* %GDK_DRAG_ENTER or %GDK_DRAG_MOTION events. If the destination does
|
||||
* not yet know the exact actions it supports, it should set any possible
|
||||
* actions first and then later call this function again.
|
||||
*/
|
||||
void
|
||||
gdk_drop_status (GdkDrop *self,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_DROP (self));
|
||||
|
||||
GDK_DROP_GET_CLASS (self)->status (self, actions);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_drop_read_async:
|
||||
* @self: a #GdkDrop
|
||||
|
@ -48,6 +48,10 @@ GdkContentFormats * gdk_drop_get_formats (GdkDrop
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkDragAction gdk_drop_get_actions (GdkDrop *self);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_status (GdkDrop *self,
|
||||
GdkDragAction actions);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gdk_drop_read_async (GdkDrop *self,
|
||||
const char **mime_types,
|
||||
|
@ -39,6 +39,8 @@ struct _GdkDrop {
|
||||
struct _GdkDropClass {
|
||||
GObjectClass parent_class;
|
||||
|
||||
void (* status) (GdkDrop *self,
|
||||
GdkDragAction action);
|
||||
void (* read_async) (GdkDrop *self,
|
||||
GdkContentFormats *formats,
|
||||
int io_priority,
|
||||
|
@ -70,14 +70,6 @@ gdk_quartz_drag_context_drag_abort (GdkDragContext *context,
|
||||
/* FIXME: Implement */
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_quartz_drag_context_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time)
|
||||
{
|
||||
context->action = action;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_quartz_drag_context_drop_finish (GdkDragContext *context,
|
||||
gboolean success,
|
||||
@ -117,7 +109,6 @@ gdk_quartz_drag_context_class_init (GdkQuartzDragContextClass *klass)
|
||||
|
||||
object_class->finalize = gdk_quartz_drag_context_finalize;
|
||||
|
||||
context_class->drag_status = gdk_quartz_drag_context_drag_status;
|
||||
context_class->drag_abort = gdk_quartz_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_quartz_drag_context_drag_drop;
|
||||
context_class->drop_finish = gdk_quartz_drag_context_drop_finish;
|
||||
|
@ -215,13 +215,12 @@ gdk_wayland_drag_context_commit_status (GdkDragContext *context)
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_drag_context_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time_)
|
||||
gdk_wayland_drag_context_status (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkWaylandDragContext *wayland_context;
|
||||
|
||||
wayland_context = GDK_WAYLAND_DRAG_CONTEXT (context);
|
||||
wayland_context = GDK_WAYLAND_DRAG_CONTEXT (drop);
|
||||
wayland_context->selected_action = action;
|
||||
}
|
||||
|
||||
@ -403,10 +402,10 @@ gdk_wayland_drag_context_class_init (GdkWaylandDragContextClass *klass)
|
||||
|
||||
object_class->finalize = gdk_wayland_drag_context_finalize;
|
||||
|
||||
drop_class->status = gdk_wayland_drag_context_status;
|
||||
drop_class->read_async = gdk_wayland_drag_context_read_async;
|
||||
drop_class->read_finish = gdk_wayland_drag_context_read_finish;
|
||||
|
||||
context_class->drag_status = gdk_wayland_drag_context_drag_status;
|
||||
context_class->drag_abort = gdk_wayland_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_wayland_drag_context_drag_drop;
|
||||
context_class->drop_finish = gdk_wayland_drag_context_drop_finish;
|
||||
|
@ -853,10 +853,10 @@ gdk_dropfiles_filter (GdkWin32Display *display,
|
||||
/* Destination side */
|
||||
|
||||
static void
|
||||
gdk_win32_drop_context_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time)
|
||||
gdk_win32_drop_context_status (GdkDrop *drop,
|
||||
GdkDragAction action)
|
||||
{
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (drop);
|
||||
GdkDragContext *src_context;
|
||||
|
||||
g_return_if_fail (context != NULL);
|
||||
@ -1204,10 +1204,10 @@ gdk_win32_drop_context_class_init (GdkWin32DropContextClass *klass)
|
||||
|
||||
object_class->finalize = gdk_win32_drop_context_finalize;
|
||||
|
||||
drop_class->status = gdk_win32_drop_context_status;
|
||||
drop_class->read_async = gdk_win32_drop_context_read_async;
|
||||
drop_class->read_finish = gdk_win32_drop_context_read_finish;
|
||||
|
||||
context_class->drag_status = gdk_win32_drop_context_drag_status;
|
||||
context_class->drop_finish = gdk_win32_drop_context_drop_finish;
|
||||
}
|
||||
|
||||
|
@ -233,9 +233,8 @@ static gboolean gdk_x11_drag_context_drag_motion (GdkDragContext *context,
|
||||
GdkDragAction suggested_action,
|
||||
GdkDragAction possible_actions,
|
||||
guint32 time);
|
||||
static void gdk_x11_drag_context_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time_);
|
||||
static void gdk_x11_drag_context_status (GdkDrop *drop,
|
||||
GdkDragAction actions);
|
||||
static void gdk_x11_drag_context_drag_abort (GdkDragContext *context,
|
||||
guint32 time_);
|
||||
static void gdk_x11_drag_context_drag_drop (GdkDragContext *context,
|
||||
@ -394,10 +393,10 @@ gdk_x11_drag_context_class_init (GdkX11DragContextClass *klass)
|
||||
|
||||
object_class->finalize = gdk_x11_drag_context_finalize;
|
||||
|
||||
drop_class->status = gdk_x11_drag_context_status;
|
||||
drop_class->read_async = gdk_x11_drag_context_read_async;
|
||||
drop_class->read_finish = gdk_x11_drag_context_read_finish;
|
||||
|
||||
context_class->drag_status = gdk_x11_drag_context_drag_status;
|
||||
context_class->drag_abort = gdk_x11_drag_context_drag_abort;
|
||||
context_class->drag_drop = gdk_x11_drag_context_drag_drop;
|
||||
context_class->drop_finish = gdk_x11_drag_context_drop_finish;
|
||||
@ -2408,30 +2407,32 @@ gdk_x11_drag_context_drag_drop (GdkDragContext *context,
|
||||
/* Destination side */
|
||||
|
||||
static void
|
||||
gdk_x11_drag_context_drag_status (GdkDragContext *context,
|
||||
GdkDragAction action,
|
||||
guint32 time_)
|
||||
gdk_x11_drag_context_status (GdkDrop *drop,
|
||||
GdkDragAction actions)
|
||||
{
|
||||
GdkDragContext *context = GDK_DRAG_CONTEXT (drop);
|
||||
GdkX11DragContext *context_x11 = GDK_X11_DRAG_CONTEXT (context);
|
||||
XEvent xev;
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_drag_context_get_display (context);
|
||||
|
||||
context->action = action;
|
||||
context->action = actions;
|
||||
|
||||
if (context_x11->protocol == GDK_DRAG_PROTO_XDND)
|
||||
{
|
||||
GdkDragAction possible_actions = actions & gdk_drop_get_actions (drop);
|
||||
|
||||
xev.xclient.type = ClientMessage;
|
||||
xev.xclient.message_type = gdk_x11_get_xatom_by_name_for_display (display, "XdndStatus");
|
||||
xev.xclient.format = 32;
|
||||
xev.xclient.window = GDK_SURFACE_XID (context->source_surface);
|
||||
|
||||
xev.xclient.data.l[0] = GDK_SURFACE_XID (context->dest_surface);
|
||||
xev.xclient.data.l[1] = (action != 0) ? (2 | 1) : 0;
|
||||
xev.xclient.data.l[1] = (possible_actions != 0) ? (2 | 1) : 0;
|
||||
xev.xclient.data.l[2] = 0;
|
||||
xev.xclient.data.l[3] = 0;
|
||||
xev.xclient.data.l[4] = xdnd_action_to_atom (display, action);
|
||||
xev.xclient.data.l[4] = xdnd_action_to_atom (display, possible_actions);
|
||||
if (!xdnd_send_xevent (context_x11, context->source_surface, FALSE, &xev))
|
||||
{
|
||||
GDK_DISPLAY_NOTE (display, DND,
|
||||
|
Loading…
Reference in New Issue
Block a user