Index: gtk/gtknotebook.c
===================================================================
--- gtk/gtknotebook.c	(Revision 21122)
+++ gtk/gtknotebook.c	(Arbeitskopie)
@@ -838,6 +838,27 @@ gtk_notebook_class_init (GtkNotebookClas
                                                              0,
                                                              GTK_PARAM_READABLE));
 
+  /**
+   * GtkNotebook:smart-gap:
+   *
+   * If the "smart-gap" property is %TRUE, the
+   * notebook gap is drawn with a detail string related
+   * to whether tabs are visible on either side.
+   *
+   * This should only be enabled if the theme engine
+   * supports this, otherwise themeing may break.
+   *
+   * See gtk_notebook_paint() implementation for details.
+   *
+   * Since: 2.16
+   */
+  gtk_widget_class_install_style_property (widget_class,
+                                           g_param_spec_boolean ("smart-gap",
+                                                                 P_("Smart Gap"),
+                                                                 P_("If the \"smart-gap\" property is %TRUE, the notebook gap is drawn with a detail string related to whether tabs are visible on either side"),
+                                                                 FALSE,
+                                                                 GTK_PARAM_READABLE));
+
   notebook_signals[SWITCH_PAGE] =
     g_signal_new (I_("switch-page"),
 		  G_TYPE_FROM_CLASS (gobject_class),
@@ -4555,7 +4576,9 @@ gtk_notebook_paint (GtkWidget    *widget
   GtkNotebookPrivate *priv;
   GtkNotebookPage *page;
   GList *children;
-  gboolean showarrow;
+  gboolean smart_gap;
+  gboolean tab_front, tab_rear, tab_overflow;
+  GString *detail;
   gint width, height;
   gint x, y;
   gint border_width = GTK_CONTAINER (widget)->border_width;
@@ -4645,13 +4668,59 @@ gtk_notebook_paint (GtkWidget    *widget
 	  break;
 	}
     }
+
+  /* Determine the expected layout of tabs:
+  tab_front: TRUE if at least one visible tab is at the front
+  tab_rear: TRUE if at least one visible tab is at the rear
+  tab_overflow: TRUE if we have more tabs than we can display
+  */
+  tab_front = FALSE;
+  tab_rear = FALSE;
+  tab_overflow = FALSE;
+  children = gtk_notebook_search_page (notebook, NULL, step, TRUE);
+  while (children)
+    {
+      page = children->data;
+      children = gtk_notebook_search_page (notebook, children,
+                                           step, TRUE);
+      if (!GTK_WIDGET_VISIBLE (page->child))
+        continue;
+      if (!GTK_WIDGET_MAPPED (page->tab_label))
+        tab_overflow = TRUE;
+      else if (page->pack == GTK_PACK_START)
+          tab_front = TRUE;
+      else
+          tab_rear = TRUE;
+    }
+
+  /* The following logic takes place if, and only if, "smart-gap" is %TRUE */
+  gtk_widget_style_get (widget, "smart-gap", &smart_gap, NULL);
+  /* The following schema describes the expected detail
+  in different cases, "1" meaning any number of visible tabs:
+    1 child front               => notebook_tab_front
+    n children front            => notebook_tab_front
+    n children + arrows         => notebook
+    n children + !arrows        => notebook_tab_front_rear
+    n children rear             => notebook_tab_rear
+    1 child left + 1 child rear => notebook_tab_front_rear
+  */
+  detail = g_string_new ("notebook");
+  if (smart_gap && (tab_front || tab_rear || tab_overflow))
+    {
+      if (tab_front && !(notebook->scrollable
+       && (notebook->has_before_previous || notebook->has_after_previous)))
+        g_string_append (detail, "_front");
+      if (tab_rear && !(notebook->scrollable
+       && (notebook->has_before_next || notebook->has_after_next)))
+        g_string_append (detail, "_rear");
+    }
   gtk_paint_box_gap (widget->style, widget->window,
 		     GTK_STATE_NORMAL, GTK_SHADOW_OUT,
-		     area, widget, "notebook",
+		     area, widget, detail->str,
 		     x, y, width, height,
 		     tab_pos, gap_x, gap_width);
+  g_string_free (detail, TRUE);
 
-  showarrow = FALSE;
   children = gtk_notebook_search_page (notebook, NULL, step, TRUE);
   while (children)
     {
@@ -4660,13 +4729,11 @@ gtk_notebook_paint (GtkWidget    *widget
 					   step, TRUE);
       if (!GTK_WIDGET_VISIBLE (page->child))
 	continue;
-      if (!GTK_WIDGET_MAPPED (page->tab_label))
-	showarrow = TRUE;
       else if (page != notebook->cur_page)
 	gtk_notebook_draw_tab (notebook, page, area);
     }
 
-  if (showarrow && notebook->scrollable) 
+  if (tab_overflow && notebook->scrollable) 
     {
       if (notebook->has_before_previous)
 	gtk_notebook_draw_arrow (notebook, ARROW_LEFT_BEFORE);
