diff options
author | Benjamin Otte <otte@redhat.com> | 2018-05-07 17:31:26 +0200 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2018-05-07 18:55:09 +0200 |
commit | 34d1ebc562c83136cd778749d86abfee58e28627 (patch) | |
tree | d5bc504dae584cc9f4fbb06b3c85eb196142af0f /gdk/gdkdnd.c | |
parent | 80f5fd8435961c012c8c7202df3192631d564c6c (diff) | |
download | gtk+-34d1ebc562c83136cd778749d86abfee58e28627.tar.gz |
dnd: Make "formats" a construct-only property
... and hide the member variable inside the DragContextPrivate.
Diffstat (limited to 'gdk/gdkdnd.c')
-rw-r--r-- | gdk/gdkdnd.c | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index ae90dbdd96..191ef7eb75 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -41,6 +41,7 @@ struct _GdkDragContextPrivate { GdkDisplay *display; GdkDevice *device; + GdkContentFormats *formats; }; static struct { @@ -131,9 +132,11 @@ gdk_drag_context_get_display (GdkDragContext *context) GdkContentFormats * gdk_drag_context_get_formats (GdkDragContext *context) { + GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); + g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); - return context->formats; + return priv->formats; } /** @@ -255,7 +258,10 @@ gdk_drag_context_set_property (GObject *gobject, case PROP_CONTENT: context->content = g_value_dup_object (value); if (context->content) - context->formats = gdk_content_provider_ref_formats (context->content); + { + g_assert (priv->formats == NULL); + priv->formats = gdk_content_provider_ref_formats (context->content); + } break; case PROP_DEVICE: @@ -264,6 +270,23 @@ gdk_drag_context_set_property (GObject *gobject, priv->display = gdk_device_get_display (priv->device); break; + case PROP_FORMATS: + if (priv->formats) + { + GdkContentFormats *override = g_value_dup_boxed (value); + if (override) + { + gdk_content_formats_unref (priv->formats); + priv->formats = override; + } + } + else + { + priv->formats = g_value_dup_boxed (value); + g_assert (priv->formats != NULL); + } + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; @@ -294,7 +317,7 @@ gdk_drag_context_get_property (GObject *gobject, break; case PROP_FORMATS: - g_value_set_boxed (value, context->formats); + g_value_set_boxed (value, priv->formats); break; default: @@ -307,11 +330,12 @@ static void gdk_drag_context_finalize (GObject *object) { GdkDragContext *context = GDK_DRAG_CONTEXT (object); + GdkDragContextPrivate *priv = gdk_drag_context_get_instance_private (context); contexts = g_list_remove (contexts, context); g_clear_object (&context->content); - g_clear_pointer (&context->formats, gdk_content_formats_unref); + g_clear_pointer (&priv->formats, gdk_content_formats_unref); if (context->source_surface) g_object_unref (context->source_surface); @@ -420,7 +444,8 @@ gdk_drag_context_class_init (GdkDragContextClass *klass) "Formats", "The possible formats for data", GDK_TYPE_CONTENT_FORMATS, - G_PARAM_READABLE | + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); |