dnd: Make drag-motion and drag-drop signals use GdkDrop
authorBenjamin Otte <otte@redhat.com>
Thu, 17 May 2018 02:51:18 +0000 (04:51 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 18 Jun 2018 21:49:52 +0000 (23:49 +0200)
19 files changed:
gtk/gtkcalendar.c
gtk/gtkdnd.c
gtk/gtkdnd.h
gtk/gtkdragdest.c
gtk/gtkdragdest.h
gtk/gtkentry.c
gtk/gtkexpander.c
gtk/gtkfilechooserwidget.c
gtk/gtkiconview.c
gtk/gtkmarshalers.list
gtk/gtknotebook.c
gtk/gtkplacessidebar.c
gtk/gtkstackswitcher.c
gtk/gtktextview.c
gtk/gtktreeview.c
gtk/gtkwidget.c
gtk/gtkwidget.h
tests/testdnd.c
tests/testtoolbar.c

index 5ee5aad32f1e6287d9b67878dd76f4ad9d5a84a7..f946ced91d8bad274445ca1693d060b260614112 100644 (file)
@@ -315,17 +315,15 @@ static void     gtk_calendar_drag_data_received (GtkWidget        *widget,
                                                  GdkDrop          *drop,
                                                  GtkSelectionData *selection_data);
 static gboolean gtk_calendar_drag_motion        (GtkWidget        *widget,
-                                                 GdkDragContext   *context,
+                                                 GdkDrop          *drop,
                                                  gint              x,
-                                                 gint              y,
-                                                 guint             time);
+                                                 gint              y);
 static void     gtk_calendar_drag_leave         (GtkWidget        *widget,
                                                  GdkDrop          *drop);
 static gboolean gtk_calendar_drag_drop          (GtkWidget        *widget,
-                                                 GdkDragContext   *context,
+                                                 GdkDrop          *drop,
                                                  gint              x,
-                                                 gint              y,
-                                                 guint             time);
+                                                 gint              y);
 
 
 static void calendar_start_spinning (GtkCalendar *calendar,
@@ -2952,10 +2950,9 @@ gtk_calendar_drag_leave (GtkWidget *widget,
 
 static gboolean
 gtk_calendar_drag_motion (GtkWidget      *widget,
-                          GdkDragContext *context,
+                          GdkDrop        *drop,
                           gint            x,
-                          gint            y,
-                          guint           time)
+                          gint            y)
 {
   GtkCalendarPrivate *priv = GTK_CALENDAR (widget)->priv;
   GdkAtom target;
@@ -2966,13 +2963,13 @@ gtk_calendar_drag_motion (GtkWidget      *widget,
       gtk_drag_highlight (widget);
     }
 
-  target = gtk_drag_dest_find_target (widget, context, NULL);
-  if (target == NULL || gdk_drag_context_get_suggested_action (context) == 0)
-    gdk_drag_status (context, 0, time);
-  else if (get_status_pending (GDK_DROP (context)) == 0)
+  target = gtk_drag_dest_find_target (widget, drop, NULL);
+  if (target == NULL || gdk_drop_get_actions (drop) == 0)
+    gdk_drop_status (drop, 0);
+  else if (get_status_pending (drop) == 0)
     {
-      set_status_pending (GDK_DROP (context), gdk_drag_context_get_suggested_action (context));
-      gtk_drag_get_data (widget, context, target, time);
+      set_status_pending (drop, gdk_drop_get_actions (drop));
+      gtk_drag_get_data (widget, drop, target);
     }
 
   return TRUE;
@@ -2980,19 +2977,16 @@ gtk_calendar_drag_motion (GtkWidget      *widget,
 
 static gboolean
 gtk_calendar_drag_drop (GtkWidget      *widget,
-                        GdkDragContext *context,
+                        GdkDrop        *drop,
                         gint            x,
-                        gint            y,
-                        guint           time)
+                        gint            y)
 {
   GdkAtom target;
 
-  target = gtk_drag_dest_find_target (widget, context, NULL);
+  target = gtk_drag_dest_find_target (widget, drop, NULL);
   if (target != NULL)
     {
-      gtk_drag_get_data (widget, context,
-                         target,
-                         time);
+      gtk_drag_get_data (widget, drop, target);
       return TRUE;
     }
 
index 21534974f665170bc5ef2ac97f6df57027983b3b..15aaa39bb37ede9672223b9d67c7dbc05b2273b5 100644 (file)
@@ -154,10 +154,9 @@ static void     set_icon_helper (GdkDragContext    *context,
  ********************/
 
 typedef struct {
-  GdkDragContext *context;
+  GdkDrop *drop;
   GtkWidget *widget;
   const char *mime_type;
-  guint time;
 } GtkDragGetData;
 
 static void
@@ -185,7 +184,7 @@ gtk_drag_get_data_finish (GtkDragGetData *data,
               size >= 0)
             g_signal_emit_by_name (data->widget,
                                    "drag-data-received",
-                                   data->context,
+                                   data->drop,
                                    &sdata);
         }
     }
@@ -193,20 +192,30 @@ gtk_drag_get_data_finish (GtkDragGetData *data,
     {
       g_signal_emit_by_name (data->widget,
                              "drag-data-received",
-                             data->context,
+                             data->drop,
                              &sdata);
     }
   
   if (site && site->flags & GTK_DEST_DEFAULT_DROP)
     {
+      GdkDragAction action = site->actions & gdk_drop_get_actions (data->drop);
+
+      if (size == 0)
+        action = 0;
+
+      if (!gdk_drag_action_is_unique (action))
+        {
+          if (action & GDK_ACTION_COPY)
+            action = GDK_ACTION_COPY;
+          else if (action & GDK_ACTION_MOVE)
+            action = GDK_ACTION_MOVE;
+        }
 
-      gdk_drag_finish (data->context, 
-                       size > 0,
-                       data->time);
+      gdk_drop_finish (data->drop, action); 
     }
   
   g_object_unref (data->widget);
-  g_object_unref (data->context);
+  g_object_unref (data->drop);
   g_slice_free (GtkDragGetData, data);
 }
 
@@ -263,7 +272,7 @@ gtk_drag_get_data_got_stream (GObject      *source,
  * gtk_drag_get_data: (method)
  * @widget: the widget that will receive the
  *   #GtkWidget::drag-data-received signal
- * @context: the drag context
+ * @drop: the #GdkDrop
  * @target: the target (form of the data) to retrieve
  * @time_: a timestamp for retrieving the data. This will
  *   generally be the time received in a #GtkWidget::drag-motion
@@ -279,23 +288,21 @@ gtk_drag_get_data_got_stream (GObject      *source,
  * drops.
  */
 void
-gtk_drag_get_data (GtkWidget      *widget,
-                   GdkDragContext *context,
-                   GdkAtom         target,
-                   guint32         time_)
+gtk_drag_get_data (GtkWidget *widget,
+                   GdkDrop   *drop,
+                   GdkAtom    target)
 {
   GtkDragGetData *data;
 
   g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+  g_return_if_fail (GDK_IS_DROP (drop));
 
   data = g_slice_new0 (GtkDragGetData);
   data->widget = g_object_ref (widget);
-  data->context = g_object_ref (context);
+  data->drop = g_object_ref (drop);
   data->mime_type = target;
-  data->time = time_;
 
-  gdk_drop_read_async (GDK_DROP (context),
+  gdk_drop_read_async (drop,
                        (const gchar *[2]) { target, NULL },
                        G_PRIORITY_DEFAULT,
                        NULL,
@@ -682,7 +689,7 @@ gtk_drag_dest_motion (GtkWidget      *widget,
             }
         }
 
-      if (action && gtk_drag_dest_find_target (widget, context, NULL))
+      if (action && gtk_drag_dest_find_target (widget, GDK_DROP (context), NULL))
         {
           if (!site->have_drag)
             {
@@ -702,7 +709,7 @@ gtk_drag_dest_motion (GtkWidget      *widget,
     }
 
   g_signal_emit_by_name (widget, "drag-motion",
-                         context, x, y, time, &retval);
+                         context, x, y, &retval);
 
   return (site->flags & GTK_DEST_DEFAULT_MOTION) ? TRUE : retval;
 }
@@ -726,7 +733,7 @@ gtk_drag_dest_drop (GtkWidget      *widget,
 
   if (site->flags & GTK_DEST_DEFAULT_DROP)
     {
-      GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL);
+      GdkAtom target = gtk_drag_dest_find_target (widget, GDK_DROP (context), NULL);
 
       if (target == NULL)
         {
@@ -734,11 +741,11 @@ gtk_drag_dest_drop (GtkWidget      *widget,
           return TRUE;
         }
       else 
-        gtk_drag_get_data (widget, context, target, time);
+        gtk_drag_get_data (widget, GDK_DROP (context), target);
     }
 
   g_signal_emit_by_name (widget, "drag-drop",
-                         context, x, y, time, &retval);
+                         context, x, y, &retval);
 
   return (site->flags & GTK_DEST_DEFAULT_DROP) ? TRUE : retval;
 }
index df791ba6be0d534e6116d7763c526741c32623e3..2626ce02fb067c758a6dab9c53b59a232a87f170 100644 (file)
@@ -41,9 +41,8 @@ G_BEGIN_DECLS
 
 GDK_AVAILABLE_IN_ALL
 void gtk_drag_get_data (GtkWidget      *widget,
-                       GdkDragContext *context,
-                       GdkAtom         target,
-                       guint32         time_);
+                       GdkDrop        *drop,
+                       GdkAtom         target);
 
 GDK_AVAILABLE_IN_ALL
 GtkWidget *gtk_drag_get_source_widget (GdkDragContext *context);
index e5b65b398f87d2b5d272c4d63c28c20b94f6d6cc..d1dccd2100863c6410a35a5958560cbe95f480be 100644 (file)
@@ -380,11 +380,11 @@ gtk_drag_dest_get_track_motion (GtkWidget *widget)
 /**
  * gtk_drag_dest_find_target: (method)
  * @widget: drag destination widget
- * @context: drag context
+ * @drop: #GdkDrop
  * @target_list: (allow-none): list of droppable targets, or %NULL to use
  *    gtk_drag_dest_get_target_list (@widget).
  *
- * Looks for a match between the supported targets of @context and the
+ * Looks for a match between the supported targets of @drop and the
  * @dest_target_list, returning the first matching target, otherwise
  * returning %NULL. @dest_target_list should usually be the return
  * value from gtk_drag_dest_get_target_list(), but some widgets may
@@ -397,11 +397,11 @@ gtk_drag_dest_get_track_motion (GtkWidget *widget)
  */
 const char *
 gtk_drag_dest_find_target (GtkWidget         *widget,
-                           GdkDragContext    *context,
+                           GdkDrop           *drop,
                            GdkContentFormats *target_list)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-  g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
+  g_return_val_if_fail (GDK_IS_DROP (drop), NULL);
 
   if (target_list == NULL)
     target_list = gtk_drag_dest_get_target_list (widget);
@@ -410,6 +410,6 @@ gtk_drag_dest_find_target (GtkWidget         *widget,
     return NULL;
 
   return gdk_content_formats_match_mime_type (target_list,
-                                              gdk_drag_context_get_formats (context));
+                                              gdk_drop_get_formats (drop));
 }
 
index b8c958715210e0b4627c7bba282c425c19bff546..f241f514a7e873f5b9ecfa56455386309192985d 100644 (file)
@@ -77,7 +77,7 @@ void gtk_drag_dest_unset (GtkWidget          *widget);
 
 GDK_AVAILABLE_IN_ALL
 const char *            gtk_drag_dest_find_target       (GtkWidget              *widget,
-                                                         GdkDragContext         *context,
+                                                         GdkDrop                *drop,
                                                          GdkContentFormats      *target_list);
 GDK_AVAILABLE_IN_ALL
 GdkContentFormats*      gtk_drag_dest_get_target_list   (GtkWidget              *widget);
index 22bdb055a2be68a094a9840be280054681a30d95..47f972216312055cd46405faae6010c407e7d016 100644 (file)
@@ -437,15 +437,13 @@ static void   gtk_entry_display_changed      (GtkWidget        *widget,
                                              GdkDisplay       *old_display);
 
 static gboolean gtk_entry_drag_drop          (GtkWidget        *widget,
-                                              GdkDragContext   *context,
+                                              GdkDrop          *drop,
                                               gint              x,
-                                              gint              y,
-                                              guint             time);
+                                              gint              y);
 static gboolean gtk_entry_drag_motion        (GtkWidget        *widget,
-                                             GdkDragContext   *context,
+                                              GdkDrop          *drop,
                                              gint              x,
-                                             gint              y,
-                                             guint             time);
+                                             gint              y);
 static void     gtk_entry_drag_leave         (GtkWidget        *widget,
                                              GdkDrop          *drop);
 static void     gtk_entry_drag_data_received (GtkWidget        *widget,
@@ -8601,36 +8599,34 @@ gtk_entry_drag_leave (GtkWidget *widget,
 }
 
 static gboolean
-gtk_entry_drag_drop  (GtkWidget        *widget,
-                     GdkDragContext   *context,
-                     gint              x,
-                     gint              y,
-                     guint             time)
+gtk_entry_drag_drop (GtkWidget *widget,
+                    GdkDrop   *drop,
+                    gint       x,
+                    gint       y)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
   GdkAtom target = NULL;
 
   if (priv->editable)
-    target = gtk_drag_dest_find_target (widget, context, NULL);
+    target = gtk_drag_dest_find_target (widget, drop, NULL);
 
   if (target != NULL)
     {
       priv->drop_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
-      gtk_drag_get_data (widget, context, target, time);
+      gtk_drag_get_data (widget, drop, target);
     }
   else
-    gdk_drag_finish (context, FALSE, time);
+    gdk_drop_finish (drop, 0);
   
   return TRUE;
 }
 
 static gboolean
-gtk_entry_drag_motion (GtkWidget        *widget,
-                      GdkDragContext   *context,
-                      gint              x,
-                      gint              y,
-                      guint             time)
+gtk_entry_drag_motion (GtkWidget *widget,
+                       GdkDrop   *drop,
+                       gint       x,
+                       gint       y)
 {
   GtkEntry *entry = GTK_ENTRY (widget);
   GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
@@ -8642,7 +8638,7 @@ gtk_entry_drag_motion (GtkWidget        *widget,
   new_position = gtk_entry_find_position (entry, x + priv->scroll_offset);
 
   if (priv->editable &&
-      gtk_drag_dest_find_target (widget, context, NULL) != NULL)
+      gtk_drag_dest_find_target (widget, drop, NULL) != NULL)
     {
       suggested_action = GDK_ACTION_COPY | GDK_ACTION_MOVE;
 
@@ -8666,7 +8662,7 @@ gtk_entry_drag_motion (GtkWidget        *widget,
   if (show_placeholder_text (entry))
     priv->dnd_position = -1;
 
-  gdk_drag_status (context, suggested_action, time);
+  gdk_drop_status (drop, suggested_action);
   if (suggested_action == 0)
     gtk_drag_unhighlight (widget);
   else
index 8ab06558a1aaaea52a4062d545a639c725e11afb..31bd9b7ce19f4040ee21ba6c57322f020a0c33a3 100644 (file)
@@ -179,10 +179,9 @@ static void     gtk_expander_size_allocate  (GtkWidget           *widget,
 static gboolean gtk_expander_focus          (GtkWidget        *widget,
                                              GtkDirectionType  direction);
 static gboolean gtk_expander_drag_motion    (GtkWidget        *widget,
-                                             GdkDragContext   *context,
+                                             GdkDrop          *drop,
                                              gint              x,
-                                             gint              y,
-                                             guint             time);
+                                             gint              y);
 static void     gtk_expander_drag_leave     (GtkWidget        *widget,
                                              GdkDrop          *drop);
 
@@ -526,11 +525,10 @@ expand_timeout (gpointer data)
 }
 
 static gboolean
-gtk_expander_drag_motion (GtkWidget        *widget,
-                          GdkDragContext   *context,
-                          gint              x,
-                          gint              y,
-                          guint             time)
+gtk_expander_drag_motion (GtkWidget *widget,
+                          GdkDrop   *drop,
+                          gint       x,
+                          gint       y)
 {
   GtkExpander *expander = GTK_EXPANDER (widget);
   GtkExpanderPrivate *priv = gtk_expander_get_instance_private (expander);
index 346d97e7a180208510b3c0ce0c90269dd80d3c5f..458b977e07cbb18d5d988a81225065acb0bf9069 100644 (file)
@@ -1981,10 +1981,9 @@ file_list_drag_data_received_cb (GtkWidget        *widget,
 /* Don't do anything with the drag_drop signal */
 static gboolean
 file_list_drag_drop_cb (GtkWidget             *widget,
-                        GdkDragContext        *context,
+                        GdkDrop               *drop,
                         gint                   x,
                         gint                   y,
-                        guint                  time_,
                         GtkFileChooserWidget *impl)
 {
   g_signal_stop_emission_by_name (widget, "drag-drop");
@@ -2005,10 +2004,9 @@ file_list_drag_begin_cb (GtkWidget            *widget,
    dropping the dragged item onto a tree item */
 static gboolean
 file_list_drag_motion_cb (GtkWidget             *widget,
-                          GdkDragContext        *context,
+                          GdkDrop               *drop,
                           gint                   x,
                           gint                   y,
-                          guint                  time_,
                           GtkFileChooserWidget *impl)
 {
   g_signal_stop_emission_by_name (widget, "drag-motion");
index b6edde257cf081ec804a050ef9ee46f93e194f4b..63d8147cfaadc095387f9f8dae629589793b72f9 100644 (file)
@@ -291,15 +291,13 @@ static void gtk_icon_view_drag_data_delete (GtkWidget        *widget,
 static void     gtk_icon_view_drag_leave         (GtkWidget        *widget,
                                                   GdkDrop          *drop);
 static gboolean gtk_icon_view_drag_motion        (GtkWidget        *widget,
-                                                  GdkDragContext   *context,
+                                                  GdkDrop          *drop,
                                                   gint              x,
-                                                  gint              y,
-                                                  guint             time);
+                                                  gint              y);
 static gboolean gtk_icon_view_drag_drop          (GtkWidget        *widget,
-                                                  GdkDragContext   *context,
+                                                  GdkDrop          *drop,
                                                   gint              x,
-                                                  gint              y,
-                                                  guint             time);
+                                                  gint              y);
 static void     gtk_icon_view_drag_data_received (GtkWidget        *widget,
                                                   GdkDrop          *drop,
                                                   GtkSelectionData *selection_data);
@@ -5878,7 +5876,7 @@ drag_scroll_timeout (gpointer data)
 
 static gboolean
 set_destination (GtkIconView    *icon_view,
-                GdkDragContext *context,
+                GdkDrop        *drop,
                 gint            x,
                 gint            y,
                 GdkDragAction  *suggested_action,
@@ -5911,7 +5909,7 @@ set_destination (GtkIconView    *icon_view,
       return FALSE; /* no longer a drop site */
     }
 
-  *target = gtk_drag_dest_find_target (widget, context,
+  *target = gtk_drag_dest_find_target (widget, drop,
                                        gtk_drag_dest_get_target_list (widget));
   if (*target == NULL)
     return FALSE;
@@ -5963,19 +5961,7 @@ set_destination (GtkIconView    *icon_view,
 out:
   if (can_drop)
     {
-      GtkWidget *source_widget;
-
-      *suggested_action = gdk_drag_context_get_suggested_action (context);
-      source_widget = gtk_drag_get_source_widget (context);
-
-      if (source_widget == widget)
-        {
-          /* Default to MOVE, unless the user has
-           * pressed ctrl or shift to affect available actions
-           */
-          if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0)
-            *suggested_action = GDK_ACTION_MOVE;
-        }
+      *suggested_action = GDK_ACTION_ALL;
 
       gtk_icon_view_set_drag_dest_item (GTK_ICON_VIEW (widget),
                                        path, pos);
@@ -6232,11 +6218,10 @@ gtk_icon_view_drag_leave (GtkWidget *widget,
 }
 
 static gboolean 
-gtk_icon_view_drag_motion (GtkWidget      *widget,
-                          GdkDragContext *context,
-                          gint            x,
-                          gint            y,
-                          guint           time)
+gtk_icon_view_drag_motion (GtkWidget *widget,
+                          GdkDrop   *drop,
+                          gint       x,
+                          gint       y)
 {
   GtkTreePath *path = NULL;
   GtkIconViewDropPosition pos;
@@ -6247,7 +6232,7 @@ gtk_icon_view_drag_motion (GtkWidget      *widget,
 
   icon_view = GTK_ICON_VIEW (widget);
 
-  if (!set_destination (icon_view, context, x, y, &suggested_action, &target))
+  if (!set_destination (icon_view, drop, x, y, &suggested_action, &target))
     return FALSE;
 
   icon_view->priv->event_last_x = x;
@@ -6261,7 +6246,7 @@ gtk_icon_view_drag_motion (GtkWidget      *widget,
   if (path == NULL && !empty)
     {
       /* Can't drop here. */
-      gdk_drag_status (context, 0, time);
+      gdk_drop_status (drop, 0);
     }
   else
     {
@@ -6276,13 +6261,13 @@ gtk_icon_view_drag_motion (GtkWidget      *widget,
           /* Request data so we can use the source row when
            * determining whether to accept the drop
            */
-          set_status_pending (GDK_DROP (context), suggested_action);
-          gtk_drag_get_data (widget, context, target, time);
+          set_status_pending (drop, suggested_action);
+          gtk_drag_get_data (widget, drop, target);
         }
       else
         {
-          set_status_pending (GDK_DROP (context), 0);
-          gdk_drag_status (context, suggested_action, time);
+          set_status_pending (drop, 0);
+          gdk_drop_status (drop, suggested_action);
         }
     }
 
@@ -6293,11 +6278,10 @@ gtk_icon_view_drag_motion (GtkWidget      *widget,
 }
 
 static gboolean 
-gtk_icon_view_drag_drop (GtkWidget      *widget,
-                        GdkDragContext *context,
-                        gint            x,
-                        gint            y,
-                        guint           time)
+gtk_icon_view_drag_drop (GtkWidget *widget,
+                        GdkDrop   *drop,
+                        gint       x,
+                        gint       y)
 {
   GtkIconView *icon_view;
   GtkTreePath *path;
@@ -6317,7 +6301,7 @@ gtk_icon_view_drag_drop (GtkWidget      *widget,
   if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag-drop"))
     return FALSE;
 
-  if (!set_destination (icon_view, context, x, y, &suggested_action, &target))
+  if (!set_destination (icon_view, drop, x, y, &suggested_action, &target))
     return FALSE;
   
   path = get_logical_destination (icon_view, &drop_append_mode);
@@ -6327,8 +6311,8 @@ gtk_icon_view_drag_drop (GtkWidget      *widget,
       /* in case a motion had requested drag data, change things so we
        * treat drag data receives as a drop.
        */
-      set_status_pending (GDK_DROP (context), 0);
-      set_dest_row (GDK_DROP (context), model, path, 
+      set_status_pending (drop, 0);
+      set_dest_row (drop, model, path, 
                    icon_view->priv->empty_view_drop, drop_append_mode);
     }
 
@@ -6340,20 +6324,45 @@ gtk_icon_view_drag_drop (GtkWidget      *widget,
 
   if (target != NULL)
     {
-      gtk_drag_get_data (widget, context, target, time);
+      gtk_drag_get_data (widget, drop, target);
       return TRUE;
     }
   else
     return FALSE;
 }
 
+static GdkDragAction
+gtk_icon_view_get_action (GtkWidget *treeview,
+                          GdkDrop   *drop)
+{
+  GdkDragContext *drag = gdk_drop_get_drag (drop);
+  GtkWidget *source_widget = gtk_drag_get_source_widget (drag);
+  GdkDragAction actions;
+
+  actions = gdk_drop_get_actions (drop);
+
+  if (source_widget == treeview &&
+      actions & GDK_ACTION_MOVE)
+    return GDK_ACTION_MOVE;
+
+  if (actions & GDK_ACTION_COPY)
+    return GDK_ACTION_COPY;
+
+  if (actions & GDK_ACTION_MOVE)
+    return GDK_ACTION_MOVE;
+
+  if (actions & GDK_ACTION_LINK)
+    return GDK_ACTION_LINK;
+
+  return 0;
+}
+
 static void
 gtk_icon_view_drag_data_received (GtkWidget        *widget,
                                  GdkDrop          *drop,
                                  GtkSelectionData *selection_data)
 {
   GtkTreePath *path;
-  gboolean accepted = FALSE;
   GtkTreeModel *model;
   GtkIconView *icon_view;
   GtkTreePath *dest_row;
@@ -6412,13 +6421,16 @@ gtk_icon_view_drag_data_received (GtkWidget        *widget,
 
   if (gtk_selection_data_get_length (selection_data) >= 0)
     {
-      if (gtk_tree_drag_dest_drag_data_received (GTK_TREE_DRAG_DEST (model),
-                                                 dest_row,
-                                                 selection_data))
-        accepted = TRUE;
+      suggested_action = gtk_icon_view_get_action (widget, drop);
+
+      if (suggested_action &&
+          !gtk_tree_drag_dest_drag_data_received (GTK_TREE_DRAG_DEST (model),
+                                                  dest_row,
+                                                  selection_data))
+        suggested_action = 0;
     }
 
-  gdk_drop_finish (drop, accepted ? suggested_action : 0);
+  gdk_drop_finish (drop, suggested_action);
 
   gtk_tree_path_free (dest_row);
 
index 0c11e01103c04eda6bb52feab7e6103b37b50128..edd509031af9626c27909b33f5a61abdaf074d3b 100644 (file)
@@ -29,7 +29,7 @@ BOOLEAN:ENUM,DOUBLE
 BOOLEAN:ENUM,INT
 BOOLEAN:OBJECT
 BOOLEAN:OBJECT,UINT,FLAGS
-BOOLEAN:OBJECT,INT,INT,UINT
+BOOLEAN:OBJECT,INT,INT
 BOOLEAN:OBJECT,STRING,STRING,BOXED
 BOOLEAN:OBJECT,BOXED
 BOOLEAN:OBJECT,OBJECT,BOXED
index a30060de06c4ac2570e3630e9c5e8dc262857c42..b9e3b81ba2524454667c71b9eaa4f6310b1a0378 100644 (file)
@@ -392,17 +392,15 @@ static gboolean gtk_notebook_drag_failed     (GtkWidget        *widget,
                                               GdkDragContext   *context,
                                               GtkDragResult     result);
 static gboolean gtk_notebook_drag_motion     (GtkWidget        *widget,
-                                              GdkDragContext   *context,
+                                              GdkDrop          *drop,
                                               gint              x,
-                                              gint              y,
-                                              guint             time);
+                                              gint              y);
 static void gtk_notebook_drag_leave          (GtkWidget        *widget,
                                               GdkDrop          *drop);
 static gboolean gtk_notebook_drag_drop       (GtkWidget        *widget,
-                                              GdkDragContext   *context,
+                                              GdkDrop          *drop,
                                               gint              x,
-                                              gint              y,
-                                              guint             time);
+                                              gint              y);
 static void gtk_notebook_drag_data_get       (GtkWidget        *widget,
                                               GdkDragContext   *context,
                                               GtkSelectionData *data,
@@ -3018,11 +3016,10 @@ gtk_notebook_switch_tab_timeout (gpointer data)
 }
 
 static gboolean
-gtk_notebook_drag_motion (GtkWidget      *widget,
-                          GdkDragContext *context,
-                          gint            x,
-                          gint            y,
-                          guint           time)
+gtk_notebook_drag_motion (GtkWidget *widget,
+                          GdkDrop   *drop,
+                          gint       x,
+                          gint       y)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPrivate *priv = notebook->priv;
@@ -3037,14 +3034,14 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
     {
       priv->click_child = arrow;
       gtk_notebook_set_scroll_timer (notebook);
-      gdk_drag_status (context, 0, time);
+      gdk_drop_status (drop, 0);
 
       retval = TRUE;
       goto out;
     }
 
   stop_scrolling (notebook);
-  target = gtk_drag_dest_find_target (widget, context, NULL);
+  target = gtk_drag_dest_find_target (widget, drop, NULL);
   tab_target = g_intern_static_string ("GTK_NOTEBOOK_TAB");
 
   if (target == tab_target)
@@ -3055,7 +3052,7 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
 
       retval = TRUE;
 
-      source = GTK_NOTEBOOK (gtk_drag_get_source_widget (context));
+      source = GTK_NOTEBOOK (gtk_drag_get_source_widget (gdk_drop_get_drag (drop)));
       g_assert (source->priv->cur_page != NULL);
       source_child = source->priv->cur_page->child;
 
@@ -3066,14 +3063,14 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
           !(widget == source_child ||
             gtk_widget_is_ancestor (widget, source_child)))
         {
-          gdk_drag_status (context, GDK_ACTION_MOVE, time);
+          gdk_drop_status (drop, GDK_ACTION_MOVE);
           goto out;
         }
       else
         {
           /* it's a tab, but doesn't share
            * ID with this notebook */
-          gdk_drag_status (context, 0, time);
+          gdk_drop_status (drop, 0);
         }
     }
 
@@ -3117,23 +3114,22 @@ gtk_notebook_drag_leave (GtkWidget *widget,
 }
 
 static gboolean
-gtk_notebook_drag_drop (GtkWidget        *widget,
-                        GdkDragContext   *context,
-                        gint              x,
-                        gint              y,
-                        guint             time)
+gtk_notebook_drag_drop (GtkWidget *widget,
+                        GdkDrop   *drop,
+                        gint       x,
+                        gint       y)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GdkAtom target, tab_target;
 
-  target = gtk_drag_dest_find_target (widget, context, NULL);
+  target = gtk_drag_dest_find_target (widget, drop, NULL);
   tab_target = g_intern_static_string ("GTK_NOTEBOOK_TAB");
 
   if (target == tab_target)
     {
       notebook->priv->mouse_x = x;
       notebook->priv->mouse_y = y;
-      gtk_drag_get_data (widget, context, target, time);
+      gtk_drag_get_data (widget, drop, target);
       return TRUE;
     }
 
index 9b147e8b834239308fd48697e6dd20494d6983f2..b13b8dad168bf32dbaedc7156c46a2e61aa28da8 100644 (file)
@@ -1620,20 +1620,19 @@ update_possible_drop_targets (GtkPlacesSidebar *sidebar,
 
 static gboolean
 get_drag_data (GtkWidget      *list_box,
-               GdkDragContext *context,
-               GtkListBoxRow  *row,
-               guint           time)
+               GdkDrop        *drop,
+               GtkListBoxRow  *row)
 {
   GdkAtom target;
 
-  target = gtk_drag_dest_find_target (list_box, context, NULL);
+  target = gtk_drag_dest_find_target (list_box, drop, NULL);
 
   if (target == NULL)
     return FALSE;
 
   if (row)
-    g_object_set_data_full (G_OBJECT (context), "places-sidebar-row", g_object_ref (row), g_object_unref);
-  gtk_drag_get_data (list_box, context, target, time);
+    g_object_set_data_full (G_OBJECT (drop), "places-sidebar-row", g_object_ref (row), g_object_unref);
+  gtk_drag_get_data (list_box, drop, target);
 
   return TRUE;
 }
@@ -1766,14 +1765,12 @@ create_placeholder_row (GtkPlacesSidebar *sidebar)
 }
 
 static gboolean
-drag_motion_callback (GtkWidget      *widget,
-                      GdkDragContext *context,
-                      gint            x,
-                      gint            y,
-                      guint           time,
-                      gpointer        user_data)
-{
-  GdkDrop *drop = GDK_DROP (context);
+drag_motion_callback (GtkWidget *widget,
+                      GdkDrop   *drop,
+                      gint       x,
+                      gint       y,
+                      gpointer   user_data)
+{
   gint action;
   GtkListBoxRow *row;
   GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
@@ -1790,7 +1787,7 @@ drag_motion_callback (GtkWidget      *widget,
 
   /* Nothing to do if no drag data */
   if (!sidebar->drag_data_received &&
-      !get_drag_data (sidebar->list_box, context, row, time))
+      !get_drag_data (sidebar->list_box, drop, row))
     goto out;
 
   /* Nothing to do if the target is not valid drop destination */
@@ -1896,7 +1893,7 @@ drag_motion_callback (GtkWidget      *widget,
 
   g_signal_stop_emission_by_name (sidebar->list_box, "drag-motion");
 
-  gdk_drag_status (context, action, time);
+  gdk_drop_status (drop, action);
 
   return TRUE;
 }
@@ -2144,12 +2141,11 @@ drag_leave_callback (GtkWidget *widget,
 }
 
 static gboolean
-drag_drop_callback (GtkWidget      *list_box,
-                    GdkDragContext *context,
-                    gint            x,
-                    gint            y,
-                    guint           time,
-                    gpointer        user_data)
+drag_drop_callback (GtkWidget *list_box,
+                    GdkDrop   *drop,
+                    gint       x,
+                    gint       y,
+                    gpointer   user_data)
 {
   gboolean retval = FALSE;
   GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (user_data);
@@ -2157,7 +2153,7 @@ drag_drop_callback (GtkWidget      *list_box,
 
   row = gtk_list_box_get_row_at_y (GTK_LIST_BOX (sidebar->list_box), y);
   sidebar->drop_occurred = TRUE;
-  retval = get_drag_data (sidebar->list_box, context, row, time);
+  retval = get_drag_data (sidebar->list_box, drop, row);
   g_signal_stop_emission_by_name (sidebar->list_box, "drag-drop");
 
   return retval;
index 7d70c969069a0fb80869a282343bcf4be6e9d152..bb3b692090ea0ad810aaddd40e647b96290bdcac 100644 (file)
@@ -291,11 +291,10 @@ gtk_stack_switcher_switch_timeout (gpointer data)
 }
 
 static gboolean
-gtk_stack_switcher_drag_motion (GtkWidget      *widget,
-                                GdkDragContext *context,
-                                gint            x,
-                                gint            y,
-                                guint           time)
+gtk_stack_switcher_drag_motion (GtkWidget *widget,
+                                GdkDrop   *drop,
+                                gint       x,
+                                gint       y)
 {
   GtkStackSwitcher *self = GTK_STACK_SWITCHER (widget);
   GtkStackSwitcherPrivate *priv;
index 65570f5780749596c6161259fc10f2d831730be6..e2371b6b7c71888e6d2e603cc1b26e6c2c050042 100644 (file)
@@ -431,15 +431,13 @@ static void gtk_text_view_drag_data_delete (GtkWidget        *widget,
 static void     gtk_text_view_drag_leave         (GtkWidget        *widget,
                                                   GdkDrop          *drop);
 static gboolean gtk_text_view_drag_motion        (GtkWidget        *widget,
-                                                  GdkDragContext   *context,
+                                                  GdkDrop          *drop,
                                                   gint              x,
-                                                  gint              y,
-                                                  guint             time);
+                                                  gint              y);
 static gboolean gtk_text_view_drag_drop          (GtkWidget        *widget,
-                                                  GdkDragContext   *context,
+                                                  GdkDrop          *drop,
                                                   gint              x,
-                                                  gint              y,
-                                                  guint             time);
+                                                  gint              y);
 static void     gtk_text_view_drag_data_received (GtkWidget        *widget,
                                                   GdkDrop          *drop,
                                                   GtkSelectionData *selection_data);
@@ -7718,11 +7716,10 @@ gtk_text_view_drag_leave (GtkWidget *widget,
 }
 
 static gboolean
-gtk_text_view_drag_motion (GtkWidget        *widget,
-                           GdkDragContext   *context,
-                           gint              x,
-                           gint              y,
-                           guint             time)
+gtk_text_view_drag_motion (GtkWidget *widget,
+                           GdkDrop   *drop,
+                           gint       x,
+                           gint       y)
 {
   GtkTextIter newplace;
   GtkTextView *text_view;
@@ -7754,7 +7751,7 @@ gtk_text_view_drag_motion (GtkWidget        *widget,
                                      &newplace,
                                      bx, by);  
 
-  target = gtk_drag_dest_find_target (widget, context,
+  target = gtk_drag_dest_find_target (widget, drop,
                                       gtk_drag_dest_get_target_list (widget));
 
   if (target == NULL)
@@ -7776,11 +7773,11 @@ gtk_text_view_drag_motion (GtkWidget        *widget,
   if (can_accept)
     {
       gtk_text_mark_set_visible (priv->dnd_mark, cursor_visible (text_view));
-      gdk_drag_status (context, GDK_ACTION_COPY | GDK_ACTION_MOVE, time);
+      gdk_drop_status (drop, GDK_ACTION_COPY | GDK_ACTION_MOVE);
     }
   else
     {
-      gdk_drag_status (context, 0, time);
+      gdk_drop_status (drop, 0);
       gtk_text_mark_set_visible (priv->dnd_mark, FALSE);
     }
 
@@ -7805,11 +7802,10 @@ gtk_text_view_drag_motion (GtkWidget        *widget,
 }
 
 static gboolean
-gtk_text_view_drag_drop (GtkWidget        *widget,
-                         GdkDragContext   *context,
-                         gint              x,
-                         gint              y,
-                         guint             time)
+gtk_text_view_drag_drop (GtkWidget *widget,
+                         GdkDrop   *drop,
+                         gint       x,
+                         gint       y)
 {
   GtkTextView *text_view;
   GtkTextViewPrivate *priv;
@@ -7831,12 +7827,12 @@ gtk_text_view_drag_drop (GtkWidget        *widget,
                                     priv->dnd_mark);
 
   if (gtk_text_iter_can_insert (&drop_point, priv->editable))
-    target = gtk_drag_dest_find_target (widget, context, NULL);
+    target = gtk_drag_dest_find_target (widget, drop, NULL);
 
   if (target != NULL)
-    gtk_drag_get_data (widget, context, target, time);
+    gtk_drag_get_data (widget, drop, target);
   else
-    gdk_drag_finish (context, FALSE, time);
+    gdk_drop_finish (drop, 0);
 
   return TRUE;
 }
index 1e27c17a8d45bfe4bb52750dcec0199f3e26931e..ce894c915ec4baee20af0ada48a66cd53b5eff95 100644 (file)
@@ -632,15 +632,13 @@ static void gtk_tree_view_drag_data_delete (GtkWidget        *widget,
 static void     gtk_tree_view_drag_leave         (GtkWidget        *widget,
                                                   GdkDrop          *drop);
 static gboolean gtk_tree_view_drag_motion        (GtkWidget        *widget,
-                                                  GdkDragContext   *context,
+                                                  GdkDrop          *drop,
                                                   gint              x,
-                                                  gint              y,
-                                                  guint             time);
+                                                  gint              y);
 static gboolean gtk_tree_view_drag_drop          (GtkWidget        *widget,
-                                                  GdkDragContext   *context,
+                                                  GdkDrop          *drop,
                                                   gint              x,
-                                                  gint              y,
-                                                  guint             time);
+                                                  gint              y);
 static void     gtk_tree_view_drag_data_received (GtkWidget        *widget,
                                                   GdkDrop          *drop,
                                                   GtkSelectionData *selection_data);
@@ -7130,7 +7128,7 @@ scroll_row_timeout (gpointer data)
 /* Returns TRUE if event should not be propagated to parent widgets */
 static gboolean
 set_destination_row (GtkTreeView    *tree_view,
-                     GdkDragContext *context,
+                     GdkDrop        *drop,
                      /* coordinates relative to the widget */
                      gint            x,
                      gint            y,
@@ -7168,7 +7166,7 @@ set_destination_row (GtkTreeView    *tree_view,
       return FALSE; /* no longer a drop site */
     }
 
-  *target = gtk_drag_dest_find_target (widget, context,
+  *target = gtk_drag_dest_find_target (widget, drop,
                                        gtk_drag_dest_get_target_list (widget));
   if (*target == NULL)
     {
@@ -7540,12 +7538,10 @@ gtk_tree_view_drag_leave (GtkWidget *widget,
 
 
 static gboolean
-gtk_tree_view_drag_motion (GtkWidget        *widget,
-                           GdkDragContext   *context,
-                          /* coordinates relative to the widget */
-                           gint              x,
-                           gint              y,
-                           guint             time)
+gtk_tree_view_drag_motion (GtkWidget *widget,
+                           GdkDrop   *drop,
+                           gint       x,
+                           gint       y)
 {
   gboolean empty;
   GtkTreePath *path = NULL;
@@ -7556,7 +7552,7 @@ gtk_tree_view_drag_motion (GtkWidget        *widget,
 
   tree_view = GTK_TREE_VIEW (widget);
 
-  if (!set_destination_row (tree_view, context, x, y, &suggested_action, &target))
+  if (!set_destination_row (tree_view, drop, x, y, &suggested_action, &target))
     return FALSE;
 
   tree_view->priv->event_last_x = x;
@@ -7570,7 +7566,7 @@ gtk_tree_view_drag_motion (GtkWidget        *widget,
   if (path == NULL && !empty)
     {
       /* Can't drop here. */
-      gdk_drag_status (context, 0, time);
+      gdk_drop_status (drop, 0);
     }
   else
     {
@@ -7592,13 +7588,13 @@ gtk_tree_view_drag_motion (GtkWidget        *widget,
           /* Request data so we can use the source row when
            * determining whether to accept the drop
            */
-          set_status_pending (GDK_DROP (context), suggested_action);
-          gtk_drag_get_data (widget, context, target, time);
+          set_status_pending (drop, suggested_action);
+          gtk_drag_get_data (widget, drop, target);
         }
       else
         {
-          set_status_pending (GDK_DROP (context), 0);
-          gdk_drag_status (context, suggested_action, time);
+          set_status_pending (drop, 0);
+          gdk_drop_status (drop, suggested_action);
         }
     }
 
@@ -7610,12 +7606,10 @@ gtk_tree_view_drag_motion (GtkWidget        *widget,
 
 
 static gboolean
-gtk_tree_view_drag_drop (GtkWidget        *widget,
-                         GdkDragContext   *context,
-                        /* coordinates relative to the widget */
-                         gint              x,
-                         gint              y,
-                         guint             time)
+gtk_tree_view_drag_drop (GtkWidget *widget,
+                         GdkDrop   *drop,
+                         gint       x,
+                         gint       y)
 {
   GtkTreeView *tree_view;
   GtkTreePath *path;
@@ -7641,7 +7635,7 @@ gtk_tree_view_drag_drop (GtkWidget        *widget,
   if (!check_model_dnd (model, GTK_TYPE_TREE_DRAG_DEST, "drag_drop"))
     return FALSE;
 
-  if (!set_destination_row (tree_view, context, x, y, &suggested_action, &target))
+  if (!set_destination_row (tree_view, drop, x, y, &suggested_action, &target))
     return FALSE;
 
   path = get_logical_dest_row (tree_view, &path_down_mode, &drop_append_mode);
@@ -7651,8 +7645,8 @@ gtk_tree_view_drag_drop (GtkWidget        *widget,
       /* in case a motion had requested drag data, change things so we
        * treat drag data receives as a drop.
        */
-      set_status_pending (GDK_DROP (context), 0);
-      set_dest_row (GDK_DROP (context), model, path,
+      set_status_pending (drop, 0);
+      set_dest_row (drop, model, path,
                     path_down_mode, tree_view->priv->empty_view_drop,
                     drop_append_mode);
     }
@@ -7667,7 +7661,7 @@ gtk_tree_view_drag_drop (GtkWidget        *widget,
 
   if (target != NULL)
     {
-      gtk_drag_get_data (widget, context, target, time);
+      gtk_drag_get_data (widget, drop, target);
       return TRUE;
     }
   else
index 18a02883f845990cbf8b145112b0eefb3813c4a5..a9768dde1cb1d0b8c0a4c68d45a870751e9898cb 100644 (file)
@@ -1830,10 +1830,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   /**
    * GtkWidget::drag-motion:
    * @widget: the object which received the signal
-   * @context: the drag context
+   * @drop: the #GdkDrop
    * @x: the x coordinate of the current cursor position
    * @y: the y coordinate of the current cursor position
-   * @time: the timestamp of the motion event
    *
    * The ::drag-motion signal is emitted on the drop site when the user
    * moves the cursor over the widget during a drag. The signal handler
@@ -1858,11 +1857,10 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    * the drop site with gtk_drag_highlight().
    * |[<!-- language="C" -->
    * static void
-   * drag_motion (GtkWidget      *widget,
-   *              GdkDragContext *context,
-   *              gint            x,
-   *              gint            y,
-   *              guint           time)
+   * drag_motion (GtkWidget *widget,
+   *              GdkDrop   *drop,
+   *              gint       x,
+   *              gint       y,
    * {
    *   GdkAtom target;
    *
@@ -1874,14 +1872,14 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    *      gtk_drag_highlight (widget);
    *    }
    *
-   *   target = gtk_drag_dest_find_target (widget, context, NULL);
+   *   target = gtk_drag_dest_find_target (widget, drop, NULL);
    *   if (target == NULL)
-   *     gdk_drag_status (context, 0, time);
+   *     gdk_drop_status (drop, 0);
    *   else
    *    {
    *      private_data->pending_status
-   *         = gdk_drag_context_get_suggested_action (context);
-   *      gtk_drag_get_data (widget, context, target, time);
+   *         = gdk_drop_get_actions (drop);
+   *      gtk_drag_get_data (widget, drop, target);
    *    }
    *
    *   return TRUE;
@@ -1889,12 +1887,8 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    *
    * static void
    * drag_data_received (GtkWidget        *widget,
-   *                     GdkDragContext   *context,
-   *                     gint              x,
-   *                     gint              y,
-   *                     GtkSelectionData *selection_data,
-   *                     guint             info,
-   *                     guint             time)
+   *                     GdkDrop          *drop,
+   *                     GtkSelectionData *selection_data)
    * {
    *   PrivateData *private_data = GET_PRIVATE_DATA (widget);
    *
@@ -1909,11 +1903,9 @@ gtk_widget_class_init (GtkWidgetClass *klass)
    *
    *      str = gtk_selection_data_get_text (selection_data);
    *      if (!data_is_acceptable (str))
-   *        gdk_drag_status (context, 0, time);
+   *        gdk_drop_status (drop, 0);
    *      else
-   *        gdk_drag_status (context,
-   *                         private_data->suggested_action,
-   *                         time);
+   *        gdk_drag_status (drop, GDK_ACTION_ALL);
    *    }
    *   else
    *    {
@@ -1930,20 +1922,18 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkWidgetClass, drag_motion),
                  _gtk_boolean_handled_accumulator, NULL,
-                 _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
-                 G_TYPE_BOOLEAN, 4,
-                 GDK_TYPE_DRAG_CONTEXT,
-                 G_TYPE_INT,
+                 _gtk_marshal_BOOLEAN__OBJECT_INT_INT,
+                 G_TYPE_BOOLEAN, 3,
+                 GDK_TYPE_DROP,
                  G_TYPE_INT,
-                 G_TYPE_UINT);
+                 G_TYPE_INT);
 
   /**
    * GtkWidget::drag-drop:
    * @widget: the object which received the signal
-   * @context: the drag context
+   * @drop: the #GdkDrop
    * @x: the x coordinate of the current cursor position
    * @y: the y coordinate of the current cursor position
-   * @time: the timestamp of the motion event
    *
    * The ::drag-drop signal is emitted on the drop site when the user drops
    * the data onto the widget. The signal handler must determine whether
@@ -1964,12 +1954,11 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GtkWidgetClass, drag_drop),
                  _gtk_boolean_handled_accumulator, NULL,
-                 _gtk_marshal_BOOLEAN__OBJECT_INT_INT_UINT,
-                 G_TYPE_BOOLEAN, 4,
-                 GDK_TYPE_DRAG_CONTEXT,
-                 G_TYPE_INT,
+                 _gtk_marshal_BOOLEAN__OBJECT_INT_INT,
+                 G_TYPE_BOOLEAN, 3,
+                 GDK_TYPE_DROP,
                  G_TYPE_INT,
-                 G_TYPE_UINT);
+                 G_TYPE_INT);
 
   /**
    * GtkWidget::drag-data-get:
index 2008f44eeea017e29876161e828023531c8d1e60..5d54aaac8b6a3bdbabed37801534177ffa0ca41a 100644 (file)
@@ -308,15 +308,13 @@ struct _GtkWidgetClass
   void     (* drag_leave)          (GtkWidget          *widget,
                                     GdkDrop            *drop);
   gboolean (* drag_motion)         (GtkWidget          *widget,
-                                    GdkDragContext     *context,
+                                    GdkDrop            *drop,
                                     gint                x,
-                                    gint                y,
-                                    guint               time_);
+                                    gint                y);
   gboolean (* drag_drop)           (GtkWidget          *widget,
-                                    GdkDragContext     *context,
+                                    GdkDrop            *drop,
                                     gint                x,
-                                    gint                y,
-                                    guint               time_);
+                                    gint                y);
   void     (* drag_data_received)  (GtkWidget          *widget,
                                     GdkDrop            *drop,
                                     GtkSelectionData   *selection_data);
index a819a8f824bcaa7f2d7ee954b9a304ac3a09028c..26cbfe1e21ac54a018a4ac4ba5644f6f607f99ff 100644 (file)
@@ -299,7 +299,7 @@ static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
 
 void  
 target_drag_leave         (GtkWidget          *widget,
-                           GdkDragContext     *context,
+                           GdkDrop            *drop,
                            guint               time)
 {
   g_print("leave\n");
@@ -309,12 +309,12 @@ target_drag_leave    (GtkWidget          *widget,
 
 gboolean
 target_drag_motion        (GtkWidget          *widget,
-                           GdkDragContext     *context,
+                           GdkDrop            *drop,
                            gint                x,
-                           gint                y,
-                           guint               time)
+                           gint                y)
 {
   GtkWidget *source_widget;
+  GdkDragContext *drag;
   char *s;
 
   if (!have_drag)
@@ -323,25 +323,25 @@ target_drag_motion           (GtkWidget          *widget,
       gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_open);
     }
 
-  source_widget = gtk_drag_get_source_widget (context);
+  drag = gdk_drop_get_drag (drop);
+  source_widget = drag ? gtk_drag_get_source_widget (drag) : NULL;
   g_print ("motion, source %s\n", source_widget ?
           G_OBJECT_TYPE_NAME (source_widget) :
           "NULL");
 
-  s = gdk_content_formats_to_string (gdk_drag_context_get_formats (context));
+  s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
   g_print ("%s\n", s);
 
-  gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time);
+  gdk_drop_status (drop, GDK_ACTION_ALL);
 
   return TRUE;
 }
 
 gboolean
 target_drag_drop          (GtkWidget          *widget,
-                           GdkDragContext     *context,
+                           GdkDrop            *drop,
                            gint                x,
-                           gint                y,
-                           guint               time)
+                           gint                y)
 {
   GdkContentFormats *formats;
   const char *format;
@@ -351,53 +351,69 @@ target_drag_drop     (GtkWidget          *widget,
 
   gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_closed);
 
-  formats = gdk_drag_context_get_formats (context);
+  formats = gdk_drop_get_formats (drop);
   format = gdk_content_formats_match_mime_type (formats, formats);
   if (format)
     {
-      gtk_drag_get_data (widget, context,
-                        format,
-                        time);
+      gtk_drag_get_data (widget, drop, format);
       return TRUE;
     }
   
   return FALSE;
 }
 
+static GdkDragAction
+action_make_unique (GdkDragAction action)
+{
+  if (gdk_drag_action_is_unique (action))
+    return action;
+
+  if (action & GDK_ACTION_COPY)
+    return GDK_ACTION_COPY;
+
+  if (action & GDK_ACTION_MOVE)
+    return GDK_ACTION_MOVE;
+  
+  if (action & GDK_ACTION_LINK)
+    return GDK_ACTION_LINK;
+  
+  g_assert_not_reached ();
+  return 0;
+}
+
 void  
 target_drag_data_received  (GtkWidget          *widget,
-                           GdkDragContext     *context,
-                           GtkSelectionData   *selection_data,
-                           guint               info,
-                           guint               time)
+                           GdkDrop            *drop,
+                           GtkSelectionData   *selection_data)
 {
   if (gtk_selection_data_get_length (selection_data) >= 0 &&
       gtk_selection_data_get_format (selection_data) == 8)
     {
+      GdkDragAction action = gdk_drop_get_actions (drop);
       g_print ("Received \"%s\" in trashcan\n", (gchar *) gtk_selection_data_get_data (selection_data));
-      gdk_drag_finish (context, TRUE, time);
+      action = action_make_unique (action);
+      gdk_drop_finish (drop, action);
       return;
     }
   
-  gdk_drag_finish (context, FALSE, time);
+  gdk_drop_finish (drop, 0);
 }
   
 void  
 label_drag_data_received  (GtkWidget          *widget,
-                           GdkDragContext     *context,
-                           GtkSelectionData   *selection_data,
-                           guint               info,
-                           guint               time)
+                          GdkDrop            *drop,
+                          GtkSelectionData   *selection_data)
 {
   if (gtk_selection_data_get_length (selection_data) >= 0 &&
       gtk_selection_data_get_format (selection_data) == 8)
     {
+      GdkDragAction action = action_make_unique (gdk_drop_get_actions (drop));
       g_print ("Received \"%s\" in label\n", (gchar *) gtk_selection_data_get_data (selection_data));
-      gdk_drag_finish (context, TRUE, time);
+      gdk_drop_finish (drop, action);
       return;
     }
   
-  gdk_drag_finish (context, FALSE, time);
+  gdk_drop_finish (drop, 0);
 }
 
 void  
@@ -439,10 +455,9 @@ popdown_cb (gpointer data)
 
 gboolean
 popup_motion      (GtkWidget          *widget,
-                   GdkDragContext     *context,
+                   GdkDrop            *drop,
                    gint                x,
-                   gint                y,
-                   guint               time)
+                   gint                y)
 {
   if (!in_popup)
     {
@@ -460,8 +475,7 @@ popup_motion           (GtkWidget          *widget,
 
 void  
 popup_leave       (GtkWidget          *widget,
-                   GdkDragContext     *context,
-                   guint               time)
+                   GdkDrop            *drop)
 {
   if (in_popup)
     {
@@ -506,9 +520,9 @@ popup_cb (gpointer data)
                                   GTK_DEST_DEFAULT_ALL,
                                    targets,
                                   GDK_ACTION_COPY | GDK_ACTION_MOVE);
-               g_signal_connect (button, "drag_motion",
+               g_signal_connect (button, "drag-motion",
                                  G_CALLBACK (popup_motion), NULL);
-               g_signal_connect (button, "drag_leave",
+               g_signal_connect (button, "drag-leave",
                                  G_CALLBACK (popup_leave), NULL);
              }
          gtk_container_add (GTK_CONTAINER (popup_window), grid);
@@ -529,10 +543,9 @@ popup_cb (gpointer data)
 
 gboolean
 popsite_motion    (GtkWidget          *widget,
-                   GdkDragContext     *context,
+                   GdkDrop            *drop,
                    gint                x,
-                   gint                y,
-                   guint               time)
+                   gint                y)
 {
   if (!popup_timer)
     popup_timer = g_timeout_add (500, popup_cb, NULL);
@@ -542,8 +555,7 @@ popsite_motion         (GtkWidget          *widget,
 
 void  
 popsite_leave     (GtkWidget          *widget,
-                   GdkDragContext     *context,
-                   guint               time)
+                   GdkDrop            *drop)
 {
   if (popup_timer)
     {
@@ -623,9 +635,9 @@ main (int argc, char **argv)
   gtk_widget_set_vexpand (label, TRUE);
   gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
 
-  g_signal_connect (label, "drag_motion",
+  g_signal_connect (label, "drag-motion",
                    G_CALLBACK (popsite_motion), NULL);
-  g_signal_connect (label, "drag_leave",
+  g_signal_connect (label, "drag-leave",
                    G_CALLBACK (popsite_leave), NULL);
   gdk_content_formats_unref (targets);
   
@@ -635,16 +647,16 @@ main (int argc, char **argv)
   gtk_widget_set_vexpand (pixmap, TRUE);
   gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
 
-  g_signal_connect (pixmap, "drag_leave",
+  g_signal_connect (pixmap, "drag-leave",
                    G_CALLBACK (target_drag_leave), NULL);
 
-  g_signal_connect (pixmap, "drag_motion",
+  g_signal_connect (pixmap, "drag-motion",
                    G_CALLBACK (target_drag_motion), NULL);
 
-  g_signal_connect (pixmap, "drag_drop",
+  g_signal_connect (pixmap, "drag-drop",
                    G_CALLBACK (target_drag_drop), NULL);
 
-  g_signal_connect (pixmap, "drag_data_received",
+  g_signal_connect (pixmap, "drag-data-received",
                    G_CALLBACK (target_drag_data_received), NULL);
 
   /* Drag site */
@@ -664,9 +676,9 @@ main (int argc, char **argv)
   gtk_widget_set_vexpand (button, TRUE);
   gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
 
-  g_signal_connect (button, "drag_data_get",
+  g_signal_connect (button, "drag-data-get",
                    G_CALLBACK (source_drag_data_get), NULL);
-  g_signal_connect (button, "drag_data_delete",
+  g_signal_connect (button, "drag-data-delete",
                    G_CALLBACK (source_drag_data_delete), NULL);
 
   gtk_widget_show (window);
index daf4de875c93edec54615eee71e08b58436b5061..24d80b9d1e829c2f1697b320fc1bc8fc26edb570 100644 (file)
@@ -293,8 +293,10 @@ bold_toggled (GtkToggleToolButton *button)
 }
 
 static gboolean
-toolbar_drag_drop (GtkWidget *widget, GdkDragContext *context,
-                  gint x, gint y, guint time, GtkWidget *label)
+toolbar_drag_drop (GtkWidget *widget,
+                   GdkDrop   *drop,
+                  gint x, gint y,
+                   GtkWidget *label)
 {
   gchar buf[32];
 
@@ -375,12 +377,12 @@ popup_context_menu (GtkToolbar *toolbar, gint x, gint y, gint button_number)
 static GtkToolItem *drag_item = NULL;
 
 static gboolean
-toolbar_drag_motion (GtkToolbar     *toolbar,
-                    GdkDragContext *context,
-                    gint            x,
-                    gint            y,
-                    guint           time,
-                    gpointer        null)
+toolbar_drag_motion (GtkToolbar *toolbar,
+                    GdkDrop    *drop,
+                    gint        x,
+                    gint        y,
+                    guint       time,
+                    gpointer    null)
 {
   gint index;
   
@@ -390,7 +392,7 @@ toolbar_drag_motion (GtkToolbar     *toolbar,
       g_object_ref_sink (g_object_ref (drag_item));
     }
   
-  gdk_drag_status (context, GDK_ACTION_MOVE, time);
+  gdk_drop_status (drop, GDK_ACTION_MOVE);
 
   index = gtk_toolbar_get_drop_index (toolbar, x, y);