[gtk+/refactor: 100/110] gtk/gtknotebook.c: use accessor functions to access GtkWidget



commit e92191788f348dedc5c4b3440fb53fe4ff9176be
Author: Javier Jardón <jjardon gnome org>
Date:   Wed Aug 11 23:06:29 2010 +0200

    gtk/gtknotebook.c: use accessor functions to access GtkWidget

 gtk/gtknotebook.c |  413 +++++++++++++++++++++++++++++++----------------------
 1 files changed, 239 insertions(+), 174 deletions(-)
---
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 44d1c9a..b053fec 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -195,7 +195,7 @@ enum {
 #define PAGE_TOP_Y(_page_)    (((GtkNotebookPage *) (_page_))->allocation.y)
 #define PAGE_BOTTOM_Y(_page_) (((GtkNotebookPage *) (_page_))->allocation.y + ((GtkNotebookPage *) (_page_))->allocation.height)
 #define PAGE_MIDDLE_Y(_page_) (((GtkNotebookPage *) (_page_))->allocation.y + ((GtkNotebookPage *) (_page_))->allocation.height / 2)
-#define NOTEBOOK_IS_TAB_LABEL_PARENT(_notebook_,_page_) (((GtkNotebookPage *) (_page_))->tab_label->parent == ((GtkWidget *) (_notebook_)))
+#define NOTEBOOK_IS_TAB_LABEL_PARENT(_notebook_,_page_) (gtk_widget_get_parent (((GtkNotebookPage *) (_page_))->tab_label) == ((GtkWidget *) (_notebook_)))
 
 struct _GtkNotebookPage
 {
@@ -1603,6 +1603,7 @@ gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
 					GdkRectangle *rectangle)
 {
   GtkNotebookPriv *priv = notebook->priv;
+  GtkAllocation allocation, action_allocation;
   GtkWidget *widget = GTK_WIDGET (notebook);
   guint border_width = gtk_container_get_border_width (GTK_CONTAINER (notebook));
   GtkNotebookPage *visible_page = NULL;
@@ -1625,47 +1626,53 @@ gtk_notebook_get_event_window_position (GtkNotebook  *notebook,
     {
       if (rectangle)
 	{
+          gtk_widget_get_allocation (widget, &allocation);
+
 	  is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
-	  rectangle->x = widget->allocation.x + border_width;
-	  rectangle->y = widget->allocation.y + border_width;
+	  rectangle->x = allocation.x + border_width;
+	  rectangle->y = allocation.y + border_width;
 
 	  switch (tab_pos)
 	    {
 	    case GTK_POS_TOP:
 	    case GTK_POS_BOTTOM:
-	      rectangle->width = widget->allocation.width - 2 * border_width;
+	      rectangle->width = allocation.width - 2 * border_width;
 	      rectangle->height = visible_page->requisition.height;
 	      if (tab_pos == GTK_POS_BOTTOM)
-		rectangle->y += widget->allocation.height - 2 * border_width - rectangle->height;
+		rectangle->y += allocation.height - 2 * border_width - rectangle->height;
 
               for (i = 0; i < N_ACTION_WIDGETS; i++)
                 {
                   if (priv->action_widget[i] &&
                       gtk_widget_get_visible (priv->action_widget[i]))
                     {
-                      rectangle->width -= priv->action_widget[i]->allocation.width;
+                      gtk_widget_get_allocation (priv->action_widget[i], &action_allocation);
+
+                      rectangle->width -= action_allocation.width;
                       if ((!is_rtl && i == ACTION_WIDGET_START) ||
                           (is_rtl && i == ACTION_WIDGET_END))
-                        rectangle->x += priv->action_widget[i]->allocation.width;
+                        rectangle->x += action_allocation.width;
                     }
                 }
 	      break;
 	    case GTK_POS_LEFT:
 	    case GTK_POS_RIGHT:
 	      rectangle->width = visible_page->requisition.width;
-	      rectangle->height = widget->allocation.height - 2 * border_width;
+	      rectangle->height = allocation.height - 2 * border_width;
 	      if (tab_pos == GTK_POS_RIGHT)
-		rectangle->x += widget->allocation.width - 2 * border_width - rectangle->width;
+		rectangle->x += allocation.width - 2 * border_width - rectangle->width;
 
               for (i = 0; i < N_ACTION_WIDGETS; i++)
                 {
                   if (priv->action_widget[i] &&
                       gtk_widget_get_visible (priv->action_widget[i]))
                     {
-                      rectangle->height -= priv->action_widget[i]->allocation.height;
+                      gtk_widget_get_allocation (priv->action_widget[i], &action_allocation);
+
+                      rectangle->height -= action_allocation.height;
 
                       if (i == ACTION_WIDGET_START)
-                        rectangle->y += priv->action_widget[i]->allocation.height;
+                        rectangle->y += action_allocation.height;
                     }
                 }
               break;
@@ -1753,6 +1760,7 @@ gtk_notebook_realize (GtkWidget *widget)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPriv *priv = notebook->priv;
+  GdkWindow *window;
   GdkWindowAttr attributes;
   gint attributes_mask;
   GdkRectangle event_window_pos;
@@ -1760,10 +1768,11 @@ gtk_notebook_realize (GtkWidget *widget)
   gtk_widget_set_realized (widget, TRUE);
 
   gtk_notebook_get_event_window_position (notebook, &event_window_pos);
-  
-  widget->window = gtk_widget_get_parent_window (widget);
-  g_object_ref (widget->window);
-  
+
+  window = gtk_widget_get_parent_window (widget);
+  gtk_widget_set_window (widget, window);
+  g_object_ref (window);
+
   attributes.window_type = GDK_WINDOW_CHILD;
   attributes.x = event_window_pos.x;
   attributes.y = event_window_pos.y;
@@ -1781,7 +1790,7 @@ gtk_notebook_realize (GtkWidget *widget)
 					   &attributes, attributes_mask);
   gdk_window_set_user_data (priv->event_window, notebook);
 
-  widget->style = gtk_style_attach (widget->style, widget->window);
+  gtk_widget_style_attach (widget);
 }
 
 static void
@@ -1812,8 +1821,11 @@ gtk_notebook_size_request (GtkWidget      *widget,
   GtkNotebookPriv *priv = notebook->priv;
   GtkNotebookPage *page;
   GList *children;
+  GtkRequisition widget_requisition;
   GtkRequisition child_requisition;
   GtkRequisition action_widget_requisition[2] = { { 0 }, { 0 } };
+  GtkStyle *style;
+  GtkWidget *parent;
   gboolean switch_page = FALSE;
   gint vis_pages;
   gint focus_width;
@@ -1824,6 +1836,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
   gint scroll_arrow_vlength;
   guint border_width;
 
+  style = gtk_widget_get_style (widget);
   gtk_widget_style_get (widget,
                         "focus-line-width", &focus_width,
 			"tab-overlap", &tab_overlap,
@@ -1833,8 +1846,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
                         "scroll-arrow-vlength", &scroll_arrow_vlength,
 			NULL);
 
-  widget->requisition.width = 0;
-  widget->requisition.height = 0;
+  widget_requisition.width = 0;
+  widget_requisition.height = 0;
 
   for (children = priv->children, vis_pages = 0; children;
        children = children->next)
@@ -1845,30 +1858,37 @@ gtk_notebook_size_request (GtkWidget      *widget,
 	{
 	  vis_pages++;
 	  gtk_widget_size_request (page->child, &child_requisition);
-	  
-	  widget->requisition.width = MAX (widget->requisition.width,
-					   child_requisition.width);
-	  widget->requisition.height = MAX (widget->requisition.height,
-					    child_requisition.height);
-
-	  if (priv->menu && page->menu_label->parent &&
-	      !gtk_widget_get_visible (page->menu_label->parent))
-	    gtk_widget_show (page->menu_label->parent);
+
+          widget_requisition.width = MAX (widget_requisition.width, child_requisition.width);
+          widget_requisition.height = MAX (widget_requisition.height, child_requisition.height);
+
+          if (page->menu_label)
+            {
+              parent = gtk_widget_get_parent (page->menu_label);
+	      if (priv->menu && parent &&
+	          !gtk_widget_get_visible (parent))
+                gtk_widget_show (parent);
+            }
 	}
       else
 	{
 	  if (page == priv->cur_page)
 	    switch_page = TRUE;
-	  if (priv->menu && page->menu_label->parent &&
-	      gtk_widget_get_visible (page->menu_label->parent))
-	    gtk_widget_hide (page->menu_label->parent);
+
+          if (page->menu_label)
+            {
+              parent = gtk_widget_get_parent (page->menu_label);
+              if (priv->menu && parent &&
+                  gtk_widget_get_visible (parent))
+	        gtk_widget_hide (parent);
+            }
 	}
     }
 
   if (priv->show_border || priv->show_tabs)
     {
-      widget->requisition.width += widget->style->xthickness * 2;
-      widget->requisition.height += widget->style->ythickness * 2;
+      widget_requisition.width += style->xthickness * 2;
+      widget_requisition.height += style->ythickness * 2;
 
       if (priv->show_tabs)
 	{
@@ -1893,12 +1913,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
 		  gtk_widget_size_request (page->tab_label,
 					   &child_requisition);
 
-		  page->requisition.width = 
-		    child_requisition.width +
-		    2 * widget->style->xthickness;
-		  page->requisition.height = 
-		    child_requisition.height +
-		    2 * widget->style->ythickness;
+		  page->requisition.width = child_requisition.width + 2 * style->xthickness;
+		  page->requisition.height = child_requisition.height + 2 * style->ythickness;
 
 		  switch (priv->tab_pos)
 		    {
@@ -1931,8 +1947,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
                   if (priv->action_widget[i])
                     {
                       gtk_widget_size_request (priv->action_widget[i], &action_widget_requisition[i]);
-                      action_widget_requisition[i].width += widget->style->xthickness;
-                      action_widget_requisition[i].height += widget->style->ythickness;
+                      action_widget_requisition[i].width += style->xthickness;
+                      action_widget_requisition[i].height += style->ythickness;
                     }
                 }
 
@@ -1944,7 +1960,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
 		    break;
 
 		  if (priv->scrollable && vis_pages > 1 &&
-		      widget->requisition.width < tab_width)
+		      widget_requisition.width < tab_width)
 		    tab_height = MAX (tab_height, scroll_arrow_hlength);
 
                   tab_height = MAX (tab_height, action_widget_requisition[ACTION_WIDGET_START].height);
@@ -1971,20 +1987,20 @@ gtk_notebook_size_request (GtkWidget      *widget,
 		    }
 
 		  if (priv->scrollable && vis_pages > 1 &&
-		      widget->requisition.width < tab_width)
+                      widget_requisition.width < tab_width)
 		    tab_width = tab_max + 2 * (scroll_arrow_hlength + arrow_spacing);
 
 		  action_width += action_widget_requisition[ACTION_WIDGET_START].width;
 		  action_width += action_widget_requisition[ACTION_WIDGET_END].width;
+
                   if (priv->homogeneous && !priv->scrollable)
-                    widget->requisition.width = MAX (widget->requisition.width,
-                                                     vis_pages * tab_max +
-                                                     tab_overlap + action_width);
+                    widget_requisition.width = MAX (widget_requisition.width,
+                                                    vis_pages * tab_max + tab_overlap + action_width);
                   else
-                    widget->requisition.width = MAX (widget->requisition.width,
-                                                     tab_width + tab_overlap + action_width);
+                    widget_requisition.width = MAX (widget_requisition.width,
+                                                    tab_width + tab_overlap + action_width);
 
-		  widget->requisition.height += tab_height;
+		  widget_requisition.height += tab_height;
 		  break;
 		case GTK_POS_LEFT:
 		case GTK_POS_RIGHT:
@@ -1992,7 +2008,7 @@ gtk_notebook_size_request (GtkWidget      *widget,
 		    break;
 
 		  if (priv->scrollable && vis_pages > 1 &&
-		      widget->requisition.height < tab_height)
+		      widget_requisition.height < tab_height)
 		    tab_width = MAX (tab_width,
                                      arrow_spacing + 2 * scroll_arrow_vlength);
 
@@ -2022,27 +2038,25 @@ gtk_notebook_size_request (GtkWidget      *widget,
 		    }
 
 		  if (priv->scrollable && vis_pages > 1 &&
-		      widget->requisition.height < tab_height)
+		      widget_requisition.height < tab_height)
 		    tab_height = tab_max + (2 * scroll_arrow_vlength + arrow_spacing);
+
 		  action_height += action_widget_requisition[ACTION_WIDGET_START].height;
 		  action_height += action_widget_requisition[ACTION_WIDGET_END].height;
 
                   if (priv->homogeneous && !priv->scrollable)
-                    widget->requisition.height =
-		      MAX (widget->requisition.height,
-			   vis_pages * tab_max + tab_overlap + action_height);
+                    widget_requisition.height = MAX (widget_requisition.height,
+                                                      vis_pages * tab_max + tab_overlap + action_height);
                   else
-                    widget->requisition.height =
-		      MAX (widget->requisition.height,
-			   tab_height + tab_overlap + action_height);
+                    widget_requisition.height = MAX (widget_requisition.height,
+                                                      tab_height + tab_overlap + action_height);
 
 		  if (!priv->homogeneous || priv->scrollable)
 		    vis_pages = 1;
-		  widget->requisition.height = MAX (widget->requisition.height,
-						    vis_pages * tab_max +
-						    tab_overlap);
 
-		  widget->requisition.width += tab_width;
+                  widget_requisition.height = MAX (widget_requisition.height,
+                                                   vis_pages * tab_max + tab_overlap);
+                  widget_requisition.width += tab_width;
 		  break;
 		}
 	    }
@@ -2062,8 +2076,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
 
   border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
 
-  widget->requisition.width += border_width * 2;
-  widget->requisition.height += border_width * 2;
+  widget_requisition.width += border_width * 2;
+  widget_requisition.height += border_width * 2;
 
   if (switch_page)
     {
@@ -2082,8 +2096,8 @@ gtk_notebook_size_request (GtkWidget      *widget,
 	}
       else if (gtk_widget_get_visible (widget))
 	{
-	  widget->requisition.width = border_width * 2;
-	  widget->requisition.height= border_width * 2;
+	  widget_requisition.width = border_width * 2;
+	  widget_requisition.height= border_width * 2;
 	}
     }
   if (vis_pages && !priv->cur_page)
@@ -2095,6 +2109,9 @@ gtk_notebook_size_request (GtkWidget      *widget,
 	  gtk_notebook_switch_page (notebook, GTK_NOTEBOOK_PAGE (children));
 	}
     }
+
+  _gtk_widget_set_requisition (widget, &widget_requisition);
+  *requisition = widget_requisition;
 }
 
 static void
@@ -2108,8 +2125,9 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
   gint focus_width;
 
   gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);
-  
-  widget->allocation = *allocation;
+
+  gtk_widget_set_allocation (widget, allocation);
+
   if (gtk_widget_get_realized (widget))
     {
       GdkRectangle position;
@@ -2128,25 +2146,32 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
 
   if (priv->children)
     {
-      guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+      GtkAllocation widget_allocation;
       GtkNotebookPage *page;
       GtkAllocation child_allocation;
       GList *children;
       gint i;
-      
-      child_allocation.x = widget->allocation.x + border_width;
-      child_allocation.y = widget->allocation.y + border_width;
+      guint border_width;
+
+      gtk_widget_get_allocation (widget, &widget_allocation);
+
+      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+
+      child_allocation.x = widget_allocation.x + border_width;
+      child_allocation.y = widget_allocation.y + border_width;
       child_allocation.width = MAX (1, allocation->width - border_width * 2);
       child_allocation.height = MAX (1, allocation->height - border_width * 2);
 
       if (priv->show_tabs || priv->show_border)
 	{
-	  child_allocation.x += widget->style->xthickness;
-	  child_allocation.y += widget->style->ythickness;
-	  child_allocation.width = MAX (1, child_allocation.width -
-					widget->style->xthickness * 2);
-	  child_allocation.height = MAX (1, child_allocation.height -
-					 widget->style->ythickness * 2);
+          GtkStyle *style;
+
+          style = gtk_widget_get_style (widget);
+
+          child_allocation.x += style->xthickness;
+          child_allocation.y += style->ythickness;
+          child_allocation.width = MAX (1, child_allocation.width - style->xthickness * 2);
+          child_allocation.height = MAX (1, child_allocation.height - style->ythickness * 2);
 
 	  if (priv->show_tabs && priv->children && priv->cur_page)
 	    {
@@ -2171,44 +2196,41 @@ gtk_notebook_size_allocate (GtkWidget     *widget,
               for (i = 0; i < N_ACTION_WIDGETS; i++)
                 {
                   GtkAllocation widget_allocation;
+                  GtkRequisition requisition;
 
                   if (!priv->action_widget[i])
                     continue;
 
-		  widget_allocation.x = widget->allocation.x + border_width;
-		  widget_allocation.y = widget->allocation.y + border_width;
+		  widget_allocation.x = widget_allocation.x + border_width;
+		  widget_allocation.y = widget_allocation.y + border_width;
 		  is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
 
 		  switch (tab_pos)
 		    {
 		    case GTK_POS_BOTTOM:
-		      widget_allocation.y +=
-			widget->allocation.height - 2 * border_width - priv->cur_page->requisition.height;
+		      widget_allocation.y += widget_allocation.height - 2 * border_width - priv->cur_page->requisition.height;
 		      /* fall through */
 		    case GTK_POS_TOP:
-		      widget_allocation.width = priv->action_widget[i]->requisition.width;
-		      widget_allocation.height = priv->cur_page->requisition.height - widget->style->ythickness;
+                      gtk_widget_get_requisition (priv->action_widget[i], &requisition);
+		      widget_allocation.width = requisition.width;
+                      widget_allocation.height = priv->cur_page->requisition.height - style->ythickness;
 
 		      if ((i == ACTION_WIDGET_START && is_rtl) ||
                           (i == ACTION_WIDGET_END && !is_rtl))
-			widget_allocation.x +=
-			  widget->allocation.width - 2 * border_width -
-			  priv->action_widget[i]->requisition.width;
+			widget_allocation.x += widget_allocation.width - 2 * border_width - requisition.width;
                       if (tab_pos == GTK_POS_TOP) /* no fall through */
                           widget_allocation.y += 2 * focus_width;
 		      break;
 		    case GTK_POS_RIGHT:
-		      widget_allocation.x +=
-			widget->allocation.width - 2 * border_width - priv->cur_page->requisition.width;
+		      widget_allocation.x += widget_allocation.width - 2 * border_width - priv->cur_page->requisition.width;
 		      /* fall through */
 		    case GTK_POS_LEFT:
-		      widget_allocation.height = priv->action_widget[i]->requisition.height;
-		      widget_allocation.width = priv->cur_page->requisition.width - widget->style->xthickness;
+                      gtk_widget_get_requisition (priv->action_widget[i], &requisition);
+		      widget_allocation.height = requisition.height;
+                      widget_allocation.width = priv->cur_page->requisition.width - style->xthickness;
 
                       if (i == ACTION_WIDGET_END)
-                        widget_allocation.y +=
-                          widget->allocation.height - 2 * border_width -
-                          priv->action_widget[i]->requisition.height;
+                        widget_allocation.y += widget_allocation.height - 2 * border_width - requisition.height;
                       if (tab_pos == GTK_POS_LEFT) /* no fall through */  
                         widget_allocation.x += 2 * focus_width;
 		      break;
@@ -2254,7 +2276,7 @@ gtk_notebook_expose (GtkWidget      *widget,
        * ARGB visuals or shape windows.
        */
       cr = gdk_cairo_create (priv->drag_window);
-      gdk_cairo_set_source_color (cr, &widget->style->bg [GTK_STATE_NORMAL]);
+      gdk_cairo_set_source_color (cr, &gtk_widget_get_style (widget)->bg [GTK_STATE_NORMAL]);
       cairo_paint (cr);
       cairo_destroy (cr);
 
@@ -2283,7 +2305,7 @@ gtk_notebook_expose (GtkWidget      *widget,
 	      page = GTK_NOTEBOOK_PAGE (pages);
 	      pages = pages->next;
 
-	      if (page->tab_label->window == event->window &&
+              if (gtk_widget_get_window (page->tab_label) == event->window &&
 		  gtk_widget_is_drawable (page->tab_label))
 		gtk_container_propagate_expose (GTK_CONTAINER (notebook),
 						page->tab_label, event);
@@ -2505,7 +2527,7 @@ get_widget_coordinates (GtkWidget *widget,
   if (!gdk_event_get_coords (event, &tx, &ty))
     return FALSE;
 
-  while (window && window != widget->window)
+  while (window && window != gtk_widget_get_window (widget))
     {
       gint window_x, window_y;
 
@@ -2671,6 +2693,7 @@ popup_position_func (GtkMenu  *menu,
                      gboolean *push_in,
                      gpointer  data)
 {
+  GtkAllocation allocation;
   GtkNotebook *notebook = data;
   GtkNotebookPriv *priv = notebook->priv;
   GtkWidget *w;
@@ -2688,15 +2711,17 @@ popup_position_func (GtkMenu  *menu,
      w = GTK_WIDGET (notebook);
    }
 
-  gdk_window_get_origin (w->window, x, y);
+  gdk_window_get_origin (gtk_widget_get_window (w), x, y);
   gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
 
+  gtk_widget_get_allocation (w, &allocation);
+
   if (gtk_widget_get_direction (w) == GTK_TEXT_DIR_RTL)
-    *x += w->allocation.x + w->allocation.width - requisition.width;
+    *x += allocation.x + allocation.width - requisition.width;
   else
-    *x += w->allocation.x;
+    *x += allocation.x;
 
-  *y += w->allocation.y + w->allocation.height;
+  *y += allocation.y + allocation.height;
 
   *push_in = FALSE;
 }
@@ -2852,9 +2877,11 @@ hide_drag_window (GtkNotebook        *notebook,
 		  GtkNotebookPage    *page)
 {
   GtkWidget *widget = GTK_WIDGET (notebook);
-  GtkWidget *parent = page->tab_label->parent;
+  GtkWidget *parent;
+
+  parent = gtk_widget_get_parent (page->tab_label);
 
-  if (page->tab_label->window != widget->window ||
+  if (gtk_widget_get_window (page->tab_label) != gtk_widget_get_window (widget) ||
       !NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page))
     {
       g_object_ref (page->tab_label);
@@ -3116,7 +3143,8 @@ gtk_notebook_motion_notify (GtkWidget      *widget,
    * (priv->drag_window has a pointer grab), but we need coordinates relative to
    * the notebook widget.
    */
-  gdk_window_get_origin (widget->window, &x_win, &y_win);
+  gdk_window_get_origin (gtk_widget_get_window (widget),
+                         &x_win, &y_win);
   priv->mouse_x = event->x_root - x_win;
   priv->mouse_y = event->y_root - y_win;
 
@@ -3243,7 +3271,7 @@ gtk_notebook_draw_focus (GtkWidget      *widget,
 
   if (gtk_widget_has_focus (widget) && gtk_widget_is_drawable (widget) &&
       priv->show_tabs && priv->cur_page &&
-      priv->cur_page->tab_label->window == event->window)
+      gtk_widget_get_window (priv->cur_page->tab_label) == event->window)
     {
       GtkNotebookPage *page;
 
@@ -3251,17 +3279,19 @@ gtk_notebook_draw_focus (GtkWidget      *widget,
 
       if (gtk_widget_intersect (page->tab_label, &event->area, NULL))
         {
+          GtkAllocation allocation;
           GdkRectangle area;
           gint focus_width;
 
           gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL);
 
-          area.x = page->tab_label->allocation.x - focus_width;
-          area.y = page->tab_label->allocation.y - focus_width;
-          area.width = page->tab_label->allocation.width + 2 * focus_width;
-          area.height = page->tab_label->allocation.height + 2 * focus_width;
+          gtk_widget_get_allocation (page->tab_label, &allocation);
+          area.x = allocation.x - focus_width;
+          area.y = allocation.y - focus_width;
+          area.width = allocation.width + 2 * focus_width;
+          area.height = allocation.height + 2 * focus_width;
 
-	  gtk_paint_focus (widget->style, event->window, 
+	  gtk_paint_focus (gtk_widget_get_style (widget), event->window,
                            gtk_widget_get_state (widget), NULL, widget, "tab",
 			   area.x, area.y, area.width, area.height);
         }
@@ -3452,6 +3482,7 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
 			  gint            y,
 			  guint           time)
 {
+  GtkAllocation allocation;
   GtkNotebook *notebook = GTK_NOTEBOOK (widget);
   GtkNotebookPriv *priv = notebook->priv;
   GdkRectangle position;
@@ -3460,9 +3491,11 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
   guint timeout;
   GdkAtom target, tab_target;
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   arrow = gtk_notebook_get_arrow (notebook,
-				  x + widget->allocation.x,
-				  y + widget->allocation.y);
+                                  x + allocation.x,
+                                  y + allocation.y);
   if (arrow)
     {
       priv->click_child = arrow;
@@ -3502,8 +3535,8 @@ gtk_notebook_drag_motion (GtkWidget      *widget,
 	}
     }
 
-  x += widget->allocation.x;
-  y += widget->allocation.y;
+  x += allocation.x;
+  y += allocation.y;
 
   if (gtk_notebook_get_event_window_position (notebook, &position) &&
       x >= position.x && x <= position.x + position.width &&
@@ -3580,6 +3613,7 @@ do_detach_tab (GtkNotebook     *from,
 	       gint             y)
 {
   GtkNotebookPriv *to_priv = to->priv;
+  GtkAllocation allocation;
   GtkWidget *tab_label, *menu_label;
   gboolean tab_expand, tab_fill, reorderable, detachable;
   GList *element;
@@ -3609,8 +3643,9 @@ do_detach_tab (GtkNotebook     *from,
 
   gtk_container_remove (GTK_CONTAINER (from), child);
 
-  to_priv->mouse_x = x + GTK_WIDGET (to)->allocation.x;
-  to_priv->mouse_y = y + GTK_WIDGET (to)->allocation.y;
+  gtk_widget_get_allocation (GTK_WIDGET (to), &allocation);
+  to_priv->mouse_x = x + allocation.x;
+  to_priv->mouse_y = y + allocation.y;
 
   element = get_drop_position (to, tab_pack);
   page_num = g_list_position (to_priv->children, element);
@@ -4142,6 +4177,7 @@ gtk_notebook_set_focus_child (GtkContainer *container,
   GtkNotebook *notebook = GTK_NOTEBOOK (container);
   GtkNotebookPriv *priv = notebook->priv;
   GtkWidget *page_child;
+  GtkWidget *parent;
   GtkWidget *toplevel;
 
   /* If the old focus widget was within a page of the notebook,
@@ -4155,7 +4191,8 @@ gtk_notebook_set_focus_child (GtkContainer *container,
       page_child = GTK_WINDOW (toplevel)->focus_widget; 
       while (page_child)
 	{
-	  if (page_child->parent == GTK_WIDGET (container))
+          parent = gtk_widget_get_parent (page_child);
+	  if (parent == GTK_WIDGET (container))
 	    {
 	      GList *list = gtk_notebook_find_child (notebook, page_child, NULL);
 	      if (list != NULL) 
@@ -4172,7 +4209,7 @@ gtk_notebook_set_focus_child (GtkContainer *container,
 		}
 	    }
 
-	  page_child = page_child->parent;
+	  page_child = parent;
 	}
     }
   
@@ -4393,59 +4430,65 @@ static void
 gtk_notebook_redraw_tabs (GtkNotebook *notebook)
 {
   GtkNotebookPriv *priv = notebook->priv;
+  GtkAllocation allocation;
   GtkWidget *widget;
   GtkNotebookPage *page;
+  GtkStyle *style;
   GdkRectangle redraw_rect;
   gint border;
   gint tab_pos = get_effective_tab_pos (notebook);
 
   widget = GTK_WIDGET (notebook);
-  border = gtk_container_get_border_width (GTK_CONTAINER (notebook));
 
   if (!gtk_widget_get_mapped (widget) || !priv->first_tab)
     return;
 
+  border = gtk_container_get_border_width (GTK_CONTAINER (notebook));
+
+  style = gtk_widget_get_style (widget);
+
   page = priv->first_tab->data;
 
   redraw_rect.x = border;
   redraw_rect.y = border;
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   switch (tab_pos)
     {
     case GTK_POS_BOTTOM:
-      redraw_rect.y = widget->allocation.height - border -
-	page->allocation.height - widget->style->ythickness;
+      redraw_rect.y = allocation.height - border - page->allocation.height - style->ythickness;
 
       if (page != priv->cur_page)
-	redraw_rect.y -= widget->style->ythickness;
+	redraw_rect.y -= style->ythickness;
       /* fall through */
     case GTK_POS_TOP:
-      redraw_rect.width = widget->allocation.width - 2 * border;
-      redraw_rect.height = page->allocation.height + widget->style->ythickness;
+      redraw_rect.width = allocation.width - 2 * border;
+      redraw_rect.height = page->allocation.height + style->ythickness;
 
       if (page != priv->cur_page)
-	redraw_rect.height += widget->style->ythickness;
+	redraw_rect.height += style->ythickness;
       break;
     case GTK_POS_RIGHT:
-      redraw_rect.x = widget->allocation.width - border -
-	page->allocation.width - widget->style->xthickness;
+      redraw_rect.x = allocation.width - border - page->allocation.width - style->xthickness;
 
       if (page != priv->cur_page)
-	redraw_rect.x -= widget->style->xthickness;
+	redraw_rect.x -= style->xthickness;
       /* fall through */
     case GTK_POS_LEFT:
-      redraw_rect.width = page->allocation.width + widget->style->xthickness;
-      redraw_rect.height = widget->allocation.height - 2 * border;
+      redraw_rect.width = page->allocation.width + style->xthickness;
+      redraw_rect.height = allocation.height - 2 * border;
 
       if (page != priv->cur_page)
-	redraw_rect.width += widget->style->xthickness;
+	redraw_rect.width += style->xthickness;
       break;
     }
 
-  redraw_rect.x += widget->allocation.x;
-  redraw_rect.y += widget->allocation.y;
+  redraw_rect.x += allocation.x;
+  redraw_rect.y += allocation.y;
 
-  gdk_window_invalidate_rect (widget->window, &redraw_rect, TRUE);
+  gdk_window_invalidate_rect (gtk_widget_get_window (widget),
+                              &redraw_rect, TRUE);
 }
 
 static void
@@ -4471,7 +4514,7 @@ gtk_notebook_redraw_arrows (GtkNotebook *notebook)
 	    continue;
 
 	  gtk_notebook_get_arrow_rect (notebook, &rect, arrow[i]);
-	  gdk_window_invalidate_rect (GTK_WIDGET (notebook)->window, 
+	  gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (notebook)),
 				      &rect, FALSE);
 	}
     }
@@ -4626,7 +4669,7 @@ gtk_notebook_real_remove (GtkNotebook *notebook,
 
   if (priv->menu)
     {
-      GtkWidget *parent = page->menu_label->parent;
+      GtkWidget *parent = gtk_widget_get_parent (page->menu_label);
 
       gtk_notebook_menu_label_unparent (parent, NULL);
       gtk_container_remove (GTK_CONTAINER (priv->menu), parent);
@@ -4800,6 +4843,7 @@ static void
 gtk_notebook_paint (GtkWidget    *widget,
 		    GdkRectangle *area)
 {
+  GtkAllocation allocation;
   GtkNotebook *notebook;
   GtkNotebookPriv *priv;
   GtkNotebookPage *page;
@@ -4824,14 +4868,17 @@ gtk_notebook_paint (GtkWidget    *widget,
       !priv->cur_page || !gtk_widget_get_visible (priv->cur_page->child))
     return;
 
-  x = widget->allocation.x + border_width;
-  y = widget->allocation.y + border_width;
-  width = widget->allocation.width - border_width * 2;
-  height = widget->allocation.height - border_width * 2;
+  gtk_widget_get_allocation (widget, &allocation);
+
+  x = allocation.x + border_width;
+  y = allocation.y + border_width;
+  width = allocation.width - border_width * 2;
+  height = allocation.height - border_width * 2;
 
   if (priv->show_border && (!priv->show_tabs || !priv->children))
     {
-      gtk_paint_box (widget->style, widget->window,
+      gtk_paint_box (gtk_widget_get_style (widget),
+                     gtk_widget_get_window (widget),
 		     GTK_STATE_NORMAL, GTK_SHADOW_OUT,
 		     area, widget, "notebook",
 		     x, y, width, height);
@@ -4875,9 +4922,9 @@ gtk_notebook_paint (GtkWidget    *widget,
 	case GTK_POS_TOP:
 	case GTK_POS_BOTTOM:
 	  if (priv->operation == DRAG_OPERATION_REORDER)
-	    gap_x = priv->drag_window_x - widget->allocation.x - border_width;
+	    gap_x = priv->drag_window_x - allocation.x - border_width;
 	  else
-	    gap_x = priv->cur_page->allocation.x - widget->allocation.x - border_width;
+	    gap_x = priv->cur_page->allocation.x - allocation.x - border_width;
 
 	  gap_width = priv->cur_page->allocation.width;
 	  step = is_rtl ? STEP_NEXT : STEP_PREV;
@@ -4885,16 +4932,17 @@ gtk_notebook_paint (GtkWidget    *widget,
 	case GTK_POS_LEFT:
 	case GTK_POS_RIGHT:
 	  if (priv->operation == DRAG_OPERATION_REORDER)
-	    gap_x = priv->drag_window_y - border_width - widget->allocation.y;
+	    gap_x = priv->drag_window_y - border_width - allocation.y;
 	  else
-	    gap_x = priv->cur_page->allocation.y - widget->allocation.y - border_width;
+	    gap_x = priv->cur_page->allocation.y - allocation.y - border_width;
 
 	  gap_width = priv->cur_page->allocation.height;
 	  step = STEP_PREV;
 	  break;
 	}
     }
-  gtk_paint_box_gap (widget->style, widget->window,
+  gtk_paint_box_gap (gtk_widget_get_style (widget),
+                     gtk_widget_get_window (widget),
 		     GTK_STATE_NORMAL, GTK_SHADOW_OUT,
 		     area, widget, "notebook",
 		     x, y, width, height,
@@ -4953,7 +5001,7 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
   if (priv->operation == DRAG_OPERATION_REORDER && page == priv->cur_page)
     window = priv->drag_window;
   else
-    window = widget->window;
+    window = gtk_widget_get_window (widget);
 
   page_area.x = page->allocation.x;
   page_area.y = page->allocation.y;
@@ -4969,7 +5017,7 @@ gtk_notebook_draw_tab (GtkNotebook     *notebook,
       else 
 	state_type = GTK_STATE_ACTIVE;
 
-      gtk_paint_extension (widget->style, window,
+      gtk_paint_extension (gtk_widget_get_style (widget), window,
 			   state_type, GTK_SHADOW_OUT,
 			   area, widget, "tab",
 			   page_area.x, page_area.y,
@@ -5043,8 +5091,10 @@ gtk_notebook_draw_arrow (GtkNotebook      *notebook,
           arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT);
           arrow_size = scroll_arrow_hlength;
         }
-     
-      gtk_paint_arrow (widget->style, widget->window, state_type, 
+
+      gtk_paint_arrow (gtk_widget_get_style (widget),
+                       gtk_widget_get_window (widget),
+                       state_type,
 		       shadow_type, NULL, widget, "notebook",
 		       arrow, TRUE, arrow_rect.x, arrow_rect.y, 
 		       arrow_size, arrow_size);
@@ -5068,6 +5118,8 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
 			gint        *tab_space)
 {
   GtkNotebookPriv *priv = notebook->priv;
+  GtkAllocation allocation, action_allocation;
+  GtkStyle *style;
   GtkWidget *widget;
   GList *children;
   gint tab_pos = get_effective_tab_pos (notebook);
@@ -5083,30 +5135,34 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
   children = priv->children;
   is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
 
+  style = gtk_widget_get_style (widget);
   gtk_widget_style_get (GTK_WIDGET (notebook),
                         "arrow-spacing", &arrow_spacing,
                         "scroll-arrow-hlength", &scroll_arrow_hlength,
                         "scroll-arrow-vlength", &scroll_arrow_vlength,
                         NULL);
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   border_width = gtk_container_get_border_width (GTK_CONTAINER (notebook));
 
   switch (tab_pos)
     {
     case GTK_POS_TOP:
     case GTK_POS_BOTTOM:
-      *min = widget->allocation.x + border_width;
-      *max = widget->allocation.x + widget->allocation.width - border_width;
+      *min = allocation.x + border_width;
+      *max = allocation.x + allocation.width - border_width;
 
       for (i = 0; i < N_ACTION_WIDGETS; i++)
         {
           if (priv->action_widget[i])
             {
+              gtk_widget_get_allocation (priv->action_widget[i], &action_allocation);
               if ((i == ACTION_WIDGET_START && !is_rtl) ||
                   (i == ACTION_WIDGET_END && is_rtl))
-                *min += priv->action_widget[i]->allocation.width + widget->style->xthickness;
+                *min += action_allocation.width + style->xthickness;
               else
-                *max -= priv->action_widget[i]->allocation.width + widget->style->xthickness;
+                *max -= action_allocation.width + style->xthickness;
             }
         }
 
@@ -5124,17 +5180,18 @@ gtk_notebook_tab_space (GtkNotebook *notebook,
       break;
     case GTK_POS_RIGHT:
     case GTK_POS_LEFT:
-      *min = widget->allocation.y + border_width;
-      *max = widget->allocation.y + widget->allocation.height - border_width;
+      *min = allocation.y + border_width;
+      *max = allocation.y + allocation.height - border_width;
 
       for (i = 0; i < N_ACTION_WIDGETS; i++)
         {
           if (priv->action_widget[i])
             {
+              gtk_widget_get_allocation (priv->action_widget[i], &action_allocation);
               if (i == ACTION_WIDGET_START)
-                *min += priv->action_widget[i]->allocation.height + widget->style->ythickness;
+                *min += action_allocation.height + style->ythickness;
               else
-                *max -= priv->action_widget[i]->allocation.height + widget->style->ythickness;
+                *max -= action_allocation.height + style->ythickness;
             }
         }
 
@@ -5460,9 +5517,11 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook  *notebook,
 					gint          max)
 {
   GtkNotebookPriv *priv = notebook->priv;
+  GtkAllocation allocation;
   GtkWidget *widget;
   GtkContainer *container;
   GtkNotebookPage *page;
+  GtkStyle *style;
   gboolean allocate_at_bottom;
   gint tab_overlap, tab_pos, tab_extra_space;
   gint left_x, right_x, top_y, bottom_y, anchor;
@@ -5478,17 +5537,20 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook  *notebook,
   allocate_at_bottom = get_allocate_at_bottom (widget, direction);
   anchor = 0;
 
+  gtk_widget_get_allocation (widget, &allocation);
+
   border_width = gtk_container_get_border_width (container);
-  child_allocation.x = widget->allocation.x + border_width;
-  child_allocation.y = widget->allocation.y + border_width;
+  child_allocation.x = allocation.x + border_width;
+  child_allocation.y = allocation.y + border_width;
 
-  xthickness = widget->style->xthickness;
-  ythickness = widget->style->ythickness;
+  style = gtk_widget_get_style (widget);
+  xthickness = style->xthickness;
+  ythickness = style->ythickness;
 
   switch (tab_pos)
     {
     case GTK_POS_BOTTOM:
-      child_allocation.y = widget->allocation.y + widget->allocation.height -
+      child_allocation.y = allocation.y + allocation.height -
 	priv->cur_page->requisition.height - border_width;
       /* fall through */
     case GTK_POS_TOP:
@@ -5498,7 +5560,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook  *notebook,
       break;
       
     case GTK_POS_RIGHT:
-      child_allocation.x = widget->allocation.x + widget->allocation.width -
+      child_allocation.x = allocation.x + allocation.width -
 	priv->cur_page->requisition.width - border_width;
       /* fall through */
     case GTK_POS_LEFT:
@@ -5835,8 +5897,10 @@ gtk_notebook_page_allocate (GtkNotebook     *notebook,
 {
   GtkWidget *widget = GTK_WIDGET (notebook);
   GtkNotebookPriv *priv = notebook->priv;
+  GtkAllocation allocation;
   GtkAllocation child_allocation;
   GtkRequisition tab_requisition;
+  GtkStyle *style;
   gint xthickness;
   gint ythickness;
   gint padding;
@@ -5854,8 +5918,9 @@ gtk_notebook_page_allocate (GtkNotebook     *notebook,
       return was_visible;
     }
 
-  xthickness = widget->style->xthickness;
-  ythickness = widget->style->ythickness;
+  style = gtk_widget_get_style (widget);
+  xthickness = style->xthickness;
+  ythickness = style->ythickness;
 
   gtk_widget_get_child_requisition (page->tab_label, &tab_requisition);
   gtk_widget_style_get (widget,
@@ -5917,10 +5982,11 @@ gtk_notebook_page_allocate (GtkNotebook     *notebook,
       break;
     }
 
-  tab_allocation_changed = (child_allocation.x != page->tab_label->allocation.x ||
-			    child_allocation.y != page->tab_label->allocation.y ||
-			    child_allocation.width != page->tab_label->allocation.width ||
-			    child_allocation.height != page->tab_label->allocation.height);
+  gtk_widget_get_allocation (page->tab_label, &allocation);
+  tab_allocation_changed = (child_allocation.x != allocation.x ||
+			    child_allocation.y != allocation.y ||
+			    child_allocation.width != allocation.width ||
+			    child_allocation.height != allocation.height);
 
   gtk_widget_size_allocate (page->tab_label, &child_allocation);
 
@@ -6217,8 +6283,7 @@ gtk_notebook_menu_switch_page (GtkWidget       *widget,
   GList *children;
   guint page_num;
 
-  notebook = GTK_NOTEBOOK (gtk_menu_get_attach_widget
-			   (GTK_MENU (widget->parent)));
+  notebook = GTK_NOTEBOOK (gtk_menu_get_attach_widget (GTK_MENU (gtk_widget_get_parent (widget))));
   priv = notebook->priv;
 
   if (priv->cur_page == page)
@@ -7341,7 +7406,7 @@ gtk_notebook_set_menu_label (GtkNotebook *notebook,
     {
       if (priv->menu)
 	gtk_container_remove (GTK_CONTAINER (priv->menu),
-			      page->menu_label->parent);
+                              gtk_widget_get_parent (page->menu_label));
 
       if (!page->default_menu)
 	g_object_unref (page->menu_label);
@@ -7429,8 +7494,8 @@ gtk_notebook_child_reordered (GtkNotebook     *notebook,
   if (priv->menu)
     {
       GtkWidget *menu_item;
-      
-      menu_item = page->menu_label->parent;
+
+      menu_item = gtk_widget_get_parent (page->menu_label);
       gtk_container_remove (GTK_CONTAINER (menu_item), page->menu_label);
       gtk_container_remove (GTK_CONTAINER (priv->menu), menu_item);
       gtk_notebook_menu_item_create (notebook, g_list_find (priv->children, page));
@@ -7846,7 +7911,7 @@ gtk_notebook_set_action_widget (GtkNotebook *notebook,
 
   g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
   g_return_if_fail (!widget || GTK_IS_WIDGET (widget));
-  g_return_if_fail (!widget || widget->parent == NULL);
+  g_return_if_fail (!widget || gtk_widget_get_parent (widget) == NULL);
 
   priv = notebook->priv;
 



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