droptarget: Rename :drop to :current-drop

Rename the GtkDropTraget:drop property to :current-drop,
to avoid naming collision with the signal of the same
name.

We leave the old property and getter in place, deprecated
and marked as non-introspectable.

Fixes: #4028
This commit is contained in:
Matthias Clasen 2021-06-14 16:23:35 -04:00
parent a6b4e53dca
commit b09087d634
4 changed files with 52 additions and 6 deletions

View File

@ -148,6 +148,7 @@ struct _GtkDropTargetClass
enum { enum {
PROP_0, PROP_0,
PROP_ACTIONS, PROP_ACTIONS,
PROP_CURRENT_DROP,
PROP_DROP, PROP_DROP,
PROP_FORMATS, PROP_FORMATS,
PROP_PRELOAD, PROP_PRELOAD,
@ -186,6 +187,7 @@ gtk_drop_target_end_drop (GtkDropTarget *self)
g_clear_object (&self->drop); g_clear_object (&self->drop);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DROP]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DROP]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CURRENT_DROP]);
if (G_IS_VALUE (&self->value)) if (G_IS_VALUE (&self->value))
{ {
@ -320,6 +322,7 @@ gtk_drop_target_start_drop (GtkDropTarget *self,
self->drop = g_object_ref (drop); self->drop = g_object_ref (drop);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DROP]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DROP]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CURRENT_DROP]);
if (self->preload) if (self->preload)
gtk_drop_target_load (self); gtk_drop_target_load (self);
@ -565,6 +568,7 @@ gtk_drop_target_get_property (GObject *object,
break; break;
case PROP_DROP: case PROP_DROP:
case PROP_CURRENT_DROP:
g_value_set_object (value, self->drop); g_value_set_object (value, self->drop);
break; break;
@ -620,15 +624,31 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
/** /**
* GtkDropTarget:drop: (attributes org.gtk.Property.get=gtk_drop_target_get_drop) * GtkDropTarget:drop: (attributes org.gtk.Property.get=gtk_drop_target_get_drop) (skip)
* *
* The `GdkDrop` that is currently being performed. * The `GdkDrop` that is currently being performed.
*
* Deprecated: 4.4: Use [property@Gtk.DropTarget:current-drop] instead
*/ */
properties[PROP_DROP] = properties[PROP_DROP] =
g_param_spec_object ("drop", g_param_spec_object ("drop",
P_("Drop"), P_("Drop"),
P_("Current drop"), P_("Current drop"),
GDK_TYPE_DROP, GDK_TYPE_DROP,
GTK_PARAM_READABLE | G_PARAM_DEPRECATED);
/**
* GtkDropTarget:current-drop: (attributes org.gtk.Property.get=gtk_drop_target_get_current_drop)
*
* The `GdkDrop` that is currently being performed.
*
* Since: 4.4
*/
properties[PROP_CURRENT_DROP] =
g_param_spec_object ("current-drop",
P_("Current drop"),
P_("Current drop"),
GDK_TYPE_DROP,
GTK_PARAM_READABLE); GTK_PARAM_READABLE);
/** /**
@ -1010,6 +1030,8 @@ gtk_drop_target_get_preload (GtkDropTarget *self)
* If no drop operation is going on, %NULL is returned. * If no drop operation is going on, %NULL is returned.
* *
* Returns: (nullable) (transfer none): The current drop * Returns: (nullable) (transfer none): The current drop
*
* Deprecated: 4.4: Use [method@Gtk.DropTarget.get_current_drop] instead
*/ */
GdkDrop * GdkDrop *
gtk_drop_target_get_drop (GtkDropTarget *self) gtk_drop_target_get_drop (GtkDropTarget *self)
@ -1019,6 +1041,26 @@ gtk_drop_target_get_drop (GtkDropTarget *self)
return self->drop; return self->drop;
} }
/**
* gtk_drop_target_get_current_drop: (attributes org.gtk.Method.get_property=current-drop)
* @self: a `GtkDropTarget`
*
* Gets the currently handled drop operation.
*
* If no drop operation is going on, %NULL is returned.
*
* Returns: (nullable) (transfer none): The current drop
*
* Since: 4.4
*/
GdkDrop *
gtk_drop_target_get_current_drop (GtkDropTarget *self)
{
g_return_val_if_fail (GTK_IS_DROP_TARGET (self), NULL);
return self->drop;
}
/** /**
* gtk_drop_target_get_value: (attributes org.gtk.Method.get_property=value) * gtk_drop_target_get_value: (attributes org.gtk.Method.get_property=value)
* @self: a `GtkDropTarget` * @self: a `GtkDropTarget`
@ -1044,7 +1086,7 @@ gtk_drop_target_get_value (GtkDropTarget *self)
* *
* Rejects the ongoing drop operation. * Rejects the ongoing drop operation.
* *
* If no drop operation is ongoing, i.e when [property@Gtk.DropTarget:drop] * If no drop operation is ongoing, i.e when [property@Gtk.DropTarget:current-drop]
* is %NULL, this function does nothing. * is %NULL, this function does nothing.
* *
* This function should be used when delaying the decision * This function should be used when delaying the decision
@ -1061,3 +1103,4 @@ gtk_drop_target_reject (GtkDropTarget *self)
gtk_drop_target_end_drop (self); gtk_drop_target_end_drop (self);
} }

View File

@ -71,9 +71,12 @@ void gtk_drop_target_set_preload (GtkDropTarget
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
gboolean gtk_drop_target_get_preload (GtkDropTarget *self); gboolean gtk_drop_target_get_preload (GtkDropTarget *self);
GDK_AVAILABLE_IN_ALL GDK_DEPRECATED_IN_4_4_FOR(gtk_drop_target_get_current_drop)
GdkDrop * gtk_drop_target_get_drop (GtkDropTarget *self); GdkDrop * gtk_drop_target_get_drop (GtkDropTarget *self);
GDK_AVAILABLE_IN_4_4
GdkDrop * gtk_drop_target_get_current_drop (GtkDropTarget *self);
GDK_AVAILABLE_IN_ALL GDK_AVAILABLE_IN_ALL
const GValue * gtk_drop_target_get_value (GtkDropTarget *self); const GValue * gtk_drop_target_get_value (GtkDropTarget *self);

View File

@ -3379,7 +3379,7 @@ gtk_notebook_drag_motion (GtkDropTarget *dest,
double y, double y,
GtkNotebook *notebook) GtkNotebook *notebook)
{ {
GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_drop (dest)); GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_current_drop (dest));
GtkNotebook *source; GtkNotebook *source;
notebook->mouse_x = x; notebook->mouse_x = x;
@ -3404,7 +3404,7 @@ gtk_notebook_drag_drop (GtkDropTarget *dest,
double y, double y,
GtkNotebook *self) GtkNotebook *self)
{ {
GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_drop (dest)); GdkDrag *drag = gdk_drop_get_drag (gtk_drop_target_get_current_drop (dest));
GtkNotebook *source; GtkNotebook *source;
GtkNotebookPage *page = g_value_get_object (value); GtkNotebookPage *page = g_value_get_object (value);

View File

@ -1851,7 +1851,7 @@ drag_drop_callback (GtkDropTarget *target,
emit_drag_perform_drop (sidebar, emit_drag_perform_drop (sidebar,
dest_file, dest_file,
g_value_get_boxed (value), g_value_get_boxed (value),
gdk_drop_get_actions (gtk_drop_target_get_drop (target))); gdk_drop_get_actions (gtk_drop_target_get_current_drop (target)));
g_object_unref (dest_file); g_object_unref (dest_file);
} }