summaryrefslogtreecommitdiff
path: root/gdk/gdkdnd.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2018-04-30 14:10:44 +0200
committerBenjamin Otte <otte@redhat.com>2018-06-18 23:49:19 +0200
commitf247d268d4aa02c945ed7297080b685d9df79464 (patch)
tree879b3e327a739098be808d0190a3c86b29e7e2ad /gdk/gdkdnd.c
parent841a29837e5929bd07a45081e5eec43c1bc910f5 (diff)
downloadgtk+-f247d268d4aa02c945ed7297080b685d9df79464.tar.gz
dnd: Add GdkDrop base class for GdkDragContext
The ultimate goal of this patch series is to split GdkDragContext into GdkDrop + GdkDrag classes for the destination and source side of a dnd operation. The refactoring is meant to work something like this: 1. Introduce GdkDrop as a base class 2. Make all drop related code (like GdkEvent) use GdkDrop instead of GdkDragContext. Move/duplicate APIs to allow that. 3. Port all drop contexts in the backends from GdkDragContext to GdkDrop 4. Delete all APIs in GdkDragContext that aren't needed anymore. 5. Make GdkDragContext no longer a GdkDrop subclass 6. Rename GdkDragContext to GdkDrag
Diffstat (limited to 'gdk/gdkdnd.c')
-rw-r--r--gdk/gdkdnd.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c
index 191ef7eb75..083adf9a5a 100644
--- a/gdk/gdkdnd.c
+++ b/gdk/gdkdnd.c
@@ -35,12 +35,16 @@
#include "gdkenumtypes.h"
#include "gdkeventsprivate.h"
+#define DROP_SUBCLASS 1
+
typedef struct _GdkDragContextPrivate GdkDragContextPrivate;
struct _GdkDragContextPrivate
{
+#ifndef DROP_SUBCLASS
GdkDisplay *display;
GdkDevice *device;
+#endif
GdkContentFormats *formats;
};
@@ -60,9 +64,11 @@ static struct {
enum {
PROP_0,
PROP_CONTENT,
+#ifndef DROP_SUBCLASS
PROP_DEVICE,
PROP_DISPLAY,
PROP_FORMATS,
+#endif
N_PROPERTIES
};
@@ -78,7 +84,7 @@ static GParamSpec *properties[N_PROPERTIES] = { NULL, };
static guint signals[N_SIGNALS] = { 0 };
static GList *contexts = NULL;
-G_DEFINE_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
+G_DEFINE_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, GDK_TYPE_DROP)
/**
* SECTION:dnd
@@ -114,11 +120,15 @@ G_DEFINE_TYPE_WITH_PRIVATE (GdkDragContext, gdk_drag_context, G_TYPE_OBJECT)
GdkDisplay *
gdk_drag_context_get_display (GdkDragContext *context)
{
+#ifdef DROP_SUBCLASS
+ return gdk_drop_get_display (GDK_DROP (context));
+#else
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
return priv->display;
+#endif
}
/**
@@ -136,6 +146,12 @@ gdk_drag_context_get_formats (GdkDragContext *context)
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
+#ifdef DROP_SUBCLASS
+ GdkContentFormats *formats = gdk_drop_get_formats (GDK_DROP (context));
+
+ if (formats)
+ return formats;
+#endif
return priv->formats;
}
@@ -231,11 +247,15 @@ gdk_drag_context_get_dest_surface (GdkDragContext *context)
GdkDevice *
gdk_drag_context_get_device (GdkDragContext *context)
{
+#ifdef DROP_SUBCLASS
+ return gdk_drop_get_device (GDK_DROP (context));
+#else
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
return priv->device;
+#endif
}
static void
@@ -264,6 +284,7 @@ gdk_drag_context_set_property (GObject *gobject,
}
break;
+#ifndef DROP_SUBCLASS
case PROP_DEVICE:
priv->device = g_value_dup_object (value);
g_assert (priv->device != NULL);
@@ -286,6 +307,7 @@ gdk_drag_context_set_property (GObject *gobject,
g_assert (priv->formats != NULL);
}
break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
@@ -300,7 +322,9 @@ gdk_drag_context_get_property (GObject *gobject,
GParamSpec *pspec)
{
GdkDragContext *context = GDK_DRAG_CONTEXT (gobject);
+#ifndef DROP_SUBCLASS
GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context);
+#endif
switch (prop_id)
{
@@ -308,6 +332,7 @@ gdk_drag_context_get_property (GObject *gobject,
g_value_set_object (value, context->content);
break;
+#ifndef DROP_SUBCLASS
case PROP_DEVICE:
g_value_set_object (value, priv->device);
break;
@@ -319,6 +344,7 @@ gdk_drag_context_get_property (GObject *gobject,
case PROP_FORMATS:
g_value_set_boxed (value, priv->formats);
break;
+#endif
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
@@ -405,6 +431,7 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
+#ifndef DROP_SUBCLASS
/**
* GdkDragContext:device:
*
@@ -448,6 +475,7 @@ gdk_drag_context_class_init (GdkDragContextClass *klass)
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS |
G_PARAM_EXPLICIT_NOTIFY);
+#endif
/**
* GdkDragContext::cancel: