Index: gtkwidget.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.c,v
retrieving revision 1.443.2.1
diff -u -r1.443.2.1 gtkwidget.c
--- gtkwidget.c	9 Sep 2006 05:07:07 -0000	1.443.2.1
+++ gtkwidget.c	12 Oct 2006 16:13:41 -0000
@@ -8057,5 +8057,58 @@
   g_object_notify (G_OBJECT (widget), "no-show-all");
 }
 
+/**
+ * gtk_widget_get_event_position:
+ * @widget: a #GtkWidget
+ * @event: a #GdkEvent
+ * @x: return location for the x coordinate (relative to @widget)
+ * @y: return location for the y coordinate (relative to @widget)
+ * 
+ * Gets the x/y coordinates from an event in values relative
+ * to the given widget instead of the event window. This will only work
+ * if the widget is realized, both the given widget and the event window
+ * widget share a common toplevel and the event delivers event window
+ * coordinates.
+ * 
+ * Return Value: #FALSE if the widget is not realized, the widget and
+ * the event window do not share a common toplevel, or the event doesn't
+ * deliver event window coordinates. Oterwise #TRUE.
+ *
+ * Since: 2.12
+ **/
+gboolean
+gtk_widget_get_event_position (GtkWidget *widget,
+			       GdkEvent  *event,
+			       gint      *x,
+			       gint      *y)
+{
+  GtkWidget *event_widget;
+  gdouble event_x, event_y;
+  gint window_x, window_y, coord_x, coord_y;
+
+  g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+  g_return_val_if_fail (GTK_WIDGET_REALIZED (widget), FALSE);
+  g_return_val_if_fail (gdk_event_get_coords (event, &event_x, &event_y), FALSE);
+
+  gdk_window_get_user_data (((GdkEventAny*) event)->window, &event_widget);
+  gdk_window_get_position (((GdkEventAny*) event)->window, &window_x, &window_y);
+
+  coord_x = window_x - event_widget->allocation.x + (gint) event_x;
+  coord_y = window_y - event_widget->allocation.y + (gint) event_y;
+
+  if (widget == event_widget)
+    {
+      if (x)
+       *x = coord_x;
+
+      if (y)
+       *y = coord_y;
+
+      return TRUE;
+    }
+  else
+    return gtk_widget_translate_coordinates (event_widget, widget, (gint) event_x, (gint) event_y, x, y);
+}
+
 #define __GTK_WIDGET_C__
 #include "gtkaliasdef.c"
Index: gtkwidget.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwidget.h,v
retrieving revision 1.159
diff -u -r1.159 gtkwidget.h
--- gtkwidget.h	25 Apr 2006 14:27:31 -0000	1.159
+++ gtkwidget.h	12 Oct 2006 16:13:42 -0000
@@ -634,6 +634,10 @@
 					       gint        src_y,
 					       gint       *dest_x,
 					       gint       *dest_y);
+gboolean     gtk_widget_get_event_position    (GtkWidget *widget,
+					       GdkEvent  *event,
+					       gint      *x,
+					       gint      *y);
 
 /* Hide widget and return TRUE.
  */
Index: gtknotebook.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.c,v
retrieving revision 1.226.2.2
diff -u -r1.226.2.2 gtknotebook.c
--- gtknotebook.c	8 Oct 2006 19:03:00 -0000	1.226.2.2
+++ gtknotebook.c	12 Oct 2006 16:13:51 -0000
@@ -7386,5 +7386,36 @@
     }
 }
 
+/**
+ * gtk_notebook_get_tab_at_pos:
+ * @notebook: a #GtkNotebook
+ * @x: x coordinate (relative to the notebook widget)
+ * @y: y coordinate (relative to the notebook widget)
+ * 
+ * Returns the index corresponding to the tab under the x/y
+ * coordinates, or -1 if no tab is found in these coordinates.
+ * 
+ * Return Value: The index corresponding to the tab, or -1
+ *
+ * Since: 2.12
+ **/
+gint
+gtk_notebook_get_tab_at_pos (GtkNotebook *notebook,
+			     gint         x,
+			     gint         y)
+{
+  GtkWidget *widget;
+  GList *page;
+
+  g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), -1);
+
+  widget = GTK_WIDGET (notebook);
+  x += widget->allocation.x;
+  y += widget->allocation.y;
+
+  page = get_tab_at_pos (notebook, x, y);
+  return g_list_position (notebook->children, page);
+}
+
 #define __GTK_NOTEBOOK_C__
 #include "gtkaliasdef.c"
Index: gtknotebook.h
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtknotebook.h,v
retrieving revision 1.40
diff -u -r1.40 gtknotebook.h
--- gtknotebook.h	8 Jun 2006 00:17:00 -0000	1.40
+++ gtknotebook.h	12 Oct 2006 16:13:51 -0000
@@ -267,6 +267,9 @@
 void gtk_notebook_set_tab_detachable      (GtkNotebook *notebook,
 					   GtkWidget   *child,
 					   gboolean     detachable);
+gint gtk_notebook_get_tab_at_pos          (GtkNotebook *notebook,
+					   gint         x,
+					   gint         y);
 
 #ifndef GTK_DISABLE_DEPRECATED
 #define	gtk_notebook_current_page               gtk_notebook_get_current_page
