[gtk/dnd-gestures-2: 14/30] USe gtk_widget_add_controller instead of gtk_drag_source_attach



commit 834b82fb257bfbfb1368e127b17bcd33cc517210
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 6 19:46:47 2020 -0500

    USe gtk_widget_add_controller instead of gtk_drag_source_attach

 demos/gtk-demo/clipboard.c          | 4 ++--
 demos/icon-browser/iconbrowserwin.c | 4 ++--
 gtk/gtkcolorbutton.c                | 3 +--
 gtk/gtkcolorswatch.c                | 2 +-
 gtk/gtklinkbutton.c                 | 2 +-
 gtk/gtknotebook.c                   | 1 +
 gtk/gtkpathbar.c                    | 2 +-
 tests/testdnd.c                     | 2 +-
 tests/testdnd2.c                    | 4 ++--
 tests/testlist3.c                   | 2 +-
 tests/testtoolbar.c                 | 2 +-
 11 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index 3da096060e..303ff313f6 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -344,9 +344,9 @@ do_clipboard (GtkWidget *do_widget)
 
       /* make image a drag source */
       source = gtk_drag_source_new ();
-      gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
       g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
       g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
+      gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
 
       /* accept drops on image */
       formats = gdk_content_formats_new (NULL, 0);
@@ -378,7 +378,7 @@ do_clipboard (GtkWidget *do_widget)
       source = gtk_drag_source_new ();
       g_signal_connect (source, "prepare", G_CALLBACK (prepare_drag), NULL);
       g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
-      gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
+      gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
 
       /* accept drops on image */
       formats = gdk_content_formats_new (NULL, 0);
diff --git a/demos/icon-browser/iconbrowserwin.c b/demos/icon-browser/iconbrowserwin.c
index 84ccb27259..f4c3f71d3a 100644
--- a/demos/icon-browser/iconbrowserwin.c
+++ b/demos/icon-browser/iconbrowserwin.c
@@ -428,7 +428,7 @@ setup_image_dnd (GtkWidget *image)
   gtk_drag_source_set_content (source, content);
   g_object_unref (content);
   g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
-  gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
+  gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
 }
 
 static void
@@ -443,7 +443,7 @@ setup_scalable_image_dnd (GtkWidget *image)
   g_object_unref (content);
 
   g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
-  gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
+  gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
 }
 
 static void
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index a951958c48..5df2fad3df 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -338,8 +338,7 @@ gtk_color_button_init (GtkColorButton *button)
   gtk_drag_source_set_content (source, content);
   g_object_unref (content);
   g_signal_connect (source, "drag-begin", G_CALLBACK (gtk_color_button_drag_begin), button);
-
-  gtk_drag_source_attach (source, priv->button, GDK_BUTTON1_MASK|GDK_BUTTON3_MASK);
+  gtk_widget_add_controller (priv->button, GTK_EVENT_CONTROLLER (source));
 
   context = gtk_widget_get_style_context (GTK_WIDGET (priv->button));
   gtk_style_context_add_class (context, "color");
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index 49b40598a8..78ed87dc8d 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -608,7 +608,7 @@ gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
       g_object_unref (content);
       g_signal_connect (source, "drag-begin", G_CALLBACK (gtk_color_swatch_drag_begin), swatch);
 
-      gtk_drag_source_attach (source, GTK_WIDGET (swatch), GDK_BUTTON1_MASK | GDK_BUTTON3_MASK);
+      gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (source));
     }
 
   priv->has_color = TRUE;
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index 5c113516c6..2621591a5e 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -337,7 +337,7 @@ gtk_link_button_init (GtkLinkButton *link_button)
   GTK_LINK_CONTENT (content)->link = link_button;
   gtk_drag_source_set_content (source, content);
   g_object_unref (content);
-  gtk_drag_source_attach (source, GTK_WIDGET (link_button), GDK_BUTTON1_MASK);
+  gtk_widget_add_controller (GTK_WIDGET (link_button), GTK_EVENT_CONTROLLER (source));
 
   gesture = gtk_gesture_click_new ();
   gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), FALSE);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index c93be978f8..585a3143d1 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -34,6 +34,7 @@
 #include "gtkbutton.h"
 #include "gtkcssstylepropertyprivate.h"
 #include "gtkdragdest.h"
+#include "gtkdragicon.h"
 #include "gtkeventcontrollermotion.h"
 #include "gtkgestureclick.h"
 #include "gtkgizmoprivate.h"
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 248ff308ae..37a7b05487 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -1370,7 +1370,7 @@ make_directory_button (GtkPathBar  *path_bar,
   content = gdk_content_provider_new_for_value (&value);
   gtk_drag_source_set_content (source, content);
   g_object_unref (content);
-  gtk_drag_source_attach (source, button_data->button, GDK_BUTTON1_MASK);
+  gtk_widget_add_controller (button_data->button, GTK_EVENT_CONTROLLER (source));
   g_value_unset (&value);
 
   return button_data;
diff --git a/tests/testdnd.c b/tests/testdnd.c
index ceefa34c5c..e2d62953b7 100644
--- a/tests/testdnd.c
+++ b/tests/testdnd.c
@@ -642,7 +642,7 @@ main (int argc, char **argv)
   gtk_drag_source_set_content (source, content);
   g_object_unref (content);
   gtk_drag_source_set_actions (source, GDK_ACTION_COPY|GDK_ACTION_MOVE);
-  gtk_drag_source_attach (source, button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK);
+  gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (source));
   gtk_drag_source_set_icon (source, GDK_PAINTABLE (texture), 0, 0);
 
   g_object_unref (texture);
diff --git a/tests/testdnd2.c b/tests/testdnd2.c
index 693da26ee2..a9e4b8629a 100644
--- a/tests/testdnd2.c
+++ b/tests/testdnd2.c
@@ -307,7 +307,7 @@ make_image (const gchar *icon_name, int hotspot)
   g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), NULL);
   g_signal_connect (source, "drag-end", G_CALLBACK (drag_end), NULL);
   g_signal_connect (source, "drag-failed", G_CALLBACK (drag_failed), NULL);
-  gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK);
+  gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
 
   dest = gtk_drop_target_new (formats, GDK_ACTION_COPY|GDK_ACTION_MOVE|GDK_ACTION_ASK);
   g_signal_connect (dest, "drag-drop", G_CALLBACK (image_drag_drop), image);
@@ -347,7 +347,7 @@ make_spinner (void)
   source = gtk_drag_source_new ();
   gtk_drag_source_set_content (source, content);
   g_signal_connect (source, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
-  gtk_drag_source_attach (source, spinner, GDK_BUTTON1_MASK);
+  gtk_widget_add_controller (spinner, GTK_EVENT_CONTROLLER (source));
 
   g_object_unref (content);
   g_value_unset (&value);
diff --git a/tests/testlist3.c b/tests/testlist3.c
index 2180544d04..45076a73ed 100644
--- a/tests/testlist3.c
+++ b/tests/testlist3.c
@@ -88,7 +88,7 @@ create_row (const gchar *text)
   gtk_drag_source_set_content (source, content);
   gtk_drag_source_set_actions (source, GDK_ACTION_MOVE);
   g_signal_connect (source, "drag-begin", G_CALLBACK (drag_begin), image);
-  gtk_drag_source_attach (source, image, GDK_BUTTON1_MASK);
+  gtk_widget_add_controller (image, GTK_EVENT_CONTROLLER (source));
 
   targets = gdk_content_formats_new (entries, 1);
   dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
diff --git a/tests/testtoolbar.c b/tests/testtoolbar.c
index ffbcacb7a5..2a9ab3afb3 100644
--- a/tests/testtoolbar.c
+++ b/tests/testtoolbar.c
@@ -622,7 +622,7 @@ main (gint argc, gchar **argv)
   gtk_drag_source_set_content (source, content);
   gtk_drag_source_set_actions (source, GDK_ACTION_MOVE);
   g_object_unref (content);
-  gtk_drag_source_attach (source, button, GDK_BUTTON1_MASK);
+  gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (source));
   dest = gtk_drop_target_new (targets, GDK_ACTION_MOVE);
   g_signal_connect (dest, "drag_motion", G_CALLBACK (toolbar_drag_motion), toolbar);
   g_signal_connect (dest, "drag_leave", G_CALLBACK (toolbar_drag_leave), toolbar);


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