forked from AuroraMiddleware/gtk
dnd: Add gdk_drag_context_get_display()
Also turn it into a readable, construct-only property. Every GDK object should have this. (Apart from GdkDisplay, obviously.)
This commit is contained in:
parent
815cd0ed68
commit
0d31eb8670
@ -860,6 +860,7 @@ GdkDragAction
|
|||||||
gdk_drag_status
|
gdk_drag_status
|
||||||
gdk_drag_drop_succeeded
|
gdk_drag_drop_succeeded
|
||||||
|
|
||||||
|
gdk_drag_context_get_display
|
||||||
gdk_drag_context_get_actions
|
gdk_drag_context_get_actions
|
||||||
gdk_drag_context_get_suggested_action
|
gdk_drag_context_get_suggested_action
|
||||||
gdk_drag_context_get_selected_action
|
gdk_drag_context_get_selected_action
|
||||||
|
@ -96,8 +96,8 @@ _gdk_broadway_window_drag_begin (GdkWindow *window,
|
|||||||
g_return_val_if_fail (GDK_WINDOW_IS_BROADWAY (window), NULL);
|
g_return_val_if_fail (GDK_WINDOW_IS_BROADWAY (window), NULL);
|
||||||
|
|
||||||
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
|
new_context = g_object_new (GDK_TYPE_BROADWAY_DRAG_CONTEXT,
|
||||||
|
"display", gdk_window_get_display (window),
|
||||||
NULL);
|
NULL);
|
||||||
new_context->display = gdk_window_get_display (window);
|
|
||||||
|
|
||||||
return new_context;
|
return new_context;
|
||||||
}
|
}
|
||||||
|
83
gdk/gdkdnd.c
83
gdk/gdkdnd.c
@ -46,6 +46,12 @@ static struct {
|
|||||||
{ 0, "dnd-none", NULL },
|
{ 0, "dnd-none", NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_DISPLAY,
|
||||||
|
N_PROPERTIES
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
CANCEL,
|
CANCEL,
|
||||||
DROP_PERFORMED,
|
DROP_PERFORMED,
|
||||||
@ -54,6 +60,7 @@ enum {
|
|||||||
N_SIGNALS
|
N_SIGNALS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GParamSpec *properties[N_PROPERTIES] = { NULL, };
|
||||||
static guint signals[N_SIGNALS] = { 0 };
|
static guint signals[N_SIGNALS] = { 0 };
|
||||||
static GList *contexts = NULL;
|
static GList *contexts = NULL;
|
||||||
|
|
||||||
@ -73,6 +80,20 @@ static GList *contexts = NULL;
|
|||||||
* the GTK+ documentation for more information.
|
* the GTK+ documentation for more information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gdk_drag_context_get_display:
|
||||||
|
* @context: a #GdkDragContext
|
||||||
|
*
|
||||||
|
* Gets the #GdkDisplay that the drag context was created for.
|
||||||
|
*
|
||||||
|
* Returns: (transfer none): a #GdkDisplay
|
||||||
|
**/
|
||||||
|
GdkDisplay *
|
||||||
|
gdk_drag_context_get_display (GdkDragContext *context)
|
||||||
|
{
|
||||||
|
return context->display;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gdk_drag_context_get_formats:
|
* gdk_drag_context_get_formats:
|
||||||
* @context: a #GdkDragContext
|
* @context: a #GdkDragContext
|
||||||
@ -230,6 +251,47 @@ gdk_drag_context_init (GdkDragContext *context)
|
|||||||
contexts = g_list_prepend (contexts, context);
|
contexts = g_list_prepend (contexts, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_drag_context_set_property (GObject *gobject,
|
||||||
|
guint prop_id,
|
||||||
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_DISPLAY:
|
||||||
|
context->display = g_value_get_object (value);
|
||||||
|
g_assert (context->display != NULL);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gdk_drag_context_get_property (GObject *gobject,
|
||||||
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
|
||||||
|
|
||||||
|
switch (prop_id)
|
||||||
|
{
|
||||||
|
case PROP_DISPLAY:
|
||||||
|
g_value_set_object (value, context->display);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gdk_drag_context_finalize (GObject *object)
|
gdk_drag_context_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
@ -252,8 +314,27 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
|
|||||||
{
|
{
|
||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
|
object_class->get_property = gdk_drag_context_get_property;
|
||||||
|
object_class->set_property = gdk_drag_context_set_property;
|
||||||
object_class->finalize = gdk_drag_context_finalize;
|
object_class->finalize = gdk_drag_context_finalize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GdkDragContext:display:
|
||||||
|
*
|
||||||
|
* The #GdkDisplay that the drag context belongs to.
|
||||||
|
*
|
||||||
|
* Since: 3.94
|
||||||
|
*/
|
||||||
|
properties[PROP_DISPLAY] =
|
||||||
|
g_param_spec_object ("display",
|
||||||
|
"Display",
|
||||||
|
"Display owning this clipboard",
|
||||||
|
GDK_TYPE_DISPLAY,
|
||||||
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_CONSTRUCT_ONLY |
|
||||||
|
G_PARAM_STATIC_STRINGS |
|
||||||
|
G_PARAM_EXPLICIT_NOTIFY);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GdkDragContext::cancel:
|
* GdkDragContext::cancel:
|
||||||
* @context: The object on which the signal is emitted
|
* @context: The object on which the signal is emitted
|
||||||
@ -342,6 +423,8 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
|
|||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__FLAGS,
|
g_cclosure_marshal_VOID__FLAGS,
|
||||||
G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
|
G_TYPE_NONE, 1, GDK_TYPE_DRAG_ACTION);
|
||||||
|
|
||||||
|
g_object_class_install_properties (object_class, N_PROPERTIES, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -83,6 +83,8 @@ typedef enum {
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
GType gdk_drag_context_get_type (void) G_GNUC_CONST;
|
GType gdk_drag_context_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GDK_AVAILABLE_IN_3_94
|
||||||
|
GdkDisplay * gdk_drag_context_get_display (GdkDragContext *context);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
void gdk_drag_context_set_device (GdkDragContext *context,
|
void gdk_drag_context_set_device (GdkDragContext *context,
|
||||||
GdkDevice *device);
|
GdkDevice *device);
|
||||||
|
@ -43,8 +43,8 @@ _gdk_quartz_window_drag_begin (GdkWindow *window,
|
|||||||
|
|
||||||
/* Create fake context */
|
/* Create fake context */
|
||||||
_gdk_quartz_drag_source_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
|
_gdk_quartz_drag_source_context = g_object_new (GDK_TYPE_QUARTZ_DRAG_CONTEXT,
|
||||||
|
"display", display,
|
||||||
NULL);
|
NULL);
|
||||||
_gdk_quartz_drag_source_context->display = gdk_window_get_display (window);
|
|
||||||
_gdk_quartz_drag_source_context->is_source = TRUE;
|
_gdk_quartz_drag_source_context->is_source = TRUE;
|
||||||
|
|
||||||
_gdk_quartz_drag_source_context->source_window = window;
|
_gdk_quartz_drag_source_context->source_window = window;
|
||||||
|
@ -513,9 +513,10 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
|
|||||||
const char *const *mimetypes;
|
const char *const *mimetypes;
|
||||||
gsize i, n_mimetypes;
|
gsize i, n_mimetypes;
|
||||||
|
|
||||||
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
|
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
|
||||||
|
"display", gdk_window_get_display (window),
|
||||||
|
NULL);
|
||||||
context = GDK_DRAG_CONTEXT (context_wayland);
|
context = GDK_DRAG_CONTEXT (context_wayland);
|
||||||
context->display = gdk_window_get_display (window);
|
|
||||||
context->source_window = g_object_ref (window);
|
context->source_window = g_object_ref (window);
|
||||||
context->is_source = TRUE;
|
context->is_source = TRUE;
|
||||||
context->formats = gdk_content_formats_ref (formats);
|
context->formats = gdk_content_formats_ref (formats);
|
||||||
@ -544,9 +545,10 @@ _gdk_wayland_drop_context_new (GdkDisplay *display,
|
|||||||
GdkWaylandDragContext *context_wayland;
|
GdkWaylandDragContext *context_wayland;
|
||||||
GdkDragContext *context;
|
GdkDragContext *context;
|
||||||
|
|
||||||
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT, NULL);
|
context_wayland = g_object_new (GDK_TYPE_WAYLAND_DRAG_CONTEXT,
|
||||||
|
"display", display,
|
||||||
|
NULL);
|
||||||
context = GDK_DRAG_CONTEXT (context_wayland);
|
context = GDK_DRAG_CONTEXT (context_wayland);
|
||||||
context->display = display;
|
|
||||||
context->is_source = FALSE;
|
context->is_source = FALSE;
|
||||||
context->formats = gdk_content_formats_new (NULL, 0);
|
context->formats = gdk_content_formats_new (NULL, 0);
|
||||||
|
|
||||||
|
@ -238,9 +238,10 @@ gdk_drag_context_new (GdkDisplay *display)
|
|||||||
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
|
GdkWin32Display *win32_display = GDK_WIN32_DISPLAY (display);
|
||||||
GdkDragContext *context;
|
GdkDragContext *context;
|
||||||
|
|
||||||
context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT, NULL);
|
context_win32 = g_object_new (GDK_TYPE_WIN32_DRAG_CONTEXT,
|
||||||
|
"display", display,
|
||||||
|
NULL);
|
||||||
context = GDK_DRAG_CONTEXT(context_win32);
|
context = GDK_DRAG_CONTEXT(context_win32);
|
||||||
context->display = display;
|
|
||||||
|
|
||||||
gdk_drag_context_set_device (context, gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
|
gdk_drag_context_set_device (context, gdk_seat_get_pointer (gdk_display_get_default_seat (display)));
|
||||||
|
|
||||||
|
@ -1134,19 +1134,6 @@ send_client_message_async_cb (Window window,
|
|||||||
g_object_unref (context);
|
g_object_unref (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static GdkDisplay *
|
|
||||||
gdk_drag_context_get_display (GdkDragContext *context)
|
|
||||||
{
|
|
||||||
if (context->source_window)
|
|
||||||
return GDK_WINDOW_DISPLAY (context->source_window);
|
|
||||||
else if (context->dest_window)
|
|
||||||
return GDK_WINDOW_DISPLAY (context->dest_window);
|
|
||||||
|
|
||||||
g_assert_not_reached ();
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
send_client_message_async (GdkDragContext *context,
|
send_client_message_async (GdkDragContext *context,
|
||||||
Window window,
|
Window window,
|
||||||
@ -1672,10 +1659,11 @@ xdnd_enter_filter (GdkXEvent *xev,
|
|||||||
display_x11->current_dest_drag = NULL;
|
display_x11->current_dest_drag = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
context_x11 = (GdkX11DragContext *)g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
|
context_x11 = g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
|
||||||
|
"display", display,
|
||||||
|
NULL);
|
||||||
context = (GdkDragContext *)context_x11;
|
context = (GdkDragContext *)context_x11;
|
||||||
|
|
||||||
context->display = display;
|
|
||||||
context->protocol = GDK_DRAG_PROTO_XDND;
|
context->protocol = GDK_DRAG_PROTO_XDND;
|
||||||
context_x11->version = version;
|
context_x11->version = version;
|
||||||
|
|
||||||
@ -1984,9 +1972,10 @@ _gdk_x11_window_drag_begin (GdkWindow *window,
|
|||||||
{
|
{
|
||||||
GdkDragContext *context;
|
GdkDragContext *context;
|
||||||
|
|
||||||
context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT, NULL);
|
context = (GdkDragContext *) g_object_new (GDK_TYPE_X11_DRAG_CONTEXT,
|
||||||
|
"display", gdk_window_get_display (window),
|
||||||
|
NULL);
|
||||||
|
|
||||||
context->display = gdk_window_get_display (window);
|
|
||||||
context->is_source = TRUE;
|
context->is_source = TRUE;
|
||||||
context->source_window = window;
|
context->source_window = window;
|
||||||
g_object_ref (window);
|
g_object_ref (window);
|
||||||
|
Loading…
Reference in New Issue
Block a user