]> Pileus Git - ~andy/gtk/commitdiff
Don't allow dragging a notebook tab to one of its children. (#348626,
authorMatthias Clasen <mclasen@redhat.com>
Sun, 6 Aug 2006 04:10:11 +0000 (04:10 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sun, 6 Aug 2006 04:10:11 +0000 (04:10 +0000)
2006-08-06  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtknotebook.c (gtk_notebook_drag_motion): Don't allow
dragging a notebook tab to one of its children.  (#348626,
Benjamin Otte)

ChangeLog
ChangeLog.pre-2-10
gtk/gtknotebook.c
tests/testnotebookdnd.c

index 7005b23b80bf0173e5f858e63dbed71d68e5d13b..592b00c3de5b9093c3abdf2542abe805e4bc1fa8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-08-06  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtknotebook.c (gtk_notebook_drag_motion): Don't allow
+       dragging a notebook tab to one of its children.  (#348626,
+       Benjamin Otte)
+
+       * tests/testnotebookdnd.c: Test more corner cases.
+
 2006-08-05  Matthias Clasen  <mclasen@redhat.com>
 
        * docs/tutorial/gtk-tut.sgml: Remove outdated lists of
index 7005b23b80bf0173e5f858e63dbed71d68e5d13b..592b00c3de5b9093c3abdf2542abe805e4bc1fa8 100644 (file)
@@ -1,3 +1,11 @@
+2006-08-06  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/gtknotebook.c (gtk_notebook_drag_motion): Don't allow
+       dragging a notebook tab to one of its children.  (#348626,
+       Benjamin Otte)
+
+       * tests/testnotebookdnd.c: Test more corner cases.
+
 2006-08-05  Matthias Clasen  <mclasen@redhat.com>
 
        * docs/tutorial/gtk-tut.sgml: Remove outdated lists of
index 4bcc88a3a748b6dd42f0950540d7cf3d692d6c4f..4ce749ffb349e5bdc0a838afa286b973e280c297 100644 (file)
@@ -3159,7 +3159,9 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
 
       if (widget_group != -1 &&
          source_widget_group != -1 &&
-         widget_group == source_widget_group)
+         widget_group == source_widget_group &&
+         !(widget == GTK_NOTEBOOK (source_widget)->cur_page->child || 
+           gtk_widget_is_ancestor (widget, GTK_NOTEBOOK (source_widget)->cur_page->child)))
        {
          gdk_drag_status (context, GDK_ACTION_MOVE, time);
          return TRUE;
index 796ec4709c7c7eb4d72e66e45f840925d9722577..233d9003ef99ed4d16bf2abb49b91bb879fd1f36 100644 (file)
@@ -34,10 +34,10 @@ enum {
 };
 
 gchar *tabs1 [] = {
-  "a",
-  "b",
-  "c",
-  "d",
+  "aaaaaaaaaa",
+  "bbbbbbbbbb",
+  "cccccccccc",
+  "dddddddddd",
   NULL
 };
 
@@ -46,7 +46,7 @@ gchar *tabs2 [] = {
   "2",
   "3",
   "4",
-  "5",
+  "55555",
   NULL
 };
 
@@ -184,6 +184,47 @@ create_notebook (gchar           **labels,
   return notebook;
 }
 
+static GtkWidget*
+create_notebook_with_notebooks (gchar           **labels,
+                               gint              group_id,
+                               gint              packing,
+                               GtkPositionType   pos)
+{
+  GtkWidget *notebook, *title, *page;
+  gint count = 0;
+
+  notebook = gtk_notebook_new ();
+
+  gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos);
+  gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
+  gtk_container_set_border_width (GTK_CONTAINER (notebook), 6);
+  gtk_notebook_set_group_id (GTK_NOTEBOOK (notebook), group_id);
+
+  while (*labels)
+    {
+      page = create_notebook (labels, group_id, packing, pos);
+
+      title = gtk_label_new (*labels);
+
+      gtk_notebook_append_page (GTK_NOTEBOOK (notebook), page, title);
+      gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (notebook), page, TRUE);
+      gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (notebook), page, TRUE);
+
+      if (packing == PACK_END ||
+         (packing == PACK_ALTERNATE && count % 2 == 1))
+       gtk_container_child_set (GTK_CONTAINER (notebook), page, "tab-pack", GTK_PACK_END, NULL);
+
+      count++;
+      labels++;
+    }
+
+  g_signal_connect (GTK_NOTEBOOK (notebook), "page-reordered",
+                   G_CALLBACK (on_page_reordered), NULL);
+  g_signal_connect_after (G_OBJECT (notebook), "drag-begin",
+                         G_CALLBACK (on_notebook_drag_begin), NULL);
+  return notebook;
+}
+
 static GtkWidget*
 create_trash_button (void)
 {
@@ -215,7 +256,7 @@ main (gint argc, gchar *argv[])
   gtk_notebook_set_window_creation_hook (window_creation_function, NULL, NULL);
 
   gtk_table_attach_defaults (GTK_TABLE (table),
-                            create_notebook (tabs1, GROUP_A, PACK_START, GTK_POS_TOP),
+                            create_notebook (tabs1, GROUP_A, PACK_ALTERNATE, GTK_POS_TOP),
                             0, 1, 0, 1);
 
   gtk_table_attach_defaults (GTK_TABLE (table),
@@ -227,7 +268,7 @@ main (gint argc, gchar *argv[])
                             1, 2, 0, 1);
 
   gtk_table_attach_defaults (GTK_TABLE (table),
-                            create_notebook (tabs4, GROUP_A, PACK_ALTERNATE, GTK_POS_RIGHT),
+                            create_notebook_with_notebooks (tabs4, GROUP_A, PACK_ALTERNATE, GTK_POS_RIGHT),
                             1, 2, 1, 2);
 
   gtk_table_attach (GTK_TABLE (table),