[gtk/dnd-gestures-2: 74/100] notebook: Don't highlight unconditionally on dnd



commit 0443b7229cf8170e966766a2eb506b46ff010253
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 5 17:10:47 2020 -0500

    notebook: Don't highlight unconditionally on dnd
    
    Only highlight the notebook as a drop target if
    we are accepting a dropped notebook page, not
    when just switching pages during unrelated drags.

 gtk/gtknotebook.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 5675b6c1d4..ae49894cd7 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -712,6 +712,7 @@ static gboolean gtk_notebook_drag_drop       (GtkDropTarget    *dest,
                                               int               y);
 static GBytes * gtk_notebook_drag_data_get   (const char       *mime_type,
                                               gpointer          data);
+static void gtk_notebook_armed               (GtkDropTarget    *dest);
 
 /*** GtkContainer Methods ***/
 static void gtk_notebook_add                 (GtkContainer     *container,
@@ -1329,6 +1330,7 @@ gtk_notebook_init (GtkNotebook *notebook)
   g_signal_connect (dest, "drag-motion", G_CALLBACK (gtk_notebook_drag_motion), NULL);
   g_signal_connect (dest, "drag-leave", G_CALLBACK (gtk_notebook_drag_leave), NULL);
   g_signal_connect (dest, "drag-drop", G_CALLBACK (gtk_notebook_drag_drop), NULL);
+  g_signal_connect (dest, "notify::armed", G_CALLBACK (gtk_notebook_armed), NULL);
   gtk_drop_target_set_track_motion (dest, TRUE);
   gtk_drop_target_attach (dest, GTK_WIDGET (notebook));
   gdk_content_formats_unref (targets);
@@ -3337,6 +3339,20 @@ got_page (GObject *source,
     gdk_drop_finish (drop, 0);
 }
 
+static void
+gtk_notebook_armed (GtkDropTarget  *dest)
+{
+  GtkWidget *notebook;
+  GdkAtom target, tab_target;
+
+  notebook = gtk_drop_target_get_target (dest);
+  target = gtk_drop_target_find_mimetype (dest);
+  tab_target = g_intern_static_string ("GTK_NOTEBOOK_TAB");
+
+  if (target != tab_target)
+    gtk_drag_unhighlight (notebook);
+}
+
 static gboolean
 gtk_notebook_drag_drop (GtkDropTarget *dest,
                         int            x,


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