[gtk+] notebook: use the current state to get the padding values



commit d4f83cdfb61a6d781d91557c54be398b9dcbe300
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Sep 27 12:54:22 2011 -0400

    notebook: use the current state to get the padding values
    
    We want to enable the use of different padding values between active and
    inactive tabs, so that the two are completely separated (but limited by
    the active tab size).
    This way themes can decide how bigger the active tab is drawn compared
    to the normal one just specifying a different padding value from the
    CSS, like this:
    
    .notebook tab {
      padding: 2;
    }
    
    .notebook tab:active {
      padding: 4;
    }
    
    As a first step, fetch the padding values with the right state flags
    from GtkStyleContext.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=659777

 gtk/gtknotebook.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 8ea2c6c..8ca3652 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -2008,6 +2008,7 @@ gtk_notebook_get_preferred_tabs_size (GtkNotebook    *notebook,
       if (gtk_widget_get_visible (page->child))
         {
           GtkBorder tab_padding;
+          GtkStateFlags state;
 
           vis_pages++;
 
@@ -2018,10 +2019,15 @@ gtk_notebook_get_preferred_tabs_size (GtkNotebook    *notebook,
                                          &child_requisition, NULL);
 
           /* Get border/padding for tab */
+          if (page == priv->cur_page)
+            state = GTK_STATE_FLAG_ACTIVE;
+          else
+            state = GTK_STATE_FLAG_NORMAL;
+
           gtk_style_context_save (context);
           gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB,
                                         _gtk_notebook_get_tab_flags (notebook, page));
-          gtk_style_context_get_padding (context, 0, &tab_padding);
+          gtk_style_context_get_padding (context, state, &tab_padding);
           gtk_style_context_restore (context);
 
           page->requisition.width = child_requisition.width +
@@ -6155,6 +6161,7 @@ gtk_notebook_page_allocate (GtkNotebook     *notebook,
   gboolean tab_allocation_changed;
   gboolean was_visible = page->tab_allocated_visible;
   GtkBorder tab_padding;
+  GtkStateFlags state;
 
   if (!page->tab_label ||
       !gtk_widget_get_visible (page->tab_label) ||
@@ -6164,13 +6171,18 @@ gtk_notebook_page_allocate (GtkNotebook     *notebook,
       return was_visible;
     }
 
+  if (page == priv->cur_page)
+    state = GTK_STATE_FLAG_ACTIVE;
+  else
+    state = GTK_STATE_FLAG_NORMAL;
+
   context = gtk_widget_get_style_context (widget);
 
   gtk_style_context_save (context);
   gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB,
                                 _gtk_notebook_get_tab_flags (notebook, page));
 
-  gtk_style_context_get_padding (context, 0, &tab_padding);
+  gtk_style_context_get_padding (context, state, &tab_padding);
 
   gtk_widget_get_preferred_size (page->tab_label, &tab_requisition, NULL);
   gtk_widget_style_get (widget,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]