? patch
? patch-notebook
Index: gtkdnd.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkdnd.c,v
retrieving revision 1.146
diff -u -r1.146 gtkdnd.c
--- gtkdnd.c	7 Mar 2006 17:48:07 -0000	1.146
+++ gtkdnd.c	9 Mar 2006 13:02:09 -0000
@@ -1,3 +1,4 @@
+/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
 /* GTK - The GIMP Toolkit
  * Copyright (C) 1995-1999 Peter Mattis, Spencer Kimball and Josh MacDonald
  *
@@ -1352,7 +1353,7 @@
 	data.callback = (event->type == GDK_DRAG_MOTION) ?
 	  gtk_drag_dest_motion : gtk_drag_dest_drop;
 	data.time = event->dnd.time;
-	
+
 	gtk_drag_find_widget (toplevel, &data);
 
 	if (info->widget && !data.found)
@@ -1360,7 +1361,7 @@
 	    gtk_drag_dest_leave (info->widget, context, event->dnd.time);
 	    info->widget = NULL;
 	  }
-	
+
 	/* Send a reply.
 	 */
 	if (event->type == GDK_DRAG_MOTION)
@@ -1407,6 +1408,8 @@
   GList *tmp_target;
   GList *tmp_source = NULL;
   GtkWidget *source_widget;
+  GdkAtom universal_atom;
+  gboolean has_universal_atom = FALSE;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), GDK_NONE);
   g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_NONE);
@@ -1420,14 +1423,19 @@
   
   if (target_list == NULL)
     return GDK_NONE;
-  
+
+  universal_atom = gdk_atom_intern_static_string ("application/x-dnd-anything");
   tmp_target = target_list->list;
+
   while (tmp_target)
     {
       GtkTargetPair *pair = tmp_target->data;
       tmp_source = context->targets;
       while (tmp_source)
 	{
+	  if (universal_atom == GUINT_TO_POINTER (pair->target))
+	    has_universal_atom = TRUE;
+
 	  if (tmp_source->data == GUINT_TO_POINTER (pair->target))
 	    {
 	      if ((!(pair->flags & GTK_TARGET_SAME_APP) || source_widget) &&
@@ -1440,6 +1448,12 @@
 	}
       tmp_target = tmp_target->next;
     }
+
+  /* there was no specific match, if the target has the
+   * application/x-dnd-anything target, just accept the
+   * first source target */
+  if (has_universal_atom)
+    return GDK_POINTER_TO_ATOM (context->targets->data);
 
   return GDK_NONE;
 }
Index: gtknotebook.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.c,v
retrieving revision 1.196
diff -u -r1.196 gtknotebook.c
--- gtknotebook.c	8 Mar 2006 17:22:13 -0000	1.196
+++ gtknotebook.c	9 Mar 2006 13:02:17 -0000
@@ -161,16 +161,22 @@
   gint  mouse_y;
   gint  pressed_button;
   guint dnd_timer;
+  guint switch_tab_timer;
   GtkTargetList *source_targets;
   gboolean during_detach;
   gboolean has_scrolled;
 };
 
-static const GtkTargetEntry notebook_targets[] = {
+static const GtkTargetEntry notebook_source_targets [] = {
   { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
   { "application/x-rootwindow-drop", 0, 1 }
 };
 
+static const GtkTargetEntry notebook_dest_targets[] = {
+  { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 },
+  { "application/x-dnd-anything", 0, 1 }
+};
+
 #ifdef G_DISABLE_CHECKS
 #define CHECK_FIND_CHILD(notebook, child)                           \
  gtk_notebook_find_child (notebook, child, G_STRLOC)
@@ -252,6 +258,9 @@
 					      gint              x,
 					      gint              y,
 					      guint             time);
+static void gtk_notebook_drag_leave          (GtkWidget        *widget,
+					      GdkDragContext   *context,
+					      guint             time);
 static gboolean gtk_notebook_drag_drop       (GtkWidget        *widget,
 					      GdkDragContext   *context,
 					      gint              x,
@@ -503,6 +512,7 @@
   widget_class->style_set = gtk_notebook_style_set;
   widget_class->drag_begin = gtk_notebook_drag_begin;
   widget_class->drag_motion = gtk_notebook_drag_motion;
+  widget_class->drag_leave = gtk_notebook_drag_leave;
   widget_class->drag_drop = gtk_notebook_drag_drop;
   widget_class->drag_data_get = gtk_notebook_drag_data_get;
   widget_class->drag_data_received = gtk_notebook_drag_data_received;
@@ -987,12 +997,13 @@
   priv->group_id = -1;
   priv->pressed_button = -1;
   priv->dnd_timer = 0;
-  priv->source_targets = gtk_target_list_new (notebook_targets,
-					      G_N_ELEMENTS (notebook_targets));
+  priv->switch_tab_timer = 0;
+  priv->source_targets = gtk_target_list_new (notebook_source_targets,
+					      G_N_ELEMENTS (notebook_source_targets));
 
   gtk_drag_dest_set (GTK_WIDGET (notebook),
 		     GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
-		     notebook_targets, G_N_ELEMENTS (notebook_targets),
+		     notebook_dest_targets, G_N_ELEMENTS (notebook_dest_targets),
                      GDK_ACTION_MOVE);
 }
 
@@ -1278,7 +1289,13 @@
       gtk_target_list_unref (priv->source_targets);
       priv->source_targets = NULL;
     }
-  
+
+  if (priv->switch_tab_timer)
+    {
+      g_source_remove (priv->switch_tab_timer);
+      priv->switch_tab_timer = 0;
+    }
+
   GTK_OBJECT_CLASS (parent_class)->destroy (object);
 }
 
@@ -2096,7 +2113,7 @@
 static gboolean
 gtk_notebook_arrow_button_press (GtkNotebook      *notebook,
 				 GtkNotebookArrow  arrow,
-				 GdkEventButton   *event)
+				 gint              button)
 {
   GtkWidget *widget = GTK_WIDGET (notebook);
   gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
@@ -2106,10 +2123,10 @@
   if (!GTK_WIDGET_HAS_FOCUS (widget))
     gtk_widget_grab_focus (widget);
   
-  notebook->button = event->button;
+  notebook->button = button;
   notebook->click_child = arrow;
-  
-  if (event->button == 1)
+
+  if (button == 1)
     {
       gtk_notebook_do_arrow (notebook, arrow);
       
@@ -2126,9 +2143,9 @@
 	  notebook->need_timer = TRUE;
 	}
     }
-  else if (event->button == 2)
+  else if (button == 2)
     gtk_notebook_page_select (notebook, TRUE);
-  else if (event->button == 3)
+  else if (button == 3)
     gtk_notebook_switch_focus_tab (notebook,
 				   gtk_notebook_search_page (notebook,
 							     NULL,
@@ -2207,6 +2224,30 @@
   return TRUE;
 }
 
+static GList*
+get_tab_at_pos (GtkNotebook *notebook, gint x, gint y)
+{
+  GtkNotebookPage *page;
+  GList *children = notebook->children;
+
+  while (children)
+    {
+      page = children->data;
+      
+      if (GTK_WIDGET_VISIBLE (page->child) &&
+	  page->tab_label && GTK_WIDGET_MAPPED (page->tab_label) &&
+	  (x >= page->allocation.x) &&
+	  (y >= page->allocation.y) &&
+	  (x <= (page->allocation.x + page->allocation.width)) &&
+	  (y <= (page->allocation.y + page->allocation.height)))
+	return children;
+
+      children = children->next;
+    }
+
+  return NULL;
+}
+
 static gboolean
 gtk_notebook_button_press (GtkWidget      *widget,
 			   GdkEventButton *event)
@@ -2214,9 +2255,8 @@
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPrivate *priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
   GtkNotebookPage *page;
-  GList *children;
+  GList *tab;
   GtkNotebookArrow arrow;
-  gint num;
   gint x, y;
 
   if (event->type != GDK_BUTTON_PRESS || !notebook->children ||
@@ -2228,7 +2268,7 @@
 
   arrow = gtk_notebook_get_arrow (notebook, x, y);
   if (arrow)
-    return gtk_notebook_arrow_button_press (notebook, arrow, event);
+    return gtk_notebook_arrow_button_press (notebook, arrow, event->button);
 
   if (event->button == 3 && notebook->menu)
     {
@@ -2241,41 +2281,28 @@
     return FALSE;
 
   notebook->button = event->button;
-  num = 0;
-  children = notebook->children;
 
-  while (children)
+  if ((tab = get_tab_at_pos (notebook, x, y)) != NULL)
     {
-      page = children->data;
-      
-      if (GTK_WIDGET_VISIBLE (page->child) &&
-	  page->tab_label && GTK_WIDGET_MAPPED (page->tab_label) &&
-	  (x >= page->allocation.x) &&
-	  (y >= page->allocation.y) &&
-	  (x <= (page->allocation.x + page->allocation.width)) &&
-	  (y <= (page->allocation.y + page->allocation.height)))
-	{
-	  gboolean page_changed = page != notebook->cur_page;
-	  gboolean was_focus = gtk_widget_is_focus (widget);
+      gboolean page_changed, was_focus;
+
+      page = tab->data;
+      page_changed = page != notebook->cur_page;
+      was_focus = gtk_widget_is_focus (widget);
 	  
-	  gtk_notebook_switch_focus_tab (notebook, children);
-	  gtk_widget_grab_focus (widget);
+      gtk_notebook_switch_focus_tab (notebook, tab);
+      gtk_widget_grab_focus (widget);
 	  
-	  if (page_changed && !was_focus)
-	    gtk_widget_child_focus (page->child, GTK_DIR_TAB_FORWARD);
+      if (page_changed && !was_focus)
+	gtk_widget_child_focus (page->child, GTK_DIR_TAB_FORWARD);
 	  
-	  /* save press to possibly begin a drag */
-	  if (page->reorderable || page->detachable)
-	    {
-	      priv->during_detach = FALSE;
-	      priv->pressed_button = event->button;
-	      gtk_grab_add (widget);
-	    }
-
-	  break;
+      /* save press to possibly begin a drag */
+      if (page->reorderable || page->detachable)
+	{
+	  priv->during_detach = FALSE;
+	  priv->pressed_button = event->button;
+	  gtk_grab_add (widget);
 	}
-      children = children->next;
-      num++;
     }
 
   return TRUE;
@@ -2812,30 +2839,129 @@
 }
 
 static gboolean
+gtk_notebook_switch_tab_timeout (gpointer data)
+{
+  GtkNotebook *notebook;
+  GtkNotebookPrivate *priv;
+  GList *tab;
+  gint x, y;
+
+  notebook = GTK_NOTEBOOK (data);
+  priv = GTK_NOTEBOOK_GET_PRIVATE (notebook);
+
+  priv->switch_tab_timer = 0;
+  x = priv->mouse_x;
+  y = priv->mouse_y;
+
+  if ((tab = get_tab_at_pos (notebook, x, y)) != NULL)
+    {
+      /* FIXME: hack, we don't want the
+       * focus to move fom the source widget
+       */
+      notebook->child_has_focus = FALSE;
+      gtk_notebook_switch_focus_tab (notebook, tab);
+    }
+
+  return FALSE;
+}
+
+static gboolean
 gtk_notebook_drag_motion (GtkWidget      *widget,
 			  GdkDragContext *context,
 			  gint            x,
 			  gint            y,
 			  guint           time)
 {
-  GtkWidget *source_widget;
-  gint widget_group, source_widget_group;
-  
-  source_widget = gtk_drag_get_source_widget (context);
-  
-  g_assert (source_widget);
+  GtkNotebook *notebook;
+  GtkNotebookPrivate *priv;
+  GdkRectangle position;
+  GtkSettings *settings;
+  GtkNotebookArrow arrow;
+  guint timeout;
+  GdkAtom target;
+
+  notebook = GTK_NOTEBOOK (widget);
+  target = gtk_drag_dest_find_target (widget, context, NULL);
+
+  if (target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB"))
+    {
+      gint widget_group, source_widget_group;
+      GtkWidget *source_widget;
+
+      source_widget = gtk_drag_get_source_widget (context);
 
-  widget_group = gtk_notebook_get_group_id (GTK_NOTEBOOK (widget));
-  source_widget_group = gtk_notebook_get_group_id (GTK_NOTEBOOK (source_widget));
+      g_assert (source_widget);
 
-  if (widget_group != -1 &&
-      source_widget_group != -1 &&
-      widget_group == source_widget_group)
-    return TRUE;
+      widget_group = gtk_notebook_get_group_id (notebook);
+      source_widget_group = gtk_notebook_get_group_id (GTK_NOTEBOOK (source_widget));
+
+      if (widget_group != -1 &&
+	  source_widget_group != -1 &&
+	  widget_group == source_widget_group)
+	{
+	  gdk_drag_status (context, GDK_ACTION_MOVE, time);
+	  return TRUE;
+	}
+    }
+
+  priv = GTK_NOTEBOOK_GET_PRIVATE (widget);
+  x += widget->allocation.x;
+  y += widget->allocation.y;
 
   gdk_drag_status (context, 0, time);
 
-  return FALSE;
+  if (gtk_notebook_get_event_window_position (notebook, &position) &&
+      x >= position.x && x <= position.x + position.width &&
+      y >= position.y && y <= position.y + position.height)
+    {
+      priv->mouse_x = x;
+      priv->mouse_y = y;
+
+      arrow = gtk_notebook_get_arrow (notebook, x, y);
+
+      if (arrow)
+	return gtk_notebook_arrow_button_press (notebook, arrow, 1);
+
+      stop_scrolling (notebook);
+
+      if (!priv->switch_tab_timer)
+	{
+          settings = gtk_widget_get_settings (widget);
+
+          g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);
+	  priv->switch_tab_timer = g_timeout_add (timeout,
+						  (GSourceFunc) gtk_notebook_switch_tab_timeout,
+						  widget);
+	}
+    }
+  else
+    {
+      if (priv->switch_tab_timer)
+	{
+	  g_source_remove (priv->switch_tab_timer);
+	  priv->switch_tab_timer = 0;
+	}
+    }
+
+  return TRUE;
+}
+
+static void
+gtk_notebook_drag_leave (GtkWidget      *widget,
+			 GdkDragContext *context,
+			 guint           time)
+{
+  GtkNotebookPrivate *priv;
+
+  priv = GTK_NOTEBOOK_GET_PRIVATE (widget);
+
+  if (priv->switch_tab_timer)
+    {
+      g_source_remove (priv->switch_tab_timer);
+      priv->switch_tab_timer = 0;
+    }
+
+  stop_scrolling (GTK_NOTEBOOK (widget));
 }
 
 static gboolean
Index: gtkselection.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkselection.c,v
retrieving revision 1.108
diff -u -r1.108 gtkselection.c
--- gtkselection.c	7 Mar 2006 13:45:55 -0000	1.108
+++ gtkselection.c	9 Mar 2006 13:02:20 -0000
@@ -1,3 +1,4 @@
+/* -*- Mode: C; c-file-style: "gnu"; tab-width: 8 -*- */
 /* GTK - The GIMP Toolkit
  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
  *
@@ -290,6 +291,7 @@
 static GdkAtom text_plain_utf8_atom;
 static GdkAtom text_plain_locale_atom;
 static GdkAtom text_uri_list_atom;
+static GdkAtom universal_atom;
 
 static void 
 init_atoms (void)
@@ -310,6 +312,8 @@
       g_free (tmp);
 
       text_uri_list_atom = gdk_atom_intern_static_string ("text/uri-list");
+
+      universal_atom = gdk_atom_intern_static_string ("application/x-dnd-anything");
     }
 }
 
@@ -542,16 +546,27 @@
 		      guint         *info)
 {
   GList *tmp_list = list->list;
+  gboolean has_universal_atom = FALSE;
+
   while (tmp_list)
     {
       GtkTargetPair *pair = tmp_list->data;
 
+      if (pair->target == universal_atom)
+	has_universal_atom = TRUE;
+
       if (pair->target == target)
 	{
 	  *info = pair->info;
 	  return TRUE;
 	}
       tmp_list = tmp_list->next;
+    }
+
+  if (has_universal_atom)
+    {
+      *info = ((GtkTargetPair *) list->list->data)->info;
+      return TRUE;
     }
 
   return FALSE;
Index: gtksettings.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtksettings.c,v
retrieving revision 1.90
diff -u -r1.90 gtksettings.c
--- gtksettings.c	22 Feb 2006 10:10:23 -0000	1.90
+++ gtksettings.c	9 Mar 2006 13:02:21 -0000
@@ -34,6 +34,7 @@
 
 #define DEFAULT_TIMEOUT_INITIAL 200
 #define DEFAULT_TIMEOUT_REPEAT   20
+#define DEFAULT_TIMEOUT_EXPAND  500
 
 typedef struct _GtkSettingsValuePrivate GtkSettingsValuePrivate;
 
@@ -87,6 +88,7 @@
   PROP_SHOW_UNICODE_MENU,
   PROP_TIMEOUT_INITIAL,
   PROP_TIMEOUT_REPEAT,
+  PROP_TIMEOUT_EXPAND,
   PROP_COLOR_SCHEME,
   PROP_ENABLE_ANIMATIONS,
   PROP_TOUCHSCREEN_MODE,
@@ -451,6 +453,16 @@
 					     NULL);
 
   g_assert (result == PROP_TIMEOUT_REPEAT);
+
+  result = settings_install_property_parser (class,
+					     g_param_spec_int ("gtk-timeout-expand",
+ 							       P_("Expand timeout"),
+ 							       P_("Expand value for timeouts, when a widget is expanding a new region"),
+ 							       0, G_MAXINT, DEFAULT_TIMEOUT_EXPAND,
+ 							       GTK_PARAM_READWRITE),
+					     NULL);
+
+  g_assert (result == PROP_TIMEOUT_EXPAND);
 
   /**
    * GtkSettings:gtk-color-scheme:
