[gtk/drop-target-name-collision] droptarget: Rename :drop to :current-drop




commit dc76e28e6745c41d689b21b8154c3f67f5f8d194
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jun 14 16:23:35 2021 -0400

    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.
    
    Fixes: #4028

 gtk/gtkdroptarget.c    | 43 +++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkdroptarget.h    |  5 ++++-
 gtk/gtknotebook.c      |  4 ++--
 gtk/gtkplacessidebar.c |  2 +-
 4 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/gtk/gtkdroptarget.c b/gtk/gtkdroptarget.c
index 24ff0427c2..3aa1fe5998 100644
--- a/gtk/gtkdroptarget.c
+++ b/gtk/gtkdroptarget.c
@@ -148,6 +148,7 @@ struct _GtkDropTargetClass
 enum {
   PROP_0,
   PROP_ACTIONS,
+  PROP_CURRENT_DROP,
   PROP_DROP,
   PROP_FORMATS,
   PROP_PRELOAD,
@@ -186,6 +187,7 @@ gtk_drop_target_end_drop (GtkDropTarget *self)
 
   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_CURRENT_DROP]);
 
   if (G_IS_VALUE (&self->value))
     {
@@ -320,6 +322,7 @@ gtk_drop_target_start_drop (GtkDropTarget *self,
 
   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_CURRENT_DROP]);
 
   if (self->preload)
     gtk_drop_target_load (self);
@@ -565,6 +568,7 @@ gtk_drop_target_get_property (GObject    *object,
       break;
 
     case PROP_DROP:
+    case PROP_CURRENT_DROP:
       g_value_set_object (value, self->drop);
       break;
 
@@ -623,12 +627,28 @@ gtk_drop_target_class_init (GtkDropTargetClass *class)
    * GtkDropTarget:drop: (attributes org.gtk.Property.get=gtk_drop_target_get_drop)
    *
    * The `GdkDrop` that is currently being performed.
+   *
+   * Deprecated: 4.4: Use [property@Gtk.DropTarget:current-drop] instead
    */
   properties[PROP_DROP] =
        g_param_spec_object ("drop",
                             P_("Drop"),
                             P_("Current 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);
 
   /**
@@ -1010,6 +1030,8 @@ gtk_drop_target_get_preload (GtkDropTarget *self)
  * If no drop operation is going on, %NULL is returned.
  *
  * Returns: (nullable) (transfer none): The current drop
+ *
+ * Deprecated: 4.4: Use [method@Gtk.DropTarget.get_current_drop] instead
  */
 GdkDrop *
 gtk_drop_target_get_drop (GtkDropTarget *self)
@@ -1019,6 +1041,26 @@ gtk_drop_target_get_drop (GtkDropTarget *self)
   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)
  * @self: a `GtkDropTarget`
@@ -1061,3 +1103,4 @@ gtk_drop_target_reject (GtkDropTarget *self)
 
   gtk_drop_target_end_drop (self);
 }
+
diff --git a/gtk/gtkdroptarget.h b/gtk/gtkdroptarget.h
index 4020f15648..12e652a533 100644
--- a/gtk/gtkdroptarget.h
+++ b/gtk/gtkdroptarget.h
@@ -71,9 +71,12 @@ void                    gtk_drop_target_set_preload      (GtkDropTarget
 GDK_AVAILABLE_IN_ALL
 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);
 
+GDK_AVAILABLE_IN_4_4
+GdkDrop *               gtk_drop_target_get_current_drop (GtkDropTarget         *self);
+
 GDK_AVAILABLE_IN_ALL
 const GValue *          gtk_drop_target_get_value        (GtkDropTarget         *self);
 
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 57b87f5f2e..76115f09c6 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -3379,7 +3379,7 @@ gtk_notebook_drag_motion (GtkDropTarget *dest,
                           double         y,
                           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;
 
   notebook->mouse_x = x;
@@ -3404,7 +3404,7 @@ gtk_notebook_drag_drop (GtkDropTarget *dest,
                         double         y,
                         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;
   GtkNotebookPage *page = g_value_get_object (value);
 
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index d4a1f74e5d..f1081bfd7c 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -1851,7 +1851,7 @@ drag_drop_callback (GtkDropTarget    *target,
           emit_drag_perform_drop (sidebar,
                                   dest_file,
                                   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);
         }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]