[balsa/wip/gtk4] Drag and drop API changes



commit 779cc68507b7233aa8864e224470ca3f6f5c285b
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Tue Jun 19 12:36:54 2018 -0400

    Drag and drop API changes

 libbalsa/address.c           | 20 +++++++-------
 src/balsa-index.c            |  5 +---
 src/balsa-mblist.c           | 22 +++++++---------
 src/balsa-mime-widget-text.c | 17 +++---------
 src/compose-window.c         | 31 ++++++++++------------
 src/main-window.c            | 62 +++++++++++++++++++++-----------------------
 6 files changed, 69 insertions(+), 88 deletions(-)
---
diff --git a/libbalsa/address.c b/libbalsa/address.c
index 759027877..07f84a011 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -864,7 +864,7 @@ const gchar *libbalsa_address_target_list[] = {
 
 static void
 addrlist_drag_received_cb(GtkWidget        * widget,
-                          GdkDragContext   * context,
+                          GdkDrop          * drop,
                           GtkSelectionData * selection_data,
                           guint32            time,
                           gpointer           data)
@@ -906,21 +906,24 @@ addrlist_drag_received_cb(GtkWidget        * widget,
     if (!dnd_success)
         g_print ("DnD data transfer failed!\n");
 
-    gtk_drag_finish(context, dnd_success, time);
+    gdk_drop_finish(drop, dnd_success);
 }
 
 static gboolean
-addrlist_drag_drop_cb(GtkWidget *widget, GdkDragContext *context,
-                      gint x, gint y, guint time, gpointer user_data)
+addrlist_drag_drop_cb(GtkWidget *widget,
+                      GdkDrop   *drop,
+                      gint       x,
+                      gint       y,
+                      gpointer   user_data)
 {
-  gboolean        is_valid_drop_site;
+  gboolean is_valid_drop_site;
   GdkContentFormats *formats;
 
   /* Check to see if (x,y) is a valid drop site within widget */
   is_valid_drop_site = TRUE;
 
   /* If the source offers a target */
-  formats = gdk_drag_context_get_formats(context);
+  formats = gdk_drop_get_formats(drop);
   if (formats != NULL) {
       const gchar * const *mime_types;
       gsize                n_mime_types;
@@ -938,9 +941,8 @@ addrlist_drag_drop_cb(GtkWidget *widget, GdkDragContext *context,
       gtk_drag_get_data
         (
          widget,         /* will receive 'drag-data-received' signal */
-         context,        /* represents the current state of the DnD */
-         target_type,    /* the target type we want */
-         time            /* time stamp */
+         drop,           /* represents the current state of the DnD */
+         target_type     /* the target type we want */
          );
   } else {
       is_valid_drop_site = FALSE;
diff --git a/src/balsa-index.c b/src/balsa-index.c
index 8df645eef..1bd40658e 100644
--- a/src/balsa-index.c
+++ b/src/balsa-index.c
@@ -117,7 +117,6 @@ static const gchar *index_drag_types[] = {
 static void bndx_drag_cb(GtkWidget        *widget,
                          GdkDragContext   *drag_context,
                          GtkSelectionData *data,
-                         guint             time,
                          gpointer          user_data);
 
 /* Popup menu */
@@ -475,8 +474,7 @@ balsa_index_init(BalsaIndex *index)
     gtk_drag_source_set(GTK_WIDGET (index),
                         GDK_BUTTON1_MASK | GDK_SHIFT_MASK | GDK_CONTROL_MASK,
                         formats,
-                        GDK_ACTION_DEFAULT | GDK_ACTION_COPY |
-                        GDK_ACTION_MOVE);
+                        GDK_ACTION_COPY | GDK_ACTION_MOVE);
     gdk_content_formats_unref(formats);
 
     g_signal_connect(index, "drag-data-get",
@@ -849,7 +847,6 @@ static void
 bndx_drag_cb(GtkWidget        *widget,
              GdkDragContext   *drag_context,
              GtkSelectionData *data,
-             guint             time,
              gpointer          user_data)
 {
     BalsaIndex *index;
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index d4086ac8e..7a66a5a1e 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -85,8 +85,7 @@ static void bmbl_set_property(GObject * object, guint prop_id,
 static void bmbl_get_property(GObject * object, guint prop_id,
                               GValue * value, GParamSpec * pspec);
 static gboolean bmbl_drag_motion(GtkWidget * mblist,
-                                 GdkDragContext * context, gint x, gint y,
-                                 guint time);
+                                 GdkDrop * drop, gint x, gint y);
 static gboolean bmbl_popup_menu(GtkWidget * widget);
 static gboolean bmbl_selection_func(GtkTreeSelection * selection,
                                     GtkTreeModel * model,
@@ -272,8 +271,10 @@ bmbl_get_property(GObject * object, guint prop_id, GValue * value,
 }
 
 static gboolean
-bmbl_drag_motion(GtkWidget * mblist, GdkDragContext * context, gint x,
-                 gint y, guint time)
+bmbl_drag_motion(GtkWidget *mblist,
+                 GdkDrop   *drop,
+                 gint       x,
+                 gint       y)
 {
     GtkTreeView *tree_view = GTK_TREE_VIEW(mblist);
     GtkTreePath *path;
@@ -284,9 +285,8 @@ bmbl_drag_motion(GtkWidget * mblist, GdkDragContext * context, gint x,
 
     ret_val =
         GTK_WIDGET_CLASS(balsa_mblist_parent_class)->drag_motion(mblist,
-                                                                 context,
-                                                                 x, y,
-                                                                 time);
+                                                                 drop,
+                                                                 x, y);
 
     gtk_tree_view_get_drag_dest_row(tree_view, &path, NULL);
     if (!path)
@@ -297,10 +297,9 @@ bmbl_drag_motion(GtkWidget * mblist, GdkDragContext * context, gint x,
                                     GTK_TREE_VIEW_DROP_INTO_OR_BEFORE);
     gtk_tree_path_free(path);
 
-    gdk_drag_status(context,
-                    (gdk_drag_context_get_actions(context) ==
-                     GDK_ACTION_COPY) ? GDK_ACTION_COPY :
-                    GDK_ACTION_MOVE, time);
+    gdk_drop_status(drop,
+                    gdk_drop_get_actions(drop) == GDK_ACTION_COPY ?
+                    GDK_ACTION_COPY : GDK_ACTION_MOVE);
 
     return (ret_val && can_drop);
 }
@@ -1177,7 +1176,6 @@ balsa_mblist_default_signal_bindings(BalsaMBList * mblist)
     formats = gdk_content_formats_new(bmbl_drop_types, G_N_ELEMENTS(bmbl_drop_types));
     gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(mblist),
                                          formats,
-                                         GDK_ACTION_DEFAULT |
                                          GDK_ACTION_COPY |
                                          GDK_ACTION_MOVE);
     gdk_content_formats_unref(formats);
diff --git a/src/balsa-mime-widget-text.c b/src/balsa-mime-widget-text.c
index fd55899c9..4c66c8940 100644
--- a/src/balsa-mime-widget-text.c
+++ b/src/balsa-mime-widget-text.c
@@ -42,7 +42,7 @@
 static GtkWidget * create_text_widget(const char * content_type);
 static void bm_modify_font_from_string(GtkWidget * widget, const char *font);
 static GtkTextTag * quote_tag(GtkTextBuffer * buffer, gint level, gint margin);
-static gboolean fix_text_widget(GtkWidget *widget, gpointer data);
+static void fix_text_widget(GtkWidget *widget, gpointer data);
 static void text_view_populate_popup(GtkWidget *widget, GtkMenu *menu,
                                      gpointer user_data);
 
@@ -462,27 +462,16 @@ quote_tag(GtkTextBuffer * buffer, gint level, gint margin)
 
 /* set the gtk_text widget's cursor to a vertical bar
    fix event mask so that pointer motions are reported (if necessary) */
-static gboolean
+static void
 fix_text_widget(GtkWidget *widget, gpointer data)
 {
-    if (data != NULL) {
-        GdkSurface *surface = gtk_widget_get_surface(widget);
-
-        gdk_surface_set_events(surface,
-                               gdk_surface_get_events(surface) |
-                               GDK_POINTER_MOTION_MASK |
-                               GDK_LEAVE_NOTIFY_MASK);
-    }
-
-    if (!url_cursor_normal || !url_cursor_over_url) {
+    if (url_cursor_normal == NULL) {
         url_cursor_normal =
             gdk_cursor_new_from_name("text", NULL);
         url_cursor_over_url =
             gdk_cursor_new_from_name("pointer", NULL);
     }
     gtk_widget_set_cursor(widget, url_cursor_normal);
-
-    return FALSE;
 }
 
 static void
diff --git a/src/compose-window.c b/src/compose-window.c
index 27c4b95fd..661262521 100644
--- a/src/compose-window.c
+++ b/src/compose-window.c
@@ -154,10 +154,9 @@ static void balsa_compose_window_destroy(GtkWidget *widget);
 static void balsa_compose_window_size_allocate(GtkWidget           *widget,
                                                const GtkAllocation *allocation,
                                                int                  baseline);
-static void balsa_compose_window_drag_data_received(GtkWidget          *widget,
-                                                    GdkDragContext     *context,
-                                                    GtkSelectionData   *selection_data,
-                                                    guint               time);
+static void balsa_compose_window_drag_data_received(GtkWidget        *widget,
+                                                    GdkDrop          *drop,
+                                                    GtkSelectionData *selection_data);
 static gboolean balsa_compose_window_close_request(GtkWindow *window);
 
 static void
@@ -2407,9 +2406,8 @@ rfc2396_uri(const gchar *instr)
 
 static void
 balsa_compose_window_drag_data_received(GtkWidget        *widget,
-                                        GdkDragContext   *context,
-                                        GtkSelectionData *selection_data,
-                                        guint32           time)
+                                        GdkDrop          *drop,
+                                        GtkSelectionData *selection_data)
 {
     BalsaComposeWindow *compose_window = (BalsaComposeWindow *) widget;
     const gchar *target;
@@ -2461,16 +2459,16 @@ balsa_compose_window_drag_data_received(GtkWidget        *widget,
             drag_result = FALSE;
     }
 
-    gtk_drag_finish(context, drag_result, time);
+    gdk_drop_finish(drop, drag_result);
 }
 
 
 /* to_add - address-view D&D callback; we assume it's a To: address */
 static void
 to_add(GtkWidget        *widget,
-       GdkDragContext   *context,
+       GdkDrop          *drop,
        GtkSelectionData *selection_data,
-       guint32           time)
+       gpointer          user_data)
 {
     const gchar *target;
     gboolean drag_result = FALSE;
@@ -2492,7 +2490,7 @@ to_add(GtkWidget        *widget,
         libbalsa_address_view_add_from_string(LIBBALSA_ADDRESS_VIEW(widget), "To:", address);
         drag_result = TRUE;
     }
-    gtk_drag_finish(context, drag_result, time);
+    gdk_drop_finish(drop, drag_result);
 }
 
 
@@ -3007,11 +3005,10 @@ has_file_attached(GtkTreeModel *model,
 
 /* drag_data_quote - text area D&D callback */
 static void
-drag_data_quote(GtkWidget        *widget,
-                GdkDragContext   *context,
-                GtkSelectionData *selection_data,
-                guint32           time,
-                BalsaComposeWindow     *compose_window)
+drag_data_quote(GtkWidget          *widget,
+                GdkDrop            *drop,
+                GtkSelectionData   *selection_data,
+                BalsaComposeWindow *compose_window)
 {
     const gchar *target;
     GtkTextBuffer *buffer;
@@ -3066,7 +3063,7 @@ drag_data_quote(GtkWidget        *widget,
         g_slist_free(uri_list);
     }
 
-    gtk_drag_finish(context, TRUE, time);
+    gdk_drop_finish(drop, TRUE);
 }
 
 
diff --git a/src/main-window.c b/src/main-window.c
index fd99b372a..14d66f0d1 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -158,19 +158,17 @@ static void bw_notebook_switch_page_cb(GtkWidget * notebook,
 static void bw_compose_window_destroy_cb(GtkWidget * widget, gpointer data);
 static BalsaIndex *bw_notebook_find_page(GtkNotebook * notebook,
                                          gint x, gint y);
-static void bw_notebook_drag_received_cb(GtkWidget        * widget,
-                                         GdkDragContext   * context,
-                                         gint               x,
-                                         gint               y,
-                                         GtkSelectionData * selection_data,
-                                         guint32            time,
-                                         gpointer           data);
-static gboolean bw_notebook_drag_motion_cb(GtkWidget      * widget,
-                                           GdkDragContext * context,
-                                           gint             x,
-                                           gint             y,
-                                           guint            time,
-                                           gpointer         user_data);
+static void bw_notebook_drag_received_cb(GtkWidget        *widget,
+                                         GdkDrop          *drop,
+                                         gint              x,
+                                         gint              y,
+                                         GtkSelectionData *selection_data,
+                                         gpointer          user_data);
+static gboolean bw_notebook_drag_motion_cb(GtkWidget *widget,
+                                           GdkDrop   *drop,
+                                           gint       x,
+                                           gint       y,
+                                           gpointer   user_data);
 
 
 static GtkWidget *bw_notebook_label_new (BalsaMailboxNode* mbnode);
@@ -2318,9 +2316,9 @@ balsa_window_new(GtkApplication *application)
                      G_CALLBACK(bw_notebook_switch_page_cb), window);
 
     formats = gdk_content_formats_new(notebook_drop_types, NUM_DROP_TYPES);
-    gtk_drag_dest_set (GTK_WIDGET (priv->notebook), GTK_DEST_DEFAULT_ALL,
-                       formats,
-                       GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE);
+    gtk_drag_dest_set(GTK_WIDGET (priv->notebook), GTK_DEST_DEFAULT_ALL,
+                      formats,
+                      GDK_ACTION_COPY | GDK_ACTION_MOVE);
     gdk_content_formats_unref(formats);
 
     g_signal_connect(G_OBJECT (priv->notebook), "drag-data-received",
@@ -4507,13 +4505,12 @@ bw_notebook_find_page (GtkNotebook* notebook, gint x, gint y)
  * over, then transfers them.
  **/
 static void
-bw_notebook_drag_received_cb(GtkWidget        * widget,
-                             GdkDragContext   * context,
-                             gint               x,
-                             gint               y,
-                             GtkSelectionData * selection_data,
-                             guint32            time,
-                             gpointer           data)
+bw_notebook_drag_received_cb(GtkWidget        *widget,
+                             GdkDrop          *drop,
+                             gint              x,
+                             gint              y,
+                             GtkSelectionData *selection_data,
+                             gpointer          data)
 {
     BalsaIndex* index;
     LibBalsaMailbox* mailbox;
@@ -4546,19 +4543,20 @@ bw_notebook_drag_received_cb(GtkWidget        * widget,
 
     if (mailbox != NULL && mailbox != orig_mailbox)
         balsa_index_transfer(orig_index, selected, mailbox,
-                             gdk_drag_context_get_selected_action(context) != GDK_ACTION_MOVE);
+                             gdk_drop_get_actions(drop) != GDK_ACTION_MOVE);
     balsa_index_selected_msgnos_free(orig_index, selected);
 }
 
-static gboolean bw_notebook_drag_motion_cb(GtkWidget * widget,
-                                           GdkDragContext * context,
-                                           gint x, gint y, guint time,
-                                           gpointer user_data)
+static gboolean bw_notebook_drag_motion_cb(GtkWidget *widget,
+                                           GdkDrop   *drop,
+                                           gint       x,
+                                           gint       y,
+                                           gpointer   user_data)
 {
-    gdk_drag_status(context,
-                    (gdk_drag_context_get_actions(context) ==
-                     GDK_ACTION_COPY) ? GDK_ACTION_COPY :
-                    GDK_ACTION_MOVE, time);
+    GdkDragAction action = gdk_drop_get_actions(drop);
+
+    gdk_drop_status(drop,
+                    action == GDK_ACTION_COPY ? GDK_ACTION_COPY : GDK_ACTION_MOVE);
 
     return FALSE;
 }


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