]> Pileus Git - ~andy/gtk/commitdiff
notebook: flip the render order
authorCosimo Cecchi <cosimoc@gnome.org>
Sat, 5 Mar 2011 08:01:44 +0000 (03:01 -0500)
committerCosimo Cecchi <cosimoc@gnome.org>
Mon, 7 Mar 2011 05:49:14 +0000 (00:49 -0500)
The render order for tabs is now

- left to right until the active tab
- right to left until the active tab
- active tab

This allows themes that use non-straight lines for the tab curvature to
draw them not worrying about flipping one side after the active tab.

gtk/gtknotebook.c

index 77d44f9cb7d8195f46d951a911ff6154fd3e7a8d..e601bb7205b73b0cb97d80fb2abf091fdbd0db24 100644 (file)
@@ -4906,7 +4906,7 @@ gtk_notebook_paint (GtkWidget    *widget,
   GtkNotebookPrivate *priv;
   GtkNotebookPage *page;
   GtkAllocation allocation;
-  GList *children;
+  GList *children, *other_order;
   gboolean showarrow;
   gint width, height;
   gint x, y;
@@ -5061,8 +5061,13 @@ gtk_notebook_paint (GtkWidget    *widget,
   while (children)
     {
       page = children->data;
+
+      if (page == priv->cur_page)
+        break;
+
       children = gtk_notebook_search_page (notebook, children,
                                            step, TRUE);
+
       if (!gtk_widget_get_visible (page->child) ||
           !gtk_widget_get_mapped (page->tab_label))
         continue;
@@ -5071,6 +5076,37 @@ gtk_notebook_paint (GtkWidget    *widget,
       gtk_notebook_draw_tab (notebook, page, cr, tab_flags);
     }
 
+  if (children != NULL)
+    {
+      other_order = NULL;
+
+      while (children)
+        {
+          page = children->data;
+          children = gtk_notebook_search_page (notebook, children,
+                                               step, TRUE);
+          if (!gtk_widget_get_visible (page->child) ||
+              !gtk_widget_get_mapped (page->tab_label))
+            continue;
+
+          if (children != NULL)
+            other_order = g_list_prepend (other_order, children->data);
+        }
+
+      /* draw them with the opposite order */
+      children = other_order;
+
+      while (children)
+        {
+          page = children->data;
+
+          tab_flags = _gtk_notebook_get_tab_flags (notebook, page);
+          gtk_notebook_draw_tab (notebook, page, cr, tab_flags);
+
+          children = children->next;
+        }
+    }
+
   if (showarrow && priv->scrollable)
     {
       if (priv->has_before_previous)