[gtk+/refactor: 3/3] Use accessor functions to access GtkWidget
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 3/3] Use accessor functions to access GtkWidget
- Date: Wed, 11 Aug 2010 19:47:35 +0000 (UTC)
commit cc861cc71fa0752a2960b8177259675aa286ae76
Author: Javier Jardón <jjardon gnome org>
Date: Wed Aug 11 06:35:13 2010 +0200
Use accessor functions to access GtkWidget
gtk/gtkaboutdialog.c | 3 +-
gtk/gtkalignment.c | 2 +-
gtk/gtkarrow.c | 22 ++-
gtk/gtkassistant.c | 61 ++++--
gtk/gtkbbox.c | 5 +-
gtk/gtkbox.c | 4 +-
gtk/gtkbutton.c | 115 +++++++-----
gtk/gtkcalendar.c | 255 ++++++++++++++++----------
gtk/gtkcellrendereraccel.c | 19 ++-
gtk/gtkcellrendererpixbuf.c | 6 +-
gtk/gtkcellrendererprogress.c | 23 ++-
gtk/gtkcellrendererspinner.c | 2 +-
gtk/gtkcellrenderertext.c | 8 +-
gtk/gtkcellrenderertoggle.c | 4 +-
gtk/gtkcellview.c | 21 ++-
gtk/gtkcheckbutton.c | 85 ++++++---
gtk/gtkcheckmenuitem.c | 22 ++-
gtk/gtkcolorbutton.c | 2 +-
gtk/gtkcolorsel.c | 55 ++++--
gtk/gtkcombobox.c | 170 +++++++++++-------
gtk/gtkcontainer.c | 138 +++++++++-----
gtk/gtkdialog.c | 4 +-
gtk/gtkdrawingarea.c | 39 +++--
gtk/gtkentry.c | 178 ++++++++++++------
gtk/gtkentrycompletion.c | 20 ++-
gtk/gtkeventbox.c | 47 +++--
gtk/gtkexpander.c | 107 +++++++----
gtk/gtkfilechooserdefault.c | 23 ++-
gtk/gtkfilechooserentry.c | 31 ++--
gtk/gtkfixed.c | 39 +++--
gtk/gtkfontsel.c | 4 +-
gtk/gtkframe.c | 122 +++++++------
gtk/gtkhandlebox.c | 173 ++++++++++-------
gtk/gtkhsv.c | 122 ++++++++-----
gtk/gtkiconview.c | 217 +++++++++++++---------
gtk/gtkimage.c | 36 ++--
gtk/gtkimagemenuitem.c | 51 +++--
gtk/gtkinfobar.c | 17 +-
gtk/gtkinvisible.c | 17 +-
gtk/gtkitem.c | 29 ++-
gtk/gtklabel.c | 109 ++++++-----
gtk/gtklayout.c | 54 +++---
gtk/gtklinkbutton.c | 10 +-
gtk/gtkmain.c | 6 +-
gtk/gtkmenu.c | 358 +++++++++++++++++++++--------------
gtk/gtkmenubar.c | 35 +++--
gtk/gtkmenuitem.c | 262 ++++++++++++++++-----------
gtk/gtkmenushell.c | 45 +++--
gtk/gtkmenutoolbutton.c | 48 +++--
gtk/gtkmessagedialog.c | 6 +-
gtk/gtkmisc.c | 29 ++-
gtk/gtkmnemonichash.c | 7 +-
gtk/gtknotebook.c | 417 ++++++++++++++++++++++++-----------------
gtk/gtkoffscreenwindow.c | 35 ++--
gtk/gtkpaned.c | 112 +++++++-----
gtk/gtkpathbar.c | 44 +++--
gtk/gtkplug.c | 108 +++++++-----
gtk/gtkprogressbar.c | 178 +++++++++++-------
gtk/gtkradiobutton.c | 40 +++--
gtk/gtkrange.c | 166 +++++++++-------
gtk/gtkrecentchooserdefault.c | 17 +-
gtk/gtkruler.c | 125 ++++++++-----
gtk/gtkscale.c | 76 +++++---
gtk/gtkscalebutton.c | 63 ++++---
gtk/gtkscrolledwindow.c | 78 +++++---
gtk/gtkselection.c | 39 +++--
gtk/gtkseparator.c | 65 ++++---
gtk/gtkseparatortoolitem.c | 45 +++--
gtk/gtksizegroup.c | 17 +-
gtk/gtksizerequest.c | 11 +-
gtk/gtksocket.c | 38 +++--
gtk/gtkspinbutton.c | 107 +++++++----
gtk/gtkspinner.c | 16 +-
gtk/gtkstatusbar.c | 53 +++---
gtk/gtkstatusicon.c | 31 ++-
gtk/gtkstyle.c | 13 +-
gtk/gtktable.c | 25 ++-
gtk/gtktearoffmenuitem.c | 73 +++++---
gtk/gtktestutils.c | 23 ++-
gtk/gtktextdisplay.c | 37 +++--
gtk/gtktextutil.c | 23 ++-
gtk/gtktextview.c | 160 ++++++++++-------
gtk/gtktoolbar.c | 182 +++++++++++--------
gtk/gtktoolbutton.c | 31 ++-
gtk/gtktoolitem.c | 60 ++++---
gtk/gtktoolitemgroup.c | 151 +++++++++------
gtk/gtktoolpalette.c | 70 +++++---
gtk/gtktooltip.c | 93 ++++++----
gtk/gtktreeview.c | 335 ++++++++++++++++++++++-----------
gtk/gtktreeviewcolumn.c | 6 +-
gtk/gtkuimanager.c | 18 +-
gtk/gtkviewport.c | 94 ++++++----
gtk/gtkwidget.c | 4 +-
gtk/gtkwin32embedwidget.c | 6 +-
gtk/gtkwindow-decorate.c | 2 +-
gtk/gtkwindow.c | 6 +-
96 files changed, 3984 insertions(+), 2576 deletions(-)
---
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index b16ed8c..2ebda9f 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -2010,7 +2010,8 @@ text_view_visibility_notify_event (GtkWidget *text_view,
{
GdkDevice *dev = d->data;
- gdk_window_get_device_position (text_view->window, dev, &wx, &wy, NULL);
+ gdk_window_get_device_position (gtk_widget_get_window (text_view), dev,
+ &wx, &wy, NULL);
gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
GTK_TEXT_WINDOW_WIDGET,
diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c
index d36da48..2e3a8bb 100644
--- a/gtk/gtkalignment.c
+++ b/gtk/gtkalignment.c
@@ -496,7 +496,7 @@ gtk_alignment_size_allocate (GtkWidget *widget,
padding_horizontal = 0;
padding_vertical = 0;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
bin = GTK_BIN (widget);
bin_child = gtk_bin_get_child (bin);
diff --git a/gtk/gtkarrow.c b/gtk/gtkarrow.c
index ce556d1..7ebf114 100644
--- a/gtk/gtkarrow.c
+++ b/gtk/gtkarrow.c
@@ -276,8 +276,10 @@ gtk_arrow_expose (GtkWidget *widget,
{
GtkArrow *arrow = GTK_ARROW (widget);
GtkArrowPriv *priv = arrow->priv;
+ GtkAllocation allocation;
GtkMisc *misc = GTK_MISC (widget);
GtkShadowType shadow_type;
+ GtkStateType state;
gint width, height;
gint x, y;
gint extent;
@@ -288,11 +290,12 @@ gtk_arrow_expose (GtkWidget *widget,
gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
+ gtk_widget_get_allocation (widget, &allocation);
gtk_misc_get_padding (misc, &xpad, &ypad);
gtk_misc_get_alignment (misc, &xalign, &yalign);
- width = widget->allocation.width - xpad * 2;
- height = widget->allocation.height - ypad * 2;
+ width = allocation.width - xpad * 2;
+ height = allocation.height - ypad * 2;
extent = MIN (width, height) * arrow_scaling;
effective_arrow_type = priv->arrow_type;
@@ -305,14 +308,14 @@ gtk_arrow_expose (GtkWidget *widget,
effective_arrow_type = GTK_ARROW_LEFT;
}
- x = floor (widget->allocation.x + xpad
- + ((widget->allocation.width - extent) * xalign));
- y = floor (widget->allocation.y + ypad
- + ((widget->allocation.height - extent) * yalign));
+ x = floor (allocation.x + xpad + ((allocation.width - extent) * xalign));
+ y = floor (allocation.y + ypad + ((allocation.height - extent) * yalign));
shadow_type = priv->shadow_type;
- if (widget->state == GTK_STATE_ACTIVE)
+ state = gtk_widget_get_state (widget);
+
+ if (state == GTK_STATE_ACTIVE)
{
if (shadow_type == GTK_SHADOW_IN)
shadow_type = GTK_SHADOW_OUT;
@@ -324,8 +327,9 @@ gtk_arrow_expose (GtkWidget *widget,
shadow_type = GTK_SHADOW_ETCHED_IN;
}
- gtk_paint_arrow (widget->style, widget->window,
- widget->state, shadow_type,
+ gtk_paint_arrow (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ state, shadow_type,
&event->area, widget, "arrow",
effective_arrow_type, TRUE,
x, y, extent, extent);
diff --git a/gtk/gtkassistant.c b/gtk/gtkassistant.c
index 3d38804..5cbfe90 100644
--- a/gtk/gtkassistant.c
+++ b/gtk/gtkassistant.c
@@ -1101,7 +1101,7 @@ set_title_font (GtkWidget *assistant,
gint size;
desc = pango_font_description_new ();
- size = pango_font_description_get_size (assistant->style->font_desc);
+ size = pango_font_description_get_size (gtk_widget_get_style (assistant)->font_desc);
pango_font_description_set_weight (desc, PANGO_WEIGHT_ULTRABOLD);
pango_font_description_set_size (desc, size * PANGO_SCALE_XX_LARGE);
@@ -1206,6 +1206,7 @@ gtk_assistant_size_allocate (GtkWidget *widget,
GtkAssistantPrivate *priv = assistant->priv;
GtkRequisition header_requisition, action_requisition, sidebar_requisition;
GtkAllocation child_allocation, header_allocation;
+ GtkAllocation action_area_allocation, header_image_allocation;
gint header_padding, content_padding;
guint border_width;
gboolean rtl;
@@ -1219,7 +1220,7 @@ gtk_assistant_size_allocate (GtkWidget *widget,
"content-padding", &content_padding,
NULL);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
/* Header */
@@ -1242,6 +1243,9 @@ gtk_assistant_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (priv->action_area, &child_allocation);
+ gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
+ gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
+
/* Sidebar */
gtk_widget_get_child_requisition (priv->sidebar_image, &sidebar_requisition);
@@ -1250,27 +1254,31 @@ gtk_assistant_size_allocate (GtkWidget *widget,
else
child_allocation.x = border_width;
- child_allocation.y = border_width + priv->header_image->allocation.height + 2 * header_padding;
+ child_allocation.y = border_width + header_image_allocation.height + 2 * header_padding;
child_allocation.width = sidebar_requisition.width;
child_allocation.height = allocation->height - 2 * border_width -
- priv->header_image->allocation.height - 2 * header_padding - priv->action_area->allocation.height;
+ header_image_allocation.height - 2 * header_padding - action_area_allocation.height;
gtk_widget_size_allocate (priv->sidebar_image, &child_allocation);
/* Pages */
child_allocation.x = border_width + content_padding;
child_allocation.y = border_width +
- priv->header_image->allocation.height + 2 * header_padding + content_padding;
+ header_image_allocation.height + 2 * header_padding + content_padding;
child_allocation.width = allocation->width - 2 * border_width - 2 * content_padding;
child_allocation.height = allocation->height - 2 * border_width -
- priv->header_image->allocation.height - 2 * header_padding - ACTION_AREA_SPACING - priv->action_area->allocation.height - 2 * content_padding;
+ header_image_allocation.height - 2 * header_padding - ACTION_AREA_SPACING - action_area_allocation.height - 2 * content_padding;
if (gtk_widget_get_visible (priv->sidebar_image))
{
+ GtkAllocation sidebar_image_allocation;
+
+ gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
+
if (!rtl)
- child_allocation.x += priv->sidebar_image->allocation.width;
+ child_allocation.x += sidebar_image_allocation.width;
- child_allocation.width -= priv->sidebar_image->allocation.width;
+ child_allocation.width -= sidebar_image_allocation.width;
}
while (pages)
@@ -1367,12 +1375,14 @@ assistant_paint_colored_box (GtkWidget *widget)
{
GtkAssistant *assistant = GTK_ASSISTANT (widget);
GtkAssistantPrivate *priv = assistant->priv;
+ GtkAllocation allocation, action_area_allocation, header_image_allocation;
+ GtkStyle *style;
gint border_width, header_padding, content_padding;
cairo_t *cr;
gint content_x, content_width;
gboolean rtl;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -1381,34 +1391,43 @@ assistant_paint_colored_box (GtkWidget *widget)
"content-padding", &content_padding,
NULL);
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (priv->action_area, &action_area_allocation);
+ gtk_widget_get_allocation (priv->header_image, &header_image_allocation);
+
/* colored box */
- gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_SELECTED]);
+ gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_SELECTED]);
cairo_rectangle (cr,
border_width,
border_width,
- widget->allocation.width - 2 * border_width,
- widget->allocation.height - priv->action_area->allocation.height - 2 * border_width - ACTION_AREA_SPACING);
+ allocation.width - 2 * border_width,
+ allocation.height - action_area_allocation.height - 2 * border_width - ACTION_AREA_SPACING);
cairo_fill (cr);
/* content box */
content_x = content_padding + border_width;
- content_width = widget->allocation.width - 2 * content_padding - 2 * border_width;
+ content_width = allocation.width - 2 * content_padding - 2 * border_width;
if (gtk_widget_get_visible (priv->sidebar_image))
{
+ GtkAllocation sidebar_image_allocation;
+
+ gtk_widget_get_allocation (priv->sidebar_image, &sidebar_image_allocation);
+
if (!rtl)
- content_x += priv->sidebar_image->allocation.width;
- content_width -= priv->sidebar_image->allocation.width;
+ content_x += sidebar_image_allocation.width;
+ content_width -= sidebar_image_allocation.width;
}
-
- gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_STATE_NORMAL]);
+
+ gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
cairo_rectangle (cr,
content_x,
- priv->header_image->allocation.height + content_padding + 2 * header_padding + border_width,
+ header_image_allocation.height + content_padding + 2 * header_padding + border_width,
content_width,
- widget->allocation.height - 2 * border_width - priv->action_area->allocation.height -
- priv->header_image->allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING);
+ allocation.height - 2 * border_width - action_area_allocation.height -
+ header_image_allocation.height - 2 * content_padding - 2 * header_padding - ACTION_AREA_SPACING);
cairo_fill (cr);
cairo_destroy (cr);
@@ -1754,7 +1773,7 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
g_return_val_if_fail (GTK_IS_ASSISTANT (assistant), 0);
g_return_val_if_fail (GTK_IS_WIDGET (page), 0);
- g_return_val_if_fail (page->parent == NULL, 0);
+ g_return_val_if_fail (gtk_widget_get_parent (page) == NULL, 0);
g_return_val_if_fail (!gtk_widget_is_toplevel (page), 0);
priv = assistant->priv;
diff --git a/gtk/gtkbbox.c b/gtk/gtkbbox.c
index 1720d72..ce96e62 100644
--- a/gtk/gtkbbox.c
+++ b/gtk/gtkbbox.c
@@ -392,7 +392,7 @@ gtk_button_box_set_child_secondary (GtkButtonBox *widget,
{
g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == GTK_WIDGET (widget));
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (widget));
g_object_set_data (G_OBJECT (child),
GTK_BOX_SECONDARY_CHILD,
@@ -632,7 +632,8 @@ gtk_button_box_size_allocate (GtkWidget *widget,
&n_secondaries,
&child_width,
&child_height);
- widget->allocation = *allocation;
+
+ gtk_widget_set_allocation (widget, allocation);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
width = allocation->width - border_width*2;
diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c
index cdc5f1d..fffd462 100644
--- a/gtk/gtkbox.c
+++ b/gtk/gtkbox.c
@@ -421,7 +421,7 @@ gtk_box_size_allocate (GtkWidget *widget,
gint child_size;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
count_expand_children (box, &nvis_children, &nexpand_children);
@@ -779,7 +779,7 @@ gtk_box_pack (GtkBox *box,
g_return_if_fail (GTK_IS_BOX (box));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == NULL);
+ g_return_if_fail (gtk_widget_get_parent (child) == NULL);
child_info = g_new (GtkBoxChild, 1);
child_info->widget = child;
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index e9527c1..105d5bd 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -1004,9 +1004,13 @@ gtk_button_construct_child (GtkButton *button)
if (priv->image && !priv->image_is_stock)
{
+ GtkWidget *parent;
+
image = g_object_ref (priv->image);
- if (image->parent)
- gtk_container_remove (GTK_CONTAINER (image->parent), image);
+
+ parent = gtk_widget_get_parent (image);
+ if (parent)
+ gtk_container_remove (GTK_CONTAINER (parent), image);
}
priv->image = NULL;
@@ -1275,21 +1279,24 @@ gtk_button_get_relief (GtkButton *button)
static void
gtk_button_realize (GtkWidget *widget)
{
- GtkButton *button;
+ GtkButton *button = GTK_BUTTON (widget);
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
- button = GTK_BUTTON (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
gtk_widget_set_realized (widget, TRUE);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - border_width * 2;
+ attributes.height = allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
@@ -1299,14 +1306,15 @@ gtk_button_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y;
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
-
- button->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, window);
+ g_object_ref (window);
+
+ button->event_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (button->event_window, button);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
}
static void
@@ -1444,47 +1452,50 @@ gtk_button_size_allocate (GtkWidget *widget,
{
GtkButton *button = GTK_BUTTON (widget);
GtkAllocation child_allocation;
+ GtkStyle *style;
GtkWidget *child;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- gint xthickness = GTK_WIDGET (widget)->style->xthickness;
- gint ythickness = GTK_WIDGET (widget)->style->ythickness;
+ gint xthickness, ythickness;
GtkBorder default_border;
GtkBorder inner_border;
gint focus_width;
gint focus_pad;
+ style = gtk_widget_get_style (widget);
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
+
gtk_button_get_props (button, &default_border, NULL, &inner_border, NULL);
gtk_widget_style_get (GTK_WIDGET (widget),
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
-
-
- widget->allocation = *allocation;
+
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (button->event_window,
- widget->allocation.x + border_width,
- widget->allocation.y + border_width,
- widget->allocation.width - border_width * 2,
- widget->allocation.height - border_width * 2);
+ allocation->x + border_width,
+ allocation->y + border_width,
+ allocation->width - border_width * 2,
+ allocation->height - border_width * 2);
child = gtk_bin_get_child (GTK_BIN (button));
if (child && gtk_widget_get_visible (child))
{
- child_allocation.x = widget->allocation.x + border_width + inner_border.left + xthickness;
- child_allocation.y = widget->allocation.y + border_width + inner_border.top + ythickness;
-
- child_allocation.width =
- widget->allocation.width -
+ child_allocation.x = allocation->x + border_width + inner_border.left + xthickness;
+ child_allocation.y = allocation->y + border_width + inner_border.top + ythickness;
+
+ child_allocation.width =
+ allocation->width -
xthickness * 2 -
inner_border.left -
inner_border.right -
border_width * 2;
child_allocation.height =
- widget->allocation.height -
+ allocation->height -
ythickness * 2 -
inner_border.top -
inner_border.bottom -
@@ -1548,6 +1559,10 @@ _gtk_button_paint (GtkButton *button,
if (gtk_widget_is_drawable (widget))
{
+ GtkAllocation allocation;
+ GdkWindow *window;
+ GtkStyle *style;
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
@@ -1555,16 +1570,20 @@ _gtk_button_paint (GtkButton *button,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
-
- 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);
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
+ x = allocation.x + border_width;
+ y = allocation.y + border_width;
+ width = allocation.width - border_width * 2;
+ height = allocation.height - border_width * 2;
if (gtk_widget_has_default (widget) &&
GTK_BUTTON (widget)->relief == GTK_RELIEF_NORMAL)
{
- gtk_paint_box (widget->style, widget->window,
+ gtk_paint_box (style, window,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
area, widget, "buttondefault",
x, y, width, height);
@@ -1592,7 +1611,7 @@ _gtk_button_paint (GtkButton *button,
if (button->relief != GTK_RELIEF_NONE || button->depressed ||
gtk_widget_get_state(widget) == GTK_STATE_PRELIGHT)
- gtk_paint_box (widget->style, widget->window,
+ gtk_paint_box (style, window,
state_type,
shadow_type, area, widget, "button",
x, y, width, height);
@@ -1611,10 +1630,10 @@ _gtk_button_paint (GtkButton *button,
if (interior_focus)
{
- x += widget->style->xthickness + focus_pad;
- y += widget->style->ythickness + focus_pad;
- width -= 2 * (widget->style->xthickness + focus_pad);
- height -= 2 * (widget->style->ythickness + focus_pad);
+ x += style->xthickness + focus_pad;
+ y += style->ythickness + focus_pad;
+ width -= 2 * (style->xthickness + focus_pad);
+ height -= 2 * (style->ythickness + focus_pad);
}
else
{
@@ -1630,7 +1649,8 @@ _gtk_button_paint (GtkButton *button,
y += child_displacement_y;
}
- gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
+ gtk_paint_focus (style, window,
+ gtk_widget_get_state (widget),
area, widget, "button",
x, y, width, height);
}
@@ -1895,6 +1915,7 @@ gtk_button_get_size (GtkSizeRequest *widget,
gint *natural_size)
{
GtkButton *button = GTK_BUTTON (widget);
+ GtkStyle *style;
GtkWidget *child;
GtkBorder default_border;
GtkBorder inner_border;
@@ -1910,10 +1931,11 @@ gtk_button_get_size (GtkSizeRequest *widget,
NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ style = gtk_widget_get_style (GTK_WIDGET (widget));
+
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- minimum = ((border_width +
- GTK_WIDGET (widget)->style->xthickness) * 2 +
+ minimum = ((border_width + style->xthickness) * 2 +
inner_border.left + inner_border.right);
if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
@@ -1921,8 +1943,7 @@ gtk_button_get_size (GtkSizeRequest *widget,
}
else
{
- minimum = ((border_width +
- GTK_WIDGET (widget)->style->ythickness) * 2 +
+ minimum = ((border_width + style->ythickness) * 2 +
inner_border.top + inner_border.bottom);
if (gtk_widget_get_can_default (GTK_WIDGET (widget)))
@@ -2399,14 +2420,16 @@ gtk_button_set_image (GtkButton *button,
GtkWidget *image)
{
GtkButtonPrivate *priv;
+ GtkWidget *parent;
g_return_if_fail (GTK_IS_BUTTON (button));
g_return_if_fail (image == NULL || GTK_IS_WIDGET (image));
priv = GTK_BUTTON_GET_PRIVATE (button);
- if (priv->image && priv->image->parent)
- gtk_container_remove (GTK_CONTAINER (priv->image->parent), priv->image);
+ parent = gtk_widget_get_parent (priv->image);
+ if (priv->image && parent)
+ gtk_container_remove (GTK_CONTAINER (parent), priv->image);
priv->image = image;
priv->image_is_stock = (image == NULL);
diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c
index 9d111f5..26573c2 100644
--- a/gtk/gtkcalendar.c
+++ b/gtk/gtkcalendar.c
@@ -202,16 +202,16 @@ dates_difference(guint year1, guint mm1, guint dd1,
#define SCROLL_DELAY_FACTOR 5
/* Color usage */
-#define HEADER_FG_COLOR(widget) (& (widget)->style->fg[gtk_widget_get_state (widget)])
-#define HEADER_BG_COLOR(widget) (& (widget)->style->bg[gtk_widget_get_state (widget)])
-#define SELECTED_BG_COLOR(widget) (& (widget)->style->base[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
-#define SELECTED_FG_COLOR(widget) (& (widget)->style->text[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
-#define NORMAL_DAY_COLOR(widget) (& (widget)->style->text[gtk_widget_get_state (widget)])
-#define PREV_MONTH_COLOR(widget) (& (widget)->style->mid[gtk_widget_get_state (widget)])
-#define NEXT_MONTH_COLOR(widget) (& (widget)->style->mid[gtk_widget_get_state (widget)])
-#define MARKED_COLOR(widget) (& (widget)->style->text[gtk_widget_get_state (widget)])
-#define BACKGROUND_COLOR(widget) (& (widget)->style->base[gtk_widget_get_state (widget)])
-#define HIGHLIGHT_BACK_COLOR(widget) (& (widget)->style->mid[gtk_widget_get_state (widget)])
+#define HEADER_FG_COLOR(widget) (& gtk_widget_get_style (widget)->fg[gtk_widget_get_state (widget)])
+#define HEADER_BG_COLOR(widget) (& gtk_widget_get_style (widget)->bg[gtk_widget_get_state (widget)])
+#define SELECTED_BG_COLOR(widget) (& gtk_widget_get_style (widget)->base[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
+#define SELECTED_FG_COLOR(widget) (& gtk_widget_get_style (widget)->text[gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE])
+#define NORMAL_DAY_COLOR(widget) (& gtk_widget_get_style (widget)->text[gtk_widget_get_state (widget)])
+#define PREV_MONTH_COLOR(widget) (& gtk_widget_get_style (widget)->mid[gtk_widget_get_state (widget)])
+#define NEXT_MONTH_COLOR(widget) (& gtk_widget_get_style (widget)->mid[gtk_widget_get_state (widget)])
+#define MARKED_COLOR(widget) (& gtk_widget_get_style (widget)->text[gtk_widget_get_state (widget)])
+#define BACKGROUND_COLOR(widget) (& gtk_widget_get_style (widget)->base[gtk_widget_get_state (widget)])
+#define HIGHLIGHT_BACK_COLOR(widget) (& gtk_widget_get_style (widget)->mid[gtk_widget_get_state (widget)])
enum {
ARROW_YEAR_LEFT,
@@ -1229,8 +1229,13 @@ calendar_arrow_rectangle (GtkCalendar *calendar,
{
GtkWidget *widget = GTK_WIDGET (calendar);
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
+ GtkAllocation allocation;
+ GtkStyle *style;
gboolean year_left;
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
+
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
year_left = priv->year_before;
else
@@ -1244,15 +1249,14 @@ calendar_arrow_rectangle (GtkCalendar *calendar,
{
case ARROW_MONTH_LEFT:
if (year_left)
- rect->x = (widget->allocation.width - 2 * widget->style->xthickness
- - (3 + 2*priv->arrow_width
- + priv->max_month_width));
+ rect->x = (allocation.width - 2 * style->xthickness
+ - (3 + 2 * priv->arrow_width + priv->max_month_width));
else
rect->x = 3;
break;
case ARROW_MONTH_RIGHT:
if (year_left)
- rect->x = (widget->allocation.width - 2 * widget->style->xthickness
+ rect->x = (allocation.width - 2 * style->xthickness
- 3 - priv->arrow_width);
else
rect->x = (priv->arrow_width
@@ -1262,16 +1266,15 @@ calendar_arrow_rectangle (GtkCalendar *calendar,
if (year_left)
rect->x = 3;
else
- rect->x = (widget->allocation.width - 2 * widget->style->xthickness
- - (3 + 2*priv->arrow_width
- + priv->max_year_width));
+ rect->x = (allocation.width - 2 * style->xthickness
+ - (3 + 2 * priv->arrow_width + priv->max_year_width));
break;
case ARROW_YEAR_RIGHT:
if (year_left)
rect->x = (priv->arrow_width
+ priv->max_year_width);
else
- rect->x = (widget->allocation.width - 2 * widget->style->xthickness
+ rect->x = (allocation.width - 2 * style->xthickness
- 3 - priv->arrow_width);
break;
}
@@ -1566,17 +1569,23 @@ calendar_realize_header (GtkCalendar *calendar)
/* Header window ------------------------------------- */
if (calendar->display_flags & GTK_CALENDAR_SHOW_HEADING)
{
+ GtkAllocation allocation;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.x = widget->style->xthickness;
- attributes.y = widget->style->ythickness;
- attributes.width = widget->allocation.width - 2 * attributes.x;
+ attributes.x = style->xthickness;
+ attributes.y = style->ythickness;
+ attributes.width = allocation.width - 2 * attributes.x;
attributes.height = priv->header_h;
- priv->header_win = gdk_window_new (widget->window,
+ priv->header_win = gdk_window_new (gtk_widget_get_window (widget),
&attributes, attributes_mask);
gdk_window_set_background (priv->header_win,
@@ -1640,20 +1649,23 @@ calendar_realize_day_names (GtkCalendar *calendar)
/* Day names window --------------------------------- */
if ( calendar->display_flags & GTK_CALENDAR_SHOW_DAY_NAMES)
{
+ GtkAllocation allocation;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.x = (widget->style->xthickness + inner_border);
- attributes.y = priv->header_h + (widget->style->ythickness
- + inner_border);
- attributes.width = (widget->allocation.width
- - (widget->style->xthickness + inner_border)
- * 2);
+ attributes.x = style->xthickness + inner_border;
+ attributes.y = priv->header_h + (style->ythickness + inner_border);
+ attributes.width = allocation.width - (style->xthickness + inner_border) * 2;
attributes.height = priv->day_name_h;
- priv->day_name_win = gdk_window_new (widget->window,
+ priv->day_name_win = gdk_window_new (gtk_widget_get_window (widget),
&attributes,
attributes_mask);
gdk_window_set_background (priv->day_name_win,
@@ -1679,22 +1691,31 @@ calendar_realize_week_numbers (GtkCalendar *calendar)
/* Week number window -------------------------------- */
if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
{
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
-
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- attributes.x = widget->style->xthickness + inner_border;
- else
- attributes.x = widget->allocation.width - priv->week_width - (widget->style->xthickness + inner_border);
- attributes.y = (priv->header_h + priv->day_name_h
- + (widget->style->ythickness + inner_border));
+ if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
+ {
+ attributes.x = style->xthickness + inner_border;
+ }
+ else
+ {
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ attributes.x = allocation.width - priv->week_width - (style->xthickness + inner_border);
+ }
+ attributes.y = priv->header_h + priv->day_name_h + (style->ythickness + inner_border);
attributes.width = priv->week_width;
attributes.height = priv->main_h;
- priv->week_win = gdk_window_new (widget->window,
+ priv->week_win = gdk_window_new (gtk_widget_get_window (widget),
&attributes, attributes_mask);
gdk_window_set_background (priv->week_win,
BACKGROUND_COLOR (GTK_WIDGET (calendar)));
@@ -1712,16 +1733,22 @@ gtk_calendar_realize (GtkWidget *widget)
{
GtkCalendar *calendar = GTK_CALENDAR (widget);
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
+ GtkAllocation allocation;
+ GtkStyle *style;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gint inner_border = calendar_get_inner_border (calendar);
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
+
gtk_widget_set_realized (widget, TRUE);
-
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = (gtk_widget_get_events (widget)
@@ -1730,11 +1757,13 @@ gtk_calendar_realize (GtkWidget *widget)
attributes.colormap = gtk_widget_get_colormap (widget);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (widget->parent->window,
- &attributes, attributes_mask);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
-
+
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+
+ gtk_widget_style_attach (widget);
+
/* Header window ------------------------------------- */
calendar_realize_header (calendar);
/* Day names window --------------------------------- */
@@ -1747,27 +1776,26 @@ gtk_calendar_realize (GtkWidget *widget)
| GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- attributes.x = priv->week_width + (widget->style->ythickness + inner_border);
+ attributes.x = priv->week_width + (style->ythickness + inner_border);
else
- attributes.x = widget->style->ythickness + inner_border;
+ attributes.x = style->ythickness + inner_border;
+
+ attributes.y = priv->header_h + priv->day_name_h + (style->ythickness + inner_border);
+ attributes.width = allocation.width - attributes.x - (style->xthickness + inner_border);
- attributes.y = (priv->header_h + priv->day_name_h
- + (widget->style->ythickness + inner_border));
- attributes.width = (widget->allocation.width - attributes.x
- - (widget->style->xthickness + inner_border));
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
attributes.width -= priv->week_width;
attributes.height = priv->main_h;
- priv->main_win = gdk_window_new (widget->window,
+ priv->main_win = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_background (priv->main_win,
BACKGROUND_COLOR ( GTK_WIDGET ( calendar)));
gdk_window_show (priv->main_win);
gdk_window_set_user_data (priv->main_win, widget);
- gdk_window_set_background (widget->window, BACKGROUND_COLOR (widget));
- gdk_window_show (widget->window);
- gdk_window_set_user_data (widget->window, widget);
+ gdk_window_set_background (window, BACKGROUND_COLOR (widget));
+ gdk_window_show (window);
+ gdk_window_set_user_data (window, widget);
}
static void
@@ -1905,6 +1933,7 @@ gtk_calendar_size_request (GtkWidget *widget,
{
GtkCalendar *calendar = GTK_CALENDAR (widget);
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
+ GtkStyle *style;
PangoLayout *layout;
PangoRectangle logical_rect;
@@ -2096,10 +2125,11 @@ gtk_calendar_size_request (GtkWidget *widget,
+ (priv->max_week_char_width
? priv->max_week_char_width * 2 + (focus_padding + focus_width) * 2 + calendar_xsep * 2
: 0));
-
-
- requisition->width = MAX (header_width, main_width + inner_border * 2) + widget->style->xthickness * 2;
-
+
+ style = gtk_widget_get_style (widget);
+
+ requisition->width = MAX (header_width, main_width + inner_border * 2) + style->xthickness * 2;
+
/*
* Calculate the requisition height for the widget.
*/
@@ -2134,8 +2164,8 @@ gtk_calendar_size_request (GtkWidget *widget,
height = (priv->header_h + priv->day_name_h
+ priv->main_h);
-
- requisition->height = height + (widget->style->ythickness + inner_border) * 2;
+
+ requisition->height = height + (style->ythickness + inner_border) * 2;
g_object_unref (layout);
}
@@ -2146,14 +2176,18 @@ gtk_calendar_size_allocate (GtkWidget *widget,
{
GtkCalendar *calendar = GTK_CALENDAR (widget);
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
- gint xthickness = widget->style->xthickness;
- gint ythickness = widget->style->xthickness;
+ GtkStyle *style;
+ gint xthickness, ythickness;
guint i;
gint inner_border = calendar_get_inner_border (calendar);
gint calendar_xsep = calendar_get_xsep (calendar);
- widget->allocation = *allocation;
-
+ style = gtk_widget_get_style (widget);
+ xthickness = style->xthickness;
+ ythickness = style->xthickness;
+
+ gtk_widget_set_allocation (widget, allocation);
+
if (calendar->display_flags & GTK_CALENDAR_SHOW_WEEK_NUMBERS)
{
priv->day_width = (priv->min_day_width
@@ -2175,7 +2209,7 @@ gtk_calendar_size_allocate (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
if (priv->header_win)
@@ -2196,10 +2230,10 @@ gtk_calendar_size_allocate (GtkWidget *widget,
}
if (priv->day_name_win)
- gdk_window_move_resize (priv->day_name_win,
- xthickness + inner_border,
- priv->header_h + (widget->style->ythickness + inner_border),
- allocation->width - (xthickness + inner_border) * 2,
+ gdk_window_move_resize (priv->day_name_win,
+ xthickness + inner_border,
+ priv->header_h + (style->ythickness + inner_border),
+ allocation->width - (xthickness + inner_border) * 2,
priv->day_name_h);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
{
@@ -2207,13 +2241,13 @@ gtk_calendar_size_allocate (GtkWidget *widget,
gdk_window_move_resize (priv->week_win,
(xthickness + inner_border),
priv->header_h + priv->day_name_h
- + (widget->style->ythickness + inner_border),
+ + (style->ythickness + inner_border),
priv->week_width,
priv->main_h);
gdk_window_move_resize (priv->main_win,
priv->week_width + (xthickness + inner_border),
priv->header_h + priv->day_name_h
- + (widget->style->ythickness + inner_border),
+ + (style->ythickness + inner_border),
allocation->width
- priv->week_width
- (xthickness + inner_border) * 2,
@@ -2224,7 +2258,7 @@ gtk_calendar_size_allocate (GtkWidget *widget,
gdk_window_move_resize (priv->main_win,
(xthickness + inner_border),
priv->header_h + priv->day_name_h
- + (widget->style->ythickness + inner_border),
+ + (style->ythickness + inner_border),
allocation->width
- priv->week_width
- (xthickness + inner_border) * 2,
@@ -2235,7 +2269,7 @@ gtk_calendar_size_allocate (GtkWidget *widget,
- priv->week_width
- (xthickness + inner_border),
priv->header_h + priv->day_name_h
- + (widget->style->ythickness + inner_border),
+ + (style->ythickness + inner_border),
priv->week_width,
priv->main_h);
}
@@ -2252,6 +2286,8 @@ calendar_paint_header (GtkCalendar *calendar)
{
GtkWidget *widget = GTK_WIDGET (calendar);
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
+ GtkAllocation allocation;
+ GtkStyle *style;
cairo_t *cr;
char buffer[255];
int x, y;
@@ -2271,13 +2307,16 @@ calendar_paint_header (GtkCalendar *calendar)
year_left = !priv->year_before;
cr = gdk_cairo_create (priv->header_win);
-
- header_width = widget->allocation.width - 2 * widget->style->xthickness;
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
+
+ header_width = allocation.width - 2 * style->xthickness;
+
max_month_width = priv->max_month_width;
max_year_width = priv->max_year_width;
-
- gtk_paint_shadow (widget->style, priv->header_win,
+
+ gtk_paint_shadow (style, priv->header_win,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, widget, "calendar",
0, 0, header_width, priv->header_h);
@@ -2356,6 +2395,7 @@ calendar_paint_day_names (GtkCalendar *calendar)
{
GtkWidget *widget = GTK_WIDGET (calendar);
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
+ GtkAllocation allocation;
cairo_t *cr;
char buffer[255];
int day,i;
@@ -2374,9 +2414,11 @@ calendar_paint_day_names (GtkCalendar *calendar)
"focus-line-width", &focus_width,
"focus-padding", &focus_padding,
NULL);
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+
day_width = priv->day_width;
- cal_width = widget->allocation.width;
+ cal_width = allocation.width;
day_wid_sep = day_width + DAY_XSEP;
/*
@@ -2580,6 +2622,7 @@ calendar_paint_day (GtkCalendar *calendar,
{
GtkWidget *widget = GTK_WIDGET (calendar);
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (calendar);
+ GtkStyle *style;
cairo_t *cr;
GdkColor *text_color;
gchar *detail;
@@ -2596,6 +2639,8 @@ calendar_paint_day (GtkCalendar *calendar,
g_return_if_fail (row < 6);
g_return_if_fail (col < 7);
+ style = gtk_widget_get_style (widget);
+
cr = gdk_cairo_create (priv->main_win);
day = calendar->day[row][col];
@@ -2676,11 +2721,11 @@ calendar_paint_day (GtkCalendar *calendar,
cairo_save (cr);
if (calendar->selected_day == day)
- gdk_cairo_set_source_color (cr, &widget->style->text[GTK_STATE_ACTIVE]);
+ gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_ACTIVE]);
else if (calendar->day_month[row][col] == MONTH_CURRENT)
- gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_ACTIVE]);
+ gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_ACTIVE]);
else
- gdk_cairo_set_source_color (cr, &widget->style->base[GTK_STATE_INSENSITIVE]);
+ gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_INSENSITIVE]);
cairo_set_line_width (cr, 1);
cairo_move_to (cr, day_rect.x + 2, y_loc + 0.5);
@@ -2734,8 +2779,8 @@ calendar_paint_day (GtkCalendar *calendar,
state = gtk_widget_has_focus (widget) ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE;
else
state = GTK_STATE_NORMAL;
-
- gtk_paint_focus (widget->style,
+
+ gtk_paint_focus (style,
priv->main_win,
state,
NULL, widget, "calendar-day",
@@ -2786,24 +2831,26 @@ calendar_paint_arrow (GtkCalendar *calendar,
window = priv->arrow_win[arrow];
if (window)
{
+ GtkStyle *style;
cairo_t *cr = gdk_cairo_create (window);
gint width, height;
gint state;
-
+
+ style = gtk_widget_get_style (widget);
state = priv->arrow_state[arrow];
- gdk_cairo_set_source_color (cr, &widget->style->bg[state]);
+ gdk_cairo_set_source_color (cr, &style->bg[state]);
cairo_paint (cr);
cairo_destroy (cr);
gdk_drawable_get_size (window, &width, &height);
if (arrow == ARROW_MONTH_LEFT || arrow == ARROW_YEAR_LEFT)
- gtk_paint_arrow (widget->style, window, state,
+ gtk_paint_arrow (style, window, state,
GTK_SHADOW_OUT, NULL, widget, "calendar",
GTK_ARROW_LEFT, TRUE,
width/2 - 3, height/2 - 4, 8, 8);
else
- gtk_paint_arrow (widget->style, window, state,
+ gtk_paint_arrow (style, window, state,
GTK_SHADOW_OUT, NULL, widget, "calendar",
GTK_ARROW_RIGHT, TRUE,
width/2 - 4, height/2 - 4, 8, 8);
@@ -2820,6 +2867,8 @@ gtk_calendar_expose (GtkWidget *widget,
if (gtk_widget_is_drawable (widget))
{
+ GdkWindow *window;
+
if (event->window == priv->main_win)
calendar_paint_main (calendar);
@@ -2835,18 +2884,25 @@ gtk_calendar_expose (GtkWidget *widget,
if (event->window == priv->week_win)
calendar_paint_week_numbers (calendar);
- if (event->window == widget->window)
+
+ window = gtk_widget_get_window (widget);
+ if (event->window == window)
{
- gtk_paint_shadow (widget->style, widget->window, gtk_widget_get_state (widget),
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_paint_shadow (gtk_widget_get_style (widget),
+ window,
+ gtk_widget_get_state (widget),
GTK_SHADOW_IN, NULL, widget, "calendar",
- 0, 0, widget->allocation.width, widget->allocation.height);
+ 0, 0, allocation.width, allocation.height);
}
}
return FALSE;
}
-
+
/****************************************
* Mouse handling *
****************************************/
@@ -3369,6 +3425,7 @@ static void
calendar_set_background (GtkWidget *widget)
{
GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget);
+ GdkWindow *window;
gint i;
if (gtk_widget_get_realized (widget))
@@ -3391,8 +3448,10 @@ calendar_set_background (GtkWidget *widget)
if (priv->main_win)
gdk_window_set_background (priv->main_win,
BACKGROUND_COLOR (widget));
- if (widget->window)
- gdk_window_set_background (widget->window,
+
+ window = gtk_widget_get_window (widget);
+ if (window)
+ gdk_window_set_background (window,
BACKGROUND_COLOR (widget));
}
}
diff --git a/gtk/gtkcellrendereraccel.c b/gtk/gtkcellrendereraccel.c
index 829c513..2b8f7db 100644
--- a/gtk/gtkcellrendereraccel.c
+++ b/gtk/gtkcellrendereraccel.c
@@ -582,9 +582,11 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
GtkCellRendererAccelPriv *priv;
GtkCellRendererText *celltext;
GtkCellRendererAccel *accel;
+ GtkStyle *style;
GtkWidget *label;
GtkWidget *eventbox;
GdkDevice *device, *keyb, *pointer;
+ GdkWindow *window;
gboolean editable;
guint32 time;
@@ -597,7 +599,10 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
if (editable == FALSE)
return NULL;
- g_return_val_if_fail (widget->window != NULL, NULL);
+ window = gtk_widget_get_window (widget);
+ style = gtk_widget_get_style (widget);
+
+ g_return_val_if_fail (window != NULL, NULL);
if (event)
device = gdk_event_get_device (event);
@@ -620,13 +625,13 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
time = gdk_event_get_time (event);
- if (gdk_device_grab (keyb, widget->window,
+ if (gdk_device_grab (keyb, window,
GDK_OWNERSHIP_WINDOW, FALSE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, time) != GDK_GRAB_SUCCESS)
return NULL;
- if (gdk_device_grab (pointer, widget->window,
+ if (gdk_device_grab (pointer, window,
GDK_OWNERSHIP_WINDOW, FALSE,
GDK_BUTTON_PRESS_MASK,
NULL, time) != GDK_GRAB_SUCCESS)
@@ -650,13 +655,15 @@ gtk_cell_renderer_accel_start_editing (GtkCellRenderer *cell,
label = gtk_label_new (NULL);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+
+
gtk_widget_modify_bg (eventbox, GTK_STATE_NORMAL,
- &widget->style->bg[GTK_STATE_SELECTED]);
+ &style->bg[GTK_STATE_SELECTED]);
gtk_widget_modify_fg (label, GTK_STATE_NORMAL,
- &widget->style->fg[GTK_STATE_SELECTED]);
-
+ &style->fg[GTK_STATE_SELECTED]);
+
/* This label is displayed in a treeview cell displaying
* an accelerator when the cell is clicked to change the
* acelerator.
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c
index 135b63d..eeacac2 100644
--- a/gtk/gtkcellrendererpixbuf.c
+++ b/gtk/gtkcellrendererpixbuf.c
@@ -812,8 +812,8 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
*/
gtk_icon_source_set_size (source, GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_icon_source_set_size_wildcarded (source, FALSE);
-
- invisible = gtk_style_render_icon (widget->style,
+
+ invisible = gtk_style_render_icon (gtk_widget_get_style (widget),
source,
gtk_widget_get_direction (widget),
GTK_STATE_INSENSITIVE,
@@ -844,7 +844,7 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
symbolic = create_symbolic_pixbuf (cellpixbuf, widget, state);
if (!symbolic) {
colorized = create_colorized_pixbuf (pixbuf,
- &widget->style->base[state]);
+ >k_widget_get_style (widget)->base[state]);
pixbuf = colorized;
} else {
diff --git a/gtk/gtkcellrendererprogress.c b/gtk/gtkcellrendererprogress.c
index f6f3a99..60f0bdb 100644
--- a/gtk/gtkcellrendererprogress.c
+++ b/gtk/gtkcellrendererprogress.c
@@ -534,6 +534,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
{
GtkCellRendererProgress *cellprogress = GTK_CELL_RENDERER_PROGRESS (cell);
GtkCellRendererProgressPrivate *priv= cellprogress->priv;
+ GtkStyle *style;
PangoLayout *layout;
PangoRectangle logical_rect;
gint x, y, w, h, x_pos, y_pos, bar_position, bar_size, start, full_size;
@@ -541,6 +542,8 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
GdkRectangle clip;
gboolean is_rtl;
+ style = gtk_widget_get_style (widget);
+
is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
gtk_cell_renderer_get_padding (cell, &xpad, &ypad);
@@ -553,7 +556,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
* but some engines don't paint anything with that detail for
* non-GtkProgressBar widgets.
*/
- gtk_paint_box (widget->style,
+ gtk_paint_box (style,
window,
GTK_STATE_NORMAL, GTK_SHADOW_IN,
NULL, widget, NULL,
@@ -601,7 +604,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
clip.y = bar_position;
}
- gtk_paint_box (widget->style,
+ gtk_paint_box (style,
window,
GTK_STATE_SELECTED, GTK_SHADOW_OUT,
&clip, widget, "bar",
@@ -620,13 +623,13 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
else
text_xalign = priv->text_xalign;
- x_pos = x + widget->style->xthickness + text_xalign *
- (w - 2 * widget->style->xthickness - logical_rect.width);
+ x_pos = x + style->xthickness + text_xalign *
+ (w - 2 * style->xthickness - logical_rect.width);
- y_pos = y + widget->style->ythickness + priv->text_yalign *
- (h - 2 * widget->style->ythickness - logical_rect.height);
-
- gtk_paint_layout (widget->style, window,
+ y_pos = y + style->ythickness + priv->text_yalign *
+ (h - 2 * style->ythickness - logical_rect.height);
+
+ gtk_paint_layout (style, window,
GTK_STATE_SELECTED,
FALSE, &clip, widget, "progressbar",
x_pos, y_pos,
@@ -646,7 +649,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
clip.height = bar_position - y;
}
- gtk_paint_layout (widget->style, window,
+ gtk_paint_layout (style, window,
GTK_STATE_NORMAL,
FALSE, &clip, widget, "progressbar",
x_pos, y_pos,
@@ -667,7 +670,7 @@ gtk_cell_renderer_progress_render (GtkCellRenderer *cell,
clip.height = y + h - (bar_position + bar_size);
}
- gtk_paint_layout (widget->style, window,
+ gtk_paint_layout (style, window,
GTK_STATE_NORMAL,
FALSE, &clip, widget, "progressbar",
x_pos, y_pos,
diff --git a/gtk/gtkcellrendererspinner.c b/gtk/gtkcellrendererspinner.c
index 67283ec..9db5377 100644
--- a/gtk/gtkcellrendererspinner.c
+++ b/gtk/gtkcellrendererspinner.c
@@ -376,7 +376,7 @@ gtk_cell_renderer_spinner_render (GtkCellRenderer *cellr,
state = GTK_STATE_PRELIGHT;
}
- gtk_paint_spinner (widget->style,
+ gtk_paint_spinner (gtk_widget_get_style (widget),
window,
state,
expose_area,
diff --git a/gtk/gtkcellrenderertext.c b/gtk/gtkcellrenderertext.c
index 435bb3d..3dd2131 100644
--- a/gtk/gtkcellrenderertext.c
+++ b/gtk/gtkcellrenderertext.c
@@ -1522,7 +1522,7 @@ get_size (GtkCellRenderer *cell,
PangoFontDescription *font_desc;
gint row_height;
- font_desc = pango_font_description_copy_static (widget->style->font_desc);
+ font_desc = pango_font_description_copy_static (gtk_widget_get_style (widget)->font_desc);
pango_font_description_merge_static (font_desc, priv->font, TRUE);
if (priv->scale_set)
@@ -1576,7 +1576,9 @@ get_size (GtkCellRenderer *cell,
gint char_width;
context = pango_layout_get_context (layout);
- metrics = pango_context_get_metrics (context, widget->style->font_desc, pango_context_get_language (context));
+ metrics = pango_context_get_metrics (context,
+ gtk_widget_get_style (widget)->font_desc,
+ pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
@@ -1708,7 +1710,7 @@ gtk_cell_renderer_text_render (GtkCellRenderer *cell,
else if (priv->wrap_width == -1)
pango_layout_set_width (layout, -1);
- gtk_paint_layout (widget->style,
+ gtk_paint_layout (gtk_widget_get_style (widget),
window,
state,
TRUE,
diff --git a/gtk/gtkcellrenderertoggle.c b/gtk/gtkcellrenderertoggle.c
index 9087adb..62bbc3d 100644
--- a/gtk/gtkcellrenderertoggle.c
+++ b/gtk/gtkcellrenderertoggle.c
@@ -376,7 +376,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
if (priv->radio)
{
- gtk_paint_option (widget->style,
+ gtk_paint_option (gtk_widget_get_style (widget),
window,
state, shadow,
expose_area, widget, "cellradio",
@@ -386,7 +386,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
}
else
{
- gtk_paint_check (widget->style,
+ gtk_paint_check (gtk_widget_get_style (widget),
window,
state, shadow,
expose_area, widget, "cellcheck",
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index a02fc72..08d3fda 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -361,7 +361,7 @@ gtk_cell_view_size_allocate (GtkWidget *widget,
gint extra_space;
GtkCellView *cellview;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
cellview = GTK_CELL_VIEW (widget);
@@ -379,7 +379,7 @@ gtk_cell_view_size_allocate (GtkWidget *widget,
full_requested_width += info->requested_width;
}
- extra_space = widget->allocation.width - full_requested_width;
+ extra_space = allocation->width - full_requested_width;
if (extra_space < 0)
extra_space = 0;
else if (extra_space > 0 && expand_cell_count > 0)
@@ -402,6 +402,7 @@ gtk_cell_view_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GList *i;
+ GtkAllocation allocation;
GtkCellView *cellview;
GdkRectangle area;
GtkCellRendererState state;
@@ -412,12 +413,14 @@ gtk_cell_view_expose (GtkWidget *widget,
if (!gtk_widget_is_drawable (widget))
return FALSE;
+ gtk_widget_get_allocation (widget, &allocation);
+
/* "blank" background */
if (cellview->priv->background_set)
{
- cairo_t *cr = gdk_cairo_create (GTK_WIDGET (cellview)->window);
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET (cellview)));
- gdk_cairo_rectangle (cr, &widget->allocation);
+ gdk_cairo_rectangle (cr, &allocation);
cairo_set_source_rgb (cr,
cellview->priv->background.red / 65535.,
cellview->priv->background.green / 65535.,
@@ -434,11 +437,11 @@ gtk_cell_view_expose (GtkWidget *widget,
return FALSE;
/* render cells */
- area = widget->allocation;
+ area = allocation;
/* we draw on our very own window, initialize x and y to zero */
- area.x = widget->allocation.x + (rtl ? widget->allocation.width : 0);
- area.y = widget->allocation.y;
+ area.x = allocation.x + (rtl ? allocation.width : 0);
+ area.y = allocation.y;
if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT)
state = GTK_CELL_RENDERER_PRELIT;
@@ -472,7 +475,7 @@ gtk_cell_view_expose (GtkWidget *widget,
area.x += info->real_width;
}
- area.x = rtl ? widget->allocation.x : (widget->allocation.x + widget->allocation.width);
+ area.x = rtl ? allocation.x : (allocation.x + allocation.width);
/* PACK_END */
for (i = cellview->priv->cell_list; i; i = i->next)
@@ -490,7 +493,7 @@ gtk_cell_view_expose (GtkWidget *widget,
area.x -= area.width;
gtk_cell_renderer_render (info->cell,
- widget->window,
+ gtk_widget_get_window (widget),
widget,
/* FIXME ! */
&area, &area, &event->area, state);
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 2f1dae0..30463bb 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -150,22 +150,39 @@ gtk_check_button_paint (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (gtk_widget_has_focus (widget))
{
+ GtkStyle *style;
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
-
+ GdkWindow *window;
+
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
if (interior_focus && child && gtk_widget_get_visible (child))
- gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
- area, widget, "checkbutton",
- child->allocation.x - focus_width - focus_pad,
- child->allocation.y - focus_width - focus_pad,
- child->allocation.width + 2 * (focus_width + focus_pad),
- child->allocation.height + 2 * (focus_width + focus_pad));
+ {
+ GtkAllocation child_allocation;
+
+ gtk_widget_get_allocation (child, &child_allocation);
+
+ gtk_paint_focus (style, window, gtk_widget_get_state (widget),
+ area, widget, "checkbutton",
+ child_allocation.x - focus_width - focus_pad,
+ child_allocation.y - focus_width - focus_pad,
+ child_allocation.width + 2 * (focus_width + focus_pad),
+ child_allocation.height + 2 * (focus_width + focus_pad));
+ }
else
- gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
- area, widget, "checkbutton",
- border_width + widget->allocation.x,
- border_width + widget->allocation.y,
- widget->allocation.width - 2 * border_width,
- widget->allocation.height - 2 * border_width);
+ {
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (child, &allocation);
+
+ gtk_paint_focus (style, window, gtk_widget_get_state (widget),
+ area, widget, "checkbutton",
+ border_width + allocation.x,
+ border_width + allocation.y,
+ allocation.width - 2 * border_width,
+ allocation.height - 2 * border_width);
+ }
}
}
}
@@ -259,8 +276,9 @@ gtk_check_button_size_allocate (GtkWidget *widget,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
-
- widget->allocation = *allocation;
+
+ gtk_widget_set_allocation (widget, allocation);
+
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (button->event_window,
allocation->x, allocation->y,
@@ -285,9 +303,8 @@ gtk_check_button_size_allocate (GtkWidget *widget,
child_allocation.height = MAX (child_allocation.height, 1);
child_allocation.x = (border_width + indicator_size + indicator_spacing * 3 +
- widget->allocation.x + focus_width + focus_pad);
- child_allocation.y = widget->allocation.y +
- (allocation->height - child_allocation.height) / 2;
+ allocation->x + focus_width + focus_pad);
+ child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
child_allocation.x = allocation->x + allocation->width
@@ -367,9 +384,17 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
if (gtk_widget_is_drawable (widget))
{
+ GtkAllocation allocation;
+ GtkStyle *style;
+ GdkWindow *window;
+
button = GTK_BUTTON (check_button);
toggle_button = GTK_TOGGLE_BUTTON (check_button);
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
gtk_widget_style_get (widget,
"interior-focus", &interior_focus,
"focus-line-width", &focus_width,
@@ -380,8 +405,8 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- x = widget->allocation.x + indicator_spacing + border_width;
- y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
+ x = allocation.x + indicator_spacing + border_width;
+ y = allocation.y + (allocation.height - indicator_size) / 2;
child = gtk_bin_get_child (GTK_BIN (check_button));
if (!interior_focus || !(child && gtk_widget_get_visible (child)))
@@ -404,21 +429,21 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
state_type = GTK_STATE_NORMAL;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x);
+ x = allocation.x + allocation.width - (indicator_size + x - allocation.x);
if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT)
{
GdkRectangle restrict_area;
GdkRectangle new_area;
-
- restrict_area.x = widget->allocation.x + border_width;
- restrict_area.y = widget->allocation.y + border_width;
- restrict_area.width = widget->allocation.width - (2 * border_width);
- restrict_area.height = widget->allocation.height - (2 * border_width);
-
+
+ restrict_area.x = allocation.x + border_width;
+ restrict_area.y = allocation.y + border_width;
+ restrict_area.width = allocation.width - (2 * border_width);
+ restrict_area.height = allocation.height - (2 * border_width);
+
if (gdk_rectangle_intersect (area, &restrict_area, &new_area))
{
- gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT,
+ gtk_paint_flat_box (style, window, GTK_STATE_PRELIGHT,
GTK_SHADOW_ETCHED_OUT,
area, widget, "checkbutton",
new_area.x, new_area.y,
@@ -426,7 +451,7 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
}
}
- gtk_paint_check (widget->style, widget->window,
+ gtk_paint_check (style, window,
state_type, shadow_type,
area, widget, "checkbutton",
x, y, indicator_size, indicator_size);
diff --git a/gtk/gtkcheckmenuitem.c b/gtk/gtkcheckmenuitem.c
index 55aa8f4..e930556 100644
--- a/gtk/gtkcheckmenuitem.c
+++ b/gtk/gtkcheckmenuitem.c
@@ -469,6 +469,8 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
if (gtk_widget_is_drawable (widget))
{
+ GtkAllocation allocation;
+ GtkStyle *style;
guint border_width;
guint offset;
guint toggle_size;
@@ -476,6 +478,9 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
guint horizontal_padding;
guint indicator_size;
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
gtk_widget_style_get (widget,
"toggle-spacing", &toggle_spacing,
"horizontal-padding", &horizontal_padding,
@@ -484,26 +489,29 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- offset = border_width + widget->style->xthickness + 2;
+ offset = border_width + style->xthickness + 2;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
{
- x = widget->allocation.x + offset + horizontal_padding +
+ x = allocation.x + offset + horizontal_padding +
(toggle_size - toggle_spacing - indicator_size) / 2;
}
else
{
- x = widget->allocation.x + widget->allocation.width -
+ x = allocation.x + allocation.width -
offset - horizontal_padding - toggle_size + toggle_spacing +
(toggle_size - toggle_spacing - indicator_size) / 2;
}
-
- y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
+
+ y = allocation.y + (allocation.height - indicator_size) / 2;
if (priv->active ||
priv->always_show_toggle ||
(gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT))
{
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
state_type = gtk_widget_get_state (widget);
if (priv->inconsistent)
@@ -518,14 +526,14 @@ gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
if (priv->draw_as_radio)
{
- gtk_paint_option (widget->style, widget->window,
+ gtk_paint_option (style, window,
state_type, shadow_type,
area, widget, "option",
x, y, indicator_size, indicator_size);
}
else
{
- gtk_paint_check (widget->style, widget->window,
+ gtk_paint_check (style, window,
state_type, shadow_type,
area, widget, "check",
x, y, indicator_size, indicator_size);
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index d977081..0fc7bee 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -309,7 +309,7 @@ expose_event (GtkWidget *widget,
if (!gtk_widget_is_sensitive (GTK_WIDGET (color_button)))
{
- gdk_cairo_set_source_color (cr, >K_WIDGET(color_button)->style->bg[GTK_STATE_INSENSITIVE]);
+ gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET(color_button))->bg[GTK_STATE_INSENSITIVE]);
checkered = gtk_color_button_get_checkered ();
cairo_mask (cr, checkered);
cairo_pattern_destroy (checkered);
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c
index b7034d0..a85110a 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -814,6 +814,7 @@ color_sample_drag_handle (GtkWidget *widget,
static void
color_sample_draw_sample (GtkColorSelection *colorsel, int which)
{
+ GtkAllocation allocation;
GtkWidget *da;
gint x, y, wid, heig, goff;
ColorSelectionPrivate *priv;
@@ -833,14 +834,18 @@ color_sample_draw_sample (GtkColorSelection *colorsel, int which)
}
else
{
+ GtkAllocation old_sample_allocation;
+
da = priv->cur_sample;
- goff = priv->old_sample->allocation.width % 32;
+ gtk_widget_get_allocation (priv->old_sample, &old_sample_allocation);
+ goff = old_sample_allocation.width % 32;
}
- cr = gdk_cairo_create (da->window);
-
- wid = da->allocation.width;
- heig = da->allocation.height;
+ cr = gdk_cairo_create (gtk_widget_get_window (da));
+
+ gtk_widget_get_allocation (da, &allocation);
+ wid = allocation.width;
+ heig = allocation.height;
/* Below needs tweaking for non-power-of-two */
@@ -1046,26 +1051,32 @@ palette_paint (GtkWidget *drawing_area,
GdkRectangle *area,
gpointer data)
{
+ GdkWindow *window;
cairo_t *cr;
gint focus_width;
-
- if (drawing_area->window == NULL)
+
+ window = gtk_widget_get_window (drawing_area);
+
+ if (window == NULL)
return;
- cr = gdk_cairo_create (drawing_area->window);
+ cr = gdk_cairo_create (window);
- gdk_cairo_set_source_color (cr, &drawing_area->style->bg[GTK_STATE_NORMAL]);
+ gdk_cairo_set_source_color (cr, >k_widget_get_style (drawing_area)->bg[GTK_STATE_NORMAL]);
gdk_cairo_rectangle (cr, area);
cairo_fill (cr);
if (gtk_widget_has_focus (drawing_area))
{
+ GtkAllocation allocation;
+
set_focus_line_attributes (drawing_area, cr, &focus_width);
+ gtk_widget_get_allocation (drawing_area, &allocation);
cairo_rectangle (cr,
- focus_width / 2., focus_width / 2.,
- drawing_area->allocation.width - focus_width,
- drawing_area->allocation.height - focus_width);
+ focus_width / 2., focus_width / 2.,
+ allocation.width - focus_width,
+ allocation.height - focus_width);
cairo_stroke (cr);
}
@@ -1318,7 +1329,7 @@ palette_expose (GtkWidget *drawing_area,
GdkEventExpose *event,
gpointer data)
{
- if (drawing_area->window == NULL)
+ if (gtk_widget_get_window (drawing_area) == NULL)
return FALSE;
palette_paint (drawing_area, &(event->area), data);
@@ -1333,6 +1344,7 @@ popup_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GtkRequisition req;
gint root_x, root_y;
@@ -1342,13 +1354,15 @@ popup_position_func (GtkMenu *menu,
g_return_if_fail (gtk_widget_get_realized (widget));
- gdk_window_get_origin (widget->window, &root_x, &root_y);
-
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ &root_x, &root_y);
+
gtk_widget_size_request (GTK_WIDGET (menu), &req);
+ gtk_widget_get_allocation (widget, &allocation);
/* Put corner of menu centered on color cell */
- *x = root_x + widget->allocation.width / 2;
- *y = root_y + widget->allocation.height / 2;
+ *x = root_x + allocation.width / 2;
+ *y = root_y + allocation.height / 2;
/* Ensure sanity */
screen = gtk_widget_get_screen (widget);
@@ -1887,6 +1901,7 @@ get_screen_color (GtkWidget *button)
GdkDevice *device, *keyb_device, *pointer_device;
GdkCursor *picker_cursor;
GdkGrabStatus grab_status;
+ GdkWindow *window;
GtkWidget *grab_widget, *toplevel;
guint32 time = gtk_get_current_event_time ();
@@ -1927,8 +1942,10 @@ get_screen_color (GtkWidget *button)
priv->dropper_grab_widget = grab_widget;
}
+ window = gtk_widget_get_window (priv->dropper_grab_widget);
+
if (gdk_device_grab (keyb_device,
- priv->dropper_grab_widget->window,
+ window,
GDK_OWNERSHIP_APPLICATION, FALSE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, time) != GDK_GRAB_SUCCESS)
@@ -1936,7 +1953,7 @@ get_screen_color (GtkWidget *button)
picker_cursor = make_picker_cursor (screen);
grab_status = gdk_device_grab (pointer_device,
- priv->dropper_grab_widget->window,
+ window,
GDK_OWNERSHIP_APPLICATION,
FALSE,
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK,
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index e8a535f..652a45a 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1104,7 +1104,7 @@ gtk_combo_box_state_changed (GtkWidget *widget,
{
if (priv->tree_view && priv->cell_view)
gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view),
- &widget->style->base[gtk_widget_get_state (widget)]);
+ >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
}
gtk_widget_queue_draw (widget);
@@ -1188,7 +1188,7 @@ gtk_combo_box_style_set (GtkWidget *widget,
if (priv->tree_view && priv->cell_view)
gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view),
- &widget->style->base[gtk_widget_get_state (widget)]);
+ >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
child = gtk_bin_get_child (GTK_BIN (combo_box));
if (GTK_IS_ENTRY (child))
@@ -1219,7 +1219,8 @@ gtk_combo_box_add (GtkContainer *container,
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
GtkComboBoxPrivate *priv = combo_box->priv;
- if (priv->cell_view && priv->cell_view->parent)
+ if (priv->cell_view &&
+ gtk_widget_get_parent (priv->cell_view))
{
gtk_widget_unparent (priv->cell_view);
_gtk_bin_set_child (GTK_BIN (container), NULL);
@@ -1237,8 +1238,8 @@ gtk_combo_box_add (GtkContainer *container,
if (!priv->tree_view && priv->separator)
{
- gtk_container_remove (GTK_CONTAINER (priv->separator->parent),
- priv->separator);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (priv->separator)),
+ priv->separator);
priv->separator = NULL;
gtk_widget_queue_resize (GTK_WIDGET (container));
@@ -1483,6 +1484,7 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
gpointer user_data)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (user_data);
+ GtkAllocation child_allocation;
gint sx, sy;
GtkWidget *child;
GtkRequisition req;
@@ -1495,28 +1497,31 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
sx = sy = 0;
+ gtk_widget_get_allocation (child, &child_allocation);
+
if (!gtk_widget_get_has_window (child))
{
- sx += child->allocation.x;
- sy += child->allocation.y;
+ sx += child_allocation.x;
+ sy += child_allocation.y;
}
- gdk_window_get_root_coords (child->window, sx, sy, &sx, &sy);
+ gdk_window_get_root_coords (gtk_widget_get_window (child),
+ sx, sy, &sx, &sy);
if (GTK_SHADOW_NONE != combo_box->priv->shadow_type)
- sx -= GTK_WIDGET (combo_box)->style->xthickness;
+ sx -= gtk_widget_get_style (GTK_WIDGET (combo_box))->xthickness;
gtk_widget_size_request (GTK_WIDGET (menu), &req);
if (gtk_widget_get_direction (GTK_WIDGET (combo_box)) == GTK_TEXT_DIR_LTR)
*x = sx;
else
- *x = sx + child->allocation.width - req.width;
+ *x = sx + child_allocation.width - req.width;
*y = sy;
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
monitor_num = gdk_screen_get_monitor_at_window (screen,
- GTK_WIDGET (combo_box)->window);
+ gtk_widget_get_window (GTK_WIDGET (combo_box)));
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
if (*x < monitor.x)
@@ -1524,12 +1529,12 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
else if (*x + req.width > monitor.x + monitor.width)
*x = monitor.x + monitor.width - req.width;
- if (monitor.y + monitor.height - *y - child->allocation.height >= req.height)
- *y += child->allocation.height;
+ if (monitor.y + monitor.height - *y - child_allocation.height >= req.height)
+ *y += child_allocation.height;
else if (*y - monitor.y >= req.height)
*y -= req.height;
- else if (monitor.y + monitor.height - *y - child->allocation.height > *y - monitor.y)
- *y += child->allocation.height;
+ else if (monitor.y + monitor.height - *y - child_allocation.height > *y - monitor.y)
+ *y += child_allocation.height;
else
*y -= req.height;
@@ -1543,6 +1548,7 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkComboBox *combo_box;
GtkWidget *active;
GtkWidget *child;
@@ -1562,8 +1568,10 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
active = gtk_menu_get_active (GTK_MENU (combo_box->priv->popup_widget));
- menu_xpos = widget->allocation.x;
- menu_ypos = widget->allocation.y + widget->allocation.height / 2 - 2;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ menu_xpos = allocation.x;
+ menu_ypos = allocation.y + allocation.height / 2 - 2;
if (active != NULL)
{
@@ -1589,9 +1597,10 @@ gtk_combo_box_menu_position_over (GtkMenu *menu,
}
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- menu_xpos = menu_xpos + widget->allocation.width - menu_width;
+ menu_xpos = menu_xpos + allocation.width - menu_width;
- gdk_window_get_root_coords (widget->window, menu_xpos, menu_ypos,
+ gdk_window_get_root_coords (gtk_widget_get_window (widget),
+ menu_xpos, menu_ypos,
&menu_xpos, &menu_ypos);
/* Clamp the position on screen */
@@ -1646,27 +1655,34 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
gint *height)
{
GtkComboBoxPrivate *priv = combo_box->priv;
+ GtkAllocation allocation;
GdkScreen *screen;
gint monitor_num;
GdkRectangle monitor;
GtkRequisition popup_req;
GtkPolicyType hpolicy, vpolicy;
-
+ GdkWindow *window;
+
/* under windows, the drop down list is as wide as the combo box itself.
see bug #340204 */
- GtkWidget *sample = GTK_WIDGET (combo_box);
+ GtkWidget *widget = GTK_WIDGET (combo_box);
*x = *y = 0;
- if (!gtk_widget_get_has_window (sample))
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (!gtk_widget_get_has_window (widget))
{
- *x += sample->allocation.x;
- *y += sample->allocation.y;
+ *x += allocation.x;
+ *y += allocation.y;
}
-
- gdk_window_get_root_coords (sample->window, *x, *y, x, y);
- *width = sample->allocation.width;
+ window = gtk_widget_get_window (widget);
+
+ gdk_window_get_root_coords (gtk_widget_get_window (widget),
+ *x, *y, x, y);
+
+ *width = allocation.width;
hpolicy = vpolicy = GTK_POLICY_NEVER;
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window),
@@ -1684,8 +1700,7 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
*height = popup_req.height;
screen = gtk_widget_get_screen (GTK_WIDGET (combo_box));
- monitor_num = gdk_screen_get_monitor_at_window (screen,
- GTK_WIDGET (combo_box)->window);
+ monitor_num = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
if (*x < monitor.x)
@@ -1693,13 +1708,13 @@ gtk_combo_box_list_position (GtkComboBox *combo_box,
else if (*x + *width > monitor.x + monitor.width)
*x = monitor.x + monitor.width - *width;
- if (*y + sample->allocation.height + *height <= monitor.y + monitor.height)
- *y += sample->allocation.height;
+ if (*y + allocation.height + *height <= monitor.y + monitor.height)
+ *y += allocation.height;
else if (*y - *height >= monitor.y)
*y -= *height;
- else if (monitor.y + monitor.height - (*y + sample->allocation.height) > *y - monitor.y)
+ else if (monitor.y + monitor.height - (*y + allocation.height) > *y - monitor.y)
{
- *y += sample->allocation.height;
+ *y += allocation.height;
*height = monitor.y + monitor.height - *y;
}
else
@@ -1851,7 +1866,10 @@ gtk_combo_box_menu_popup (GtkComboBox *combo_box,
if (priv->wrap_width == 0)
{
- width = GTK_WIDGET (combo_box)->allocation.width;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (GTK_WIDGET (combo_box), &allocation);
+ width = allocation.width;
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
gtk_widget_size_request (priv->popup_widget, &requisition);
@@ -2008,7 +2026,7 @@ gtk_combo_box_popup_for_device (GtkComboBox *combo_box,
if (!gtk_widget_has_focus (priv->tree_view))
gtk_widget_grab_focus (priv->tree_view);
- if (!popup_grab_on_window (priv->popup_window->window,
+ if (!popup_grab_on_window (gtk_widget_get_window (priv->popup_window),
keyboard, pointer, time))
{
gtk_widget_hide (priv->popup_window);
@@ -2169,6 +2187,8 @@ gtk_combo_box_size_request (GtkWidget *widget,
gint arrow_size;
guint border_width;
GtkRequisition bin_req;
+ GtkStyle *style;
+ GtkWidget *child;
PangoContext *context;
PangoFontMetrics *metrics;
PangoFontDescription *font_desc;
@@ -2188,7 +2208,8 @@ gtk_combo_box_size_request (GtkWidget *widget,
"arrow-size", &arrow_size,
NULL);
- font_desc = gtk_bin_get_child (GTK_BIN (widget))->style->font_desc;
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ font_desc = gtk_widget_get_style (child)->font_desc;
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context, font_desc,
pango_context_get_language (context));
@@ -2211,8 +2232,9 @@ gtk_combo_box_size_request (GtkWidget *widget,
gtk_widget_size_request (priv->button, &button_req);
border_width = gtk_container_get_border_width (GTK_CONTAINER (combo_box));
- xthickness = priv->button->style->xthickness;
- ythickness = priv->button->style->ythickness;
+ style = gtk_widget_get_style (priv->button);
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
bin_req.width = MAX (bin_req.width, priv->width);
bin_req.height = MAX (bin_req.height, priv->height);
@@ -2258,8 +2280,9 @@ gtk_combo_box_size_request (GtkWidget *widget,
{
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
- requisition->width += 2 * (border_width + GTK_WIDGET (priv->cell_view_frame)->style->xthickness);
- requisition->height += 2 * (border_width + GTK_WIDGET (priv->cell_view_frame)->style->ythickness);
+ style = gtk_widget_get_style (priv->cell_view_frame);
+ requisition->width += 2 * (border_width + style->xthickness);
+ requisition->height += 2 * (border_width + style->ythickness);
}
}
@@ -2272,8 +2295,9 @@ gtk_combo_box_size_request (GtkWidget *widget,
if (GTK_SHADOW_NONE != priv->shadow_type)
{
- requisition->height += 2 * widget->style->ythickness;
- requisition->width += 2 * widget->style->xthickness;
+ style = gtk_widget_get_style (widget);
+ requisition->height += 2 * style->ythickness;
+ requisition->width += 2 * style->xthickness;
}
}
@@ -2304,20 +2328,22 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
gint focus_width, focus_pad;
GtkAllocation child;
GtkRequisition req;
+ GtkStyle *style;
gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
child_widget = gtk_bin_get_child (GTK_BIN (widget));
- gtk_widget_style_get (GTK_WIDGET (widget),
+ style = gtk_widget_get_style (widget);
+ gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
if (GTK_SHADOW_NONE != priv->shadow_type)
{
- shadow_width = widget->style->xthickness;
- shadow_height = widget->style->ythickness;
+ shadow_width = style->xthickness;
+ shadow_height = style->ythickness;
}
else
{
@@ -2343,8 +2369,9 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
/* set some things ready */
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->button));
- xthickness = priv->button->style->xthickness;
- ythickness = priv->button->style->ythickness;
+ style = gtk_widget_get_style (priv->button);
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
child.x = allocation->x;
child.y = allocation->y;
@@ -2402,7 +2429,10 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
gtk_menu_reposition (GTK_MENU (priv->popup_widget));
if (priv->wrap_width == 0)
{
- width = GTK_WIDGET (combo_box)->allocation.width;
+ GtkAllocation combo_box_allocation;
+
+ gtk_widget_get_allocation (GTK_WIDGET (combo_box), &combo_box_allocation);
+ width = combo_box_allocation.width;
gtk_widget_set_size_request (priv->popup_widget, -1, -1);
gtk_widget_size_request (priv->popup_widget, &requisition);
gtk_widget_set_size_request (priv->popup_widget,
@@ -2463,8 +2493,9 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
if (priv->has_frame)
{
border_width = gtk_container_get_border_width (GTK_CONTAINER (priv->cell_view_frame));
- delta_x = border_width + GTK_WIDGET (priv->cell_view_frame)->style->xthickness;
- delta_y = border_width + GTK_WIDGET (priv->cell_view_frame)->style->ythickness;
+ style = gtk_widget_get_style (priv->cell_view_frame);
+ delta_x = border_width + style->xthickness;
+ delta_y = border_width + style->ythickness;
child.x += delta_x;
child.y += delta_y;
@@ -2592,11 +2623,16 @@ gtk_combo_box_expose_event (GtkWidget *widget,
if (gtk_widget_is_drawable (widget) &&
GTK_SHADOW_NONE != priv->shadow_type)
{
- gtk_paint_shadow (widget->style, widget->window,
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_paint_shadow (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
GTK_STATE_NORMAL, priv->shadow_type,
NULL, widget, "combobox",
- widget->allocation.x, widget->allocation.y,
- widget->allocation.width, widget->allocation.height);
+ allocation.x, allocation.y,
+ allocation.width, allocation.height);
}
gtk_container_propagate_expose (GTK_CONTAINER (widget),
@@ -3711,7 +3747,8 @@ gtk_combo_box_menu_row_changed (GtkTreeModel *model,
gtk_combo_box_menu_row_inserted (model, path, iter, combo_box);
}
- if (priv->wrap_width && item->parent == priv->popup_widget)
+ if (priv->wrap_width &&
+ gtk_widget_get_parent (item) == priv->popup_widget)
{
GtkWidget *pitem = NULL;
GtkTreePath *prev;
@@ -4130,23 +4167,26 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box,
gint x,
gint y)
{
- GtkWidget *tree_view = combo_box->priv->tree_view;
GtkAdjustment *adj;
+ GtkAllocation allocation;
+ GtkWidget *tree_view = combo_box->priv->tree_view;
gdouble value;
+ gtk_widget_get_allocation (tree_view, &allocation);
+
adj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window));
if (adj && adj->upper - adj->lower > adj->page_size)
{
- if (x <= tree_view->allocation.x &&
+ if (x <= allocation.x &&
adj->lower < adj->value)
{
- value = adj->value - (tree_view->allocation.x - x + 1);
+ value = adj->value - (allocation.x - x + 1);
gtk_adjustment_set_value (adj, value);
}
- else if (x >= tree_view->allocation.x + tree_view->allocation.width &&
+ else if (x >= allocation.x + allocation.width &&
adj->upper - adj->page_size > adj->value)
{
- value = adj->value + (x - tree_view->allocation.x - tree_view->allocation.width + 1);
+ value = adj->value + (x - allocation.x - allocation.width + 1);
gtk_adjustment_set_value (adj, MAX (value, 0.0));
}
}
@@ -4154,16 +4194,16 @@ gtk_combo_box_list_auto_scroll (GtkComboBox *combo_box,
adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (combo_box->priv->scrolled_window));
if (adj && adj->upper - adj->lower > adj->page_size)
{
- if (y <= tree_view->allocation.y &&
+ if (y <= allocation.y &&
adj->lower < adj->value)
{
- value = adj->value - (tree_view->allocation.y - y + 1);
+ value = adj->value - (allocation.y - y + 1);
gtk_adjustment_set_value (adj, value);
}
- else if (y >= tree_view->allocation.height &&
+ else if (y >= allocation.height &&
adj->upper - adj->page_size > adj->value)
{
- value = adj->value + (y - tree_view->allocation.height + 1);
+ value = adj->value + (y - allocation.height + 1);
gtk_adjustment_set_value (adj, MAX (value, 0.0));
}
}
@@ -4177,7 +4217,7 @@ gtk_combo_box_list_scroll_timeout (GtkComboBox *combo_box)
if (priv->auto_scroll)
{
- gdk_window_get_device_position (priv->tree_view->window,
+ gdk_window_get_device_position (gtk_widget_get_window (priv->tree_view),
priv->grab_pointer,
&x, &y, NULL);
gtk_combo_box_list_auto_scroll (combo_box, x, y);
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 624b49a..234172e 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -324,7 +324,8 @@ gtk_container_buildable_add_child (GtkBuildable *buildable,
{
GTK_BUILDER_WARN_INVALID_CHILD_TYPE (buildable, type);
}
- else if (GTK_IS_WIDGET (child) && GTK_WIDGET (child)->parent == NULL)
+ else if (GTK_IS_WIDGET (child) &&
+ gtk_widget_get_parent (GTK_WIDGET (child)) == NULL)
{
gtk_container_add (GTK_CONTAINER (buildable), GTK_WIDGET (child));
}
@@ -610,7 +611,7 @@ gtk_container_child_get_valist (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == GTK_WIDGET (container));
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container));
g_object_ref (container);
g_object_ref (child);
@@ -679,7 +680,7 @@ gtk_container_child_get_property (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == GTK_WIDGET (container));
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container));
g_return_if_fail (property_name != NULL);
g_return_if_fail (G_IS_VALUE (value));
@@ -755,7 +756,7 @@ gtk_container_child_set_valist (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == GTK_WIDGET (container));
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container));
g_object_ref (container);
g_object_ref (child);
@@ -828,7 +829,7 @@ gtk_container_child_set_property (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == GTK_WIDGET (container));
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container));
g_return_if_fail (property_name != NULL);
g_return_if_fail (G_IS_VALUE (value));
@@ -876,14 +877,14 @@ gtk_container_add_with_properties (GtkContainer *container,
{
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (widget->parent == NULL);
+ g_return_if_fail (gtk_widget_get_parent (widget) == NULL);
g_object_ref (container);
g_object_ref (widget);
gtk_widget_freeze_child_notify (widget);
g_signal_emit (container, container_signals[ADD], 0, widget);
- if (widget->parent)
+ if (gtk_widget_get_parent (widget))
{
va_list var_args;
@@ -917,7 +918,7 @@ gtk_container_child_set (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == GTK_WIDGET (container));
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container));
va_start (var_args, first_prop_name);
gtk_container_child_set_valist (container, child, first_prop_name, var_args);
@@ -944,7 +945,7 @@ gtk_container_child_get (GtkContainer *container,
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == GTK_WIDGET (container));
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container));
va_start (var_args, first_prop_name);
gtk_container_child_get_valist (container, child, first_prop_name, var_args);
@@ -1208,10 +1209,14 @@ void
gtk_container_add (GtkContainer *container,
GtkWidget *widget)
{
+ GtkWidget *parent;
+
g_return_if_fail (GTK_IS_CONTAINER (container));
g_return_if_fail (GTK_IS_WIDGET (widget));
- if (widget->parent != NULL)
+ parent = gtk_widget_get_parent (widget);
+
+ if (parent != NULL)
{
g_warning ("Attempting to add a widget with type %s to a container of "
"type %s, but the widget is already inside a container of type %s, "
@@ -1219,7 +1224,7 @@ gtk_container_add (GtkContainer *container,
"explains how to reparent a widget.",
g_type_name (G_OBJECT_TYPE (widget)),
g_type_name (G_OBJECT_TYPE (container)),
- g_type_name (G_OBJECT_TYPE (widget->parent)));
+ g_type_name (G_OBJECT_TYPE (parent)));
return;
}
@@ -1253,8 +1258,8 @@ gtk_container_remove (GtkContainer *container,
* a direct child of the container.
*/
g_return_if_fail (GTK_IS_TOOLBAR (container) ||
- widget->parent == GTK_WIDGET (container));
-
+ gtk_widget_get_parent (widget) == GTK_WIDGET (container));
+
g_signal_emit (container, container_signals[REMOVE], 0, widget);
}
@@ -1344,11 +1349,13 @@ gtk_container_set_reallocate_redraws (GtkContainer *container,
static GtkContainer*
gtk_container_get_resize_container (GtkContainer *container)
{
+ GtkWidget *parent;
GtkWidget *widget = GTK_WIDGET (container);
- while (widget->parent)
+ parent = gtk_widget_get_parent (widget);
+ while (parent)
{
- widget = widget->parent;
+ widget = parent;
if (GTK_IS_RESIZE_CONTAINER (widget))
break;
}
@@ -1389,6 +1396,7 @@ _gtk_container_queue_resize (GtkContainer *container)
{
GtkContainerPriv *priv;
GtkContainer *resize_container;
+ GtkWidget *parent;
GtkWidget *widget;
g_return_if_fail (GTK_IS_CONTAINER (container));
@@ -1405,11 +1413,13 @@ _gtk_container_queue_resize (GtkContainer *container)
GTK_PRIVATE_SET_FLAG (widget, GTK_WIDTH_REQUEST_NEEDED);
GTK_PRIVATE_SET_FLAG (widget, GTK_HEIGHT_REQUEST_NEEDED);
+ parent = gtk_widget_get_parent (widget);
+
if ((resize_container && widget == GTK_WIDGET (resize_container)) ||
- !widget->parent)
+ !parent)
break;
-
- widget = widget->parent;
+
+ widget = parent;
}
if (resize_container)
@@ -1464,16 +1474,20 @@ static void
gtk_container_real_check_resize (GtkContainer *container)
{
GtkWidget *widget = GTK_WIDGET (container);
+ GtkAllocation allocation;
GtkRequisition requisition;
gtk_widget_size_request (widget, &requisition);
-
- if (requisition.width > widget->allocation.width ||
- requisition.height > widget->allocation.height)
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (requisition.width > allocation.width ||
+ requisition.height > allocation.height)
{
if (GTK_IS_RESIZE_CONTAINER (container))
- gtk_widget_size_allocate (GTK_WIDGET (container),
- >K_WIDGET (container)->allocation);
+ {
+ gtk_widget_size_allocate (widget, &allocation);
+ gtk_widget_set_allocation (widget, &allocation);
+ }
else
gtk_widget_queue_resize (widget);
}
@@ -1493,6 +1507,7 @@ gtk_container_real_check_resize (GtkContainer *container)
void
gtk_container_resize_children (GtkContainer *container)
{
+ GtkAllocation allocation;
GtkWidget *widget;
/* resizing invariants:
@@ -1503,7 +1518,10 @@ gtk_container_resize_children (GtkContainer *container)
g_return_if_fail (GTK_IS_CONTAINER (container));
widget = GTK_WIDGET (container);
- gtk_widget_size_allocate (widget, &widget->allocation);
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_widget_size_allocate (widget, &allocation);
+ gtk_widget_set_allocation (widget, &allocation);
}
/**
@@ -1673,7 +1691,7 @@ _gtk_container_child_composite_name (GtkContainer *container,
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
- g_return_val_if_fail (child->parent == GTK_WIDGET (container), NULL);
+ g_return_val_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (container), NULL);
g_object_get (child, "composite-child", &composite_child, NULL);
if (composite_child)
@@ -1729,6 +1747,7 @@ gtk_container_real_set_focus_child (GtkContainer *container,
{
GtkAdjustment *hadj;
GtkAdjustment *vadj;
+ GtkAllocation allocation;
GtkWidget *focus_child;
gint x, y;
@@ -1746,14 +1765,17 @@ gtk_container_real_set_focus_child (GtkContainer *container,
gtk_widget_translate_coordinates (focus_child, priv->focus_child,
0, 0, &x, &y);
- x += priv->focus_child->allocation.x;
- y += priv->focus_child->allocation.y;
-
+ gtk_widget_get_allocation (priv->focus_child, &allocation);
+ x += allocation.x;
+ y += allocation.y;
+
+ gtk_widget_get_allocation (focus_child, &allocation);
+
if (vadj)
- gtk_adjustment_clamp_page (vadj, y, y + focus_child->allocation.height);
-
+ gtk_adjustment_clamp_page (vadj, y, y + allocation.height);
+
if (hadj)
- gtk_adjustment_clamp_page (hadj, x, x + focus_child->allocation.width);
+ gtk_adjustment_clamp_page (hadj, x, x + allocation.width);
}
}
}
@@ -1839,18 +1861,22 @@ tab_compare (gconstpointer a,
gconstpointer b,
gpointer data)
{
+ GtkAllocation child1_allocation, child2_allocation;
const GtkWidget *child1 = a;
const GtkWidget *child2 = b;
GtkTextDirection text_direction = GPOINTER_TO_INT (data);
- gint y1 = child1->allocation.y + child1->allocation.height / 2;
- gint y2 = child2->allocation.y + child2->allocation.height / 2;
+ gtk_widget_get_allocation ((GtkWidget *) child1, &child1_allocation);
+ gtk_widget_get_allocation ((GtkWidget *) child2, &child2_allocation);
+
+ gint y1 = child1_allocation.y + child1_allocation.height / 2;
+ gint y2 = child2_allocation.y + child2_allocation.height / 2;
if (y1 == y2)
{
- gint x1 = child1->allocation.x + child1->allocation.width / 2;
- gint x2 = child2->allocation.x + child2->allocation.width / 2;
-
+ gint x1 = child1_allocation.x + child1_allocation.width / 2;
+ gint x2 = child2_allocation.x + child2_allocation.width / 2;
+
if (text_direction == GTK_TEXT_DIR_RTL)
return (x1 < x2) ? 1 : ((x1 == x2) ? 0 : -1);
else
@@ -1886,7 +1912,7 @@ get_allocation_coords (GtkContainer *container,
GtkWidget *widget,
GdkRectangle *allocation)
{
- *allocation = widget->allocation;
+ gtk_widget_set_allocation (widget, allocation);
return gtk_widget_translate_coordinates (widget, GTK_WIDGET (container),
0, 0, &allocation->x, &allocation->y);
@@ -1908,7 +1934,9 @@ find_old_focus (GtkContainer *container,
while (widget && widget != (GtkWidget *)container)
{
- GtkWidget *parent = widget->parent;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
if (parent && (gtk_container_get_focus_child (GTK_CONTAINER (parent)) != widget))
goto next;
@@ -2050,9 +2078,12 @@ gtk_container_focus_sort_up_down (GtkContainer *container,
{
/* No old focus widget, need to figure out starting x,y some other way
*/
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (container);
GdkRectangle old_focus_rect;
+ gtk_widget_get_allocation (widget, &allocation);
+
if (old_focus_coords (container, &old_focus_rect))
{
compare.x = old_focus_rect.x + old_focus_rect.width / 2;
@@ -2060,15 +2091,15 @@ gtk_container_focus_sort_up_down (GtkContainer *container,
else
{
if (!gtk_widget_get_has_window (widget))
- compare.x = widget->allocation.x + widget->allocation.width / 2;
+ compare.x = allocation.x + allocation.width / 2;
else
- compare.x = widget->allocation.width / 2;
+ compare.x = allocation.width / 2;
}
if (!gtk_widget_get_has_window (widget))
- compare.y = (direction == GTK_DIR_DOWN) ? widget->allocation.y : widget->allocation.y + widget->allocation.height;
+ compare.y = (direction == GTK_DIR_DOWN) ? allocation.y : allocation.y + allocation.height;
else
- compare.y = (direction == GTK_DIR_DOWN) ? 0 : + widget->allocation.height;
+ compare.y = (direction == GTK_DIR_DOWN) ? 0 : + allocation.height;
}
children = g_list_sort_with_data (children, up_down_compare, &compare);
@@ -2177,9 +2208,12 @@ gtk_container_focus_sort_left_right (GtkContainer *container,
{
/* No old focus widget, need to figure out starting x,y some other way
*/
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (container);
GdkRectangle old_focus_rect;
+ gtk_widget_get_allocation (widget, &allocation);
+
if (old_focus_coords (container, &old_focus_rect))
{
compare.y = old_focus_rect.y + old_focus_rect.height / 2;
@@ -2187,15 +2221,15 @@ gtk_container_focus_sort_left_right (GtkContainer *container,
else
{
if (!gtk_widget_get_has_window (widget))
- compare.y = widget->allocation.y + widget->allocation.height / 2;
+ compare.y = allocation.y + allocation.height / 2;
else
- compare.y = widget->allocation.height / 2;
+ compare.y = allocation.height / 2;
}
if (!gtk_widget_get_has_window (widget))
- compare.x = (direction == GTK_DIR_RIGHT) ? widget->allocation.x : widget->allocation.x + widget->allocation.width;
+ compare.x = (direction == GTK_DIR_RIGHT) ? allocation.x : allocation.x + allocation.width;
else
- compare.x = (direction == GTK_DIR_RIGHT) ? 0 : widget->allocation.width;
+ compare.x = (direction == GTK_DIR_RIGHT) ? 0 : allocation.width;
}
children = g_list_sort_with_data (children, left_right_compare, &compare);
@@ -2653,7 +2687,7 @@ gtk_container_map_child (GtkWidget *child,
gpointer client_data)
{
if (gtk_widget_get_visible (child) &&
- GTK_WIDGET_CHILD_VISIBLE (child) &&
+ gtk_widget_get_child_visible (child) &&
!gtk_widget_get_mapped (child))
gtk_widget_map (child);
}
@@ -2668,7 +2702,7 @@ gtk_container_map (GtkWidget *widget)
NULL);
if (gtk_widget_get_has_window (widget))
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
}
static void
@@ -2677,7 +2711,7 @@ gtk_container_unmap (GtkWidget *widget)
gtk_widget_set_mapped (widget, FALSE);
if (gtk_widget_get_has_window (widget))
- gdk_window_hide (widget->window);
+ gdk_window_hide (gtk_widget_get_window (widget));
else
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback)gtk_widget_unmap,
@@ -2715,11 +2749,11 @@ gtk_container_propagate_expose (GtkContainer *container,
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (event != NULL);
- g_assert (child->parent == GTK_WIDGET (container));
-
+ g_assert (gtk_widget_get_parent (child) == GTK_WIDGET (container));
+
if (gtk_widget_is_drawable (child) &&
!gtk_widget_get_has_window (child) &&
- (child->window == event->window))
+ gtk_widget_get_window (child) == event->window)
{
child_event = gdk_event_new (GDK_EXPOSE);
child_event->expose = *event;
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 7cce1d4..e62f68e 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -497,8 +497,8 @@ gtk_dialog_close (GtkDialog *dialog)
GdkEvent *event;
event = gdk_event_new (GDK_DELETE);
-
- event->any.window = g_object_ref (widget->window);
+
+ event->any.window = g_object_ref (gtk_widget_get_window (widget));
event->any.send_event = TRUE;
gtk_main_do_event (event);
diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c
index e5968f7..6357ca6 100644
--- a/gtk/gtkdrawingarea.c
+++ b/gtk/gtkdrawingarea.c
@@ -62,6 +62,8 @@ static void
gtk_drawing_area_realize (GtkWidget *widget)
{
GtkDrawingArea *darea = GTK_DRAWING_AREA (widget);
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -73,11 +75,13 @@ gtk_drawing_area_realize (GtkWidget *widget)
{
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -85,12 +89,13 @@ gtk_drawing_area_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, darea);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (window, darea);
+ gtk_widget_set_window (widget, window);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL);
}
gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget));
@@ -103,12 +108,12 @@ gtk_drawing_area_size_allocate (GtkWidget *widget,
g_return_if_fail (GTK_IS_DRAWING_AREA (widget));
g_return_if_fail (allocation != NULL);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
{
if (gtk_widget_get_has_window (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
@@ -119,17 +124,19 @@ gtk_drawing_area_size_allocate (GtkWidget *widget,
static void
gtk_drawing_area_send_configure (GtkDrawingArea *darea)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GdkEvent *event = gdk_event_new (GDK_CONFIGURE);
widget = GTK_WIDGET (darea);
+ gtk_widget_get_allocation (widget, &allocation);
- event->configure.window = g_object_ref (widget->window);
+ event->configure.window = g_object_ref (gtk_widget_get_window (widget));
event->configure.send_event = TRUE;
- event->configure.x = widget->allocation.x;
- event->configure.y = widget->allocation.y;
- event->configure.width = widget->allocation.width;
- event->configure.height = widget->allocation.height;
+ event->configure.x = allocation.x;
+ event->configure.y = allocation.y;
+ event->configure.width = allocation.width;
+ event->configure.height = allocation.height;
gtk_widget_event (widget, event);
gdk_event_free (event);
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 723098e..1cccba9 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -2255,7 +2255,7 @@ find_invisible_char (GtkWidget *widget)
0x273a /* SIXTEEN POINTED ASTERISK */
};
- if (widget->style)
+ if (gtk_widget_get_style (widget))
gtk_widget_style_get (widget,
"invisible-char", &invisible_chars[0],
NULL);
@@ -2673,12 +2673,12 @@ realize_icon_info (GtkWidget *widget,
GDK_LEAVE_NOTIFY_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- icon_info->window = gdk_window_new (widget->window,
+ icon_info->window = gdk_window_new (gtk_widget_get_window (widget),
&attributes,
attributes_mask);
gdk_window_set_user_data (icon_info->window, widget);
gdk_window_set_background (icon_info->window,
- &widget->style->base[gtk_widget_get_state (widget)]);
+ >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
gtk_widget_queue_resize (widget);
}
@@ -2752,7 +2752,10 @@ gtk_entry_realize (GtkWidget *widget)
{
GtkEntry *entry;
GtkEntryPrivate *priv;
+ GtkStateType state;
+ GtkStyle *style;
EntryIconInfo *icon_info;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
int i;
@@ -2780,8 +2783,9 @@ gtk_entry_realize (GtkWidget *widget)
GDK_LEAVE_NOTIFY_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, entry);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, entry);
get_text_area_size (entry, &attributes.x, &attributes.y, &attributes.width, &attributes.height);
@@ -2791,17 +2795,19 @@ gtk_entry_realize (GtkWidget *widget)
attributes_mask |= GDK_WA_CURSOR;
}
- entry->text_area = gdk_window_new (widget->window, &attributes, attributes_mask);
+ entry->text_area = gdk_window_new (window, &attributes, attributes_mask);
gdk_window_set_user_data (entry->text_area, entry);
if (attributes_mask & GDK_WA_CURSOR)
gdk_cursor_unref (attributes.cursor);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
- gdk_window_set_background (widget->window, &widget->style->base[gtk_widget_get_state (widget)]);
- gdk_window_set_background (entry->text_area, &widget->style->base[gtk_widget_get_state (widget)]);
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+ gdk_window_set_background (window, &style->base[state]);
+ gdk_window_set_background (entry->text_area, &style->base[state]);
gdk_window_show (entry->text_area);
@@ -2877,11 +2883,14 @@ _gtk_entry_get_borders (GtkEntry *entry,
{
GtkWidget *widget = GTK_WIDGET (entry);
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
+ GtkStyle *style;
if (entry->has_frame)
{
- *xborder = widget->style->xthickness;
- *yborder = widget->style->ythickness;
+ style = gtk_widget_get_style (widget);
+
+ *xborder = style->xthickness;
+ *yborder = style->ythickness;
}
else
{
@@ -2912,7 +2921,7 @@ gtk_entry_size_request (GtkWidget *widget,
gtk_widget_ensure_style (widget);
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context,
- widget->style->font_desc,
+ gtk_widget_get_style (widget)->font_desc,
pango_context_get_language (context));
entry->ascent = pango_font_metrics_get_ascent (metrics);
@@ -2991,15 +3000,17 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
{
GtkWidget *widget = GTK_WIDGET (entry);
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
+ GtkAllocation allocation;
+ GtkRequisition requisition;
gint frame_height;
gint xborder, yborder;
- GtkRequisition requisition;
gtk_widget_get_child_requisition (widget, &requisition);
+ gtk_widget_get_allocation (widget, &allocation);
_gtk_entry_get_borders (entry, &xborder, &yborder);
if (gtk_widget_get_realized (widget))
- gdk_drawable_get_size (widget->window, NULL, &frame_height);
+ gdk_drawable_get_size (gtk_widget_get_window (widget), NULL, &frame_height);
else
frame_height = requisition.height;
@@ -3013,7 +3024,7 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
*y = frame_height / 2 - (requisition.height - yborder * 2) / 2;
if (width)
- *width = GTK_WIDGET (entry)->allocation.width - xborder * 2;
+ *width = allocation.width - xborder * 2;
if (height)
*height = requisition.height - yborder * 2;
@@ -3044,29 +3055,31 @@ get_widget_window_size (GtkEntry *entry,
gint *width,
gint *height)
{
+ GtkAllocation allocation;
GtkRequisition requisition;
GtkWidget *widget = GTK_WIDGET (entry);
-
+
gtk_widget_get_child_requisition (widget, &requisition);
+ gtk_widget_get_allocation (widget, &allocation);
if (x)
- *x = widget->allocation.x;
+ *x = allocation.x;
if (y)
{
if (entry->is_cell_renderer)
- *y = widget->allocation.y;
+ *y = allocation.y;
else
- *y = widget->allocation.y + (widget->allocation.height - requisition.height) / 2;
+ *y = allocation.y + (allocation.height - requisition.height) / 2;
}
if (width)
- *width = widget->allocation.width;
+ *width = allocation.width;
if (height)
{
if (entry->is_cell_renderer)
- *height = widget->allocation.height;
+ *height = allocation.height;
else
*height = requisition.height;
}
@@ -3103,9 +3116,9 @@ gtk_entry_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkEntry *entry = GTK_ENTRY (widget);
-
- widget->allocation = *allocation;
-
+
+ gtk_widget_set_allocation (widget, allocation);
+
if (gtk_widget_get_realized (widget))
{
/* We call gtk_widget_get_child_requisition, since we want (for
@@ -3116,7 +3129,8 @@ gtk_entry_size_allocate (GtkWidget *widget,
GtkEntryCompletion* completion;
get_widget_window_size (entry, &x, &y, &width, &height);
- gdk_window_move_resize (widget->window, x, y, width, height);
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ x, y, width, height);
place_windows (entry);
gtk_entry_recompute (entry);
@@ -3281,11 +3295,15 @@ gtk_entry_draw_frame (GtkWidget *widget,
GdkEventExpose *event)
{
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
+ GtkStyle *style;
+ GdkWindow *window;
gint x = 0, y = 0, width, height;
gboolean state_hint;
GtkStateType state;
- gdk_drawable_get_size (widget->window, &width, &height);
+ window = gtk_widget_get_window (widget);
+
+ gdk_drawable_get_size (window, &width, &height);
/* Fix a problem with some themes which assume that entry->text_area's
* width equals widget->window's width */
@@ -3308,6 +3326,7 @@ gtk_entry_draw_frame (GtkWidget *widget,
height -= 2 * priv->focus_width;
}
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget, "state-hint", &state_hint, NULL);
if (state_hint)
state = gtk_widget_has_focus (widget) ?
@@ -3315,7 +3334,7 @@ gtk_entry_draw_frame (GtkWidget *widget,
else
state = GTK_STATE_NORMAL;
- gtk_paint_shadow (widget->style, widget->window,
+ gtk_paint_shadow (style, window,
state, priv->shadow_type,
&event->area, widget, "entry", x, y, width, height);
@@ -3328,8 +3347,8 @@ gtk_entry_draw_frame (GtkWidget *widget,
y -= priv->focus_width;
width += 2 * priv->focus_width;
height += 2 * priv->focus_width;
-
- gtk_paint_focus (widget->style, widget->window,
+
+ gtk_paint_focus (style, window,
gtk_widget_get_state (widget),
&event->area, widget, "entry",
0, 0, width, height);
@@ -3341,6 +3360,7 @@ gtk_entry_get_progress_border (GtkWidget *widget,
GtkBorder *progress_border)
{
GtkBorder *tmp_border;
+ GtkStyle *style;
gtk_widget_style_get (widget, "progress-border", &tmp_border, NULL);
if (tmp_border)
@@ -3350,10 +3370,12 @@ gtk_entry_get_progress_border (GtkWidget *widget,
}
else
{
- progress_border->left = widget->style->xthickness;
- progress_border->right = widget->style->xthickness;
- progress_border->top = widget->style->ythickness;
- progress_border->bottom = widget->style->ythickness;
+ style = gtk_widget_get_style (widget);
+
+ progress_border->left = style->xthickness;
+ progress_border->right = style->xthickness;
+ progress_border->top = style->ythickness;
+ progress_border->bottom = style->ythickness;
}
}
@@ -3373,7 +3395,7 @@ get_progress_area (GtkWidget *widget,
*x = progress_border.left;
*y = progress_border.top;
- gdk_drawable_get_size (widget->window, width, height);
+ gdk_drawable_get_size (gtk_widget_get_window (widget), width, height);
*width -= progress_border.left + progress_border.right;
*height -= progress_border.top + progress_border.bottom;
@@ -3429,7 +3451,7 @@ gtk_entry_draw_progress (GtkWidget *widget,
if ((width <= 0) || (height <= 0))
return;
- if (event->window != widget->window)
+ if (event->window != gtk_widget_get_window (widget))
{
gint pos_x, pos_y;
@@ -3443,7 +3465,7 @@ gtk_entry_draw_progress (GtkWidget *widget,
if (!gtk_widget_get_sensitive (widget))
state = GTK_STATE_INSENSITIVE;
- gtk_paint_box (widget->style, event->window,
+ gtk_paint_box (gtk_widget_get_style (widget), event->window,
state, GTK_SHADOW_OUT,
&event->area, widget, "entry-progress",
x, y,
@@ -3455,18 +3477,22 @@ gtk_entry_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkEntry *entry = GTK_ENTRY (widget);
+ GtkStyle *style;
gboolean state_hint;
GtkStateType state;
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (entry);
+ style = gtk_widget_get_style (widget);
+
gtk_widget_style_get (widget, "state-hint", &state_hint, NULL);
+
if (state_hint)
state = gtk_widget_has_focus (widget) ?
GTK_STATE_ACTIVE : gtk_widget_get_state (widget);
else
state = gtk_widget_get_state(widget);
- if (widget->window == event->window)
+ if (gtk_widget_get_window (widget) == event->window)
{
gtk_entry_draw_frame (widget, event);
}
@@ -3476,7 +3502,7 @@ gtk_entry_expose (GtkWidget *widget,
gdk_drawable_get_size (entry->text_area, &width, &height);
- gtk_paint_flat_box (widget->style, entry->text_area,
+ gtk_paint_flat_box (style, entry->text_area,
state, GTK_SHADOW_NONE,
&event->area, widget, "entry_bg",
0, 0, width, height);
@@ -3508,7 +3534,7 @@ gtk_entry_expose (GtkWidget *widget,
gdk_drawable_get_size (icon_info->window, &width, &height);
- gtk_paint_flat_box (widget->style, icon_info->window,
+ gtk_paint_flat_box (style, icon_info->window,
gtk_widget_get_state (widget), GTK_SHADOW_NONE,
NULL, widget, "entry_bg",
0, 0, width, height);
@@ -4251,13 +4277,22 @@ gtk_entry_state_changed (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_background (widget->window, &widget->style->base[gtk_widget_get_state (widget)]);
- gdk_window_set_background (entry->text_area, &widget->style->base[gtk_widget_get_state (widget)]);
+ GtkStateType state;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ gdk_window_set_background (gtk_widget_get_window (widget),
+ &style->base[state]);
+ gdk_window_set_background (entry->text_area,
+ &style->base[state]);
for (i = 0; i < MAX_ICONS; i++)
{
EntryIconInfo *icon_info = priv->icons[i];
if (icon_info && icon_info->window)
- gdk_window_set_background (icon_info->window, &widget->style->base[gtk_widget_get_state (widget)]);
+ gdk_window_set_background (icon_info->window,
+ &style->base[state]);
}
if (gtk_widget_is_sensitive (widget))
@@ -4469,13 +4504,20 @@ gtk_entry_style_set (GtkWidget *widget,
if (previous_style && gtk_widget_get_realized (widget))
{
- gdk_window_set_background (widget->window, &widget->style->base[gtk_widget_get_state (widget)]);
- gdk_window_set_background (entry->text_area, &widget->style->base[gtk_widget_get_state (widget)]);
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+
+ gdk_window_set_background (gtk_widget_get_window (widget),
+ &style->base[gtk_widget_get_state (widget)]);
+ gdk_window_set_background (entry->text_area,
+ &style->base[gtk_widget_get_state (widget)]);
for (i = 0; i < MAX_ICONS; i++)
{
EntryIconInfo *icon_info = priv->icons[i];
if (icon_info && icon_info->window)
- gdk_window_set_background (icon_info->window, &widget->style->base[gtk_widget_get_state (widget)]);
+ gdk_window_set_background (icon_info->window,
+ &style->base[gtk_widget_get_state (widget)]);
}
}
@@ -5541,19 +5583,22 @@ draw_text_with_color (GtkEntry *entry, cairo_t *cr, GdkColor *default_color)
PangoRectangle logical_rect;
GdkColor *selection_color, *text_color;
GtkBorder inner_border;
+ GtkStyle *style;
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges);
+ style = gtk_widget_get_style (widget);
+
if (gtk_widget_has_focus (widget))
{
- selection_color = &widget->style->base [GTK_STATE_SELECTED];
- text_color = &widget->style->text [GTK_STATE_SELECTED];
+ selection_color = &style->base [GTK_STATE_SELECTED];
+ text_color = &style->text [GTK_STATE_SELECTED];
}
else
{
- selection_color = &widget->style->base [GTK_STATE_ACTIVE];
- text_color = &widget->style->text [GTK_STATE_ACTIVE];
+ selection_color = &style->base [GTK_STATE_ACTIVE];
+ text_color = &style->text [GTK_STATE_ACTIVE];
}
_gtk_entry_effective_inner_border (entry, &inner_border);
@@ -5591,17 +5636,19 @@ gtk_entry_draw_text (GtkEntry *entry)
if (gtk_widget_is_drawable (widget))
{
+ GtkStateType state;
+ GtkStyle *style;
GdkColor text_color, bar_text_color;
gint pos_x, pos_y;
gint width, height;
gint progress_x, progress_y, progress_width, progress_height;
- GtkStateType state;
state = GTK_STATE_SELECTED;
if (!gtk_widget_get_sensitive (widget))
state = GTK_STATE_INSENSITIVE;
- text_color = widget->style->text[widget->state];
- bar_text_color = widget->style->fg[state];
+ style = gtk_widget_get_style (widget);
+ text_color = style->text[gtk_widget_get_state (widget)];
+ bar_text_color = style->fg[state];
get_progress_area (widget,
&progress_x, &progress_y,
@@ -5784,7 +5831,7 @@ gtk_entry_draw_cursor (GtkEntry *entry,
gdk_cairo_rectangle (cr, &rect);
cairo_clip (cr);
cairo_move_to (cr, x, y);
- gdk_cairo_set_source_color (cr, &widget->style->base[widget->state]);
+ gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
pango_cairo_show_layout (cr, layout);
}
@@ -6047,26 +6094,29 @@ gtk_entry_adjust_scroll (GtkEntry *entry)
static void
gtk_entry_move_adjustments (GtkEntry *entry)
{
+ GtkAllocation allocation;
+ GtkAdjustment *adjustment;
PangoContext *context;
PangoFontMetrics *metrics;
gint x, layout_x, border_x, border_y;
gint char_width;
- GtkAdjustment *adjustment;
adjustment = g_object_get_qdata (G_OBJECT (entry), quark_cursor_hadjustment);
if (!adjustment)
return;
+ gtk_widget_get_allocation (&(entry->widget), &allocation);
+
/* Cursor position, layout offset, border width, and widget allocation */
gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &x, NULL);
get_layout_position (entry, &layout_x, NULL);
_gtk_entry_get_borders (entry, &border_x, &border_y);
- x += entry->widget.allocation.x + layout_x + border_x;
+ x += allocation.x + layout_x + border_x;
/* Approximate width of a char, so user can see what is ahead/behind */
context = gtk_widget_get_pango_context (GTK_WIDGET (entry));
metrics = pango_context_get_metrics (context,
- entry->widget.style->font_desc,
+ gtk_widget_get_style (&(entry->widget))->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE;
@@ -8790,14 +8840,16 @@ gtk_entry_drag_motion (GtkWidget *widget,
guint time)
{
GtkEntry *entry = GTK_ENTRY (widget);
+ GtkStyle *style;
GtkWidget *source_widget;
GdkDragAction suggested_action;
gint new_position, old_position;
gint sel1, sel2;
-
- x -= widget->style->xthickness;
- y -= widget->style->ythickness;
-
+
+ style = gtk_widget_get_style (widget);
+ x -= style->xthickness;
+ y -= style->ythickness;
+
old_position = entry->dnd_position;
new_position = gtk_entry_find_position (entry, x + entry->scroll_offset);
@@ -8855,12 +8907,14 @@ gtk_entry_drag_data_received (GtkWidget *widget,
{
GtkEntry *entry = GTK_ENTRY (widget);
GtkEditable *editable = GTK_EDITABLE (widget);
+ GtkStyle *style;
gchar *str;
str = (gchar *) gtk_selection_data_get_text (selection_data);
- x -= widget->style->xthickness;
- y -= widget->style->ythickness;
+ style = gtk_widget_get_style (widget);
+ x -= style->xthickness;
+ y -= style->ythickness;
if (str && entry->editable)
{
diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c
index 8d066bc..75f2fd2 100644
--- a/gtk/gtkentrycompletion.c
+++ b/gtk/gtkentrycompletion.c
@@ -1209,7 +1209,7 @@ gtk_entry_completion_insert_action (GtkEntryCompletion *completion,
1, markup,
-1);
- if (!completion->priv->action_view->parent)
+ if (!gtk_widget_get_parent (completion->priv->action_view))
{
GtkTreePath *path = gtk_tree_path_new_from_indices (0, -1);
@@ -1375,12 +1375,14 @@ gtk_entry_completion_list_motion_notify (GtkWidget *widget,
gboolean
_gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
{
+ GtkAllocation allocation;
gint x, y;
gint matches, actions, items, height, x_border, y_border;
GdkScreen *screen;
gint monitor_num;
gint vertical_separator;
GdkRectangle monitor;
+ GdkWindow *window;
GtkRequisition popup_req;
GtkRequisition entry_req;
GtkTreePath *path;
@@ -1389,10 +1391,12 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
GtkTreeViewColumn *action_column;
gint action_height;
- if (!completion->priv->entry->window)
+ window = gtk_widget_get_window (completion->priv->entry);
+
+ if (!window)
return FALSE;
- gdk_window_get_origin (completion->priv->entry->window, &x, &y);
+ gdk_window_get_origin (window, &x, &y);
_gtk_entry_get_borders (GTK_ENTRY (completion->priv->entry), &x_border, &y_border);
matches = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (completion->priv->filter_model), NULL);
@@ -1413,8 +1417,7 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
gtk_widget_realize (completion->priv->tree_view);
screen = gtk_widget_get_screen (GTK_WIDGET (completion->priv->entry));
- monitor_num = gdk_screen_get_monitor_at_window (screen,
- GTK_WIDGET (completion->priv->entry)->window);
+ monitor_num = gdk_screen_get_monitor_at_window (screen, window);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
@@ -1429,8 +1432,9 @@ _gtk_entry_completion_resize_popup (GtkEntryCompletion *completion)
else
gtk_widget_show (completion->priv->scrolled_window);
+ gtk_widget_get_allocation (completion->priv->entry, &allocation);
if (completion->priv->popup_set_width)
- width = MIN (completion->priv->entry->allocation.width, monitor.width) - 2 * x_border;
+ width = MIN (allocation.width, monitor.width) - 2 * x_border;
else
width = -1;
@@ -1504,7 +1508,7 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion,
renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column));
gtk_widget_ensure_style (completion->priv->tree_view);
g_object_set (GTK_CELL_RENDERER (renderers->data), "cell-background-gdk",
- &completion->priv->tree_view->style->bg[GTK_STATE_NORMAL],
+ >k_widget_get_style (completion->priv->tree_view)->bg[GTK_STATE_NORMAL],
NULL);
g_list_free (renderers);
@@ -1532,7 +1536,7 @@ _gtk_entry_completion_popup (GtkEntryCompletion *completion,
gtk_widget_show (completion->priv->popup_window);
gtk_device_grab_add (completion->priv->popup_window, device, TRUE);
- gdk_device_grab (device, completion->priv->popup_window->window,
+ gdk_device_grab (device, gtk_widget_get_window (completion->priv->popup_window),
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c
index 3e575e1..70fd1aa 100644
--- a/gtk/gtkeventbox.c
+++ b/gtk/gtkeventbox.c
@@ -366,20 +366,24 @@ gtk_event_box_set_above_child (GtkEventBox *event_box,
static void
gtk_event_box_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
GtkEventBoxPrivate *priv;
gboolean visible_window;
+ gtk_widget_get_allocation (widget, &allocation);
+
gtk_widget_set_realized (widget, TRUE);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - 2*border_width;
- attributes.height = widget->allocation.height - 2*border_width;
+
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - 2*border_width;
+ attributes.height = allocation.height - 2*border_width;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = gtk_widget_get_events (widget)
| GDK_BUTTON_MOTION_MASK
@@ -399,15 +403,17 @@ gtk_event_box_realize (GtkWidget *widget)
attributes.wclass = GDK_INPUT_OUTPUT;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
}
else
{
- 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);
}
if (!visible_window || priv->above_child)
@@ -418,16 +424,15 @@ gtk_event_box_realize (GtkWidget *widget)
else
attributes_mask = 0;
- priv->event_window = gdk_window_new (widget->window,
+ priv->event_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (priv->event_window, widget);
}
+ gtk_widget_style_attach (widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
-
if (visible_window)
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL);
}
static void
@@ -512,8 +517,10 @@ gtk_event_box_size_allocate (GtkWidget *widget,
guint border_width;
GtkWidget *child;
- widget->allocation = *allocation;
bin = GTK_BIN (widget);
+
+ gtk_widget_set_allocation (widget, allocation);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (!gtk_widget_get_has_window (widget))
@@ -541,7 +548,7 @@ gtk_event_box_size_allocate (GtkWidget *widget,
child_allocation.height);
if (gtk_widget_get_has_window (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x + border_width,
allocation->y + border_width,
child_allocation.width,
@@ -558,8 +565,10 @@ gtk_event_box_paint (GtkWidget *widget,
GdkRectangle *area)
{
if (!gtk_widget_get_app_paintable (widget))
- gtk_paint_flat_box (widget->style, widget->window,
- widget->state, GTK_SHADOW_NONE,
+ gtk_paint_flat_box (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (widget),
+ GTK_SHADOW_NONE,
area, widget, "eventbox",
0, 0, -1, -1);
}
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index a209536..fdb3b7c 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -430,7 +430,9 @@ gtk_expander_destroy (GtkObject *object)
static void
gtk_expander_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkExpanderPrivate *priv;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
@@ -438,6 +440,7 @@ gtk_expander_realize (GtkWidget *widget)
gint label_height;
priv = GTK_EXPANDER (widget)->priv;
+
gtk_widget_set_realized (widget, TRUE);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -454,10 +457,12 @@ gtk_expander_realize (GtkWidget *widget)
else
label_height = 0;
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = MAX (widget->allocation.width - 2 * border_width, 1);
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = MAX (allocation.width - 2 * border_width, 1);
attributes.height = MAX (expander_rect.height, label_height - 2 * border_width);
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget) |
@@ -468,14 +473,15 @@ gtk_expander_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y;
- 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);
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (priv->event_window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
}
static void
@@ -497,6 +503,7 @@ static void
get_expander_bounds (GtkExpander *expander,
GdkRectangle *rect)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GtkExpanderPrivate *priv;
gint border_width;
@@ -510,6 +517,8 @@ get_expander_bounds (GtkExpander *expander,
widget = GTK_WIDGET (expander);
priv = expander->priv;
+ gtk_widget_get_allocation (widget, &allocation);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gtk_widget_style_get (widget,
@@ -522,20 +531,20 @@ get_expander_bounds (GtkExpander *expander,
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
- rect->x = widget->allocation.x + border_width;
- rect->y = widget->allocation.y + border_width;
+ rect->x = allocation.x + border_width;
+ rect->y = allocation.y + border_width;
if (ltr)
rect->x += expander_spacing;
else
- rect->x += widget->allocation.width - 2 * border_width -
+ rect->x += allocation.width - 2 * border_width -
expander_spacing - expander_size;
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
{
GtkAllocation label_allocation;
- label_allocation = priv->label_widget->allocation;
+ gtk_widget_get_allocation (priv->label_widget, &label_allocation);
if (expander_size < label_allocation.height)
rect->y += focus_width + focus_pad + (label_allocation.height - expander_size) / 2;
@@ -583,7 +592,7 @@ gtk_expander_size_allocate (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
gtk_widget_style_get (widget,
"interior-focus", &interior_focus,
@@ -626,15 +635,14 @@ gtk_expander_size_allocate (GtkWidget *widget,
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
if (priv->label_fill)
- label_allocation.x = widget->allocation.x + label_xoffset;
+ label_allocation.x = allocation->x + label_xoffset;
else if (ltr)
- label_allocation.x = widget->allocation.x + label_xoffset;
+ label_allocation.x = allocation->x + label_xoffset;
else
- label_allocation.x =
- widget->allocation.x + widget->allocation.width -
- (label_allocation.width + label_xoffset);
+ label_allocation.x = allocation->x + allocation->width -
+ (label_allocation.width + label_xoffset);
- label_allocation.y = widget->allocation.y + border_width + focus_width + focus_pad;
+ label_allocation.y = allocation->y + border_width + focus_width + focus_pad;
label_allocation.height = MIN (label_height,
allocation->height - 2 * border_width -
2 * focus_width - 2 * focus_pad -
@@ -671,8 +679,8 @@ gtk_expander_size_allocate (GtkWidget *widget,
top_height = MAX (top_min_height,
label_height + (interior_focus ? 2 * focus_width + 2 * focus_pad : 0));
- child_allocation.x = widget->allocation.x + border_width;
- child_allocation.y = widget->allocation.y + top_height + child_yoffset;
+ child_allocation.x = allocation->x + border_width;
+ child_allocation.y = allocation->y + top_height + child_yoffset;
child_allocation.width = MAX (allocation->width - 2 * border_width, 1);
child_allocation.height = allocation->height - top_height - child_ypad;
@@ -713,6 +721,7 @@ gtk_expander_unmap (GtkWidget *widget)
static void
gtk_expander_paint_prelight (GtkExpander *expander)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GtkContainer *container;
GtkExpanderPrivate *priv;
@@ -736,13 +745,20 @@ gtk_expander_paint_prelight (GtkExpander *expander)
"expander-spacing", &expander_spacing,
NULL);
+ gtk_widget_get_allocation (widget, &allocation);
+
border_width = gtk_container_get_border_width (container);
- area.x = widget->allocation.x + border_width;
- area.y = widget->allocation.y + border_width;
- area.width = widget->allocation.width - (2 * border_width);
+ area.x = allocation.x + border_width;
+ area.y = allocation.y + border_width;
+ area.width = allocation.width - (2 * border_width);
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
- area.height = priv->label_widget->allocation.height;
+ {
+ GtkAllocation label_widget_allocation;
+
+ gtk_widget_get_allocation (priv->label_widget, &label_widget_allocation);
+ area.height = label_widget_allocation.height;
+ }
else
area.height = 0;
@@ -750,7 +766,8 @@ gtk_expander_paint_prelight (GtkExpander *expander)
area.height = MAX (area.height, expander_size + 2 * expander_spacing);
area.height += !interior_focus ? (focus_width + focus_pad) * 2 : 0;
- gtk_paint_flat_box (widget->style, widget->window,
+ gtk_paint_flat_box (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
GTK_STATE_PRELIGHT,
GTK_SHADOW_ETCHED_OUT,
&area, widget, "expander",
@@ -769,7 +786,7 @@ gtk_expander_paint (GtkExpander *expander)
get_expander_bounds (expander, &clip);
- state = widget->state;
+ state = gtk_widget_get_state (widget);
if (expander->priv->prelight)
{
state = GTK_STATE_PRELIGHT;
@@ -777,8 +794,8 @@ gtk_expander_paint (GtkExpander *expander)
gtk_expander_paint_prelight (expander);
}
- gtk_paint_expander (widget->style,
- widget->window,
+ gtk_paint_expander (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
state,
&clip,
widget,
@@ -823,6 +840,10 @@ gtk_expander_paint_focus (GtkExpander *expander,
if (priv->label_widget)
{
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
if (gtk_widget_get_visible (priv->label_widget))
{
GtkAllocation label_allocation;
@@ -835,8 +856,8 @@ gtk_expander_paint_focus (GtkExpander *expander,
width += 2 * focus_pad + 2 * focus_width;
height += 2 * focus_pad + 2 * focus_width;
- x = widget->allocation.x + border_width;
- y = widget->allocation.y + border_width;
+ x = allocation.x + border_width;
+ y = allocation.y + border_width;
if (ltr)
{
@@ -845,7 +866,7 @@ gtk_expander_paint_focus (GtkExpander *expander,
}
else
{
- x += widget->allocation.width - 2 * border_width
+ x += allocation.width - 2 * border_width
- expander_spacing * 2 - expander_size - width;
}
@@ -864,8 +885,10 @@ gtk_expander_paint_focus (GtkExpander *expander,
width = rect.width + 2 * focus_pad;
height = rect.height + 2 * focus_pad;
}
-
- gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
+
+ gtk_paint_focus (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (widget),
area, widget, "expander",
x, y, width, height);
}
@@ -939,12 +962,15 @@ gtk_expander_state_changed (GtkWidget *widget,
static void
gtk_expander_redraw_expander (GtkExpander *expander)
{
- GtkWidget *widget;
-
- widget = GTK_WIDGET (expander);
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (expander);
if (gtk_widget_get_realized (widget))
- gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
+ {
+ gtk_widget_get_allocation (widget, &allocation);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), &allocation, FALSE);
+ gtk_widget_set_allocation (widget, &allocation);
+ }
}
static gboolean
@@ -1521,14 +1547,15 @@ static gboolean
gtk_expander_animation_timeout (GtkExpander *expander)
{
GtkExpanderPrivate *priv = expander->priv;
+ GtkWidget *widget = GTK_WIDGET (expander);
GtkWidget *child;
GdkRectangle area;
gboolean finish = FALSE;
- if (gtk_widget_get_realized (GTK_WIDGET (expander)))
+ if (gtk_widget_get_realized (widget))
{
get_expander_bounds (expander, &area);
- gdk_window_invalidate_rect (GTK_WIDGET (expander)->window, &area, TRUE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), &area, TRUE);
}
if (priv->expanded)
@@ -1563,7 +1590,7 @@ gtk_expander_animation_timeout (GtkExpander *expander)
child = gtk_bin_get_child (GTK_BIN (expander));
if (child)
gtk_widget_set_child_visible (child, priv->expanded);
- gtk_widget_queue_resize (GTK_WIDGET (expander));
+ gtk_widget_queue_resize (widget);
}
return !finish;
@@ -1901,7 +1928,7 @@ gtk_expander_set_label_widget (GtkExpander *expander,
g_return_if_fail (GTK_IS_EXPANDER (expander));
g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
- g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
+ g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
priv = expander->priv;
diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c
index 18c9ac0..8e03fa2 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4074,6 +4074,7 @@ popup_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (user_data);
GdkScreen *screen = gtk_widget_get_screen (widget);
GtkRequisition req;
@@ -4082,12 +4083,13 @@ popup_position_func (GtkMenu *menu,
g_return_if_fail (gtk_widget_get_realized (widget));
- gdk_window_get_origin (widget->window, x, y);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
gtk_widget_size_request (GTK_WIDGET (menu), &req);
- *x += (widget->allocation.width - req.width) / 2;
- *y += (widget->allocation.height - req.height) / 2;
+ gtk_widget_get_allocation (widget, &allocation);
+ *x += (allocation.width - req.width) / 2;
+ *y += (allocation.height - req.height) / 2;
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num);
@@ -5964,22 +5966,24 @@ static void
set_busy_cursor (GtkFileChooserDefault *impl,
gboolean busy)
{
+ GtkWidget *widget;
GtkWindow *toplevel;
GdkDisplay *display;
GdkCursor *cursor;
toplevel = get_toplevel (GTK_WIDGET (impl));
- if (!toplevel || !gtk_widget_get_realized (GTK_WIDGET (toplevel)))
+ widget = GTK_WIDGET (toplevel);
+ if (!toplevel || !gtk_widget_get_realized (widget))
return;
- display = gtk_widget_get_display (GTK_WIDGET (toplevel));
+ display = gtk_widget_get_display (widget);
if (busy)
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
else
cursor = NULL;
- gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_display_flush (display);
if (cursor)
@@ -7762,11 +7766,14 @@ find_good_size_from_style (GtkWidget *widget,
gint *height)
{
GtkFileChooserDefault *impl;
+ GtkStyle *style;
int font_size;
GdkScreen *screen;
double resolution;
- g_assert (widget->style != NULL);
+ style = gtk_widget_get_style (widget);
+
+ g_assert (style != NULL);
impl = GTK_FILE_CHOOSER_DEFAULT (widget);
screen = gtk_widget_get_screen (widget);
@@ -7779,7 +7786,7 @@ find_good_size_from_style (GtkWidget *widget,
else
resolution = 96.0; /* wheeee */
- font_size = pango_font_description_get_size (widget->style->font_desc);
+ font_size = pango_font_description_get_size (style->font_desc);
font_size = PANGO_PIXELS (font_size) * resolution / 72.0;
*width = font_size * NUM_CHARS;
diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c
index 28cde5d..d358397 100644
--- a/gtk/gtkfilechooserentry.c
+++ b/gtk/gtkfilechooserentry.c
@@ -884,17 +884,19 @@ completion_feedback_window_expose_event_cb (GtkWidget *widget,
/* Stolen from gtk_tooltip_paint_window() */
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (data);
+ GtkAllocation allocation;
- gtk_paint_flat_box (chooser_entry->completion_feedback_window->style,
- chooser_entry->completion_feedback_window->window,
+ gtk_widget_get_allocation (chooser_entry->completion_feedback_window, &allocation);
+
+ gtk_paint_flat_box (gtk_widget_get_style (chooser_entry->completion_feedback_window),
+ gtk_widget_get_window (chooser_entry->completion_feedback_window),
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
NULL,
chooser_entry->completion_feedback_window,
"tooltip",
0, 0,
- chooser_entry->completion_feedback_window->allocation.width,
- chooser_entry->completion_feedback_window->allocation.height);
+ allocation.width, allocation.height);
return FALSE;
}
@@ -921,7 +923,7 @@ completion_feedback_window_realize_cb (GtkWidget *widget,
* GtkEntry hides the cursor when the user types. We don't want the cursor to
* come back if the completion feedback ends up where the mouse is.
*/
- set_invisible_mouse_cursor (widget->window);
+ set_invisible_mouse_cursor (gtk_widget_get_window (widget));
}
static void
@@ -929,6 +931,7 @@ create_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
{
/* Stolen from gtk_tooltip_init() */
+ GtkStyle *style;
GtkWidget *alignment;
chooser_entry->completion_feedback_window = gtk_window_new (GTK_WINDOW_POPUP);
@@ -939,11 +942,10 @@ create_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
gtk_widget_set_name (chooser_entry->completion_feedback_window, "gtk-tooltip");
alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ style = gtk_widget_get_style (chooser_entry->completion_feedback_window);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
- chooser_entry->completion_feedback_window->style->ythickness,
- chooser_entry->completion_feedback_window->style->ythickness,
- chooser_entry->completion_feedback_window->style->xthickness,
- chooser_entry->completion_feedback_window->style->xthickness);
+ style->ythickness, style->ythickness,
+ style->xthickness, style->xthickness);
gtk_container_add (GTK_CONTAINER (chooser_entry->completion_feedback_window), alignment);
gtk_widget_show (alignment);
@@ -1013,21 +1015,22 @@ show_completion_feedback_window (GtkFileChooserEntry *chooser_entry)
/* More or less stolen from gtk_tooltip_position() */
GtkRequisition feedback_req;
+ GtkWidget *widget = GTK_WIDGET (chooser_entry);
gint entry_x, entry_y;
gint cursor_x;
- GtkAllocation *entry_allocation;
+ GtkAllocation entry_allocation;
int feedback_x, feedback_y;
gtk_widget_size_request (chooser_entry->completion_feedback_window, &feedback_req);
- gdk_window_get_origin (GTK_WIDGET (chooser_entry)->window, &entry_x, &entry_y);
- entry_allocation = &(GTK_WIDGET (chooser_entry)->allocation);
+ gdk_window_get_origin (gtk_widget_get_window (widget), &entry_x, &entry_y);
+ gtk_widget_get_allocation (widget, &entry_allocation);
get_entry_cursor_x (chooser_entry, &cursor_x);
/* FIXME: fit to the screen if we bump on the screen's edge */
- feedback_x = entry_x + cursor_x + entry_allocation->height / 2; /* cheap "half M-width" */
- feedback_y = entry_y + (entry_allocation->height - feedback_req.height) / 2;
+ feedback_x = entry_x + cursor_x + entry_allocation.height / 2; /* cheap "half M-width" */
+ feedback_y = entry_y + (entry_allocation.height - feedback_req.height) / 2;
gtk_window_move (GTK_WINDOW (chooser_entry->completion_feedback_window), feedback_x, feedback_y);
gtk_widget_show (chooser_entry->completion_feedback_window);
diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c
index 22b7777..1c26c74 100644
--- a/gtk/gtkfixed.c
+++ b/gtk/gtkfixed.c
@@ -196,8 +196,8 @@ gtk_fixed_move_internal (GtkFixed *fixed,
g_return_if_fail (GTK_IS_FIXED (fixed));
g_return_if_fail (GTK_IS_WIDGET (widget));
- g_return_if_fail (widget->parent == GTK_WIDGET (fixed));
-
+ g_return_if_fail (gtk_widget_get_parent (widget) == GTK_WIDGET (fixed));
+
child = get_child (fixed, widget);
g_assert (child);
@@ -287,6 +287,8 @@ gtk_fixed_get_child_property (GtkContainer *container,
static void
gtk_fixed_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -296,11 +298,13 @@ gtk_fixed_realize (GtkWidget *widget)
{
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -308,13 +312,14 @@ gtk_fixed_realize (GtkWidget *widget)
attributes.event_mask |= GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes,
- attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL);
}
}
@@ -371,12 +376,12 @@ gtk_fixed_size_allocate (GtkWidget *widget,
GList *children;
guint border_width;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_has_window (widget))
{
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x,
allocation->y,
allocation->width,
@@ -399,8 +404,8 @@ gtk_fixed_size_allocate (GtkWidget *widget,
if (!gtk_widget_get_has_window (widget))
{
- child_allocation.x += widget->allocation.x;
- child_allocation.y += widget->allocation.y;
+ child_allocation.x += allocation->x;
+ child_allocation.y += allocation->y;
}
child_allocation.width = child_requisition.width;
diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c
index 9f9bed4..a9fdef8 100644
--- a/gtk/gtkfontsel.c
+++ b/gtk/gtkfontsel.c
@@ -1163,6 +1163,7 @@ static void
gtk_font_selection_update_preview (GtkFontSelection *fontsel)
{
GtkFontSelectionPriv *priv = fontsel->priv;
+ GtkRequisition requisition;
GtkRcStyle *rc_style;
gint new_height;
GtkRequisition old_requisition;
@@ -1180,7 +1181,8 @@ gtk_font_selection_update_preview (GtkFontSelection *fontsel)
gtk_widget_size_request (preview_entry, NULL);
/* We don't ever want to be over MAX_PREVIEW_HEIGHT pixels high. */
- new_height = CLAMP (preview_entry->requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
+ gtk_widget_get_requisition (preview_entry, &requisition);
+ new_height = CLAMP (requisition.height, INITIAL_PREVIEW_HEIGHT, MAX_PREVIEW_HEIGHT);
if (new_height > old_requisition.height || new_height < old_requisition.height - 30)
gtk_widget_set_size_request (preview_entry, -1, new_height);
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 32b191b..79ad621 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -418,7 +418,7 @@ gtk_frame_set_label_widget (GtkFrame *frame,
g_return_if_fail (GTK_IS_FRAME (frame));
g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
- g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
+ g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
priv = frame->priv;
@@ -593,6 +593,9 @@ gtk_frame_paint (GtkWidget *widget,
{
GtkFrame *frame;
GtkFramePriv *priv;
+ GtkStateType state;
+ GtkStyle *style;
+ GdkWindow *window;
gint x, y, width, height;
if (gtk_widget_is_drawable (widget))
@@ -600,10 +603,14 @@ gtk_frame_paint (GtkWidget *widget,
frame = GTK_FRAME (widget);
priv = frame->priv;
- x = priv->child_allocation.x - widget->style->xthickness;
- y = priv->child_allocation.y - widget->style->ythickness;
- width = priv->child_allocation.width + 2 * widget->style->xthickness;
- height = priv->child_allocation.height + 2 * widget->style->ythickness;
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+ state = gtk_widget_get_state (widget);
+
+ x = priv->child_allocation.x - style->xthickness;
+ y = priv->child_allocation.y - style->ythickness;
+ width = priv->child_allocation.width + 2 * style->xthickness;
+ height = priv->child_allocation.height + 2 * style->ythickness;
if (priv->label_widget)
{
@@ -616,30 +623,29 @@ gtk_frame_paint (GtkWidget *widget,
else
xalign = 1 - priv->label_xalign;
- height_extra = MAX (0, priv->label_allocation.height - widget->style->ythickness)
- - priv->label_yalign * priv->label_allocation.height;
+ height_extra = MAX (0, priv->label_allocation.height - style->ythickness)
+ - priv->label_yalign * priv->label_allocation.height;
y -= height_extra;
height += height_extra;
-
- x2 = widget->style->xthickness + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
-
+
+ x2 = style->xthickness + (priv->child_allocation.width - priv->label_allocation.width - 2 * LABEL_PAD - 2 * LABEL_SIDE_PAD) * xalign + LABEL_SIDE_PAD;
/* If the label is completely over or under the frame we can omit the gap */
if (priv->label_yalign == 0.0 || priv->label_yalign == 1.0)
- gtk_paint_shadow (widget->style, widget->window,
- widget->state, priv->shadow_type,
+ gtk_paint_shadow (style, window,
+ state, priv->shadow_type,
area, widget, "frame",
x, y, width, height);
else
- gtk_paint_shadow_gap (widget->style, widget->window,
- widget->state, priv->shadow_type,
+ gtk_paint_shadow_gap (style, window,
+ state, priv->shadow_type,
area, widget, "frame",
x, y, width, height,
GTK_POS_TOP,
x2, priv->label_allocation.width + 2 * LABEL_PAD);
}
else
- gtk_paint_shadow (widget->style, widget->window,
- widget->state, priv->shadow_type,
+ gtk_paint_shadow (style, window,
+ state, priv->shadow_type,
area, widget, "frame",
x, y, width, height);
}
@@ -669,23 +675,18 @@ gtk_frame_size_allocate (GtkWidget *widget,
GtkAllocation new_allocation;
GtkWidget *child;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
gtk_frame_compute_child_allocation (frame, &new_allocation);
/* If the child allocation changed, that means that the frame is drawn
* in a new place, so we must redraw the entire widget.
*/
- if (gtk_widget_get_mapped (widget)
-#if 0
- &&
- (new_allocation.x != priv->child_allocation.x ||
- new_allocation.y != priv->child_allocation.y ||
- new_allocation.width != priv->child_allocation.width ||
- new_allocation.height != priv->child_allocation.height)
-#endif
- )
- gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
+ if (gtk_widget_get_mapped (widget))
+ {
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
+ gtk_widget_set_allocation (widget, allocation);
+ }
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
@@ -695,9 +696,12 @@ gtk_frame_size_allocate (GtkWidget *widget,
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
{
+ GtkStyle *style;
gint nat_width, width, height;
gfloat xalign;
+ style = gtk_widget_get_style (widget);
+
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
xalign = priv->label_xalign;
else
@@ -716,8 +720,7 @@ gtk_frame_size_allocate (GtkWidget *widget,
priv->label_allocation.width = width;
-
- priv->label_allocation.y = priv->child_allocation.y - MAX (height, widget->style->ythickness);
+ priv->label_allocation.y = priv->child_allocation.y - MAX (height, style->ythickness);
priv->label_allocation.height = height;
gtk_widget_size_allocate (priv->label_widget, &priv->label_allocation);
@@ -740,10 +743,15 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame,
{
GtkFramePriv *priv = frame->priv;
GtkWidget *widget = GTK_WIDGET (frame);
- GtkAllocation *allocation = &widget->allocation;
+ GtkAllocation allocation;
+ GtkStyle *style;
gint top_margin;
guint border_width;
+ style = gtk_widget_get_style (widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (frame));
if (priv->label_widget)
@@ -752,30 +760,28 @@ gtk_frame_real_compute_child_allocation (GtkFrame *frame,
gtk_size_request_get_width (GTK_SIZE_REQUEST (priv->label_widget), NULL, &nat_width);
- width = widget->allocation.width;
+ width = allocation.width;
width -= 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
- width -= (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
+ width -= (border_width + style->xthickness) * 2;
width = MIN (width, nat_width);
gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (priv->label_widget), width,
&height, NULL);
- top_margin = MAX (height, widget->style->ythickness);
+ top_margin = MAX (height, style->ythickness);
}
else
- top_margin = widget->style->ythickness;
-
- child_allocation->x = border_width + widget->style->xthickness;
- child_allocation->width = MAX(1, (gint)allocation->width - child_allocation->x * 2);
-
+ top_margin = style->ythickness;
+
+ child_allocation->x = border_width + style->xthickness;
child_allocation->y = border_width + top_margin;
- child_allocation->height = MAX (1, ((gint)allocation->height - child_allocation->y -
- border_width -
- (gint)widget->style->ythickness));
-
- child_allocation->x += allocation->x;
- child_allocation->y += allocation->y;
+ child_allocation->width = MAX (1, (gint) allocation.width - child_allocation->x * 2);
+ child_allocation->height = MAX (1, ((gint) allocation.height - child_allocation->y -
+ border_width - (gint) style->ythickness));
+
+ child_allocation->x += allocation.x;
+ child_allocation->y += allocation.y;
}
static void
@@ -784,15 +790,18 @@ gtk_frame_get_size (GtkSizeRequest *request,
gint *minimum_size,
gint *natural_size)
{
+ GtkFrame *frame = GTK_FRAME (request);
+ GtkFramePriv *priv = frame->priv;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (request);
GtkWidget *child;
- GtkFrame *frame = GTK_FRAME (widget);
- GtkFramePriv *priv = frame->priv;
GtkBin *bin = GTK_BIN (widget);
gint child_min, child_nat;
gint minimum, natural;
guint border_width;
+ style = gtk_widget_get_style (widget);
+
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
@@ -806,8 +815,8 @@ gtk_frame_get_size (GtkSizeRequest *request,
{
gtk_size_request_get_height (GTK_SIZE_REQUEST (priv->label_widget),
&child_min, &child_nat);
- minimum = MAX (0, child_min - widget->style->ythickness);
- natural = MAX (0, child_nat - widget->style->ythickness);
+ minimum = MAX (0, child_min - style->ythickness);
+ natural = MAX (0, child_nat - style->ythickness);
}
}
else
@@ -839,13 +848,13 @@ gtk_frame_get_size (GtkSizeRequest *request,
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- minimum += (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
- natural += (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
+ minimum += (border_width + style->xthickness) * 2;
+ natural += (border_width + style->xthickness) * 2;
}
else
{
- minimum += (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
- natural += (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
+ minimum += (border_width + style->ythickness) * 2;
+ natural += (border_width + style->ythickness) * 2;
}
if (minimum_size)
@@ -883,15 +892,18 @@ gtk_frame_get_height_for_width (GtkSizeRequest *request,
GtkFrame *frame = GTK_FRAME (widget);
GtkFramePriv *priv = frame->priv;
GtkBin *bin = GTK_BIN (widget);
+ GtkStyle *style;
gint child_min, child_nat, label_width;
gint minimum, natural;
guint border_width;
+ style = gtk_widget_get_style (widget);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- minimum = (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
- natural = (border_width + GTK_WIDGET (widget)->style->ythickness) * 2;
+ minimum = (border_width + style->ythickness) * 2;
+ natural = (border_width + style->ythickness) * 2;
- width -= (border_width + GTK_WIDGET (widget)->style->xthickness) * 2;
+ width -= (border_width + style->xthickness) * 2;
label_width = width - 2 * LABEL_PAD + 2 * LABEL_SIDE_PAD;
if (priv->label_widget && gtk_widget_get_visible (priv->label_widget))
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index ead564c..89303d9 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -390,7 +390,7 @@ gtk_handle_box_map (GtkWidget *widget)
}
gdk_window_show (priv->bin_window);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
}
static void
@@ -401,7 +401,7 @@ gtk_handle_box_unmap (GtkWidget *widget)
gtk_widget_set_mapped (widget, FALSE);
- gdk_window_hide (widget->window);
+ gdk_window_hide (gtk_widget_get_window (widget));
if (priv->float_window_mapped)
{
gdk_window_hide (priv->float_window);
@@ -414,16 +414,23 @@ gtk_handle_box_realize (GtkWidget *widget)
{
GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
GtkHandleBoxPriv *priv = hb->priv;
+ GtkAllocation allocation;
+ GtkRequisition requisition;
+ GtkStateType state;
+ GtkStyle *style;
GtkWidget *child;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -431,13 +438,16 @@ gtk_handle_box_realize (GtkWidget *widget)
attributes.event_mask = (gtk_widget_get_events (widget)
| GDK_EXPOSURE_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
attributes.x = 0;
attributes.y = 0;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = (gtk_widget_get_events (widget) |
GDK_EXPOSURE_MASK |
@@ -446,17 +456,21 @@ gtk_handle_box_realize (GtkWidget *widget)
GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- priv->bin_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+
+ priv->bin_window = gdk_window_new (window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (priv->bin_window, widget);
child = gtk_bin_get_child (GTK_BIN (hb));
if (child)
gtk_widget_set_parent_window (child, priv->bin_window);
-
+
+ gtk_widget_get_requisition (widget, &requisition);
+
attributes.x = 0;
attributes.y = 0;
- attributes.width = widget->requisition.width;
- attributes.height = widget->requisition.height;
+ attributes.width = requisition.width;
+ attributes.height = requisition.height;
attributes.window_type = GDK_WINDOW_TOPLEVEL;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -474,12 +488,14 @@ gtk_handle_box_realize (GtkWidget *widget)
gdk_window_set_user_data (priv->float_window, widget);
gdk_window_set_decorations (priv->float_window, 0);
gdk_window_set_type_hint (priv->float_window, GDK_WINDOW_TYPE_HINT_TOOLBAR);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, gtk_widget_get_state (widget));
- gtk_style_set_background (widget->style, priv->bin_window, gtk_widget_get_state (widget));
- gtk_style_set_background (widget->style, priv->float_window, gtk_widget_get_state (widget));
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+ gtk_style_set_background (style, window, state);
+ gtk_style_set_background (style, priv->bin_window, state);
+ gtk_style_set_background (style, priv->float_window, state);
+ gdk_window_set_back_pixmap (window, NULL, TRUE);
}
static void
@@ -508,10 +524,15 @@ gtk_handle_box_style_set (GtkWidget *widget,
if (gtk_widget_get_realized (widget) &&
gtk_widget_get_has_window (widget))
{
- gtk_style_set_background (widget->style, widget->window,
- widget->state);
- gtk_style_set_background (widget->style, priv->bin_window, widget->state);
- gtk_style_set_background (widget->style, priv->float_window, widget->state);
+ GtkStateType state;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ gtk_style_set_background (style, gtk_widget_get_window (widget), state);
+ gtk_style_set_background (style, priv->bin_window, state);
+ gtk_style_set_background (style, priv->float_window, state);
}
}
@@ -594,9 +615,9 @@ gtk_handle_box_size_request (GtkWidget *widget,
{
if (handle_position == GTK_POS_LEFT ||
handle_position == GTK_POS_RIGHT)
- requisition->height += widget->style->ythickness;
+ requisition->height += gtk_widget_get_style (widget)->ythickness;
else
- requisition->width += widget->style->xthickness;
+ requisition->width += gtk_widget_get_style (widget)->xthickness;
}
}
else
@@ -641,17 +662,14 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
{
child_requisition.width = 0;
child_requisition.height = 0;
- }
-
- widget->allocation = *allocation;
+ }
- if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ gtk_widget_set_allocation (widget, allocation);
+ if (gtk_widget_get_realized (widget))
+ gdk_window_move_resize (gtk_widget_get_window (widget),
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
if (child != NULL && gtk_widget_get_visible (child))
{
@@ -698,8 +716,8 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
}
else
{
- child_allocation.width = MAX (1, (gint)widget->allocation.width - 2 * border_width);
- child_allocation.height = MAX (1, (gint)widget->allocation.height - 2 * border_width);
+ child_allocation.width = MAX (1, (gint) allocation->width - 2 * border_width);
+ child_allocation.height = MAX (1, (gint) allocation->height - 2 * border_width);
if (handle_position == GTK_POS_LEFT ||
handle_position == GTK_POS_RIGHT)
@@ -711,8 +729,8 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
gdk_window_move_resize (priv->bin_window,
0,
0,
- widget->allocation.width,
- widget->allocation.height);
+ allocation->width,
+ allocation->height);
}
gtk_widget_size_allocate (child, &child_allocation);
@@ -722,35 +740,42 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
static void
gtk_handle_box_draw_ghost (GtkHandleBox *hb)
{
- GtkWidget *widget;
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (hb);
+ GtkStateType state;
+ GtkStyle *style;
+ GdkWindow *window;
guint x;
guint y;
guint width;
guint height;
gint handle_position;
- widget = GTK_WIDGET (hb);
-
+ gtk_widget_get_allocation (widget, &allocation);
+
handle_position = effective_handle_position (hb);
if (handle_position == GTK_POS_LEFT ||
handle_position == GTK_POS_RIGHT)
{
- x = handle_position == GTK_POS_LEFT ? 0 : widget->allocation.width - DRAG_HANDLE_SIZE;
+ x = handle_position == GTK_POS_LEFT ? 0 : allocation.width - DRAG_HANDLE_SIZE;
y = 0;
width = DRAG_HANDLE_SIZE;
- height = widget->allocation.height;
+ height = allocation.height;
}
else
{
x = 0;
- y = handle_position == GTK_POS_TOP ? 0 : widget->allocation.height - DRAG_HANDLE_SIZE;
- width = widget->allocation.width;
+ y = handle_position == GTK_POS_TOP ? 0 : allocation.height - DRAG_HANDLE_SIZE;
+ width = allocation.width;
height = DRAG_HANDLE_SIZE;
}
- gtk_paint_shadow (widget->style,
- widget->window,
- gtk_widget_get_state (widget),
- GTK_SHADOW_ETCHED_IN,
+
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+ state = gtk_widget_get_state (widget);
+
+ gtk_paint_shadow (style, window,
+ state, GTK_SHADOW_ETCHED_IN,
NULL, widget, "handle",
x,
y,
@@ -758,28 +783,27 @@ gtk_handle_box_draw_ghost (GtkHandleBox *hb)
height);
if (handle_position == GTK_POS_LEFT ||
handle_position == GTK_POS_RIGHT)
- gtk_paint_hline (widget->style,
- widget->window,
- gtk_widget_get_state (widget),
+ gtk_paint_hline (style, window,
+ state,
NULL, widget, "handlebox",
handle_position == GTK_POS_LEFT ? DRAG_HANDLE_SIZE : 0,
- handle_position == GTK_POS_LEFT ? widget->allocation.width : widget->allocation.width - DRAG_HANDLE_SIZE,
- widget->allocation.height / 2);
+ handle_position == GTK_POS_LEFT ? allocation.width : allocation.width - DRAG_HANDLE_SIZE,
+ allocation.height / 2);
else
- gtk_paint_vline (widget->style,
- widget->window,
- gtk_widget_get_state (widget),
+ gtk_paint_vline (style, window,
+ state,
NULL, widget, "handlebox",
handle_position == GTK_POS_TOP ? DRAG_HANDLE_SIZE : 0,
- handle_position == GTK_POS_TOP ? widget->allocation.height : widget->allocation.height - DRAG_HANDLE_SIZE,
- widget->allocation.width / 2);
+ handle_position == GTK_POS_TOP ? allocation.height : allocation.height - DRAG_HANDLE_SIZE,
+ allocation.width / 2);
}
static void
draw_textured_frame (GtkWidget *widget, GdkWindow *window, GdkRectangle *rect, GtkShadowType shadow,
GdkRectangle *clip, GtkOrientation orientation)
{
- gtk_paint_handle (widget->style, window, GTK_STATE_NORMAL, shadow,
+ gtk_paint_handle (gtk_widget_get_style (widget), window,
+ GTK_STATE_NORMAL, shadow,
clip, widget, "handlebox",
rect->x, rect->y, rect->width, rect->height,
orientation);
@@ -932,14 +956,14 @@ gtk_handle_box_paint (GtkWidget *widget,
gdk_drawable_get_size (priv->bin_window, &width, &height);
if (!event)
- gtk_paint_box (widget->style,
+ gtk_paint_box (gtk_widget_get_style (widget),
priv->bin_window,
gtk_widget_get_state (widget),
priv->shadow_type,
area, widget, "handlebox_bin",
0, 0, -1, -1);
else
- gtk_paint_box (widget->style,
+ gtk_paint_box (gtk_widget_get_style (widget),
priv->bin_window,
gtk_widget_get_state (widget),
priv->shadow_type,
@@ -1012,7 +1036,7 @@ gtk_handle_box_expose (GtkWidget *widget,
hb = GTK_HANDLE_BOX (widget);
priv = hb->priv;
- if (event->window == widget->window)
+ if (event->window == gtk_widget_get_window (widget))
{
if (priv->child_detached)
gtk_handle_box_draw_ghost (hb);
@@ -1092,8 +1116,10 @@ gtk_handle_box_button_press (GtkWidget *widget,
if (child)
{
+ GtkAllocation child_allocation;
guint border_width;
+ gtk_widget_get_allocation (child, &child_allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (hb));
switch (handle_position)
@@ -1105,10 +1131,10 @@ gtk_handle_box_button_press (GtkWidget *widget,
in_handle = event->y < DRAG_HANDLE_SIZE;
break;
case GTK_POS_RIGHT:
- in_handle = event->x > 2 * border_width + child->allocation.width;
+ in_handle = event->x > 2 * border_width + child_allocation.width;
break;
case GTK_POS_BOTTOM:
- in_handle = event->y > 2 * border_width + child->allocation.height;
+ in_handle = event->y > 2 * border_width + child_allocation.height;
break;
default:
in_handle = FALSE;
@@ -1126,6 +1152,7 @@ gtk_handle_box_button_press (GtkWidget *widget,
if (event->type == GDK_BUTTON_PRESS) /* Start a drag */
{
GtkWidget *invisible = gtk_handle_box_get_invisible ();
+ GdkWindow *window;
gint desk_x, desk_y;
gint root_x, root_y;
gint width, height;
@@ -1147,10 +1174,11 @@ gtk_handle_box_button_press (GtkWidget *widget,
priv->deskoff_x = desk_x - root_x;
priv->deskoff_y = desk_y - root_y;
- if (gdk_window_is_viewable (widget->window))
+ window = gtk_widget_get_window (widget);
+ if (gdk_window_is_viewable (window))
{
- gdk_window_get_origin (widget->window, &root_x, &root_y);
- gdk_drawable_get_size (widget->window, &width, &height);
+ gdk_window_get_origin (window, &root_x, &root_y);
+ gdk_drawable_get_size (window, &width, &height);
priv->attach_allocation.x = root_x;
priv->attach_allocation.y = root_y;
@@ -1169,7 +1197,7 @@ gtk_handle_box_button_press (GtkWidget *widget,
fleur = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
GDK_FLEUR);
if (gdk_device_grab (event->device,
- invisible->window,
+ gtk_widget_get_window (invisible),
GDK_OWNERSHIP_WINDOW,
FALSE,
(GDK_BUTTON1_MOTION_MASK |
@@ -1319,7 +1347,7 @@ gtk_handle_box_motion (GtkWidget *widget,
{
priv->child_detached = FALSE;
gdk_window_hide (priv->float_window);
- gdk_window_reparent (priv->bin_window, widget->window, 0, 0);
+ gdk_window_reparent (priv->bin_window, gtk_widget_get_window (widget), 0, 0);
priv->float_window_mapped = FALSE;
g_signal_emit (hb,
handle_box_signals[SIGNAL_CHILD_ATTACHED],
@@ -1461,7 +1489,8 @@ gtk_handle_box_reattach (GtkHandleBox *hb)
if (gtk_widget_get_realized (widget))
{
gdk_window_hide (priv->float_window);
- gdk_window_reparent (priv->bin_window, widget->window, 0, 0);
+ gdk_window_reparent (priv->bin_window, gtk_widget_get_window (widget),
+ 0, 0);
child = gtk_bin_get_child (GTK_BIN (hb));
if (child)
diff --git a/gtk/gtkhsv.c b/gtk/gtkhsv.c
index c8758b2..5d1fdcc 100644
--- a/gtk/gtkhsv.c
+++ b/gtk/gtkhsv.c
@@ -261,6 +261,7 @@ gtk_hsv_realize (GtkWidget *widget)
{
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
+ GtkAllocation allocation;
GdkWindow *parent_window;
GdkWindowAttr attr;
int attr_mask;
@@ -268,12 +269,14 @@ gtk_hsv_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
/* Create window */
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+
attr.window_type = GDK_WINDOW_CHILD;
- attr.x = widget->allocation.x;
- attr.y = widget->allocation.y;
- attr.width = widget->allocation.width;
- attr.height = widget->allocation.height;
+ attr.x = allocation.x;
+ attr.y = allocation.y;
+ attr.width = allocation.width;
+ attr.height = allocation.height;
attr.wclass = GDK_INPUT_ONLY;
attr.event_mask = gtk_widget_get_events (widget);
attr.event_mask |= (GDK_KEY_PRESS_MASK
@@ -282,18 +285,16 @@ gtk_hsv_realize (GtkWidget *widget)
| GDK_POINTER_MOTION_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_LEAVE_NOTIFY_MASK);
-
attr_mask = GDK_WA_X | GDK_WA_Y;
-
+
parent_window = gtk_widget_get_parent_window (widget);
-
- widget->window = parent_window;
- g_object_ref (widget->window);
-
+ gtk_widget_set_window (widget, parent_window);
+ g_object_ref (parent_window);
+
priv->window = gdk_window_new (parent_window, &attr, attr_mask);
gdk_window_set_user_data (priv->window, hsv);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
+
+ gtk_widget_style_attach (widget);
}
/* Unrealize handler for the HSV color selector */
@@ -337,8 +338,8 @@ gtk_hsv_size_allocate (GtkWidget *widget,
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
- widget->allocation = *allocation;
-
+ gtk_widget_set_allocation (widget, allocation);
+
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (priv->window,
allocation->x,
@@ -511,13 +512,17 @@ compute_triangle (GtkHSV *hsv,
gint *vy)
{
GtkHSVPriv *priv = hsv->priv;
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (hsv);
gdouble center_x;
gdouble center_y;
gdouble inner, outer;
gdouble angle;
- center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
- center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
outer = priv->size / 2.0;
inner = outer - priv->ring_width;
angle = priv->h * 2.0 * G_PI;
@@ -537,13 +542,17 @@ is_in_ring (GtkHSV *hsv,
gdouble y)
{
GtkHSVPriv *priv = hsv->priv;
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (hsv);
gdouble dx, dy, dist;
gdouble center_x;
gdouble center_y;
gdouble inner, outer;
- center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
- center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
outer = priv->size / 2.0;
inner = outer - priv->ring_width;
@@ -562,14 +571,18 @@ compute_sv (GtkHSV *hsv,
gdouble *s,
gdouble *v)
{
+ GtkWidget *widget = GTK_WIDGET (hsv);
+ GtkAllocation allocation;
int ihx, ihy, isx, isy, ivx, ivy;
double hx, hy, sx, sy, vx, vy;
double center_x;
double center_y;
+ gtk_widget_get_allocation (widget, &allocation);
+
compute_triangle (hsv, &ihx, &ihy, &isx, &isy, &ivx, &ivy);
- center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
- center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
hx = ihx - center_x;
hy = center_y - ihy;
sx = isx - center_x;
@@ -665,13 +678,17 @@ compute_v (GtkHSV *hsv,
gdouble x,
gdouble y)
{
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (hsv);
double center_x;
double center_y;
double dx, dy;
double angle;
- center_x = GTK_WIDGET (hsv)->allocation.width / 2.0;
- center_y = GTK_WIDGET (hsv)->allocation.height / 2.0;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
dx = x - center_x;
dy = center_y - y;
@@ -852,6 +869,7 @@ paint_ring (GtkHSV *hsv,
gint height)
{
GtkHSVPriv *priv = hsv->priv;
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (hsv);
int xx, yy;
gdouble dx, dy, dist;
@@ -872,11 +890,11 @@ paint_ring (GtkHSV *hsv,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
-
- priv = hsv->priv;
- center_x = widget->allocation.width / 2.0;
- center_y = widget->allocation.height / 2.0;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ center_x = allocation.width / 2.0;
+ center_y = allocation.height / 2.0;
outer = priv->size / 2.0;
inner = outer - priv->ring_width;
@@ -1182,6 +1200,7 @@ paint_triangle (GtkHSV *hsv,
if (gtk_widget_has_focus (widget) &&
!priv->focus_on_ring)
{
+ GtkAllocation allocation;
gint focus_width;
gint focus_pad;
@@ -1189,16 +1208,18 @@ paint_triangle (GtkHSV *hsv,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
-
- gtk_paint_focus (widget->style, widget->window,
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_paint_focus (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
NULL, widget, detail,
- widget->allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad,
- widget->allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad,
+ allocation.x + xx - FOCUS_RADIUS - focus_width - focus_pad,
+ allocation.y + yy - FOCUS_RADIUS - focus_width - focus_pad,
2 * (FOCUS_RADIUS + focus_width + focus_pad),
2 * (FOCUS_RADIUS + focus_width + focus_pad));
}
-
}
/* Paints the contents of the HSV color selector */
@@ -1221,37 +1242,42 @@ gtk_hsv_expose (GtkWidget *widget,
{
GtkHSV *hsv = GTK_HSV (widget);
GtkHSVPriv *priv = hsv->priv;
+ GtkAllocation allocation;
GdkRectangle rect, dest;
+ GdkWindow *window;
cairo_t *cr;
- if (!(event->window == widget->window && gtk_widget_is_drawable (widget)))
+ window = gtk_widget_get_window (widget);
+
+ if (!(event->window == window && gtk_widget_is_drawable (widget)))
return FALSE;
- rect.x = widget->allocation.x;
- rect.y = widget->allocation.y;
- rect.width = widget->allocation.width;
- rect.height = widget->allocation.height;
-
+ gtk_widget_get_allocation (widget, &allocation);
+
+ rect.x = allocation.x;
+ rect.y = allocation.y;
+ rect.width = allocation.width;
+ rect.height = allocation.height;
+
if (!gdk_rectangle_intersect (&event->area, &rect, &dest))
return FALSE;
-
- cr = gdk_cairo_create (widget->window);
- cairo_translate (cr, widget->allocation.x, widget->allocation.y);
+ cr = gdk_cairo_create (window);
+
+ cairo_translate (cr, allocation.x, allocation.y);
paint (hsv, cr,
- dest.x - widget->allocation.x,
- dest.y - widget->allocation.y,
+ dest.x - allocation.x,
+ dest.y - allocation.y,
dest.width, dest.height);
cairo_destroy (cr);
if (gtk_widget_has_focus (widget) && priv->focus_on_ring)
- gtk_paint_focus (widget->style, widget->window,
+ gtk_paint_focus (gtk_widget_get_style (widget),
+ window,
gtk_widget_get_state (widget),
&event->area, widget, NULL,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ allocation.x, allocation.y,
+ allocation.width, allocation.height);
return FALSE;
}
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index a29d333..daa0b46 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1324,20 +1324,22 @@ gtk_icon_view_get_property (GObject *object,
static void
gtk_icon_view_realize (GtkWidget *widget)
{
- GtkIconView *icon_view;
+ GtkIconView *icon_view = GTK_ICON_VIEW (widget);
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
-
- icon_view = GTK_ICON_VIEW (widget);
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
/* Make the main, clipping window */
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -1345,16 +1347,19 @@ gtk_icon_view_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_back_pixmap (window, NULL, FALSE);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
/* Make the window for the icon view */
attributes.x = 0;
attributes.y = 0;
- attributes.width = MAX (icon_view->priv->width, widget->allocation.width);
- attributes.height = MAX (icon_view->priv->height, widget->allocation.height);
+ attributes.width = MAX (icon_view->priv->width, allocation.width);
+ attributes.height = MAX (icon_view->priv->height, allocation.height);
attributes.event_mask = (GDK_EXPOSURE_MASK |
GDK_SCROLL_MASK |
GDK_POINTER_MOTION_MASK |
@@ -1364,12 +1369,13 @@ gtk_icon_view_realize (GtkWidget *widget)
GDK_KEY_RELEASE_MASK) |
gtk_widget_get_events (widget);
- icon_view->priv->bin_window = gdk_window_new (widget->window,
+ icon_view->priv->bin_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (icon_view->priv->bin_window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
+ gtk_widget_style_attach (widget);
+ gdk_window_set_background (icon_view->priv->bin_window,
+ >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
gdk_window_show (icon_view->priv->bin_window);
}
@@ -1393,11 +1399,16 @@ gtk_icon_view_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
GtkIconView *icon_view = GTK_ICON_VIEW (widget);
+ GtkStateType state;
+ GtkStyle *style;
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
- gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ gdk_window_set_background (gtk_widget_get_window (widget), &style->base[state]);
+ gdk_window_set_background (icon_view->priv->bin_window, &style->base[state]);
}
gtk_widget_queue_draw (widget);
@@ -1408,11 +1419,16 @@ gtk_icon_view_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
GtkIconView *icon_view = GTK_ICON_VIEW (widget);
+ GtkStateType state;
+ GtkStyle *style;
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_background (widget->window, &widget->style->base[widget->state]);
- gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ gdk_window_set_background (gtk_widget_get_window (widget), &style->base[state]);
+ gdk_window_set_background (icon_view->priv->bin_window, &style->base[state]);
}
gtk_widget_queue_resize (widget);
@@ -1482,11 +1498,11 @@ gtk_icon_view_size_allocate (GtkWidget *widget,
GtkAdjustment *hadjustment, *vadjustment;
- widget->allocation = *allocation;
-
+ gtk_widget_set_allocation (widget, allocation);
+
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
gdk_window_resize (icon_view->priv->bin_window,
@@ -1599,53 +1615,49 @@ gtk_icon_view_expose (GtkWidget *widget,
if (dest_item)
{
+ GtkStateType state;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
switch (dest_pos)
{
case GTK_ICON_VIEW_DROP_INTO:
- gtk_paint_focus (widget->style,
- icon_view->priv->bin_window,
- gtk_widget_get_state (widget),
- NULL,
+ gtk_paint_focus (style, icon_view->priv->bin_window,
+ state, NULL,
widget,
"iconview-drop-indicator",
dest_item->x, dest_item->y,
dest_item->width, dest_item->height);
break;
case GTK_ICON_VIEW_DROP_ABOVE:
- gtk_paint_focus (widget->style,
- icon_view->priv->bin_window,
- gtk_widget_get_state (widget),
- NULL,
+ gtk_paint_focus (style, icon_view->priv->bin_window,
+ state, NULL,
widget,
"iconview-drop-indicator",
dest_item->x, dest_item->y - 1,
dest_item->width, 2);
break;
case GTK_ICON_VIEW_DROP_LEFT:
- gtk_paint_focus (widget->style,
- icon_view->priv->bin_window,
- gtk_widget_get_state (widget),
- NULL,
+ gtk_paint_focus (style, icon_view->priv->bin_window,
+ state, NULL,
widget,
"iconview-drop-indicator",
dest_item->x - 1, dest_item->y,
2, dest_item->height);
break;
case GTK_ICON_VIEW_DROP_BELOW:
- gtk_paint_focus (widget->style,
- icon_view->priv->bin_window,
- gtk_widget_get_state (widget),
- NULL,
+ gtk_paint_focus (style, icon_view->priv->bin_window,
+ state, NULL,
widget,
"iconview-drop-indicator",
dest_item->x, dest_item->y + dest_item->height - 1,
dest_item->width, 2);
break;
case GTK_ICON_VIEW_DROP_RIGHT:
- gtk_paint_focus (widget->style,
- icon_view->priv->bin_window,
- gtk_widget_get_state (widget),
- NULL,
+ gtk_paint_focus (style, icon_view->priv->bin_window,
+ state, NULL,
widget,
"iconview-drop-indicator",
dest_item->x + dest_item->width - 1, dest_item->y,
@@ -1694,6 +1706,7 @@ static gboolean
gtk_icon_view_motion (GtkWidget *widget,
GdkEventMotion *event)
{
+ GtkAllocation allocation;
GtkIconView *icon_view;
gint abs_y;
@@ -1710,12 +1723,14 @@ gtk_icon_view_motion (GtkWidget *widget,
(icon_view->priv->vadjustment->upper -
icon_view->priv->vadjustment->lower));
- if (abs_y < 0 || abs_y > widget->allocation.height)
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (abs_y < 0 || abs_y > allocation.height)
{
if (abs_y < 0)
icon_view->priv->scroll_value_diff = abs_y;
else
- icon_view->priv->scroll_value_diff = abs_y - widget->allocation.height;
+ icon_view->priv->scroll_value_diff = abs_y - allocation.height;
icon_view->priv->event_last_x = event->x;
icon_view->priv->event_last_y = event->y;
@@ -2685,6 +2700,8 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
gint *y,
gint *maximum_width)
{
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (icon_view);
gint focus_width;
gint x, current_width;
GList *items, *last_item;
@@ -2694,7 +2711,7 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
gint i;
gboolean rtl;
- rtl = gtk_widget_get_direction (GTK_WIDGET (icon_view)) == GTK_TEXT_DIR_RTL;
+ rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
max_height = g_new0 (gint, icon_view->priv->n_cells);
x = 0;
@@ -2702,7 +2719,7 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
items = first_item;
current_width = 0;
- gtk_widget_style_get (GTK_WIDGET (icon_view),
+ gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
NULL);
@@ -2723,7 +2740,9 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
if (items != first_item)
{
- if ((icon_view->priv->columns <= 0 && current_width > GTK_WIDGET (icon_view)->allocation.width) ||
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if ((icon_view->priv->columns <= 0 && current_width > allocation.width) ||
(icon_view->priv->columns > 0 && col >= icon_view->priv->columns))
break;
}
@@ -2800,9 +2819,11 @@ gtk_icon_view_set_adjustment_upper (GtkAdjustment *adj,
static void
gtk_icon_view_layout (GtkIconView *icon_view)
{
- gint y = 0, maximum_width = 0;
- GList *icons;
+ GtkAllocation allocation;
+ GtkRequisition requisition;
GtkWidget *widget;
+ GList *icons;
+ gint y = 0, maximum_width = 0;
gint row;
gint item_width;
@@ -2862,14 +2883,16 @@ gtk_icon_view_layout (GtkIconView *icon_view)
gtk_icon_view_set_adjustment_upper (icon_view->priv->vadjustment,
icon_view->priv->height);
- if (icon_view->priv->width != widget->requisition.width ||
- icon_view->priv->height != widget->requisition.height)
+ gtk_widget_get_requisition (widget, &requisition);
+ if (icon_view->priv->width != requisition.width ||
+ icon_view->priv->height != requisition.height)
gtk_widget_queue_resize_no_redraw (widget);
+ gtk_widget_get_allocation (widget, &allocation);
if (gtk_widget_get_realized (GTK_WIDGET (icon_view)))
gdk_window_resize (icon_view->priv->bin_window,
- MAX (icon_view->priv->width, widget->allocation.width),
- MAX (icon_view->priv->height, widget->allocation.height));
+ MAX (icon_view->priv->width, allocation.width),
+ MAX (icon_view->priv->height, allocation.height));
if (icon_view->priv->scroll_to_path)
{
@@ -3159,13 +3182,16 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
gint i;
GtkStateType state;
GtkCellRendererState flags;
-
+ GtkStyle *style;
+ GtkWidget *widget = GTK_WIDGET (icon_view);
+
if (icon_view->priv->model == NULL)
return;
gtk_icon_view_set_cell_data (icon_view, item);
- gtk_widget_style_get (GTK_WIDGET (icon_view),
+ style = gtk_widget_get_style (widget);
+ gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
NULL);
@@ -3174,7 +3200,7 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
if (item->selected)
{
flags = GTK_CELL_RENDERER_SELECTED;
- if (gtk_widget_has_focus (GTK_WIDGET (icon_view)))
+ if (gtk_widget_has_focus (widget))
state = GTK_STATE_SELECTED;
else
state = GTK_STATE_ACTIVE;
@@ -3184,15 +3210,15 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
flags = 0;
state = GTK_STATE_NORMAL;
}
-
+
if (item->selected)
{
- gtk_paint_flat_box (GTK_WIDGET (icon_view)->style,
- (GdkWindow *) drawable,
+ gtk_paint_flat_box (style,
+ GDK_WINDOW (drawable),
GTK_STATE_SELECTED,
GTK_SHADOW_NONE,
area,
- GTK_WIDGET (icon_view),
+ widget,
"icon_view_item",
x, y,
item->width, item->height);
@@ -3206,18 +3232,18 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
continue;
gtk_icon_view_get_cell_area (icon_view, item, info, &cell_area);
-
+
cell_area.x = x - item->x + cell_area.x;
cell_area.y = y - item->y + cell_area.y;
gtk_cell_renderer_render (info->cell,
drawable,
- GTK_WIDGET (icon_view),
+ widget,
&cell_area, &cell_area, area, flags);
}
if (draw_focus &&
- gtk_widget_has_focus (GTK_WIDGET (icon_view)) &&
+ gtk_widget_has_focus (widget) &&
item == icon_view->priv->cursor_item)
{
for (l = icon_view->priv->cell_list, i = 0; l; l = l->next, i++)
@@ -3238,11 +3264,11 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
if (i == icon_view->priv->cursor_cell)
{
- gtk_paint_focus (GTK_WIDGET (icon_view)->style,
+ gtk_paint_focus (style,
drawable,
GTK_STATE_NORMAL,
area,
- GTK_WIDGET (icon_view),
+ widget,
"icon_view",
x - item->x + box.x - padding,
y - item->y + box.y - padding,
@@ -3256,11 +3282,11 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
* around the whole item.
*/
if (icon_view->priv->cursor_cell < 0)
- gtk_paint_focus (GTK_WIDGET (icon_view)->style,
+ gtk_paint_focus (style,
drawable,
GTK_STATE_NORMAL,
area,
- GTK_WIDGET (icon_view),
+ widget,
"icon_view",
x - padding,
y - padding,
@@ -3293,7 +3319,7 @@ gtk_icon_view_paint_rubberband (GtkIconView *icon_view,
NULL);
if (!fill_color_gdk)
- fill_color_gdk = gdk_color_copy (>K_WIDGET (icon_view)->style->base[GTK_STATE_SELECTED]);
+ fill_color_gdk = gdk_color_copy (>k_widget_get_style (GTK_WIDGET (icon_view))->base[GTK_STATE_SELECTED]);
cairo_set_source_rgba (cr,
fill_color_gdk->red / 65535.,
@@ -4362,18 +4388,21 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
gfloat col_align)
{
GtkIconViewItem *item = NULL;
+ GtkWidget *widget;
g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
g_return_if_fail (path != NULL);
g_return_if_fail (row_align >= 0.0 && row_align <= 1.0);
g_return_if_fail (col_align >= 0.0 && col_align <= 1.0);
+ widget = GTK_WIDGET (icon_view);
+
if (gtk_tree_path_get_depth (path) > 0)
item = g_list_nth_data (icon_view->priv->items,
gtk_tree_path_get_indices(path)[0]);
if (!item || item->width < 0 ||
- !gtk_widget_get_realized (GTK_WIDGET (icon_view)))
+ !gtk_widget_get_realized (widget))
{
if (icon_view->priv->scroll_to_path)
gtk_tree_row_reference_free (icon_view->priv->scroll_to_path);
@@ -4392,24 +4421,25 @@ gtk_icon_view_scroll_to_path (GtkIconView *icon_view,
if (use_align)
{
+ GtkAllocation allocation;
gint x, y;
gint focus_width;
gfloat offset;
- gtk_widget_style_get (GTK_WIDGET (icon_view),
+ gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
NULL);
gdk_window_get_position (icon_view->priv->bin_window, &x, &y);
-
- offset = y + item->y - focus_width -
- row_align * (GTK_WIDGET (icon_view)->allocation.height - item->height);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ offset = y + item->y - focus_width - row_align * (allocation.height - item->height);
gtk_adjustment_set_value (icon_view->priv->vadjustment,
icon_view->priv->vadjustment->value + offset);
- offset = x + item->x - focus_width -
- col_align * (GTK_WIDGET (icon_view)->allocation.width - item->width);
+ offset = x + item->x - focus_width - col_align * (allocation.width - item->width);
gtk_adjustment_set_value (icon_view->priv->hadjustment,
icon_view->priv->hadjustment->value + offset);
@@ -4426,32 +4456,36 @@ static void
gtk_icon_view_scroll_to_item (GtkIconView *icon_view,
GtkIconViewItem *item)
{
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (icon_view);
gint x, y, width, height;
gint focus_width;
- gtk_widget_style_get (GTK_WIDGET (icon_view),
+ gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
NULL);
gdk_drawable_get_size (GDK_DRAWABLE (icon_view->priv->bin_window),
&width, &height);
gdk_window_get_position (icon_view->priv->bin_window, &x, &y);
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+
if (y + item->y - focus_width < 0)
gtk_adjustment_set_value (icon_view->priv->vadjustment,
icon_view->priv->vadjustment->value + y + item->y - focus_width);
- else if (y + item->y + item->height + focus_width > GTK_WIDGET (icon_view)->allocation.height)
+ else if (y + item->y + item->height + focus_width > allocation.height)
gtk_adjustment_set_value (icon_view->priv->vadjustment,
icon_view->priv->vadjustment->value + y + item->y + item->height
- + focus_width - GTK_WIDGET (icon_view)->allocation.height);
+ + focus_width - allocation.height);
if (x + item->x - focus_width < 0)
gtk_adjustment_set_value (icon_view->priv->hadjustment,
- icon_view->priv->hadjustment->value + x + item->x - focus_width);
- else if (x + item->x + item->width + focus_width > GTK_WIDGET (icon_view)->allocation.width)
+ icon_view->priv->hadjustment->value + x + item->x - focus_width);
+ else if (x + item->x + item->width + focus_width > allocation.width)
gtk_adjustment_set_value (icon_view->priv->hadjustment,
icon_view->priv->hadjustment->value + x + item->x + item->width
- + focus_width - GTK_WIDGET (icon_view)->allocation.width);
+ + focus_width - allocation.width);
gtk_adjustment_changed (icon_view->priv->hadjustment);
gtk_adjustment_changed (icon_view->priv->vadjustment);
@@ -6557,11 +6591,14 @@ remove_scroll_timeout (GtkIconView *icon_view)
static void
gtk_icon_view_autoscroll (GtkIconView *icon_view)
{
+ GdkWindow *window;
gint px, py, x, y, width, height;
gint hoffset, voffset;
- gdk_window_get_pointer (GTK_WIDGET (icon_view)->window, &px, &py, NULL);
- gdk_window_get_geometry (GTK_WIDGET (icon_view)->window, &x, &y, &width, &height, NULL);
+ window = gtk_widget_get_window (GTK_WIDGET (icon_view));
+
+ gdk_window_get_pointer (window, &px, &py, NULL);
+ gdk_window_get_geometry (window, &x, &y, &width, &height, NULL);
/* see if we are near the edge. */
voffset = py - (y + 2 * SCROLL_EDGE_SIZE);
@@ -7462,8 +7499,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
cr = gdk_cairo_create (drawable);
cairo_set_line_width (cr, 1.);
- gdk_cairo_set_source_color
- (cr, &widget->style->base[gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
cairo_rectangle (cr, 0, 0, item->width + 2, item->height + 2);
cairo_fill (cr);
@@ -8625,6 +8661,7 @@ gtk_icon_view_item_accessible_remove_state (GtkIconViewItemAccessible *item,
static gboolean
gtk_icon_view_item_accessible_is_showing (GtkIconViewItemAccessible *item)
{
+ GtkAllocation allocation;
GtkIconView *icon_view;
GdkRectangle visible_rect;
gboolean is_showing;
@@ -8640,6 +8677,8 @@ gtk_icon_view_item_accessible_is_showing (GtkIconViewItemAccessible *item)
if (item->item == NULL)
return FALSE;
+ gtk_widget_get_allocation (item->widget, &allocation);
+
icon_view = GTK_ICON_VIEW (item->widget);
visible_rect.x = 0;
if (icon_view->priv->hadjustment)
@@ -8647,8 +8686,8 @@ gtk_icon_view_item_accessible_is_showing (GtkIconViewItemAccessible *item)
visible_rect.y = 0;
if (icon_view->priv->hadjustment)
visible_rect.y += icon_view->priv->vadjustment->value;
- visible_rect.width = item->widget->allocation.width;
- visible_rect.height = item->widget->allocation.height;
+ visible_rect.width = allocation.width;
+ visible_rect.height = allocation.height;
if (((item->item->x + item->item->width) < visible_rect.x) ||
((item->item->y + item->item->height) < (visible_rect.y)) ||
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index fbd21ba..643b505 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -1518,13 +1518,15 @@ animation_timeout (gpointer data)
delay = gdk_pixbuf_animation_iter_get_delay_time (priv->data.anim.iter);
if (delay >= 0)
{
+ GtkWidget *widget = GTK_WIDGET (image);
+
priv->data.anim.frame_timeout =
gdk_threads_add_timeout (delay, animation_timeout, image);
- gtk_widget_queue_draw (GTK_WIDGET (image));
+ gtk_widget_queue_draw (widget);
- if (gtk_widget_is_drawable (GTK_WIDGET (image)))
- gdk_window_process_updates (GTK_WIDGET (image)->window, TRUE);
+ if (gtk_widget_is_drawable (widget))
+ gdk_window_process_updates (gtk_widget_get_window (widget), TRUE);
}
return FALSE;
@@ -1789,7 +1791,9 @@ gtk_image_expose (GtkWidget *widget,
if (gtk_widget_get_mapped (widget) &&
priv->storage_type != GTK_IMAGE_EMPTY)
{
+ GtkAllocation allocation;
GtkMisc *misc;
+ GtkRequisition requisition;
GdkRectangle area, image_bound;
gint x, y, mask_x, mask_y;
gint xpad, ypad;
@@ -1809,8 +1813,10 @@ gtk_image_expose (GtkWidget *widget,
*/
if (priv->need_calc_size)
gtk_image_calc_size (image);
-
- if (!gdk_rectangle_intersect (&area, &widget->allocation, &area))
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ if (!gdk_rectangle_intersect (&area, &allocation, &area))
return FALSE;
gtk_misc_get_alignment (misc, &xalign, &yalign);
@@ -1819,10 +1825,9 @@ gtk_image_expose (GtkWidget *widget,
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
xalign = 1.0 - xalign;
- x = floor (widget->allocation.x + xpad
- + ((widget->allocation.width - widget->requisition.width) * xalign));
- y = floor (widget->allocation.y + ypad
- + ((widget->allocation.height - widget->requisition.height) * yalign));
+ gtk_widget_get_requisition (widget, &requisition);
+ x = floor (allocation.x + xpad + ((allocation.width - requisition.width) * xalign));
+ y = floor (allocation.y + ypad + ((allocation.height - requisition.height) * yalign));
mask_x = x;
mask_y = y;
@@ -1898,7 +1903,7 @@ gtk_image_expose (GtkWidget *widget,
case GTK_IMAGE_ICON_SET:
pixbuf =
gtk_icon_set_render_icon (priv->data.icon_set.icon_set,
- widget->style,
+ gtk_widget_get_style (widget),
gtk_widget_get_direction (widget),
gtk_widget_get_state (widget),
priv->icon_size,
@@ -2007,8 +2012,8 @@ gtk_image_expose (GtkWidget *widget,
gtk_icon_source_set_size (source,
GTK_ICON_SIZE_SMALL_TOOLBAR);
gtk_icon_source_set_size_wildcarded (source, FALSE);
-
- rendered = gtk_style_render_icon (widget->style,
+
+ rendered = gtk_style_render_icon (gtk_widget_get_style (widget),
source,
gtk_widget_get_direction (widget),
gtk_widget_get_state (widget),
@@ -2025,7 +2030,7 @@ gtk_image_expose (GtkWidget *widget,
if (pixbuf)
{
- cairo_t *cr = gdk_cairo_create (widget->window);
+ cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
gdk_cairo_rectangle (cr, &image_bound);
cairo_fill (cr);
@@ -2040,7 +2045,7 @@ gtk_image_expose (GtkWidget *widget,
switch (priv->storage_type)
{
case GTK_IMAGE_PIXMAP:
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
if (mask)
{
@@ -2063,7 +2068,6 @@ gtk_image_expose (GtkWidget *widget,
cairo_destroy (cr);
break;
-
case GTK_IMAGE_PIXBUF:
case GTK_IMAGE_STOCK:
case GTK_IMAGE_ICON_SET:
@@ -2244,7 +2248,7 @@ gtk_image_calc_size (GtkImage *image)
case GTK_IMAGE_ICON_SET:
pixbuf = gtk_icon_set_render_icon (priv->data.icon_set.icon_set,
- widget->style,
+ gtk_widget_get_style (widget),
gtk_widget_get_direction (widget),
gtk_widget_get_state (widget),
priv->icon_size,
diff --git a/gtk/gtkimagemenuitem.c b/gtk/gtkimagemenuitem.c
index d9e4625..6965d4d 100644
--- a/gtk/gtkimagemenuitem.c
+++ b/gtk/gtkimagemenuitem.c
@@ -325,9 +325,13 @@ gtk_image_menu_item_toggle_size_request (GtkMenuItem *menu_item,
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (menu_item);
GtkImageMenuItemPriv *priv = image_menu_item->priv;
GtkPackDirection pack_dir;
+ GtkWidget *parent;
+ GtkWidget *widget = GTK_WIDGET (menu_item);
- if (GTK_IS_MENU_BAR (GTK_WIDGET (menu_item)->parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (GTK_WIDGET (menu_item)->parent));
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
@@ -420,9 +424,12 @@ gtk_image_menu_item_size_request (GtkWidget *widget,
gint child_width = 0;
gint child_height = 0;
GtkPackDirection pack_dir;
-
- if (GTK_IS_MENU_BAR (widget->parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent));
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
@@ -460,10 +467,14 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
{
GtkImageMenuItem *image_menu_item = GTK_IMAGE_MENU_ITEM (widget);
GtkImageMenuItemPriv *priv = image_menu_item->priv;
+ GtkAllocation widget_allocation;
GtkPackDirection pack_dir;
-
- if (GTK_IS_MENU_BAR (widget->parent))
- pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent));
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_BAR (parent))
+ pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
else
pack_dir = GTK_PACK_DIRECTION_LTR;
@@ -488,48 +499,50 @@ gtk_image_menu_item_size_allocate (GtkWidget *widget,
gtk_widget_get_child_requisition (priv->image,
&child_requisition);
+ gtk_widget_get_allocation (widget, &widget_allocation);
+
if (pack_dir == GTK_PACK_DIRECTION_LTR ||
pack_dir == GTK_PACK_DIRECTION_RTL)
{
offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) +
- widget->style->xthickness;
-
+ gtk_widget_get_style (widget)->xthickness;
+
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
(pack_dir == GTK_PACK_DIRECTION_LTR))
x = offset + horizontal_padding +
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
toggle_spacing - child_requisition.width) / 2;
else
- x = widget->allocation.width - offset - horizontal_padding -
+ x = widget_allocation.width - offset - horizontal_padding -
GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing +
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
toggle_spacing - child_requisition.width) / 2;
-
- y = (widget->allocation.height - child_requisition.height) / 2;
+
+ y = (widget_allocation.height - child_requisition.height) / 2;
}
else
{
offset = gtk_container_get_border_width (GTK_CONTAINER (image_menu_item)) +
- widget->style->ythickness;
-
+ gtk_widget_get_style (widget)->ythickness;
+
if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) ==
(pack_dir == GTK_PACK_DIRECTION_TTB))
y = offset + horizontal_padding +
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
toggle_spacing - child_requisition.height) / 2;
else
- y = widget->allocation.height - offset - horizontal_padding -
+ y = widget_allocation.height - offset - horizontal_padding -
GTK_MENU_ITEM (image_menu_item)->toggle_size + toggle_spacing +
(GTK_MENU_ITEM (image_menu_item)->toggle_size -
toggle_spacing - child_requisition.height) / 2;
- x = (widget->allocation.width - child_requisition.width) / 2;
+ x = (widget_allocation.width - child_requisition.width) / 2;
}
child_allocation.width = child_requisition.width;
child_allocation.height = child_requisition.height;
- child_allocation.x = widget->allocation.x + MAX (x, 0);
- child_allocation.y = widget->allocation.y + MAX (y, 0);
+ child_allocation.x = widget_allocation.x + MAX (x, 0);
+ child_allocation.y = widget_allocation.y + MAX (y, 0);
gtk_widget_size_allocate (priv->image, &child_allocation);
}
diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c
index 08de226..7de08fb 100644
--- a/gtk/gtkinfobar.c
+++ b/gtk/gtkinfobar.c
@@ -310,21 +310,22 @@ gtk_info_bar_expose (GtkWidget *widget,
if (priv->message_type != GTK_MESSAGE_OTHER)
{
+ GtkAllocation allocation;
const char *detail;
detail = type_detail[priv->message_type];
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_paint_box (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
NULL,
widget,
detail,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ allocation.x, allocation.y,
+ allocation.width, allocation.height);
}
if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->expose_event)
@@ -569,9 +570,9 @@ gtk_info_bar_update_colors (GtkInfoBar *info_bar)
}
}
- if (!gdk_color_equal (bg, &widget->style->bg[GTK_STATE_NORMAL]))
+ if (!gdk_color_equal (bg, &style->bg[GTK_STATE_NORMAL]))
gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, bg);
- if (!gdk_color_equal (fg, &widget->style->fg[GTK_STATE_NORMAL]))
+ if (!gdk_color_equal (fg, &style->fg[GTK_STATE_NORMAL]))
gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, fg);
}
diff --git a/gtk/gtkinvisible.c b/gtk/gtkinvisible.c
index 2d8bd65..6403154 100644
--- a/gtk/gtkinvisible.c
+++ b/gtk/gtkinvisible.c
@@ -232,6 +232,7 @@ static void
gtk_invisible_realize (GtkWidget *widget)
{
GdkWindow *parent;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -252,11 +253,11 @@ gtk_invisible_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
- widget->window = gdk_window_new (parent, &attributes, attributes_mask);
-
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
+ window = gdk_window_new (parent, &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_style_attach (widget);
}
static void
@@ -275,10 +276,10 @@ gtk_invisible_show (GtkWidget *widget)
static void
gtk_invisible_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
- widget->allocation = *allocation;
-}
+ gtk_widget_set_allocation (widget, allocation);
+}
static void
diff --git a/gtk/gtkitem.c b/gtk/gtkitem.c
index ddcf571..97d45f9 100644
--- a/gtk/gtkitem.c
+++ b/gtk/gtkitem.c
@@ -121,15 +121,19 @@ gtk_item_toggle (GtkItem *item)
static void
gtk_item_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -143,12 +147,15 @@ gtk_item_realize (GtkWidget *widget)
GDK_POINTER_MOTION_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL);
+ gdk_window_set_back_pixmap (window, NULL, TRUE);
}
static gint
@@ -158,7 +165,7 @@ gtk_item_enter (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- return gtk_widget_event (widget->parent, (GdkEvent*) event);
+ return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent *) event);
}
static gint
@@ -168,5 +175,5 @@ gtk_item_leave (GtkWidget *widget,
g_return_val_if_fail (GTK_IS_ITEM (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- return gtk_widget_event (widget->parent, (GdkEvent*) event);
+ return gtk_widget_event (gtk_widget_get_parent (widget), (GdkEvent*) event);
}
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index a6ddc3b..4ac3420 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -1494,7 +1494,7 @@ gtk_label_mnemonic_activate (GtkWidget *widget,
/* Try to find the widget to activate by traversing the
* widget's ancestry.
*/
- parent = widget->parent;
+ parent = gtk_widget_get_parent (widget);
if (GTK_IS_NOTEBOOK (parent))
return FALSE;
@@ -1503,10 +1503,10 @@ gtk_label_mnemonic_activate (GtkWidget *widget,
{
if (gtk_widget_get_can_focus (parent) ||
(!group_cycling && GTK_WIDGET_GET_CLASS (parent)->activate_signal) ||
- GTK_IS_NOTEBOOK (parent->parent) ||
+ GTK_IS_NOTEBOOK (gtk_widget_get_parent (parent)) ||
GTK_IS_MENU_ITEM (parent))
return gtk_widget_mnemonic_activate (parent, group_cycling);
- parent = parent->parent;
+ parent = gtk_widget_get_parent (parent);
}
/* barf if there was nothing to activate */
@@ -3016,7 +3016,8 @@ get_label_width (GtkLabel *label,
layout = pango_layout_copy (priv->layout);
context = pango_layout_get_context (layout);
- metrics = pango_context_get_metrics (context, GTK_WIDGET (label)->style->font_desc,
+ metrics = pango_context_get_metrics (context,
+ gtk_widget_get_style (GTK_WIDGET (label))->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
@@ -3132,7 +3133,8 @@ get_label_wrap_width (GtkLabel *label)
layout = pango_layout_copy (priv->layout);
context = pango_layout_get_context (layout);
- metrics = pango_context_get_metrics (context, GTK_WIDGET (label)->style->font_desc,
+ metrics = pango_context_get_metrics (context,
+ gtk_widget_get_style (GTK_WIDGET (label))->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
@@ -3176,6 +3178,7 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width)
if (!priv->layout)
{
+ GtkAllocation allocation;
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
gdouble angle = gtk_label_get_angle (label);
@@ -3231,9 +3234,10 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width)
pango_layout_set_ellipsize (priv->layout, priv->ellipsize);
pango_layout_set_single_paragraph_mode (priv->layout, priv->single_line_mode);
+ gtk_widget_get_allocation (widget, &allocation);
+
if (priv->ellipsize)
- pango_layout_set_width (priv->layout,
- widget->allocation.width * PANGO_SCALE);
+ pango_layout_set_width (priv->layout, allocation.width * PANGO_SCALE);
else if (priv->wrap)
{
GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (widget, FALSE);
@@ -3248,17 +3252,16 @@ gtk_label_ensure_layout (GtkLabel *label, gboolean guess_wrap_width)
if (aux_width > 0)
pango_layout_set_width (priv->layout, aux_width * PANGO_SCALE);
- else if (guess_wrap_width == FALSE &&
- widget->allocation.width > 1 && widget->allocation.height > 1)
+ else if (guess_wrap_width == FALSE && allocation.width > 1 && allocation.height > 1)
{
PangoRectangle rect;
gint xpad, ypad, natural_width;
gtk_misc_get_padding (GTK_MISC (label), &xpad, &ypad);
if (angle == 90 || angle == 270)
- width = widget->allocation.height - ypad * 2;
+ width = allocation.height - ypad * 2;
else
- width = widget->allocation.width - xpad * 2;
+ width = allocation.width - xpad * 2;
/* dont set a wrap width wider than the label's natural width
* incase we're allocated more space than needed */
@@ -3340,7 +3343,7 @@ get_single_line_height (GtkWidget *widget,
gint ascent, descent;
context = pango_layout_get_context (layout);
- metrics = pango_context_get_metrics (context, widget->style->font_desc,
+ metrics = pango_context_get_metrics (context, gtk_widget_get_style (widget)->font_desc,
pango_context_get_language (context));
ascent = pango_font_metrics_get_ascent (metrics);
@@ -3830,6 +3833,7 @@ get_layout_location (GtkLabel *label,
gint *xp,
gint *yp)
{
+ GtkAllocation allocation;
GtkMisc *misc;
GtkWidget *widget;
GtkLabelPriv *priv;
@@ -3866,13 +3870,14 @@ get_layout_location (GtkLabel *label,
req_width += 2 * xpad;
req_height += 2 * ypad;
- x = floor (widget->allocation.x + xpad +
- xalign * (widget->allocation.width - req_width));
+ gtk_widget_get_allocation (widget, &allocation);
+
+ x = floor (allocation.x + xpad + xalign * (allocation.width - req_width));
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- x = MAX (x, widget->allocation.x + xpad);
+ x = MAX (x, allocation.x + xpad);
else
- x = MIN (x, widget->allocation.x + widget->allocation.width - xpad);
+ x = MIN (x, allocation.x + allocation.width - xpad);
/* bgo#315462 - For single-line labels, *do* align the requisition with
@@ -3889,15 +3894,9 @@ get_layout_location (GtkLabel *label,
* middle". You want to read the first line, at least, to get some context.
*/
if (pango_layout_get_line_count (priv->layout) == 1)
- {
- y = floor (widget->allocation.y + ypad
- + (widget->allocation.height - req_height) * yalign);
- }
+ y = floor (allocation.y + ypad + (allocation.height - req_height) * yalign);
else
- {
- y = floor (widget->allocation.y + ypad
- + MAX ((widget->allocation.height - req_height) * yalign, 0));
- }
+ y = floor (allocation.y + ypad + MAX ((allocation.height - req_height) * yalign, 0));
if (xp)
*xp = x;
@@ -3914,6 +3913,7 @@ draw_insertion_cursor (GtkLabel *label,
gboolean draw_arrow)
{
GtkWidget *widget = GTK_WIDGET (label);
+ GtkAllocation allocation;
GtkTextDirection text_dir;
if (direction == PANGO_DIRECTION_LTR)
@@ -3921,8 +3921,9 @@ draw_insertion_cursor (GtkLabel *label,
else
text_dir = GTK_TEXT_DIR_RTL;
- gtk_draw_insertion_cursor (widget, widget->window, &(widget->allocation),
- cursor_location,
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_draw_insertion_cursor (widget, gtk_widget_get_window (widget),
+ &allocation, cursor_location,
is_primary, text_dir, draw_arrow);
}
@@ -4064,6 +4065,8 @@ gtk_label_expose (GtkWidget *widget,
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPriv *priv = label->priv;
GtkLabelSelectionInfo *info = priv->select_info;
+ GtkStyle *style;
+ GdkWindow *window;
gint x, y;
gtk_label_ensure_layout (label, FALSE);
@@ -4073,8 +4076,11 @@ gtk_label_expose (GtkWidget *widget,
{
get_layout_location (label, &x, &y);
- gtk_paint_layout (widget->style,
- widget->window,
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
+ gtk_paint_layout (style,
+ window,
gtk_widget_get_state (widget),
FALSE,
&event->area,
@@ -4120,10 +4126,10 @@ gtk_label_expose (GtkWidget *widget,
if (!gtk_widget_has_focus (widget))
state = GTK_STATE_ACTIVE;
- gdk_cairo_set_source_color (cr, &widget->style->base[state]);
+ gdk_cairo_set_source_color (cr, &style->base[state]);
cairo_paint (cr);
- gdk_cairo_set_source_color (cr, &widget->style->text[state]);
+ gdk_cairo_set_source_color (cr, &style->text[state]);
cairo_move_to (cr, x, y);
_gtk_pango_fill_layout (cr, priv->layout);
@@ -4175,9 +4181,9 @@ gtk_label_expose (GtkWidget *widget,
else
text_color = link_color;
if (info->link_clicked)
- base_color = &widget->style->base[GTK_STATE_ACTIVE];
+ base_color = &style->base[GTK_STATE_ACTIVE];
else
- base_color = &widget->style->base[GTK_STATE_PRELIGHT];
+ base_color = &style->base[GTK_STATE_PRELIGHT];
gdk_cairo_set_source_color (cr, base_color);
cairo_paint (cr);
@@ -4203,7 +4209,7 @@ gtk_label_expose (GtkWidget *widget,
1);
cairo_region_get_extents (clip, &rect);
- gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
+ gtk_paint_focus (style, window, gtk_widget_get_state (widget),
&event->area, widget, "label",
rect.x, rect.y, rect.width, rect.height);
@@ -4398,6 +4404,7 @@ window_to_layout_coords (GtkLabel *label,
gint *x,
gint *y)
{
+ GtkAllocation allocation;
gint lx, ly;
GtkWidget *widget;
@@ -4405,16 +4412,18 @@ window_to_layout_coords (GtkLabel *label,
/* get layout location in widget->window coords */
get_layout_location (label, &lx, &ly);
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+
if (x)
{
- *x += widget->allocation.x; /* go to widget->window */
+ *x += allocation.x; /* go to widget->window */
*x -= lx; /* go to layout */
}
if (y)
{
- *y += widget->allocation.y; /* go to widget->window */
+ *y += allocation.y; /* go to widget->window */
*y -= ly; /* go to layout */
}
}
@@ -5038,6 +5047,7 @@ static void
gtk_label_create_window (GtkLabel *label)
{
GtkLabelPriv *priv = label->priv;
+ GtkAllocation allocation;
GtkWidget *widget;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -5049,10 +5059,12 @@ gtk_label_create_window (GtkLabel *label)
if (priv->select_info->window)
return;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_ONLY;
attributes.override_redirect = TRUE;
@@ -5072,7 +5084,7 @@ gtk_label_create_window (GtkLabel *label)
}
- priv->select_info->window = gdk_window_new (widget->window,
+ priv->select_info->window = gdk_window_new (gtk_widget_get_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (priv->select_info->window, widget);
@@ -6108,6 +6120,7 @@ popup_position_func (GtkMenu *menu,
{
GtkLabel *label;
GtkWidget *widget;
+ GtkAllocation allocation;
GtkRequisition req;
GdkScreen *screen;
@@ -6117,15 +6130,19 @@ popup_position_func (GtkMenu *menu,
g_return_if_fail (gtk_widget_get_realized (widget));
screen = gtk_widget_get_screen (widget);
- gdk_window_get_origin (widget->window, x, y);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+
+ gtk_widget_get_allocation (widget, &allocation);
- *x += widget->allocation.x;
- *y += widget->allocation.y;
+ *x += allocation.x;
+ *y += allocation.y;
gtk_widget_size_request (GTK_WIDGET (menu), &req);
- *x += widget->allocation.width / 2;
- *y += widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ *x += allocation.width / 2;
+ *y += allocation.height;
*x = CLAMP (*x, 0, MAX (0, gdk_screen_get_width (screen) - req.width));
*y = CLAMP (*y, 0, MAX (0, gdk_screen_get_height (screen) - req.height));
diff --git a/gtk/gtklayout.c b/gtk/gtklayout.c
index fb87768..5d75670 100644
--- a/gtk/gtklayout.c
+++ b/gtk/gtklayout.c
@@ -465,7 +465,7 @@ gtk_layout_move (GtkLayout *layout,
{
g_return_if_fail (GTK_IS_LAYOUT (layout));
g_return_if_fail (GTK_IS_WIDGET (child_widget));
- g_return_if_fail (child_widget->parent == GTK_WIDGET (layout));
+ g_return_if_fail (gtk_widget_get_parent (child_widget) == GTK_WIDGET (layout));
gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
}
@@ -540,8 +540,11 @@ gtk_layout_set_size (GtkLayout *layout,
if (gtk_widget_get_realized (widget))
{
- width = MAX (width, widget->allocation.width);
- height = MAX (height, widget->allocation.height);
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ width = MAX (width, allocation.width);
+ height = MAX (height, allocation.height);
gdk_window_resize (priv->bin_window, width, height);
}
}
@@ -860,17 +863,21 @@ gtk_layout_realize (GtkWidget *widget)
{
GtkLayout *layout = GTK_LAYOUT (widget);
GtkLayoutPriv *priv = layout->priv;
- GList *tmp_list;
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
+ GList *tmp_list;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -878,24 +885,27 @@ gtk_layout_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_back_pixmap (window, NULL, FALSE);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
attributes.x = - priv->hadjustment->value,
attributes.y = - priv->vadjustment->value;
- attributes.width = MAX (priv->width, widget->allocation.width);
- attributes.height = MAX (priv->height, widget->allocation.height);
+ attributes.width = MAX (priv->width, allocation.width);
+ attributes.height = MAX (priv->height, allocation.height);
attributes.event_mask = GDK_EXPOSURE_MASK | GDK_SCROLL_MASK |
gtk_widget_get_events (widget);
- priv->bin_window = gdk_window_new (widget->window,
- &attributes, attributes_mask);
+ priv->bin_window = gdk_window_new (window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (priv->bin_window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL);
tmp_list = priv->children;
while (tmp_list)
@@ -918,7 +928,7 @@ gtk_layout_style_set (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
priv = GTK_LAYOUT (widget)->priv;
- gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (gtk_widget_get_style (widget), priv->bin_window, GTK_STATE_NORMAL);
}
}
@@ -945,7 +955,7 @@ gtk_layout_map (GtkWidget *widget)
}
gdk_window_show (priv->bin_window);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
}
static void
@@ -993,7 +1003,7 @@ gtk_layout_size_allocate (GtkWidget *widget,
GtkLayoutPriv *priv = layout->priv;
GList *tmp_list;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
tmp_list = priv->children;
@@ -1007,7 +1017,7 @@ gtk_layout_size_allocate (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index 7bca09e..16fbdc5 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -332,7 +332,7 @@ set_hand_cursor (GtkWidget *widget,
if (show_hand)
cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
- gdk_window_set_cursor (widget->window, cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_display_flush (display);
if (cursor)
@@ -357,6 +357,7 @@ popup_position_func (GtkMenu *menu,
{
GtkLinkButton *link_button = GTK_LINK_BUTTON (user_data);
GtkLinkButtonPrivate *priv = link_button->priv;
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (link_button);
GdkScreen *screen = gtk_widget_get_screen (widget);
GtkRequisition req;
@@ -365,12 +366,13 @@ popup_position_func (GtkMenu *menu,
g_return_if_fail (gtk_widget_get_realized (widget));
- gdk_window_get_origin (widget->window, x, y);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
gtk_widget_size_request (priv->popup_menu, &req);
- *x += widget->allocation.width / 2;
- *y += widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ *x += allocation.width / 2;
+ *y += allocation.height;
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num);
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index ea922a8..a7cd846 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1543,7 +1543,7 @@ gtk_main_do_event (GdkEvent *event)
/* Unexpected GDK_DESTROY from the outside, ignore for
* child windows, handle like a GDK_DELETE for toplevels
*/
- if (!event_widget->parent)
+ if (!gtk_widget_get_parent (event_widget))
{
g_object_ref (event_widget);
if (!gtk_widget_event (event_widget, event) &&
@@ -2411,8 +2411,8 @@ gtk_propagate_event (GtkWidget *widget,
handled_event = event->type != GDK_SCROLL;
else
handled_event = gtk_widget_event (widget, event);
-
- tmp = widget->parent;
+
+ tmp = gtk_widget_get_parent (widget);
g_object_unref (widget);
widget = tmp;
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 39c83f2..fb98f98 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -424,7 +424,7 @@ get_effective_child_attach (GtkWidget *child,
int *t,
int *b)
{
- GtkMenu *menu = GTK_MENU (child->parent);
+ GtkMenu *menu = GTK_MENU (gtk_widget_get_parent (child));
AttachInfo *ai;
menu_ensure_layout (menu);
@@ -1350,14 +1350,17 @@ gtk_menu_tearoff_bg_copy (GtkMenu *menu)
if (menu->torn_off)
{
GdkPixmap *pixmap;
+ GdkWindow *window;
cairo_t *cr;
menu->tearoff_active = FALSE;
menu->saved_scroll_offset = menu->scroll_offset;
-
- gdk_drawable_get_size (menu->tearoff_window->window, &width, &height);
-
- pixmap = gdk_pixmap_new (menu->tearoff_window->window,
+
+ window = gtk_widget_get_window (menu->tearoff_window);
+
+ gdk_drawable_get_size (window, &width, &height);
+
+ pixmap = gdk_pixmap_new (window,
width,
height,
-1);
@@ -1365,7 +1368,7 @@ gtk_menu_tearoff_bg_copy (GtkMenu *menu)
cr = gdk_cairo_create (pixmap);
/* Let's hope that function never notices we're not passing it a pixmap */
gdk_cairo_set_source_pixmap (cr,
- menu->tearoff_window->window,
+ window,
0, 0);
cairo_paint (cr);
cairo_destroy (cr);
@@ -1374,7 +1377,7 @@ gtk_menu_tearoff_bg_copy (GtkMenu *menu)
width,
height);
- gdk_window_set_back_pixmap (menu->tearoff_window->window, pixmap, FALSE);
+ gdk_window_set_back_pixmap (window, pixmap, FALSE);
g_object_unref (pixmap);
}
}
@@ -1498,7 +1501,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
viewable = FALSE;
break;
}
- tmp = tmp->parent;
+ tmp = gtk_widget_get_parent (tmp);
}
if (viewable)
@@ -1530,7 +1533,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
if (xgrab_shell && xgrab_shell != widget)
{
- if (popup_grab_on_window (xgrab_shell->window, keyboard, pointer, activate_time))
+ if (popup_grab_on_window (gtk_widget_get_window (xgrab_shell), keyboard, pointer, activate_time))
{
_gtk_menu_shell_set_grab_device (GTK_MENU_SHELL (xgrab_shell), pointer);
GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE;
@@ -1656,7 +1659,7 @@ gtk_menu_popup_for_device (GtkMenu *menu,
gtk_widget_show (menu->toplevel);
if (xgrab_shell == widget)
- popup_grab_on_window (widget->window, keyboard, pointer, activate_time); /* Should always succeed */
+ popup_grab_on_window (gtk_widget_get_window (widget), keyboard, pointer, activate_time); /* Should always succeed */
gtk_device_grab_add (GTK_WIDGET (menu), pointer, TRUE);
@@ -2041,6 +2044,7 @@ static void
gtk_menu_set_tearoff_hints (GtkMenu *menu,
gint width)
{
+ GtkRequisition requisition;
GdkGeometry geometry_hints;
if (!menu->tearoff_window)
@@ -2049,14 +2053,16 @@ gtk_menu_set_tearoff_hints (GtkMenu *menu,
if (gtk_widget_get_visible (menu->tearoff_scrollbar))
{
gtk_widget_size_request (menu->tearoff_scrollbar, NULL);
- width += menu->tearoff_scrollbar->requisition.width;
+ gtk_widget_get_requisition (menu->tearoff_scrollbar, &requisition);
+ width += requisition.width;
}
geometry_hints.min_width = width;
geometry_hints.max_width = width;
geometry_hints.min_height = 0;
- geometry_hints.max_height = GTK_WIDGET (menu)->requisition.height;
+ gtk_widget_get_requisition (GTK_WIDGET (menu), &requisition);
+ geometry_hints.max_height = requisition.height;
gtk_window_set_geometry_hints (GTK_WINDOW (menu->tearoff_window),
NULL,
@@ -2097,7 +2103,7 @@ gtk_menu_get_toplevel (GtkWidget *menu)
attach = gtk_menu_get_attach_widget (GTK_MENU (menu));
if (GTK_IS_MENU_ITEM (attach))
- attach = attach->parent;
+ attach = gtk_widget_get_parent (attach);
if (GTK_IS_MENU (attach))
return gtk_menu_get_toplevel (attach);
@@ -2138,6 +2144,7 @@ gtk_menu_set_tearoff_state (GtkMenu *menu,
if (!menu->tearoff_window)
{
+ GtkRequisition requisition;
GtkWidget *toplevel;
menu->tearoff_window = g_object_new (GTK_TYPE_WINDOW,
@@ -2166,11 +2173,13 @@ gtk_menu_set_tearoff_state (GtkMenu *menu,
menu->tearoff_hbox = gtk_hbox_new (FALSE, FALSE);
gtk_container_add (GTK_CONTAINER (menu->tearoff_window), menu->tearoff_hbox);
- gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
- menu->tearoff_adjustment =
+ gdk_drawable_get_size (gtk_widget_get_window (GTK_WIDGET (menu)),
+ &width, &height);
+ gtk_widget_get_requisition (GTK_WIDGET (menu), &requisition);
+ menu->tearoff_adjustment =
GTK_ADJUSTMENT (gtk_adjustment_new (0,
0,
- GTK_WIDGET (menu)->requisition.height,
+ requisition.height,
MENU_SCROLL_STEP2,
height/2,
height));
@@ -2191,7 +2200,8 @@ gtk_menu_set_tearoff_state (GtkMenu *menu,
gtk_menu_reparent (menu, menu->tearoff_hbox, FALSE);
- gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, NULL);
+ gdk_drawable_get_size (gtk_widget_get_window (GTK_WIDGET (menu)),
+ &width, NULL);
/* Update menu->requisition
*/
@@ -2322,10 +2332,13 @@ gtk_menu_style_set (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
GtkMenu *menu = GTK_MENU (widget);
-
- gtk_style_set_background (widget->style, menu->bin_window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, menu->view_window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+
+ gtk_style_set_background (style, menu->bin_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, menu->view_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, gtk_widget_get_window (widget), GTK_STATE_NORMAL);
}
}
@@ -2367,6 +2380,10 @@ get_arrows_border (GtkMenu *menu,
static void
gtk_menu_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GtkRequisition requisition;
+ GtkStyle *style;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
@@ -2382,51 +2399,62 @@ gtk_menu_realize (GtkWidget *widget)
menu = GTK_MENU (widget);
gtk_widget_set_realized (widget, TRUE);
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
-
attributes.event_mask = gtk_widget_get_events (widget);
-
attributes.event_mask |= (GDK_EXPOSURE_MASK | GDK_KEY_PRESS_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK );
-
+
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
+
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
- attributes.x = border_width + widget->style->xthickness + horizontal_padding;
- attributes.y = border_width + widget->style->ythickness + vertical_padding;
- attributes.width = MAX (1, widget->allocation.width - attributes.x * 2);
- attributes.height = MAX (1, widget->allocation.height - attributes.y * 2);
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = border_width + style->xthickness + horizontal_padding;
+ attributes.y = border_width + style->ythickness + vertical_padding;
+ attributes.width = MAX (1, allocation.width - attributes.x * 2);
+ attributes.height = MAX (1, allocation.height - attributes.y * 2);
get_arrows_border (menu, &arrow_border);
attributes.y += arrow_border.top;
attributes.height -= arrow_border.top;
attributes.height -= arrow_border.bottom;
- menu->view_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+ menu->view_window = gdk_window_new (window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (menu->view_window, menu);
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_requisition (widget, &requisition);
+
attributes.x = 0;
attributes.y = 0;
- attributes.width = MAX (1, widget->allocation.width - (border_width + widget->style->xthickness + horizontal_padding) * 2);
- attributes.height = MAX (1, widget->requisition.height - (border_width + widget->style->ythickness + vertical_padding) * 2);
-
- menu->bin_window = gdk_window_new (menu->view_window, &attributes, attributes_mask);
+ attributes.width = MAX (1, allocation.width - (border_width + style->xthickness + horizontal_padding) * 2);
+ attributes.height = MAX (1, requisition.height - (border_width + style->ythickness + vertical_padding) * 2);
+
+ menu->bin_window = gdk_window_new (menu->view_window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (menu->bin_window, menu);
children = GTK_MENU_SHELL (menu)->children;
@@ -2437,11 +2465,11 @@ gtk_menu_realize (GtkWidget *widget)
gtk_widget_set_parent_window (child, menu->bin_window);
}
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, menu->bin_window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, menu->view_window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (style, menu->bin_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, menu->view_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, window, GTK_STATE_NORMAL);
if (GTK_MENU_SHELL (widget)->active_menu_item)
gtk_menu_scroll_item_visible (GTK_MENU_SHELL (widget),
@@ -2532,6 +2560,7 @@ gtk_menu_size_request (GtkWidget *widget,
gint i;
GtkMenu *menu;
GtkMenuShell *menu_shell;
+ GtkStyle *style;
GtkWidget *child;
GList *children;
guint max_toggle_size;
@@ -2548,7 +2577,9 @@ gtk_menu_size_request (GtkWidget *widget,
menu = GTK_MENU (widget);
menu_shell = GTK_MENU_SHELL (widget);
priv = gtk_menu_get_private (menu);
-
+
+ style = gtk_widget_get_style (widget);
+
requisition->width = 0;
requisition->height = 0;
@@ -2607,7 +2638,7 @@ gtk_menu_size_request (GtkWidget *widget,
guint toggle_spacing;
guint indicator_size;
- gtk_style_get (widget->style,
+ gtk_style_get (style,
GTK_TYPE_CHECK_MENU_ITEM,
"toggle-spacing", &toggle_spacing,
"indicator-size", &indicator_size,
@@ -2628,9 +2659,9 @@ gtk_menu_size_request (GtkWidget *widget,
NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
- requisition->width += (border_width + horizontal_padding + widget->style->xthickness) * 2;
- requisition->height += (border_width + vertical_padding + widget->style->ythickness) * 2;
-
+ requisition->width += (border_width + horizontal_padding + style->xthickness) * 2;
+ requisition->height += (border_width + vertical_padding + style->ythickness) * 2;
+
menu->toggle_size = max_toggle_size;
/* Don't resize the tearoff if it is not active, because it won't redraw (it is only a background pixmap).
@@ -2649,6 +2680,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
GtkAllocation child_allocation;
GtkRequisition child_requisition;
GtkMenuPrivate *priv;
+ GtkStyle *style;
GList *children;
gint x, y;
gint width, height;
@@ -2663,17 +2695,19 @@ gtk_menu_size_allocate (GtkWidget *widget,
menu_shell = GTK_MENU_SHELL (widget);
priv = gtk_menu_get_private (menu);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
+
gtk_widget_get_child_requisition (GTK_WIDGET (menu), &child_requisition);
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
- x = border_width + widget->style->xthickness + horizontal_padding;
- y = border_width + widget->style->ythickness + vertical_padding;
+ x = border_width + style->xthickness + horizontal_padding;
+ y = border_width + style->ythickness + vertical_padding;
width = MAX (1, allocation->width - x * 2);
height = MAX (1, allocation->height - y * 2);
@@ -2696,7 +2730,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
@@ -2769,7 +2803,11 @@ gtk_menu_size_allocate (GtkWidget *widget,
if (menu->tearoff_active)
{
- if (allocation->height >= widget->requisition.height)
+ GtkRequisition requisition;
+
+ gtk_widget_get_requisition (widget, &requisition);
+
+ if (allocation->height >= requisition.height)
{
if (gtk_widget_get_visible (menu->tearoff_scrollbar))
{
@@ -2781,7 +2819,7 @@ gtk_menu_size_allocate (GtkWidget *widget,
}
else
{
- menu->tearoff_adjustment->upper = widget->requisition.height;
+ menu->tearoff_adjustment->upper = requisition.height;
menu->tearoff_adjustment->page_size = allocation->height;
if (menu->tearoff_adjustment->value + menu->tearoff_adjustment->page_size >
@@ -2813,12 +2851,15 @@ get_arrows_visible_area (GtkMenu *menu,
GdkRectangle *lower,
gint *arrow_space)
{
+ GtkArrowPlacement arrow_placement;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (menu);
guint border_width;
guint vertical_padding;
guint horizontal_padding;
gint scroll_arrow_height;
- GtkArrowPlacement arrow_placement;
+
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
@@ -2828,9 +2869,10 @@ get_arrows_visible_area (GtkMenu *menu,
NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- border->x = border_width + widget->style->xthickness + horizontal_padding;
- border->y = border_width + widget->style->ythickness + vertical_padding;
- gdk_drawable_get_size (widget->window, &border->width, &border->height);
+ border->x = border_width + style->xthickness + horizontal_padding;
+ border->y = border_width + style->ythickness + vertical_padding;
+ gdk_drawable_get_size (gtk_widget_get_window (widget),
+ &border->width, &border->height);
switch (arrow_placement)
{
@@ -2876,7 +2918,7 @@ get_arrows_visible_area (GtkMenu *menu,
lower->x = lower->y = lower->width = lower->height = 0;
}
- *arrow_space = scroll_arrow_height - 2 * widget->style->ythickness;
+ *arrow_space = scroll_arrow_height - 2 * style->ythickness;
}
static void
@@ -2885,9 +2927,11 @@ gtk_menu_paint (GtkWidget *widget,
{
GtkMenu *menu;
GtkMenuPrivate *priv;
+ GtkStyle *style;
GdkRectangle border;
GdkRectangle upper;
GdkRectangle lower;
+ GdkWindow *window;
gint arrow_space;
g_return_if_fail (GTK_IS_MENU (widget));
@@ -2895,9 +2939,12 @@ gtk_menu_paint (GtkWidget *widget,
menu = GTK_MENU (widget);
priv = gtk_menu_get_private (menu);
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
get_arrows_visible_area (menu, &border, &upper, &lower, &arrow_space);
- if (event->window == widget->window)
+ if (event->window == window)
{
gfloat arrow_scaling;
gint arrow_size;
@@ -2905,8 +2952,8 @@ gtk_menu_paint (GtkWidget *widget,
gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL);
arrow_size = arrow_scaling * arrow_space;
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style,
+ window,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
&event->area, widget, "menu",
@@ -2914,8 +2961,8 @@ gtk_menu_paint (GtkWidget *widget,
if (menu->upper_arrow_visible && !menu->tearoff_active)
{
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style,
+ window,
priv->upper_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu_scroll_arrow_up",
@@ -2924,22 +2971,22 @@ gtk_menu_paint (GtkWidget *widget,
upper.width,
upper.height);
- gtk_paint_arrow (widget->style,
- widget->window,
+ gtk_paint_arrow (style,
+ window,
priv->upper_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu_scroll_arrow_up",
GTK_ARROW_UP,
TRUE,
upper.x + (upper.width - arrow_size) / 2,
- upper.y + widget->style->ythickness + (arrow_space - arrow_size) / 2,
+ upper.y + style->ythickness + (arrow_space - arrow_size) / 2,
arrow_size, arrow_size);
}
if (menu->lower_arrow_visible && !menu->tearoff_active)
{
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style,
+ window,
priv->lower_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu_scroll_arrow_down",
@@ -2948,15 +2995,15 @@ gtk_menu_paint (GtkWidget *widget,
lower.width,
lower.height);
- gtk_paint_arrow (widget->style,
- widget->window,
+ gtk_paint_arrow (style,
+ window,
priv->lower_arrow_state,
GTK_SHADOW_OUT,
&event->area, widget, "menu_scroll_arrow_down",
GTK_ARROW_DOWN,
TRUE,
lower.x + (lower.width - arrow_size) / 2,
- lower.y + widget->style->ythickness + (arrow_space - arrow_size) / 2,
+ lower.y + style->ythickness + (arrow_space - arrow_size) / 2,
arrow_size, arrow_size);
}
}
@@ -2972,7 +3019,7 @@ gtk_menu_paint (GtkWidget *widget,
y -= arrow_border.top;
}
- gtk_paint_box (widget->style,
+ gtk_paint_box (style,
menu->bin_window,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
@@ -3038,6 +3085,7 @@ pointer_in_menu_window (GtkWidget *widget,
gdouble x_root,
gdouble y_root)
{
+ GtkAllocation allocation;
GtkMenu *menu = GTK_MENU (widget);
if (gtk_widget_get_mapped (menu->toplevel))
@@ -3045,10 +3093,12 @@ pointer_in_menu_window (GtkWidget *widget,
GtkMenuShell *menu_shell;
gint window_x, window_y;
- gdk_window_get_position (menu->toplevel->window, &window_x, &window_y);
+ gdk_window_get_position (gtk_widget_get_window (menu->toplevel),
+ &window_x, &window_y);
- if (x_root >= window_x && x_root < window_x + widget->allocation.width &&
- y_root >= window_y && y_root < window_y + widget->allocation.height)
+ gtk_widget_get_allocation (widget, &allocation);
+ if (x_root >= window_x && x_root < window_x + allocation.width &&
+ y_root >= window_y && y_root < window_y + allocation.height)
return TRUE;
menu_shell = GTK_MENU_SHELL (widget);
@@ -3348,6 +3398,7 @@ gtk_menu_motion_notify (GtkWidget *widget,
GtkWidget *menu_item;
GtkMenu *menu;
GtkMenuShell *menu_shell;
+ GtkWidget *parent;
gboolean need_enter;
@@ -3372,11 +3423,12 @@ gtk_menu_motion_notify (GtkWidget *widget,
* which may be different from 'widget'.
*/
menu_item = gtk_get_event_widget ((GdkEvent*) event);
+ parent = gtk_widget_get_parent (menu_item);
if (!GTK_IS_MENU_ITEM (menu_item) ||
- !GTK_IS_MENU (menu_item->parent))
+ !GTK_IS_MENU (parent))
return FALSE;
- menu_shell = GTK_MENU_SHELL (menu_item->parent);
+ menu_shell = GTK_MENU_SHELL (parent);
menu = GTK_MENU (menu_shell);
if (definitely_within_item (menu_item, event->x, event->y))
@@ -3466,12 +3518,13 @@ static void
gtk_menu_scroll_by (GtkMenu *menu,
gint step)
{
+ GtkBorder arrow_border;
+ GtkRequisition requisition;
GtkWidget *widget;
gint offset;
gint view_width, view_height;
gboolean double_arrows;
- GtkBorder arrow_border;
-
+
widget = GTK_WIDGET (menu);
offset = menu->scroll_offset + step;
@@ -3492,10 +3545,13 @@ gtk_menu_scroll_by (GtkMenu *menu,
if ((menu->scroll_offset >= 0) && (offset < 0))
offset = 0;
- gdk_drawable_get_size (widget->window, &view_width, &view_height);
+ gdk_drawable_get_size (gtk_widget_get_window (widget),
+ &view_width, &view_height);
+
+ gtk_widget_get_requisition (widget, &requisition);
if (menu->scroll_offset == 0 &&
- view_height >= widget->requisition.height)
+ view_height >= requisition.height)
return;
/* Don't scroll past the bottom if we weren't before: */
@@ -3508,9 +3564,9 @@ gtk_menu_scroll_by (GtkMenu *menu,
if (double_arrows)
view_height -= arrow_border.bottom;
- if ((menu->scroll_offset + view_height <= widget->requisition.height) &&
- (offset + view_height > widget->requisition.height))
- offset = widget->requisition.height - view_height;
+ if ((menu->scroll_offset + view_height <= requisition.height) &&
+ (offset + view_height > requisition.height))
+ offset = requisition.height - view_height;
if (offset != menu->scroll_offset)
gtk_menu_scroll_to (menu, offset);
@@ -3627,25 +3683,29 @@ get_arrows_sensitive_area (GtkMenu *menu,
GdkRectangle *upper,
GdkRectangle *lower)
{
+ GtkArrowPlacement arrow_placement;
+ GtkWidget *widget = GTK_WIDGET (menu);
+ GdkWindow *window;
gint width, height;
guint border;
guint vertical_padding;
gint win_x, win_y;
gint scroll_arrow_height;
- GtkArrowPlacement arrow_placement;
- gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
+ window = gtk_widget_get_window (widget);
- gtk_widget_style_get (GTK_WIDGET (menu),
+ gdk_drawable_get_size (window, &width, &height);
+
+ gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow-placement", &arrow_placement,
NULL);
border = gtk_container_get_border_width (GTK_CONTAINER (menu)) +
- GTK_WIDGET (menu)->style->ythickness + vertical_padding;
+ gtk_widget_get_style (widget)->ythickness + vertical_padding;
- gdk_window_get_position (GTK_WIDGET (menu)->window, &win_x, &win_y);
+ gdk_window_get_position (window, &win_x, &win_y);
switch (arrow_placement)
{
@@ -3729,7 +3789,8 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
"gtk-touchscreen-mode", &touchscreen_mode,
NULL);
- gdk_window_get_position (menu->toplevel->window, &top_x, &top_y);
+ gdk_window_get_position (gtk_widget_get_window (menu->toplevel),
+ &top_x, &top_y);
x -= top_x;
y -= top_y;
@@ -3835,7 +3896,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
{
priv->upper_arrow_state = arrow_state;
- gdk_window_invalidate_rect (GTK_WIDGET (menu)->window,
+ gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (menu)),
&rect, FALSE);
}
}
@@ -3943,7 +4004,7 @@ gtk_menu_handle_scrolling (GtkMenu *menu,
{
priv->lower_arrow_state = arrow_state;
- gdk_window_invalidate_rect (GTK_WIDGET (menu)->window,
+ gdk_window_invalidate_rect (gtk_widget_get_window (GTK_WIDGET (menu)),
&rect, FALSE);
}
}
@@ -3955,6 +4016,7 @@ gtk_menu_enter_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
GtkWidget *menu_item;
+ GtkWidget *parent;
gboolean touchscreen_mode;
if (event->mode == GDK_CROSSING_GTK_GRAB ||
@@ -3978,7 +4040,7 @@ gtk_menu_enter_notify (GtkWidget *widget,
if (!touchscreen_mode && GTK_IS_MENU_ITEM (menu_item))
{
- GtkWidget *menu = menu_item->parent;
+ GtkWidget *menu = gtk_widget_get_parent (menu_item);
if (GTK_IS_MENU (menu))
{
@@ -4016,8 +4078,9 @@ gtk_menu_enter_notify (GtkWidget *widget,
* will not correspond to the event widget's parent. Check to see
* if we are in the parent's navigation region.
*/
- if (GTK_IS_MENU_ITEM (menu_item) && GTK_IS_MENU (menu_item->parent) &&
- gtk_menu_navigating_submenu (GTK_MENU (menu_item->parent),
+ parent = gtk_widget_get_parent (menu_item);
+ if (GTK_IS_MENU_ITEM (menu_item) && GTK_IS_MENU (parent) &&
+ gtk_menu_navigating_submenu (GTK_MENU (parent),
event->x_root, event->y_root))
return TRUE;
@@ -4194,6 +4257,7 @@ gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
GtkWidget *event_widget;
GtkMenuPopdownData *popdown_data;
GtkMenuPrivate *priv;
+ GdkWindow *window;
g_return_if_fail (menu_item->submenu != NULL);
g_return_if_fail (event != NULL);
@@ -4201,15 +4265,17 @@ gtk_menu_set_submenu_navigation_region (GtkMenu *menu,
priv = gtk_menu_get_private (menu);
event_widget = gtk_get_event_widget ((GdkEvent*) event);
-
- gdk_window_get_origin (menu_item->submenu->window, &submenu_left, &submenu_top);
- gdk_drawable_get_size (menu_item->submenu->window, &width, &height);
-
+
+ window = gtk_widget_get_window (menu_item->submenu);
+ gdk_window_get_origin (window, &submenu_left, &submenu_top);
+ gdk_drawable_get_size (window, &width, &height);
+
submenu_right = submenu_left + width;
submenu_bottom = submenu_top + height;
-
- gdk_drawable_get_size (event_widget->window, &width, &height);
-
+
+ gdk_drawable_get_size (gtk_widget_get_window (event_widget),
+ &width, &height);
+
if (event->x >= 0 && event->x < width)
{
gint popdown_delay;
@@ -4347,11 +4413,12 @@ gtk_menu_position (GtkMenu *menu)
}
else
{
+ GtkStyle *style = gtk_widget_get_style (widget);
gint space_left, space_right, space_above, space_below;
gint needed_width;
gint needed_height;
- gint xthickness = widget->style->xthickness;
- gint ythickness = widget->style->ythickness;
+ gint xthickness = style->xthickness;
+ gint ythickness = style->ythickness;
gboolean rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
/* The placement of popup menus horizontally works like this (with
@@ -4467,7 +4534,8 @@ gtk_menu_position (GtkMenu *menu)
if (private->initially_pushed_in)
{
- menu_height = GTK_WIDGET (menu)->requisition.height;
+ gtk_widget_get_requisition (GTK_WIDGET (menu), &requisition);
+ menu_height = requisition.height;
if (y + menu_height > monitor.y + monitor.height)
{
@@ -4554,6 +4622,8 @@ static void
gtk_menu_scroll_to (GtkMenu *menu,
gint offset)
{
+ GtkAllocation allocation;
+ GtkRequisition requisition;
GtkWidget *widget;
gint x, y;
gint view_width, view_height;
@@ -4563,7 +4633,8 @@ gtk_menu_scroll_to (GtkMenu *menu,
guint horizontal_padding;
gboolean double_arrows;
GtkBorder arrow_border;
-
+ GtkStyle *style;
+
widget = GTK_WIDGET (menu);
if (menu->tearoff_active &&
@@ -4577,8 +4648,9 @@ gtk_menu_scroll_to (GtkMenu *menu,
}
/* Move/resize the viewport according to arrows: */
- view_width = widget->allocation.width;
- view_height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ view_width = allocation.width;
+ view_height = allocation.height;
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
@@ -4588,13 +4660,14 @@ gtk_menu_scroll_to (GtkMenu *menu,
double_arrows = get_double_arrows (menu);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
- view_width -= (border_width + widget->style->xthickness + horizontal_padding) * 2;
- view_height -= (border_width + widget->style->ythickness + vertical_padding) * 2;
- menu_height = widget->requisition.height -
- (border_width + widget->style->ythickness + vertical_padding) * 2;
+ style = gtk_widget_get_style (widget);
+ view_width -= (border_width + style->xthickness + horizontal_padding) * 2;
+ view_height -= (border_width + style->ythickness + vertical_padding) * 2;
+ gtk_widget_get_requisition (widget, &requisition);
+ menu_height = requisition.height - (border_width + style->ythickness + vertical_padding) * 2;
- x = border_width + widget->style->xthickness + horizontal_padding;
- y = border_width + widget->style->ythickness + vertical_padding;
+ x = border_width + style->xthickness + horizontal_padding;
+ y = border_width + style->ythickness + vertical_padding;
if (double_arrows && !menu->tearoff_active)
{
@@ -4768,14 +4841,13 @@ static void
gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
GtkWidget *menu_item)
{
- GtkMenu *menu;
+ GtkMenu *menu = GTK_MENU (menu_shell);
+ GtkWidget *widget = GTK_WIDGET (menu_shell);
gint child_offset, child_height;
gint width, height;
gint y;
gint arrow_height;
gboolean last_child = 0;
-
- menu = GTK_MENU (menu_shell);
/* We need to check if the selected item fully visible.
* If not we need to scroll the menu so that it becomes fully
@@ -4789,16 +4861,18 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
gboolean double_arrows;
y = menu->scroll_offset;
- gdk_drawable_get_size (GTK_WIDGET (menu)->window, &width, &height);
+ gdk_drawable_get_size (gtk_widget_get_window (widget),
+ &width, &height);
- gtk_widget_style_get (GTK_WIDGET (menu),
+ gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
NULL);
double_arrows = get_double_arrows (menu);
- height -= 2*gtk_container_get_border_width (GTK_CONTAINER (menu)) + 2*GTK_WIDGET (menu)->style->ythickness + 2*vertical_padding;
-
+ height -= 2 * gtk_container_get_border_width (GTK_CONTAINER (menu)) +
+ 2 * gtk_widget_get_style (widget)->ythickness +
+ 2 * vertical_padding;
if (child_offset < y)
{
/* Ignore the enter event we might get if the pointer is on the menu
@@ -4896,7 +4970,7 @@ gtk_menu_reparent (GtkMenu *menu,
if (unrealize)
{
g_object_ref (object);
- gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (widget)), widget);
gtk_container_add (GTK_CONTAINER (new_parent), widget);
g_object_unref (object);
}
@@ -4983,17 +5057,18 @@ gtk_menu_attach (GtkMenu *menu,
guint bottom_attach)
{
GtkMenuShell *menu_shell;
-
+ GtkWidget *parent;
+
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_MENU_ITEM (child));
- g_return_if_fail (child->parent == NULL ||
- child->parent == GTK_WIDGET (menu));
+ parent = gtk_widget_get_parent (child);
+ g_return_if_fail (parent == NULL || parent == GTK_WIDGET (menu));
g_return_if_fail (left_attach < right_attach);
g_return_if_fail (top_attach < bottom_attach);
menu_shell = GTK_MENU_SHELL (menu);
-
- if (!child->parent)
+
+ if (!parent)
{
AttachInfo *ai = get_attach_info (child);
@@ -5010,7 +5085,7 @@ gtk_menu_attach (GtkMenu *menu,
}
else
{
- gtk_container_child_set (GTK_CONTAINER (child->parent), child,
+ gtk_container_child_set (GTK_CONTAINER (parent), child,
"left-attach", left_attach,
"right-attach", right_attach,
"top-attach", top_attach,
@@ -5176,12 +5251,15 @@ gtk_menu_move_current (GtkMenuShell *menu_shell,
static gint
get_visible_size (GtkMenu *menu)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (menu);
GtkContainer *container = GTK_CONTAINER (menu);
-
- gint menu_height = (widget->allocation.height
- - 2 * (gtk_container_get_border_width (container)
- + widget->style->ythickness));
+ gint menu_height;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ menu_height = (allocation.height
+ - 2 * (gtk_container_get_border_width (container)
+ + gtk_widget_get_style (widget)->ythickness));
if (!menu->tearoff_active)
{
@@ -5242,11 +5320,13 @@ child_at (GtkMenu *menu,
static gint
get_menu_height (GtkMenu *menu)
{
- gint height;
+ GtkRequisition requisition;
GtkWidget *widget = GTK_WIDGET (menu);
+ gint height;
- height = widget->requisition.height;
- height -= gtk_container_get_border_width (GTK_CONTAINER (widget) + widget->style->ythickness) * 2;
+ gtk_widget_get_requisition (widget, &requisition);
+ height = requisition.height;
+ height -= gtk_container_get_border_width (GTK_CONTAINER (widget) + gtk_widget_get_style (widget)->ythickness) * 2;
if (!menu->tearoff_active)
{
diff --git a/gtk/gtkmenubar.c b/gtk/gtkmenubar.c
index a34d1d3..91338d4 100644
--- a/gtk/gtkmenubar.c
+++ b/gtk/gtkmenubar.c
@@ -345,8 +345,11 @@ gtk_menu_bar_size_request (GtkWidget *widget,
if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
{
- requisition->width += widget->style->xthickness * 2;
- requisition->height += widget->style->ythickness * 2;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ requisition->width += style->xthickness * 2;
+ requisition->height += style->ythickness * 2;
}
}
}
@@ -377,9 +380,10 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
direction = gtk_widget_get_direction (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
+
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
@@ -396,8 +400,11 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
{
- child_allocation.x += widget->style->xthickness;
- child_allocation.y += widget->style->ythickness;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ child_allocation.x += style->xthickness;
+ child_allocation.y += style->ythickness;
}
if (priv->pack_direction == GTK_PACK_DIRECTION_LTR ||
@@ -512,18 +519,20 @@ gtk_menu_bar_paint (GtkWidget *widget,
if (gtk_widget_is_drawable (widget))
{
+ GtkAllocation allocation;
guint border;
border = gtk_container_get_border_width (GTK_CONTAINER (widget));
-
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gtk_paint_box (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
get_shadow_type (GTK_MENU_BAR (widget)),
area, widget, "menubar",
border, border,
- widget->allocation.width - border * 2,
- widget->allocation.height - border * 2);
+ allocation.width - border * 2,
+ allocation.height - border * 2);
}
}
@@ -567,8 +576,8 @@ get_viewable_menu_bars (GtkWindow *window)
{
if (!gtk_widget_get_mapped (widget))
viewable = FALSE;
-
- widget = widget->parent;
+
+ widget = gtk_widget_get_parent (widget);
}
if (viewable)
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index ded538c..e32282c 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -590,14 +590,15 @@ gtk_menu_item_buildable_custom_finished (GtkBuildable *buildable,
if (strcmp (tagname, "accelerator") == 0)
{
- GtkMenuShell *menu_shell = (GtkMenuShell *) GTK_WIDGET (buildable)->parent;
+ GtkMenuShell *menu_shell;
GtkWidget *attach;
+ menu_shell = GTK_MENU_SHELL (gtk_widget_get_parent (GTK_WIDGET (buildable)));
if (menu_shell)
{
while (GTK_IS_MENU (menu_shell) &&
(attach = gtk_menu_get_attach_widget (GTK_MENU (menu_shell))) != NULL)
- menu_shell = (GtkMenuShell *)attach->parent;
+ menu_shell = GTK_MENU_SHELL (gtk_widget_get_parent (attach));
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (menu_shell));
}
@@ -786,7 +787,7 @@ gtk_menu_item_set_submenu (GtkMenuItem *menu_item,
gtk_menu_item_detacher);
}
- if (GTK_WIDGET (menu_item)->parent)
+ if (gtk_widget_get_parent (GTK_WIDGET (menu_item)))
gtk_widget_queue_resize (GTK_WIDGET (menu_item));
g_object_notify (G_OBJECT (menu_item), "submenu");
@@ -825,6 +826,8 @@ _gtk_menu_item_set_placement (GtkMenuItem *menu_item,
void
gtk_menu_item_select (GtkMenuItem *menu_item)
{
+ GtkWidget *parent;
+
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
gtk_item_select (GTK_ITEM (menu_item));
@@ -832,9 +835,10 @@ gtk_menu_item_select (GtkMenuItem *menu_item)
/* Enable themeing of the parent menu item depending on whether
* something is selected in its submenu
*/
- if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent))
+ parent = gtk_widget_get_parent (GTK_WIDGET (menu_item));
+ if (GTK_IS_MENU (parent))
{
- GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent);
+ GtkMenu *menu = GTK_MENU (parent);
if (menu->parent_menu_item)
gtk_widget_queue_draw (GTK_WIDGET (menu->parent_menu_item));
@@ -844,6 +848,8 @@ gtk_menu_item_select (GtkMenuItem *menu_item)
void
gtk_menu_item_deselect (GtkMenuItem *menu_item)
{
+ GtkWidget *parent;
+
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
gtk_item_deselect (GTK_ITEM (menu_item));
@@ -851,9 +857,10 @@ gtk_menu_item_deselect (GtkMenuItem *menu_item)
/* Enable themeing of the parent menu item depending on whether
* something is selected in its submenu
*/
- if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent))
+ parent = gtk_widget_get_parent (GTK_WIDGET (menu_item));
+ if (GTK_IS_MENU (parent))
{
- GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent);
+ GtkMenu *menu = GTK_MENU (parent);
if (menu->parent_menu_item)
gtk_widget_queue_draw (GTK_WIDGET (menu->parent_menu_item));
@@ -915,7 +922,7 @@ get_minimum_width (GtkWidget *widget)
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context,
- widget->style->font_desc,
+ gtk_widget_get_style (widget)->font_desc,
pango_context_get_language (context));
width = pango_font_metrics_get_approximate_char_width (metrics);
@@ -933,7 +940,9 @@ gtk_menu_item_size_request (GtkWidget *widget,
{
GtkMenuItem *menu_item;
GtkBin *bin;
+ GtkStyle *style;
GtkWidget *child;
+ GtkWidget *parent;
guint accel_width;
guint horizontal_padding;
guint border_width;
@@ -943,6 +952,7 @@ gtk_menu_item_size_request (GtkWidget *widget,
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
g_return_if_fail (requisition != NULL);
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
@@ -950,10 +960,11 @@ gtk_menu_item_size_request (GtkWidget *widget,
bin = GTK_BIN (widget);
menu_item = GTK_MENU_ITEM (widget);
- if (GTK_IS_MENU_BAR (widget->parent))
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU_BAR (parent))
{
- pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (widget->parent));
- child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent));
+ pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
+ child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
@@ -962,8 +973,8 @@ gtk_menu_item_size_request (GtkWidget *widget,
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- requisition->width = (border_width + widget->style->xthickness) * 2;
- requisition->height = (border_width + widget->style->ythickness) * 2;
+ requisition->width = (border_width + style->xthickness) * 2;
+ requisition->height = (border_width + style->ythickness) * 2;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
@@ -1008,9 +1019,9 @@ gtk_menu_item_size_request (GtkWidget *widget,
NULL);
if (wide_separators)
- requisition->height += separator_height + widget->style->ythickness;
+ requisition->height += separator_height + style->ythickness;
else
- requisition->height += widget->style->ythickness * 2;
+ requisition->height += style->ythickness * 2;
}
accel_width = 0;
@@ -1031,6 +1042,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
GtkWidget *child;
+ GtkWidget *parent;
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
g_return_if_fail (allocation != NULL);
@@ -1040,33 +1052,36 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
direction = gtk_widget_get_direction (widget);
- if (GTK_IS_MENU_BAR (widget->parent))
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU_BAR (parent))
{
- pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (widget->parent));
- child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (widget->parent));
+ pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
+ child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
pack_dir = GTK_PACK_DIRECTION_LTR;
child_pack_dir = GTK_PACK_DIRECTION_LTR;
}
-
- widget->allocation = *allocation;
+
+ gtk_widget_set_allocation (widget, allocation);
child = gtk_bin_get_child (bin);
if (child)
{
GtkRequisition child_requisition;
+ GtkStyle *style;
guint horizontal_padding;
guint border_width;
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- child_allocation.x = border_width + widget->style->xthickness;
- child_allocation.y = border_width + widget->style->ythickness;
+ child_allocation.x = border_width + style->xthickness;
+ child_allocation.y = border_width + style->ythickness;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
@@ -1074,7 +1089,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
else if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))
child_allocation.y += horizontal_padding;
-
+
child_allocation.width = MAX (1, (gint)allocation->width - child_allocation.x * 2);
child_allocation.height = MAX (1, (gint)allocation->height - child_allocation.y * 2);
@@ -1092,8 +1107,8 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
child_allocation.height -= GTK_MENU_ITEM (widget)->toggle_size;
}
- child_allocation.x += widget->allocation.x;
- child_allocation.y += widget->allocation.y;
+ child_allocation.x += allocation->x;
+ child_allocation.y += allocation->y;
gtk_widget_get_child_requisition (child, &child_requisition);
if (menu_item->submenu && menu_item->show_submenu_indicator)
@@ -1121,19 +1136,24 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
static void
gtk_menu_item_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
-
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, window);
+ g_object_ref (window);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = (gtk_widget_get_events (widget) |
@@ -1144,10 +1164,12 @@ gtk_menu_item_realize (GtkWidget *widget)
GDK_POINTER_MOTION_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
- menu_item->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
+
+ menu_item->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
gdk_window_set_user_data (menu_item->event_window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
}
static void
@@ -1186,10 +1208,13 @@ static void
gtk_menu_item_paint (GtkWidget *widget,
GdkRectangle *area)
{
+ GtkAllocation allocation;
GtkMenuItem *menu_item;
GtkStateType state_type;
GtkShadowType shadow_type, selected_shadow_type;
+ GtkStyle *style;
GtkWidget *child;
+ GdkWindow *window;
gint width, height;
gint x, y;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -1198,12 +1223,15 @@ gtk_menu_item_paint (GtkWidget *widget,
{
menu_item = GTK_MENU_ITEM (widget);
- state_type = widget->state;
-
- 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);
+ state_type = gtk_widget_get_state (widget);
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
+ x = allocation.x + border_width;
+ y = allocation.y + border_width;
+ width = allocation.width - border_width * 2;
+ height = allocation.height - border_width * 2;
child = gtk_bin_get_child (GTK_BIN (menu_item));
@@ -1212,8 +1240,8 @@ gtk_menu_item_paint (GtkWidget *widget,
gtk_widget_style_get (widget,
"selected-shadow-type", &selected_shadow_type,
NULL);
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style,
+ window,
GTK_STATE_PRELIGHT,
selected_shadow_type,
area, widget, "menuitem",
@@ -1241,7 +1269,7 @@ gtk_menu_item_paint (GtkWidget *widget,
context = gtk_widget_get_pango_context (child);
metrics = pango_context_get_metrics (context,
- child->style->font_desc,
+ gtk_widget_get_style (child)->font_desc,
pango_context_get_language (context));
arrow_size = (PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
@@ -1268,7 +1296,7 @@ gtk_menu_item_paint (GtkWidget *widget,
arrow_y = y + (height - arrow_extent) / 2;
- gtk_paint_arrow (widget->style, widget->window,
+ gtk_paint_arrow (style, window,
state_type, shadow_type,
area, widget, "menuitem",
arrow_type, TRUE,
@@ -1288,23 +1316,19 @@ gtk_menu_item_paint (GtkWidget *widget,
NULL);
if (wide_separators)
- gtk_paint_box (widget->style, widget->window,
+ gtk_paint_box (style, window,
GTK_STATE_NORMAL, GTK_SHADOW_ETCHED_OUT,
area, widget, "hseparator",
- widget->allocation.x + horizontal_padding + widget->style->xthickness,
- widget->allocation.y + (widget->allocation.height -
- separator_height -
- widget->style->ythickness) / 2,
- widget->allocation.width -
- 2 * (horizontal_padding + widget->style->xthickness),
+ allocation.x + horizontal_padding + style->xthickness,
+ allocation.y + (allocation.height - separator_height - style->ythickness) / 2,
+ allocation.width - 2 * (horizontal_padding + style->xthickness),
separator_height);
else
- gtk_paint_hline (widget->style, widget->window,
+ gtk_paint_hline (style, window,
GTK_STATE_NORMAL, area, widget, "menuitem",
- widget->allocation.x + horizontal_padding + widget->style->xthickness,
- widget->allocation.x + widget->allocation.width - horizontal_padding - widget->style->xthickness - 1,
- widget->allocation.y + (widget->allocation.height -
- widget->style->ythickness) / 2);
+ allocation.x + horizontal_padding + style->xthickness,
+ allocation.x + allocation.width - horizontal_padding - style->xthickness - 1,
+ allocation.y + (allocation.height - style->ythickness) / 2);
}
}
}
@@ -1372,15 +1396,19 @@ static gboolean
gtk_menu_item_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
- if (GTK_IS_MENU_SHELL (widget->parent))
- _gtk_menu_shell_set_keyboard_mode (GTK_MENU_SHELL (widget->parent), TRUE);
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+
+ if (GTK_IS_MENU_SHELL (parent))
+ _gtk_menu_shell_set_keyboard_mode (GTK_MENU_SHELL (parent), TRUE);
if (group_cycling &&
- widget->parent &&
- GTK_IS_MENU_SHELL (widget->parent) &&
- GTK_MENU_SHELL (widget->parent)->active)
+ parent &&
+ GTK_IS_MENU_SHELL (parent) &&
+ GTK_MENU_SHELL (parent)->active)
{
- gtk_menu_shell_select_item (GTK_MENU_SHELL (widget->parent),
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (parent),
widget);
}
else
@@ -1405,26 +1433,27 @@ static void
gtk_real_menu_item_activate_item (GtkMenuItem *menu_item)
{
GtkMenuItemPrivate *priv;
+ GtkWidget *parent;
GtkWidget *widget;
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
priv = GET_PRIVATE (menu_item);
widget = GTK_WIDGET (menu_item);
-
- if (widget->parent &&
- GTK_IS_MENU_SHELL (widget->parent))
+ parent = gtk_widget_get_parent (widget);
+
+ if (parent && GTK_IS_MENU_SHELL (parent))
{
+ GtkMenuShell *menu_shell = GTK_MENU_SHELL (parent);
+
if (menu_item->submenu == NULL)
- gtk_menu_shell_activate_item (GTK_MENU_SHELL (widget->parent),
+ gtk_menu_shell_activate_item (menu_shell,
widget, TRUE);
else
{
- GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget->parent);
-
_gtk_menu_shell_activate (menu_shell);
- gtk_menu_shell_select_item (GTK_MENU_SHELL (widget->parent), widget);
+ gtk_menu_shell_select_item (menu_shell, widget);
_gtk_menu_item_popup_submenu (widget, FALSE);
gtk_menu_shell_select_first (GTK_MENU_SHELL (menu_item->submenu), TRUE);
@@ -1492,13 +1521,16 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget,
gboolean remember_exact_time)
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
- if (gtk_widget_is_sensitive (menu_item->submenu) && widget->parent)
+ if (gtk_widget_is_sensitive (menu_item->submenu) && parent)
{
gboolean take_focus;
GtkMenuPositionFunc menu_position_func;
- take_focus = gtk_menu_shell_get_take_focus (GTK_MENU_SHELL (widget->parent));
+ take_focus = gtk_menu_shell_get_take_focus (GTK_MENU_SHELL (parent));
gtk_menu_shell_set_take_focus (GTK_MENU_SHELL (menu_item->submenu),
take_focus);
@@ -1524,17 +1556,17 @@ gtk_menu_item_real_popup_submenu (GtkWidget *widget,
* positioning function instead which places the submenu at the
* mouse cursor.
*/
- if (widget->window)
+ if (gtk_widget_get_window (widget))
menu_position_func = gtk_menu_item_position_menu;
else
menu_position_func = NULL;
gtk_menu_popup (GTK_MENU (menu_item->submenu),
- widget->parent,
+ parent,
widget,
menu_position_func,
menu_item,
- GTK_MENU_SHELL (widget->parent)->button,
+ GTK_MENU_SHELL (parent)->button,
0);
}
@@ -1552,7 +1584,7 @@ gtk_menu_item_popup_timeout (gpointer data)
menu_item = GTK_MENU_ITEM (data);
- parent = GTK_WIDGET (menu_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (menu_item));
if ((GTK_IS_MENU_SHELL (parent) && GTK_MENU_SHELL (parent)->active) ||
(GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off))
@@ -1570,9 +1602,12 @@ gtk_menu_item_popup_timeout (gpointer data)
static gint
get_popup_delay (GtkWidget *widget)
{
- if (GTK_IS_MENU_SHELL (widget->parent))
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU_SHELL (parent))
{
- return _gtk_menu_shell_get_popup_delay (GTK_MENU_SHELL (widget->parent));
+ return _gtk_menu_shell_get_popup_delay (GTK_MENU_SHELL (parent));
}
else
{
@@ -1667,7 +1702,7 @@ get_offsets (GtkMenu *menu,
"vertical-padding", &vertical_padding,
NULL);
- *vertical_offset -= GTK_WIDGET (menu)->style->ythickness;
+ *vertical_offset -= gtk_widget_get_style (GTK_WIDGET (menu))->ythickness;
*vertical_offset -= vertical_padding;
*horizontal_offset += horizontal_padding;
}
@@ -1679,9 +1714,12 @@ gtk_menu_item_position_menu (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkMenuItem *menu_item;
GtkWidget *widget;
GtkMenuItem *parent_menu_item;
+ GtkRequisition requisition;
+ GtkWidget *parent;
GdkScreen *screen;
gint twidth, theight;
gint tx, ty;
@@ -1705,8 +1743,9 @@ gtk_menu_item_position_menu (GtkMenu *menu,
direction = gtk_widget_get_direction (widget);
- twidth = GTK_WIDGET (menu)->requisition.width;
- theight = GTK_WIDGET (menu)->requisition.height;
+ gtk_widget_get_requisition (GTK_WIDGET (menu), &requisition);
+ twidth = requisition.width;
+ theight = requisition.height;
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
monitor_num = gdk_screen_get_monitor_at_window (screen, menu_item->event_window);
@@ -1714,28 +1753,32 @@ gtk_menu_item_position_menu (GtkMenu *menu,
monitor_num = 0;
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- if (!gdk_window_get_origin (widget->window, &tx, &ty))
+ if (!gdk_window_get_origin (gtk_widget_get_window (widget),
+ &tx, &ty))
{
g_warning ("Menu not on screen");
return;
}
- tx += widget->allocation.x;
- ty += widget->allocation.y;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ tx += allocation.x;
+ ty += allocation.y;
get_offsets (menu, &horizontal_offset, &vertical_offset);
available_left = tx - monitor.x;
- available_right = monitor.x + monitor.width - (tx + widget->allocation.width);
+ available_right = monitor.x + monitor.width - (tx + allocation.width);
- if (GTK_IS_MENU_BAR (widget->parent))
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU_BAR (parent))
{
menu_item->from_menubar = TRUE;
}
- else if (GTK_IS_MENU (widget->parent))
+ else if (GTK_IS_MENU (parent))
{
- if (GTK_MENU (widget->parent)->parent_menu_item)
- menu_item->from_menubar = GTK_MENU_ITEM (GTK_MENU (widget->parent)->parent_menu_item)->from_menubar;
+ if (GTK_MENU (parent)->parent_menu_item)
+ menu_item->from_menubar = GTK_MENU_ITEM (GTK_MENU (parent)->parent_menu_item)->from_menubar;
else
menu_item->from_menubar = FALSE;
}
@@ -1752,27 +1795,27 @@ gtk_menu_item_position_menu (GtkMenu *menu,
else
{
menu_item->submenu_direction = GTK_DIRECTION_LEFT;
- tx += widget->allocation.width - twidth;
+ tx += allocation.width - twidth;
}
- if ((ty + widget->allocation.height + theight) <= monitor.y + monitor.height)
- ty += widget->allocation.height;
+ if ((ty + allocation.height + theight) <= monitor.y + monitor.height)
+ ty += allocation.height;
else if ((ty - theight) >= monitor.y)
ty -= theight;
- else if (monitor.y + monitor.height - (ty + widget->allocation.height) > ty)
- ty += widget->allocation.height;
+ else if (monitor.y + monitor.height - (ty + allocation.height) > ty)
+ ty += allocation.height;
else
ty -= theight;
break;
case GTK_LEFT_RIGHT:
- if (GTK_IS_MENU (widget->parent))
- parent_menu_item = GTK_MENU_ITEM (GTK_MENU (widget->parent)->parent_menu_item);
+ if (GTK_IS_MENU (parent))
+ parent_menu_item = GTK_MENU_ITEM (GTK_MENU (parent)->parent_menu_item);
else
parent_menu_item = NULL;
-
- parent_xthickness = widget->parent->style->xthickness;
- if (parent_menu_item && !GTK_MENU (widget->parent)->torn_off)
+ parent_xthickness = gtk_widget_get_style (parent)->xthickness;
+
+ if (parent_menu_item && !GTK_MENU (parent)->torn_off)
{
menu_item->submenu_direction = parent_menu_item->submenu_direction;
}
@@ -1793,14 +1836,14 @@ gtk_menu_item_position_menu (GtkMenu *menu,
else
{
menu_item->submenu_direction = GTK_DIRECTION_RIGHT;
- tx += widget->allocation.width + parent_xthickness + horizontal_offset;
+ tx += allocation.width + parent_xthickness + horizontal_offset;
}
break;
case GTK_DIRECTION_RIGHT:
- if (tx + widget->allocation.width + parent_xthickness + horizontal_offset + twidth <= monitor.x + monitor.width ||
+ if (tx + allocation.width + parent_xthickness + horizontal_offset + twidth <= monitor.x + monitor.width ||
available_right >= available_left)
- tx += widget->allocation.width + parent_xthickness + horizontal_offset;
+ tx += allocation.width + parent_xthickness + horizontal_offset;
else
{
menu_item->submenu_direction = GTK_DIRECTION_LEFT;
@@ -1915,9 +1958,12 @@ static gboolean
gtk_menu_item_can_activate_accel (GtkWidget *widget,
guint signal_id)
{
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
/* Chain to the parent GtkMenu for further checks */
return (gtk_widget_is_sensitive (widget) && gtk_widget_get_visible (widget) &&
- widget->parent && gtk_widget_can_activate_accel (widget->parent, signal_id));
+ parent && gtk_widget_can_activate_accel (parent, signal_id));
}
static void
@@ -1946,7 +1992,11 @@ gtk_menu_item_parent_set (GtkWidget *widget,
GtkWidget *previous_parent)
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (widget);
- GtkMenu *menu = GTK_IS_MENU (widget->parent) ? GTK_MENU (widget->parent) : NULL;
+ GtkMenu *menu;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+ menu = GTK_IS_MENU (parent) ? GTK_MENU (parent) : NULL;
if (menu)
_gtk_menu_item_refresh_accel_path (menu_item,
@@ -2034,6 +2084,7 @@ void
gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,
const gchar *accel_path)
{
+ GtkWidget *parent;
GtkWidget *widget;
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
@@ -2049,9 +2100,10 @@ gtk_menu_item_set_accel_path (GtkMenuItem *menu_item,
gtk_widget_set_accel_path (widget, NULL, NULL);
/* install accelerators associated with new path */
- if (GTK_IS_MENU (widget->parent))
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU (parent))
{
- GtkMenu *menu = GTK_MENU (widget->parent);
+ GtkMenu *menu = GTK_MENU (parent);
if (menu->accel_group)
_gtk_menu_item_refresh_accel_path (GTK_MENU_ITEM (widget),
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index 3fb8ee6..b071de2 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -515,15 +515,19 @@ gtk_menu_shell_deactivate (GtkMenuShell *menu_shell)
static void
gtk_menu_shell_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -537,11 +541,14 @@ gtk_menu_shell_realize (GtkWidget *widget)
GDK_LEAVE_NOTIFY_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL);
}
void
@@ -567,6 +574,7 @@ gtk_menu_shell_button_press (GtkWidget *widget,
{
GtkMenuShell *menu_shell;
GtkWidget *menu_item;
+ GtkWidget *parent;
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
@@ -577,9 +585,10 @@ gtk_menu_shell_button_press (GtkWidget *widget,
return gtk_widget_event (menu_shell->parent_menu_shell, (GdkEvent*) event);
menu_item = gtk_menu_shell_get_item (menu_shell, (GdkEvent *)event);
+ parent = gtk_widget_get_parent (menu_item);
if (menu_item && _gtk_menu_item_is_selectable (menu_item) &&
- menu_item != GTK_MENU_SHELL (menu_item->parent)->active_menu_item)
+ menu_item != GTK_MENU_SHELL (parent)->active_menu_item)
{
/* select the menu item *before* activating the shell, so submenus
* which might be open are closed the friendly way. If we activate
@@ -588,9 +597,9 @@ gtk_menu_shell_button_press (GtkWidget *widget,
* menu item also fixes up the state as if enter_notify() would
* have run before (which normally selects the item).
*/
- if (GTK_MENU_SHELL_GET_CLASS (menu_item->parent)->submenu_placement != GTK_TOP_BOTTOM)
+ if (GTK_MENU_SHELL_GET_CLASS (parent)->submenu_placement != GTK_TOP_BOTTOM)
{
- gtk_menu_shell_select_item (GTK_MENU_SHELL (menu_item->parent), menu_item);
+ gtk_menu_shell_select_item (GTK_MENU_SHELL (parent), menu_item);
}
}
@@ -603,7 +612,7 @@ gtk_menu_shell_button_press (GtkWidget *widget,
if (menu_item)
{
if (_gtk_menu_item_is_selectable (menu_item) &&
- menu_item->parent == widget &&
+ parent == widget &&
menu_item != menu_shell->active_menu_item)
{
_gtk_menu_shell_activate (menu_shell);
@@ -656,7 +665,7 @@ gtk_menu_shell_button_press (GtkWidget *widget,
_gtk_menu_item_popup_submenu (menu_item, FALSE);
- priv = GTK_MENU_SHELL_GET_PRIVATE (menu_item->parent);
+ priv = GTK_MENU_SHELL_GET_PRIVATE (parent);
priv->activated_submenu = TRUE;
}
@@ -927,6 +936,7 @@ gtk_menu_shell_enter_notify (GtkWidget *widget,
if (menu_shell->active)
{
GtkWidget *menu_item;
+ GtkWidget *parent;
menu_item = gtk_get_event_widget ((GdkEvent*) event);
@@ -944,7 +954,8 @@ gtk_menu_shell_enter_notify (GtkWidget *widget,
return TRUE;
}
- if (menu_item->parent == widget &&
+ parent = gtk_widget_get_parent (menu_item);
+ if (parent == widget &&
GTK_IS_MENU_ITEM (menu_item))
{
if (menu_shell->ignore_enter)
@@ -968,7 +979,7 @@ gtk_menu_shell_enter_notify (GtkWidget *widget,
{
GtkMenuShellPrivate *priv;
- priv = GTK_MENU_SHELL_GET_PRIVATE (menu_item->parent);
+ priv = GTK_MENU_SHELL_GET_PRIVATE (parent);
priv->activated_submenu = TRUE;
if (!gtk_widget_get_visible (GTK_MENU_ITEM (menu_item)->submenu))
@@ -1153,7 +1164,7 @@ gtk_menu_shell_is_item (GtkMenuShell *menu_shell,
g_return_val_if_fail (GTK_IS_MENU_SHELL (menu_shell), FALSE);
g_return_val_if_fail (child != NULL, FALSE);
- parent = child->parent;
+ parent = gtk_widget_get_parent (child);
while (GTK_IS_MENU_SHELL (parent))
{
if (parent == (GtkWidget*) menu_shell)
@@ -1173,7 +1184,7 @@ gtk_menu_shell_get_item (GtkMenuShell *menu_shell,
menu_item = gtk_get_event_widget ((GdkEvent*) event);
while (menu_item && !GTK_IS_MENU_ITEM (menu_item))
- menu_item = menu_item->parent;
+ menu_item = gtk_widget_get_parent (menu_item);
if (menu_item && gtk_menu_shell_is_item (menu_shell, menu_item))
return menu_item;
diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c
index 9e8cfc4..4cd7a13 100644
--- a/gtk/gtkmenutoolbutton.c
+++ b/gtk/gtkmenutoolbutton.c
@@ -67,6 +67,7 @@ gtk_menu_tool_button_construct_contents (GtkMenuToolButton *button)
{
GtkMenuToolButtonPrivate *priv = button->priv;
GtkWidget *box;
+ GtkWidget *parent;
GtkOrientation orientation;
orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
@@ -82,19 +83,21 @@ gtk_menu_tool_button_construct_contents (GtkMenuToolButton *button)
gtk_arrow_set (GTK_ARROW (priv->arrow), GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
}
- if (priv->button && priv->button->parent)
+ parent = gtk_widget_get_parent (priv->button);
+ if (priv->button && parent)
{
g_object_ref (priv->button);
- gtk_container_remove (GTK_CONTAINER (priv->button->parent),
+ gtk_container_remove (GTK_CONTAINER (parent),
priv->button);
gtk_container_add (GTK_CONTAINER (box), priv->button);
g_object_unref (priv->button);
}
- if (priv->arrow_button && priv->arrow_button->parent)
+ parent = gtk_widget_get_parent (priv->arrow_button);
+ if (priv->arrow_button && parent)
{
g_object_ref (priv->arrow_button);
- gtk_container_remove (GTK_CONTAINER (priv->arrow_button->parent),
+ gtk_container_remove (GTK_CONTAINER (parent),
priv->arrow_button);
gtk_box_pack_end (GTK_BOX (box), priv->arrow_button,
FALSE, FALSE, 0);
@@ -253,6 +256,7 @@ menu_position_func (GtkMenu *menu,
GtkMenuToolButton *button)
{
GtkMenuToolButtonPrivate *priv = button->priv;
+ GtkAllocation arrow_allocation;
GtkWidget *widget = GTK_WIDGET (button);
GtkRequisition req;
GtkRequisition menu_req;
@@ -261,35 +265,43 @@ menu_position_func (GtkMenu *menu,
GdkRectangle monitor;
gint monitor_num;
GdkScreen *screen;
+ GdkWindow *window;
gtk_widget_size_request (GTK_WIDGET (priv->menu), &menu_req);
orientation = gtk_tool_item_get_orientation (GTK_TOOL_ITEM (button));
direction = gtk_widget_get_direction (widget);
+ window = gtk_widget_get_window (widget);
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+ monitor_num = gdk_screen_get_monitor_at_window (screen, window);
if (monitor_num < 0)
monitor_num = 0;
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ gtk_widget_get_allocation (priv->arrow_button, &arrow_allocation);
+
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gdk_window_get_origin (widget->window, x, y);
- *x += widget->allocation.x;
- *y += widget->allocation.y;
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gdk_window_get_origin (window, x, y);
+ *x += allocation.x;
+ *y += allocation.y;
if (direction == GTK_TEXT_DIR_LTR)
- *x += MAX (widget->allocation.width - menu_req.width, 0);
- else if (menu_req.width > widget->allocation.width)
- *x -= menu_req.width - widget->allocation.width;
+ *x += MAX (allocation.width - menu_req.width, 0);
+ else if (menu_req.width > allocation.width)
+ *x -= menu_req.width - allocation.width;
- if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height)
- *y += priv->arrow_button->allocation.height;
+ if ((*y + arrow_allocation.height + menu_req.height) <= monitor.y + monitor.height)
+ *y += arrow_allocation.height;
else if ((*y - menu_req.height) >= monitor.y)
*y -= menu_req.height;
- else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y)
- *y += priv->arrow_button->allocation.height;
+ else if (monitor.y + monitor.height - (*y + arrow_allocation.height) > *y)
+ *y += arrow_allocation.height;
else
*y -= menu_req.height;
}
@@ -299,13 +311,13 @@ menu_position_func (GtkMenu *menu,
gtk_widget_size_request (priv->arrow_button, &req);
if (direction == GTK_TEXT_DIR_LTR)
- *x += priv->arrow_button->allocation.width;
+ *x += arrow_allocation.width;
else
*x -= menu_req.width;
if (*y + menu_req.height > monitor.y + monitor.height &&
- *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y)
- *y += priv->arrow_button->allocation.height - menu_req.height;
+ *y + arrow_allocation.height - monitor.y > monitor.y + monitor.height - *y)
+ *y += arrow_allocation.height - menu_req.height;
}
*push_in = FALSE;
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index 9220efc..e68f89f 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -402,7 +402,7 @@ setup_primary_label_font (GtkMessageDialog *dialog)
if (priv->has_secondary_text && !priv->has_primary_markup)
{
- size = pango_font_description_get_size (priv->label->style->font_desc);
+ size = pango_font_description_get_size (gtk_widget_get_style (priv->label)->font_desc);
font_desc = pango_font_description_new ();
pango_font_description_set_weight (font_desc, PANGO_WEIGHT_BOLD);
pango_font_description_set_size (font_desc, size * PANGO_SCALE_LARGE);
@@ -745,7 +745,7 @@ gtk_message_dialog_set_image (GtkMessageDialog *dialog,
priv->message_type = GTK_MESSAGE_OTHER;
- parent = priv->image->parent;
+ parent = gtk_widget_get_parent (priv->image);
gtk_container_add (GTK_CONTAINER (parent), image);
gtk_container_remove (GTK_CONTAINER (parent), priv->image);
gtk_box_reorder_child (GTK_BOX (parent), image, 0);
@@ -1005,7 +1005,7 @@ gtk_message_dialog_style_set (GtkWidget *widget,
GtkWidget *parent;
gint border_width;
- parent = gtk_message_dialog_get_image (GTK_MESSAGE_DIALOG (widget))->parent;
+ parent = gtk_widget_get_parent (gtk_message_dialog_get_image (dialog));
if (parent)
{
diff --git a/gtk/gtkmisc.c b/gtk/gtkmisc.c
index 67bae4b..819fea4 100644
--- a/gtk/gtkmisc.c
+++ b/gtk/gtkmisc.c
@@ -335,6 +335,8 @@ gtk_misc_get_padding (GtkMisc *misc,
static void
gtk_misc_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -342,27 +344,32 @@ gtk_misc_realize (GtkWidget *widget)
if (!gtk_widget_get_has_window (widget))
{
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, window);
+ g_object_ref (window);
+
+ gtk_widget_style_attach (widget);
}
else
{
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
+ gtk_widget_style_attach (widget);
+ gdk_window_set_back_pixmap (window, NULL, TRUE);
}
}
diff --git a/gtk/gtkmnemonichash.c b/gtk/gtkmnemonichash.c
index 6f85d04..37ee016 100644
--- a/gtk/gtkmnemonichash.c
+++ b/gtk/gtkmnemonichash.c
@@ -113,6 +113,7 @@ _gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash,
{
GSList *list, *targets;
GtkWidget *widget, *chosen_widget;
+ GdkWindow *window;
gboolean overloaded;
targets = g_hash_table_lookup (mnemonic_hash->hash,
@@ -125,11 +126,11 @@ _gtk_mnemonic_hash_activate (GtkMnemonicHash *mnemonic_hash,
for (list = targets; list; list = list->next)
{
widget = GTK_WIDGET (list->data);
-
+ window = gtk_widget_get_window (widget);
+
if (gtk_widget_is_sensitive (widget) &&
gtk_widget_get_mapped (widget) &&
- widget->window &&
- gdk_window_is_viewable (widget->window))
+ window && gdk_window_is_viewable (window))
{
if (chosen_widget)
{
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 44d1c9a..f0c0d36 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,42 +1846,46 @@ 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;
+ _gtk_widget_set_requisition (widget, &widget_requisition);
for (children = priv->children, vis_pages = 0; children;
children = children->next)
{
page = children->data;
+ parent = gtk_widget_get_parent (page->menu_label);
+
if (gtk_widget_get_visible (page->child))
{
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);
+
+ gtk_widget_get_requisition (widget, &widget_requisition);
+ widget_requisition.width = MAX (widget_requisition.width, child_requisition.width);
+ widget_requisition.height = MAX (widget_requisition.height, child_requisition.height);
+ _gtk_widget_set_requisition (widget, &widget_requisition);
+
+ 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 (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;
+ _gtk_widget_set_requisition (widget, &widget_requisition);
if (priv->show_tabs)
{
@@ -1893,12 +1910,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 +1944,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;
}
}
@@ -1943,8 +1956,9 @@ gtk_notebook_size_request (GtkWidget *widget,
if (tab_height == 0)
break;
+ gtk_widget_get_requisition (widget, &widget_requisition);
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);
@@ -1970,29 +1984,33 @@ gtk_notebook_size_request (GtkWidget *widget,
page->requisition.height = tab_height;
}
+ gtk_widget_get_requisition (widget, &widget_requisition);
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;
+
+ gtk_widget_get_requisition (widget, &widget_requisition);
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;
+ _gtk_widget_set_requisition (widget, &widget_requisition);
break;
case GTK_POS_LEFT:
case GTK_POS_RIGHT:
if (tab_width == 0)
break;
+ gtk_widget_get_requisition (widget, &widget_requisition);
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 +2040,28 @@ 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);
+ _gtk_widget_set_requisition (widget, &widget_requisition);
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;
+ gtk_widget_get_requisition (widget, &widget_requisition);
+ widget_requisition.height = MAX (widget_requisition.height,
+ vis_pages * tab_max + tab_overlap);
+ widget_requisition.width += tab_width;
+ _gtk_widget_set_requisition (widget, &widget_requisition);
break;
}
}
@@ -2062,8 +2081,9 @@ 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;
+ _gtk_widget_set_requisition (widget, &widget_requisition);
if (switch_page)
{
@@ -2082,8 +2102,9 @@ 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;
+ _gtk_widget_set_requisition (widget, &widget_requisition);
}
}
if (vis_pages && !priv->cur_page)
@@ -2108,8 +2129,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 +2150,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 +2200,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 +2280,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, >k_widget_get_style (widget)->bg [GTK_STATE_NORMAL]);
cairo_paint (cr);
cairo_destroy (cr);
@@ -2283,7 +2309,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 +2531,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 +2697,7 @@ popup_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer data)
{
+ GtkAllocation allocation;
GtkNotebook *notebook = data;
GtkNotebookPriv *priv = notebook->priv;
GtkWidget *w;
@@ -2688,15 +2715,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 +2881,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 +3147,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 +3275,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 +3283,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 +3486,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 +3495,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 +3539,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 +3617,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 +3647,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 +4181,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 +4195,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 +4213,7 @@ gtk_notebook_set_focus_child (GtkContainer *container,
}
}
- page_child = page_child->parent;
+ page_child = parent;
}
}
@@ -4393,59 +4434,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 +4518,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 +4673,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 +4847,7 @@ static void
gtk_notebook_paint (GtkWidget *widget,
GdkRectangle *area)
{
+ GtkAllocation allocation;
GtkNotebook *notebook;
GtkNotebookPriv *priv;
GtkNotebookPage *page;
@@ -4824,14 +4872,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 +4926,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 +4936,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 +5005,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 +5021,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 +5095,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 +5122,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 +5139,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 +5184,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 +5521,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 +5541,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 +5564,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 +5901,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 +5922,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 +5986,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 +6287,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 +7410,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 +7498,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 +7915,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;
diff --git a/gtk/gtkoffscreenwindow.c b/gtk/gtkoffscreenwindow.c
index 1c51abe..bdd29c6 100644
--- a/gtk/gtkoffscreenwindow.c
+++ b/gtk/gtkoffscreenwindow.c
@@ -92,12 +92,12 @@ gtk_offscreen_window_size_allocate (GtkWidget *widget,
GtkWidget *child;
gint border_width;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x,
allocation->y,
allocation->width,
@@ -123,8 +123,10 @@ gtk_offscreen_window_size_allocate (GtkWidget *widget,
static void
gtk_offscreen_window_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkBin *bin;
GtkWidget *child;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
@@ -135,10 +137,12 @@ gtk_offscreen_window_realize (GtkWidget *widget)
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.window_type = GDK_WINDOW_OFFSCREEN;
attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
attributes.visual = gtk_widget_get_visual (widget);
@@ -147,17 +151,18 @@ gtk_offscreen_window_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
child = gtk_bin_get_child (bin);
if (child)
- gtk_widget_set_parent_window (child, widget->window);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_set_parent_window (child, window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window, GTK_STATE_NORMAL);
}
static void
@@ -280,7 +285,7 @@ gtk_offscreen_window_get_pixmap (GtkOffscreenWindow *offscreen)
{
g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
- return gdk_offscreen_window_get_pixmap (GTK_WIDGET (offscreen)->window);
+ return gdk_offscreen_window_get_pixmap (gtk_widget_get_window (GTK_WIDGET (offscreen)));
}
/**
@@ -304,7 +309,7 @@ gtk_offscreen_window_get_pixbuf (GtkOffscreenWindow *offscreen)
g_return_val_if_fail (GTK_IS_OFFSCREEN_WINDOW (offscreen), NULL);
- pixmap = gdk_offscreen_window_get_pixmap (GTK_WIDGET (offscreen)->window);
+ pixmap = gdk_offscreen_window_get_pixmap (gtk_widget_get_window (GTK_WIDGET (offscreen)));
if (pixmap != NULL)
{
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index c03d6e8..65a8628 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -648,7 +648,7 @@ gtk_paned_set_property (GObject *object,
priv->cursor_type = GDK_SB_V_DOUBLE_ARROW;
/* state_changed updates the cursor */
- gtk_paned_state_changed (GTK_WIDGET (paned), GTK_WIDGET (paned)->state);
+ gtk_paned_state_changed (GTK_WIDGET (paned), gtk_widget_get_state (GTK_WIDGET (paned)));
gtk_widget_queue_resize (GTK_WIDGET (paned));
break;
case PROP_POSITION:
@@ -848,8 +848,12 @@ static void
flip_child (GtkWidget *widget,
GtkAllocation *child_pos)
{
- gint x = widget->allocation.x;
- gint width = widget->allocation.width;
+ GtkAllocation allocation;
+ gint x, width;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ x = allocation.x;
+ width = allocation.width;
child_pos->x = 2 * x + width - child_pos->x - child_pos->width;
}
@@ -860,11 +864,12 @@ gtk_paned_size_allocate (GtkWidget *widget,
{
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
+ GtkAllocation widget_allocation;
guint border_width;
border_width = gtk_container_get_border_width (GTK_CONTAINER (paned));
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
priv->child2 && gtk_widget_get_visible (priv->child2))
@@ -873,6 +878,7 @@ gtk_paned_size_allocate (GtkWidget *widget,
GtkRequisition child2_requisition;
GtkAllocation child1_allocation;
GtkAllocation child2_allocation;
+ GtkAllocation priv_child1_allocation;
GdkRectangle old_handle_pos;
gint handle_size;
@@ -883,27 +889,29 @@ gtk_paned_size_allocate (GtkWidget *widget,
old_handle_pos = priv->handle_pos;
+ gtk_widget_get_allocation (widget, &widget_allocation);
+
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
gtk_paned_calc_position (paned,
- MAX (1, widget->allocation.width
+ MAX (1, widget_allocation.width
- handle_size
- 2 * border_width),
child1_requisition.width,
child2_requisition.width);
- priv->handle_pos.x = widget->allocation.x + priv->child1_size + border_width;
- priv->handle_pos.y = widget->allocation.y + border_width;
+ priv->handle_pos.x = widget_allocation.x + priv->child1_size + border_width;
+ priv->handle_pos.y = widget_allocation.y + border_width;
priv->handle_pos.width = handle_size;
- priv->handle_pos.height = MAX (1, widget->allocation.height - 2 * border_width);
+ priv->handle_pos.height = MAX (1, widget_allocation.height - 2 * border_width);
child1_allocation.height = child2_allocation.height = MAX (1, (gint) allocation->height - border_width * 2);
child1_allocation.width = MAX (1, priv->child1_size);
- child1_allocation.x = widget->allocation.x + border_width;
- child1_allocation.y = child2_allocation.y = widget->allocation.y + border_width;
+ child1_allocation.x = widget_allocation.x + border_width;
+ child1_allocation.y = child2_allocation.y = widget_allocation.y + border_width;
child2_allocation.x = child1_allocation.x + priv->child1_size + priv->handle_pos.width;
- child2_allocation.width = MAX (1, widget->allocation.x + widget->allocation.width - child2_allocation.x - border_width);
+ child2_allocation.width = MAX (1, widget_allocation.x + widget_allocation.width - child2_allocation.x - border_width);
if (gtk_widget_get_direction (GTK_WIDGET (widget)) == GTK_TEXT_DIR_RTL)
{
@@ -915,24 +923,24 @@ gtk_paned_size_allocate (GtkWidget *widget,
else
{
gtk_paned_calc_position (paned,
- MAX (1, widget->allocation.height
+ MAX (1, widget_allocation.height
- handle_size
- 2 * border_width),
child1_requisition.height,
child2_requisition.height);
- priv->handle_pos.x = widget->allocation.x + border_width;
- priv->handle_pos.y = widget->allocation.y + priv->child1_size + border_width;
- priv->handle_pos.width = MAX (1, (gint) widget->allocation.width - 2 * border_width);
+ priv->handle_pos.x = widget_allocation.x + border_width;
+ priv->handle_pos.y = widget_allocation.y + priv->child1_size + border_width;
+ priv->handle_pos.width = MAX (1, (gint) widget_allocation.width - 2 * border_width);
priv->handle_pos.height = handle_size;
child1_allocation.width = child2_allocation.width = MAX (1, (gint) allocation->width - border_width * 2);
child1_allocation.height = MAX (1, priv->child1_size);
- child1_allocation.x = child2_allocation.x = widget->allocation.x + border_width;
- child1_allocation.y = widget->allocation.y + border_width;
+ child1_allocation.x = child2_allocation.x = widget_allocation.x + border_width;
+ child1_allocation.y = widget_allocation.y + border_width;
child2_allocation.y = child1_allocation.y + priv->child1_size + priv->handle_pos.height;
- child2_allocation.height = MAX (1, widget->allocation.y + widget->allocation.height - child2_allocation.y - border_width);
+ child2_allocation.height = MAX (1, widget_allocation.y + widget_allocation.height - child2_allocation.y - border_width);
}
if (gtk_widget_get_mapped (widget) &&
@@ -941,8 +949,11 @@ gtk_paned_size_allocate (GtkWidget *widget,
old_handle_pos.width != priv->handle_pos.width ||
old_handle_pos.height != priv->handle_pos.height))
{
- gdk_window_invalidate_rect (widget->window, &old_handle_pos, FALSE);
- gdk_window_invalidate_rect (widget->window, &priv->handle_pos, FALSE);
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
+ gdk_window_invalidate_rect (window, &old_handle_pos, FALSE);
+ gdk_window_invalidate_rect (window, &priv->handle_pos, FALSE);
}
if (gtk_widget_get_realized (widget))
@@ -971,13 +982,13 @@ gtk_paned_size_allocate (GtkWidget *widget,
/* Now allocate the childen, making sure, when resizing not to
* overlap the windows
*/
+ gtk_widget_get_allocation (priv->child1, &priv_child1_allocation);
if (gtk_widget_get_mapped (widget) &&
-
((priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
- priv->child1->allocation.width < child1_allocation.width) ||
+ priv_child1_allocation.width < child1_allocation.width) ||
(priv->orientation == GTK_ORIENTATION_VERTICAL &&
- priv->child1->allocation.height < child1_allocation.height)))
+ priv_child1_allocation.height < child1_allocation.height)))
{
gtk_widget_size_allocate (priv->child2, &child2_allocation);
gtk_widget_size_allocate (priv->child1, &child1_allocation);
@@ -1000,8 +1011,10 @@ gtk_paned_size_allocate (GtkWidget *widget,
if (priv->child2)
gtk_widget_set_child_visible (priv->child2, TRUE);
- child_allocation.x = widget->allocation.x + border_width;
- child_allocation.y = widget->allocation.y + border_width;
+ gtk_widget_get_allocation (widget, &widget_allocation);
+
+ child_allocation.x = widget_allocation.x + border_width;
+ child_allocation.y = widget_allocation.y + border_width;
child_allocation.width = MAX (1, allocation->width - 2 * border_width);
child_allocation.height = MAX (1, allocation->height - 2 * border_width);
@@ -1017,14 +1030,16 @@ gtk_paned_realize (GtkWidget *widget)
{
GtkPaned *paned = GTK_PANED (widget);
GtkPanedPrivate *priv = paned->priv;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
- 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.wclass = GDK_INPUT_ONLY;
attributes.x = priv->handle_pos.x;
@@ -1046,13 +1061,13 @@ gtk_paned_realize (GtkWidget *widget)
attributes_mask |= GDK_WA_CURSOR;
}
- priv->handle = gdk_window_new (widget->window,
- &attributes, attributes_mask);
+ priv->handle = gdk_window_new (window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (priv->handle, paned);
if (attributes_mask & GDK_WA_CURSOR)
gdk_cursor_unref (attributes.cursor);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
if (priv->child1 && gtk_widget_get_visible (priv->child1) &&
priv->child2 && gtk_widget_get_visible (priv->child2))
@@ -1121,8 +1136,9 @@ gtk_paned_expose (GtkWidget *widget,
state = GTK_STATE_PRELIGHT;
else
state = gtk_widget_get_state (widget);
-
- gtk_paint_handle (widget->style, widget->window,
+
+ gtk_paint_handle (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
state, GTK_SHADOW_NONE,
&priv->handle_pos, widget, "paned",
priv->handle_pos.x, priv->handle_pos.y,
@@ -1154,24 +1170,27 @@ static void
update_drag (GtkPaned *paned)
{
GtkPanedPrivate *priv = paned->priv;
+ GtkAllocation allocation;
+ GtkWidget *widget = GTK_WIDGET (paned);
gint pos;
gint handle_size;
gint size;
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- gtk_widget_get_pointer (GTK_WIDGET (paned), &pos, NULL);
+ gtk_widget_get_pointer (widget, &pos, NULL);
else
- gtk_widget_get_pointer (GTK_WIDGET (paned), NULL, &pos);
+ gtk_widget_get_pointer (widget, NULL, &pos);
pos -= priv->drag_pos;
if (is_rtl (paned))
{
- gtk_widget_style_get (GTK_WIDGET (paned),
+ gtk_widget_style_get (widget,
"handle-size", &handle_size,
NULL);
-
- size = GTK_WIDGET (paned)->allocation.width - pos - handle_size;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ size = allocation.width - pos - handle_size;
}
else
{
@@ -1813,7 +1832,7 @@ gtk_paned_set_focus_child (GtkContainer *container,
/* If there is one or more paned widgets between us and the
* focus widget, we want the topmost of those as last_focus
*/
- for (w = last_focus; w != GTK_WIDGET (paned); w = w->parent)
+ for (w = last_focus; w != GTK_WIDGET (paned); w = gtk_widget_get_parent (w))
if (GTK_IS_PANED (w))
last_focus = w;
@@ -1838,6 +1857,8 @@ gtk_paned_get_cycle_chain (GtkPaned *paned,
GtkContainer *container = GTK_CONTAINER (paned);
GtkWidget *ancestor = NULL;
GtkWidget *focus_child;
+ GtkWidget *parent;
+ GtkWidget *widget = GTK_WIDGET (paned);
GList *temp_list = NULL;
GList *list;
@@ -1847,19 +1868,20 @@ gtk_paned_get_cycle_chain (GtkPaned *paned,
g_assert (widgets != NULL);
if (priv->last_child1_focus &&
- !gtk_widget_is_ancestor (priv->last_child1_focus, GTK_WIDGET (paned)))
+ !gtk_widget_is_ancestor (priv->last_child1_focus, widget))
{
gtk_paned_set_last_child1_focus (paned, NULL);
}
if (priv->last_child2_focus &&
- !gtk_widget_is_ancestor (priv->last_child2_focus, GTK_WIDGET (paned)))
+ !gtk_widget_is_ancestor (priv->last_child2_focus, widget))
{
gtk_paned_set_last_child2_focus (paned, NULL);
}
- if (GTK_WIDGET (paned)->parent)
- ancestor = gtk_widget_get_ancestor (GTK_WIDGET (paned)->parent, GTK_TYPE_PANED);
+ parent = gtk_widget_get_parent (widget);
+ if (parent)
+ ancestor = gtk_widget_get_ancestor (parent, GTK_TYPE_PANED);
/* The idea here is that temp_list is a list of widgets we want to cycle
* to. The list is prioritized so that the first element is our first
@@ -1997,8 +2019,8 @@ get_all_panes (GtkPaned *paned)
GtkPaned *topmost = NULL;
GList *result = NULL;
GtkWidget *w;
-
- for (w = GTK_WIDGET (paned); w != NULL; w = w->parent)
+
+ for (w = GTK_WIDGET (paned); w != NULL; w = gtk_widget_get_parent (w))
{
if (GTK_IS_PANED (w))
topmost = GTK_PANED (w);
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index be44855..44c2df3 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -407,30 +407,35 @@ static void
gtk_path_bar_realize (GtkWidget *widget)
{
GtkPathBar *path_bar;
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
path_bar = GTK_PATH_BAR (widget);
- 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);
+
+ gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= GDK_SCROLL_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
path_bar->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
+ &attributes, attributes_mask);
gdk_window_set_user_data (path_bar->event_window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
}
static void
@@ -465,7 +470,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
gint up_slider_offset = 0;
GtkRequisition child_requisition;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (path_bar->event_window,
@@ -588,6 +593,7 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
for (list = first_button; list; list = list->prev)
{
+ GtkAllocation widget_allocation;
ButtonData *button_data;
button_data = BUTTON_DATA (list->data);
@@ -604,13 +610,15 @@ gtk_path_bar_size_allocate (GtkWidget *widget,
/* Check to see if we've don't have any more space to allocate buttons */
if (need_sliders && direction == GTK_TEXT_DIR_RTL)
{
- if (child_allocation.x - path_bar->spacing - path_bar->slider_width < widget->allocation.x + border_width)
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ if (child_allocation.x - path_bar->spacing - path_bar->slider_width < widget_allocation.x + border_width)
break;
}
else if (need_sliders && direction == GTK_TEXT_DIR_LTR)
{
+ gtk_widget_get_allocation (widget, &widget_allocation);
if (child_allocation.x + child_allocation.width + path_bar->spacing + path_bar->slider_width >
- widget->allocation.x + border_width + allocation_width)
+ widget_allocation.x + border_width + allocation_width)
break;
}
@@ -803,6 +811,7 @@ gtk_path_bar_forall (GtkContainer *container,
static void
gtk_path_bar_scroll_down (GtkPathBar *path_bar)
{
+ GtkAllocation allocation, button_allocation;
GList *list;
GList *down_button = NULL;
gint space_available;
@@ -832,10 +841,13 @@ gtk_path_bar_scroll_down (GtkPathBar *path_bar)
}
}
- space_available = (GTK_WIDGET (path_bar)->allocation.width
+ gtk_widget_get_allocation (GTK_WIDGET (path_bar), &allocation);
+ gtk_widget_get_allocation (BUTTON_DATA (down_button->data)->button, &button_allocation);
+
+ space_available = (allocation.width
- 2 * gtk_container_get_border_width (GTK_CONTAINER (path_bar))
- 2 * path_bar->spacing - 2 * path_bar->slider_width
- - BUTTON_DATA (down_button->data)->button->allocation.width);
+ - button_allocation.width);
path_bar->first_scrolled_button = down_button;
/* We have space_available free space that's not being used.
@@ -847,7 +859,7 @@ gtk_path_bar_scroll_down (GtkPathBar *path_bar)
down_button = down_button->next;
if (!down_button)
break;
- space_available -= (BUTTON_DATA (down_button->data)->button->allocation.width
+ space_available -= (button_allocation.width
+ path_bar->spacing);
}
}
@@ -1161,7 +1173,7 @@ button_clicked_cb (GtkWidget *button,
if (button_data->ignore_changes)
return;
- path_bar = GTK_PATH_BAR (button->parent);
+ path_bar = GTK_PATH_BAR (gtk_widget_get_parent (button));
button_list = g_list_find (path_bar->button_list, button_data);
g_assert (button_list != NULL);
@@ -1443,7 +1455,7 @@ button_drag_data_get_cb (GtkWidget *widget,
char *uris[2];
button_data = data;
- path_bar = GTK_PATH_BAR (widget->parent); /* the button's parent *is* the path bar */
+ path_bar = GTK_PATH_BAR (gtk_widget_get_parent (widget)); /* the button's parent *is* the path bar */
uris[0] = g_file_get_uri (button_data->file);
uris[1] = NULL;
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index e5c2f0d..161b964 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -216,8 +216,10 @@ static void
gtk_plug_set_is_child (GtkPlug *plug,
gboolean is_child)
{
- g_assert (!GTK_WIDGET (plug)->parent);
-
+ GtkWidget *widget = GTK_WIDGET (plug);
+
+ g_assert (!gtk_widget_get_parent (widget));
+
if (is_child)
{
if (plug->modality_window)
@@ -235,13 +237,13 @@ gtk_plug_set_is_child (GtkPlug *plug,
* here, but don't bother remapping -- we will get mapped
* by gtk_widget_set_parent ().
*/
- if (gtk_widget_get_mapped (GTK_WIDGET (plug)))
- gtk_widget_unmap (GTK_WIDGET (plug));
-
+ if (gtk_widget_get_mapped (widget))
+ gtk_widget_unmap (widget);
+
_gtk_window_set_is_toplevel (GTK_WINDOW (plug), FALSE);
gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_PARENT);
- _gtk_widget_propagate_hierarchy_changed (GTK_WIDGET (plug), GTK_WIDGET (plug));
+ _gtk_widget_propagate_hierarchy_changed (widget, widget);
}
else
{
@@ -342,15 +344,18 @@ _gtk_plug_add_to_socket (GtkPlug *plug,
socket_->same_app = TRUE;
socket_->plug_widget = widget;
- plug->socket_window = GTK_WIDGET (socket_)->window;
+ plug->socket_window = gtk_widget_get_window (GTK_WIDGET (socket_));
g_object_ref (plug->socket_window);
g_signal_emit (plug, plug_signals[EMBEDDED], 0);
g_object_notify (G_OBJECT (plug), "embedded");
if (gtk_widget_get_realized (widget))
{
- gdk_drawable_get_size (GDK_DRAWABLE (widget->window), &w, &h);
- gdk_window_reparent (widget->window, plug->socket_window, -w, -h);
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
+ gdk_drawable_get_size (GDK_DRAWABLE (window), &w, &h);
+ gdk_window_reparent (window, plug->socket_window, -w, -h);
}
gtk_widget_set_parent (widget, GTK_WIDGET (socket_));
@@ -371,7 +376,7 @@ _gtk_plug_send_delete_event (GtkWidget *widget)
{
GdkEvent *event = gdk_event_new (GDK_DELETE);
- event->any.window = g_object_ref (widget->window);
+ event->any.window = g_object_ref (gtk_widget_get_window (widget));
event->any.send_event = FALSE;
g_object_ref (widget);
@@ -396,6 +401,7 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
GtkSocket *socket_)
{
GtkWidget *widget;
+ GdkWindow *window;
gboolean result;
gboolean widget_was_visible;
@@ -412,10 +418,11 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
g_object_ref (socket_);
widget_was_visible = gtk_widget_get_visible (widget);
-
- gdk_window_hide (widget->window);
+ window = gtk_widget_get_window (widget);
+
+ gdk_window_hide (window);
GTK_PRIVATE_SET_FLAG (plug, GTK_IN_REPARENT);
- gdk_window_reparent (widget->window,
+ gdk_window_reparent (window,
gtk_widget_get_root_window (widget),
0, 0);
gtk_widget_unparent (GTK_WIDGET (plug));
@@ -442,7 +449,7 @@ _gtk_plug_remove_from_socket (GtkPlug *plug,
if (!result)
gtk_widget_destroy (GTK_WIDGET (socket_));
- if (widget->window)
+ if (window)
_gtk_plug_send_delete_event (widget);
g_object_unref (plug);
@@ -600,19 +607,23 @@ gtk_plug_unrealize (GtkWidget *widget)
static void
gtk_plug_realize (GtkWidget *widget)
{
- GtkWindow *window = GTK_WINDOW (widget);
+ GtkAllocation allocation;
GtkPlug *plug = GTK_PLUG (widget);
+ GtkWindow *window = GTK_WINDOW (widget);
+ GdkWindow *gdk_window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD; /* XXX GDK_WINDOW_PLUG ? */
attributes.title = window->title;
attributes.wmclass_name = window->wmclass_name;
attributes.wmclass_class = window->wmclass_class;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
/* this isn't right - we should match our parent's visual/colormap.
@@ -637,24 +648,26 @@ gtk_plug_realize (GtkWidget *widget)
gdk_error_trap_push ();
if (plug->socket_window)
- widget->window = gdk_window_new (plug->socket_window,
- &attributes, attributes_mask);
+ gdk_window = gdk_window_new (plug->socket_window,
+ &attributes, attributes_mask);
else /* If it's a passive plug, we use the root window */
- widget->window = gdk_window_new (gtk_widget_get_root_window (widget),
- &attributes, attributes_mask);
+ gdk_window = gdk_window_new (gtk_widget_get_root_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, gdk_window);
gdk_display_sync (gtk_widget_get_display (widget));
if (gdk_error_trap_pop ()) /* Uh-oh */
{
gdk_error_trap_push ();
- gdk_window_destroy (widget->window);
+ gdk_window_destroy (gdk_window);
gdk_flush ();
gdk_error_trap_pop ();
- widget->window = gdk_window_new (gtk_widget_get_root_window (widget),
- &attributes, attributes_mask);
+ gdk_window = gdk_window_new (gtk_widget_get_root_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, gdk_window);
}
-
- gdk_window_add_filter (widget->window,
+
+ gdk_window_add_filter (gdk_window,
_gtk_plug_windowing_filter_func,
widget);
@@ -664,15 +677,19 @@ gtk_plug_realize (GtkWidget *widget)
_gtk_plug_windowing_realize_toplevel (plug);
}
else
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
-
- gdk_window_set_user_data (widget->window, window);
+ {
+ gdk_window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, gdk_window);
+ }
+
+ gdk_window_set_user_data (gdk_window, window);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ gdk_window, GTK_STATE_NORMAL);
- gdk_window_enable_synchronized_configure (widget->window);
+ gdk_window_enable_synchronized_configure (gdk_window);
}
static void
@@ -716,8 +733,8 @@ gtk_plug_map (GtkWidget *widget)
gtk_widget_map (child);
_gtk_plug_windowing_map_toplevel (plug);
-
- gdk_synthesize_window_state (widget->window,
+
+ gdk_synthesize_window_state (gtk_widget_get_window (widget),
GDK_WINDOW_STATE_WITHDRAWN,
0);
}
@@ -731,14 +748,17 @@ gtk_plug_unmap (GtkWidget *widget)
if (gtk_widget_is_toplevel (widget))
{
GtkPlug *plug = GTK_PLUG (widget);
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
gtk_widget_set_mapped (widget, FALSE);
- gdk_window_hide (widget->window);
+ gdk_window_hide (window);
_gtk_plug_windowing_unmap_toplevel (plug);
-
- gdk_synthesize_window_state (widget->window,
+
+ gdk_synthesize_window_state (window,
0,
GDK_WINDOW_STATE_WITHDRAWN);
}
@@ -758,10 +778,10 @@ gtk_plug_size_allocate (GtkWidget *widget,
{
GtkBin *bin = GTK_BIN (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
@@ -968,11 +988,11 @@ gtk_plug_focus (GtkWidget *widget,
if (window->focus_widget)
{
/* Wrapped off the end, clear the focus setting for the toplevel */
- parent = window->focus_widget->parent;
+ parent = gtk_widget_get_parent (window->focus_widget);
while (parent)
{
gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
- parent = GTK_WIDGET (parent)->parent;
+ parent = gtk_widget_get_parent (parent);
}
gtk_window_set_focus (GTK_WINDOW (container), NULL);
@@ -1059,11 +1079,11 @@ _gtk_plug_focus_first_last (GtkPlug *plug,
if (window->focus_widget)
{
- parent = window->focus_widget->parent;
+ parent = gtk_widget_get_parent (window->focus_widget);
while (parent)
{
gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
- parent = GTK_WIDGET (parent)->parent;
+ parent = gtk_widget_get_parent (parent);
}
gtk_window_set_focus (GTK_WINDOW (plug), NULL);
diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c
index 55a3cce..b655e99 100644
--- a/gtk/gtkprogressbar.c
+++ b/gtk/gtkprogressbar.c
@@ -273,16 +273,20 @@ gtk_progress_bar_init (GtkProgressBar *pbar)
static void
gtk_progress_bar_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -290,12 +294,14 @@ gtk_progress_bar_realize (GtkWidget *widget)
attributes.event_mask |= GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window, GTK_STATE_ACTIVE);
}
static void
@@ -392,33 +398,37 @@ gtk_progress_bar_real_update (GtkProgressBar *pbar)
if (priv->activity_mode)
{
+ GtkAllocation allocation;
+ GtkStyle *style;
guint size;
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
+
/* advance the block */
if (priv->orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
priv->orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
{
/* Update our activity step. */
- priv->activity_step = widget->allocation.width * priv->pulse_fraction;
+ priv->activity_step = allocation.width * priv->pulse_fraction;
- size = MAX (2, widget->allocation.width / priv->activity_blocks);
+ size = MAX (2, allocation.width / priv->activity_blocks);
if (priv->activity_dir == 0)
{
priv->activity_pos += priv->activity_step;
- if (priv->activity_pos + size >= widget->allocation.width - widget->style->xthickness)
+ if (priv->activity_pos + size >= allocation.width - style->xthickness)
{
- priv->activity_pos = widget->allocation.width -
- widget->style->xthickness - size;
+ priv->activity_pos = allocation.width - style->xthickness - size;
priv->activity_dir = 1;
}
}
else
{
priv->activity_pos -= priv->activity_step;
- if (priv->activity_pos <= widget->style->xthickness)
+ if (priv->activity_pos <= style->xthickness)
{
- priv->activity_pos = widget->style->xthickness;
+ priv->activity_pos = style->xthickness;
priv->activity_dir = 0;
}
}
@@ -426,26 +436,25 @@ gtk_progress_bar_real_update (GtkProgressBar *pbar)
else
{
/* Update our activity step. */
- priv->activity_step = widget->allocation.height * priv->pulse_fraction;
+ priv->activity_step = allocation.height * priv->pulse_fraction;
- size = MAX (2, widget->allocation.height / priv->activity_blocks);
+ size = MAX (2, allocation.height / priv->activity_blocks);
if (priv->activity_dir == 0)
{
priv->activity_pos += priv->activity_step;
- if (priv->activity_pos + size >= widget->allocation.height - widget->style->ythickness)
+ if (priv->activity_pos + size >= allocation.height - style->ythickness)
{
- priv->activity_pos = widget->allocation.height -
- widget->style->ythickness - size;
+ priv->activity_pos = allocation.height - style->ythickness - size;
priv->activity_dir = 1;
}
}
else
{
priv->activity_pos -= priv->activity_step;
- if (priv->activity_pos <= widget->style->ythickness)
+ if (priv->activity_pos <= style->ythickness)
{
- priv->activity_pos = widget->style->ythickness;
+ priv->activity_pos = style->ythickness;
priv->activity_dir = 0;
}
}
@@ -494,6 +503,7 @@ gtk_progress_bar_size_request (GtkWidget *widget,
{
GtkProgressBar *pbar;
GtkProgressBarPriv *priv;
+ GtkStyle *style;
gchar *buf;
PangoRectangle logical_rect;
PangoLayout *layout;
@@ -504,6 +514,7 @@ gtk_progress_bar_size_request (GtkWidget *widget,
g_return_if_fail (GTK_IS_PROGRESS_BAR (widget));
g_return_if_fail (requisition != NULL);
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"xspacing", &xspacing,
"yspacing", &yspacing,
@@ -512,8 +523,8 @@ gtk_progress_bar_size_request (GtkWidget *widget,
pbar = GTK_PROGRESS_BAR (widget);
priv = pbar->priv;
- width = 2 * widget->style->xthickness + xspacing;
- height = 2 * widget->style->ythickness + yspacing;
+ width = 2 * style->xthickness + xspacing;
+ height = 2 * style->ythickness + yspacing;
if (priv->show_text)
{
@@ -530,7 +541,7 @@ gtk_progress_bar_size_request (GtkWidget *widget,
/* The minimum size for ellipsized text is ~ 3 chars */
context = pango_layout_get_context (layout);
- metrics = pango_context_get_metrics (context, widget->style->font_desc, pango_context_get_language (context));
+ metrics = pango_context_get_metrics (context, style->font_desc, pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
@@ -566,11 +577,11 @@ static void
gtk_progress_bar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
}
@@ -580,9 +591,13 @@ static void
gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
{
GtkProgressBarPriv *priv = pbar->priv;
+ GtkAllocation allocation;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (pbar);
GtkProgressBarOrientation orientation;
+ style = gtk_widget_get_style (widget);
+
orientation = priv->orientation;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
{
@@ -599,14 +614,14 @@ gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
{
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT)
{
- priv->activity_pos = widget->style->xthickness;
+ priv->activity_pos = style->xthickness;
priv->activity_dir = 0;
}
else
{
- priv->activity_pos = widget->allocation.width -
- widget->style->xthickness - (widget->allocation.height -
- widget->style->ythickness * 2);
+ gtk_widget_get_allocation (widget, &allocation);
+ priv->activity_pos = allocation.width - style->xthickness -
+ (allocation.height - style->ythickness * 2);
priv->activity_dir = 1;
}
}
@@ -614,14 +629,14 @@ gtk_progress_bar_act_mode_enter (GtkProgressBar *pbar)
{
if (orientation == GTK_PROGRESS_TOP_TO_BOTTOM)
{
- priv->activity_pos = widget->style->ythickness;
+ priv->activity_pos = style->ythickness;
priv->activity_dir = 0;
}
else
{
- priv->activity_pos = widget->allocation.height -
- widget->style->ythickness - (widget->allocation.width -
- widget->style->xthickness * 2);
+ gtk_widget_get_allocation (widget, &allocation);
+ priv->activity_pos = allocation.height - style->ythickness -
+ (allocation.width - style->xthickness * 2);
priv->activity_dir = 1;
}
}
@@ -634,20 +649,23 @@ gtk_progress_bar_get_activity (GtkProgressBar *pbar,
gint *amount)
{
GtkProgressBarPriv *priv = pbar->priv;
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (pbar);
*offset = priv->activity_pos;
+ gtk_widget_get_allocation (widget, &allocation);
+
switch (orientation)
{
case GTK_PROGRESS_LEFT_TO_RIGHT:
case GTK_PROGRESS_RIGHT_TO_LEFT:
- *amount = MAX (2, widget->allocation.width / priv->activity_blocks);
+ *amount = MAX (2, allocation.width / priv->activity_blocks);
break;
case GTK_PROGRESS_TOP_TO_BOTTOM:
case GTK_PROGRESS_BOTTOM_TO_TOP:
- *amount = MAX (2, widget->allocation.height / priv->activity_blocks);
+ *amount = MAX (2, allocation.height / priv->activity_blocks);
break;
}
}
@@ -656,23 +674,28 @@ static void
gtk_progress_bar_paint_activity (GtkProgressBar *pbar,
GtkProgressBarOrientation orientation)
{
+ GtkAllocation allocation;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (pbar);
GdkRectangle area;
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
switch (orientation)
{
case GTK_PROGRESS_LEFT_TO_RIGHT:
case GTK_PROGRESS_RIGHT_TO_LEFT:
gtk_progress_bar_get_activity (pbar, orientation, &area.x, &area.width);
- area.y = widget->style->ythickness;
- area.height = widget->allocation.height - 2 * widget->style->ythickness;
+ area.y = style->ythickness;
+ area.height = allocation.height - 2 * style->ythickness;
break;
case GTK_PROGRESS_TOP_TO_BOTTOM:
case GTK_PROGRESS_BOTTOM_TO_TOP:
gtk_progress_bar_get_activity (pbar, orientation, &area.y, &area.height);
- area.x = widget->style->xthickness;
- area.width = widget->allocation.width - 2 * widget->style->xthickness;
+ area.x = style->xthickness;
+ area.width = allocation.width - 2 * style->xthickness;
break;
default:
@@ -680,7 +703,7 @@ gtk_progress_bar_paint_activity (GtkProgressBar *pbar,
break;
}
- gtk_paint_box (widget->style,
+ gtk_paint_box (style,
gtk_widget_get_window (widget),
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
&area, widget, "bar",
@@ -692,34 +715,39 @@ gtk_progress_bar_paint_continuous (GtkProgressBar *pbar,
gint amount,
GtkProgressBarOrientation orientation)
{
+ GtkAllocation allocation;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (pbar);
GdkRectangle area;
if (amount <= 0)
return;
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
switch (orientation)
{
case GTK_PROGRESS_LEFT_TO_RIGHT:
case GTK_PROGRESS_RIGHT_TO_LEFT:
area.width = amount;
- area.height = widget->allocation.height - widget->style->ythickness * 2;
- area.y = widget->style->ythickness;
+ area.height = allocation.height - style->ythickness * 2;
+ area.y = style->ythickness;
- area.x = widget->style->xthickness;
+ area.x = style->xthickness;
if (orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
- area.x = widget->allocation.width - amount - area.x;
+ area.x = allocation.width - amount - area.x;
break;
case GTK_PROGRESS_TOP_TO_BOTTOM:
case GTK_PROGRESS_BOTTOM_TO_TOP:
- area.width = widget->allocation.width - widget->style->xthickness * 2;
+ area.width = allocation.width - style->xthickness * 2;
area.height = amount;
- area.x = widget->style->xthickness;
+ area.x = style->xthickness;
- area.y = widget->style->ythickness;
+ area.y = style->ythickness;
if (orientation == GTK_PROGRESS_BOTTOM_TO_TOP)
- area.y = widget->allocation.height - amount - area.y;
+ area.y = allocation.height - amount - area.y;
break;
default:
@@ -727,7 +755,7 @@ gtk_progress_bar_paint_continuous (GtkProgressBar *pbar,
break;
}
- gtk_paint_box (widget->style,
+ gtk_paint_box (style,
gtk_widget_get_window (widget),
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT,
&area, widget, "bar",
@@ -741,6 +769,8 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
GtkProgressBarOrientation orientation)
{
GtkProgressBarPriv *priv = pbar->priv;
+ GtkAllocation allocation;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (pbar);
gint x;
gint y;
@@ -752,6 +782,9 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
gfloat text_xalign = 0.5;
gfloat text_yalign = 0.5;
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR)
text_xalign = 1.0 - text_xalign;
@@ -760,22 +793,18 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
layout = gtk_widget_create_pango_layout (widget, buf);
pango_layout_set_ellipsize (layout, priv->ellipsize);
if (priv->ellipsize)
- pango_layout_set_width (layout, widget->allocation.width * PANGO_SCALE);
+ pango_layout_set_width (layout, allocation.width * PANGO_SCALE);
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
- x = widget->style->xthickness + 1 + text_xalign *
- (widget->allocation.width - 2 * widget->style->xthickness -
- 2 - logical_rect.width);
+ x = style->xthickness + 1 + text_xalign * (allocation.width - 2 * style->xthickness - 2 - logical_rect.width);
- y = widget->style->ythickness + 1 + text_yalign *
- (widget->allocation.height - 2 * widget->style->ythickness -
- 2 - logical_rect.height);
+ y = style->ythickness + 1 + text_yalign * (allocation.height - 2 * style->ythickness - 2 - logical_rect.height);
- rect.x = widget->style->xthickness;
- rect.y = widget->style->ythickness;
- rect.width = widget->allocation.width - 2 * widget->style->xthickness;
- rect.height = widget->allocation.height - 2 * widget->style->ythickness;
+ rect.x = style->xthickness;
+ rect.y = style->ythickness;
+ rect.width = allocation.width - 2 * style->xthickness;
+ rect.height = allocation.height - 2 * style->ythickness;
prelight_clip = start_clip = end_clip = rect;
@@ -823,7 +852,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
}
if (start_clip.width > 0 && start_clip.height > 0)
- gtk_paint_layout (widget->style,
+ gtk_paint_layout (style,
gtk_widget_get_window (widget),
GTK_STATE_NORMAL,
FALSE,
@@ -834,7 +863,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
layout);
if (end_clip.width > 0 && end_clip.height > 0)
- gtk_paint_layout (widget->style,
+ gtk_paint_layout (style,
gtk_widget_get_window (widget),
GTK_STATE_NORMAL,
FALSE,
@@ -844,7 +873,7 @@ gtk_progress_bar_paint_text (GtkProgressBar *pbar,
x, y,
layout);
- gtk_paint_layout (widget->style,
+ gtk_paint_layout (style,
gtk_widget_get_window (widget),
GTK_STATE_PRELIGHT,
FALSE,
@@ -862,8 +891,13 @@ static void
gtk_progress_bar_paint (GtkProgressBar *pbar)
{
GtkProgressBarPriv *priv = pbar->priv;
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (pbar);
GtkProgressBarOrientation orientation;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
orientation = priv->orientation;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
@@ -874,13 +908,13 @@ gtk_progress_bar_paint (GtkProgressBar *pbar)
orientation = GTK_PROGRESS_LEFT_TO_RIGHT;
}
- gtk_paint_box (widget->style,
+ gtk_paint_box (style,
gtk_widget_get_window (widget),
GTK_STATE_NORMAL, GTK_SHADOW_IN,
NULL, widget, "trough",
0, 0,
- widget->allocation.width,
- widget->allocation.height);
+ allocation.width,
+ allocation.height);
if (priv->activity_mode)
{
@@ -902,9 +936,9 @@ gtk_progress_bar_paint (GtkProgressBar *pbar)
if (orientation == GTK_PROGRESS_LEFT_TO_RIGHT ||
orientation == GTK_PROGRESS_RIGHT_TO_LEFT)
- space = widget->allocation.width - 2 * widget->style->xthickness;
+ space = allocation.width - 2 * style->xthickness;
else
- space = widget->allocation.height - 2 * widget->style->ythickness;
+ space = allocation.height - 2 * style->ythickness;
amount = space * gtk_progress_bar_get_fraction (pbar);
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 675c29a..ebaa86c 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -545,9 +545,12 @@ get_coordinates (GtkWidget *widget,
gint *x,
gint *y)
{
- *x = widget->allocation.x + widget->allocation.width / 2;
- *y = widget->allocation.y + widget->allocation.height / 2;
-
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+ *x = allocation.x + allocation.width / 2;
+ *y = allocation.y + allocation.height / 2;
+
gtk_widget_translate_coordinates (widget, reference, *x, *y, x, y);
}
@@ -813,12 +816,15 @@ static void
gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
GdkRectangle *area)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GtkWidget *child;
GtkButton *button;
GtkToggleButton *toggle_button;
GtkStateType state_type;
GtkShadowType shadow_type;
+ GtkStyle *style;
+ GdkWindow *window;
gint x, y;
gint indicator_size, indicator_spacing;
gint focus_width;
@@ -835,16 +841,21 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"interior-focus", &interior_focus,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
+ window = gtk_widget_get_window (widget);
+
_gtk_check_button_get_props (check_button, &indicator_size, &indicator_spacing);
- x = widget->allocation.x + indicator_spacing + border_width;
- y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ x = allocation.x + indicator_spacing + border_width;
+ y = allocation.y + (allocation.height - indicator_size) / 2;
child = gtk_bin_get_child (GTK_BIN (check_button));
if (!interior_focus || !(child && gtk_widget_get_visible (child)))
@@ -867,21 +878,22 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
state_type = GTK_STATE_NORMAL;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- x = widget->allocation.x + widget->allocation.width - (indicator_size + x - widget->allocation.x);
+ x = allocation.x + allocation.width - (indicator_size + x - allocation.x);
if (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT)
{
GdkRectangle restrict_area;
GdkRectangle new_area;
-
- restrict_area.x = widget->allocation.x + border_width;
- restrict_area.y = widget->allocation.y + border_width;
- restrict_area.width = widget->allocation.width - (2 * border_width);
- restrict_area.height = widget->allocation.height - (2 * border_width);
-
+
+ restrict_area.x = allocation.x + border_width;
+ restrict_area.y = allocation.y + border_width;
+ restrict_area.width = allocation.width - (2 * border_width);
+ restrict_area.height = allocation.height - (2 * border_width);
+
if (gdk_rectangle_intersect (area, &restrict_area, &new_area))
{
- gtk_paint_flat_box (widget->style, widget->window, GTK_STATE_PRELIGHT,
+ gtk_paint_flat_box (style, window,
+ GTK_STATE_PRELIGHT,
GTK_SHADOW_ETCHED_OUT,
area, widget, "checkbutton",
new_area.x, new_area.y,
@@ -889,7 +901,7 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
}
}
- gtk_paint_option (widget->style, widget->window,
+ gtk_paint_option (style, window,
state_type, shadow_type,
area, widget, "radiobutton",
x, y, indicator_size, indicator_size);
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 430764a..d3b2426 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -1513,8 +1513,8 @@ gtk_range_size_allocate (GtkWidget *widget,
range = GTK_RANGE (widget);
- widget->allocation = *allocation;
-
+ gtk_widget_set_allocation (widget, allocation);
+
range->layout->recalc_marks = TRUE;
range->need_recalc = TRUE;
@@ -1522,16 +1522,16 @@ gtk_range_size_allocate (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (range->event_window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
}
static void
gtk_range_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkRange *range;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -1541,14 +1541,17 @@ gtk_range_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
- 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);
+
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
@@ -1564,7 +1567,7 @@ gtk_range_realize (GtkWidget *widget)
&attributes, attributes_mask);
gdk_window_set_user_data (range->event_window, range);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
}
static void
@@ -1704,10 +1707,13 @@ draw_stepper (GtkRange *range,
gboolean prelighted,
GdkRectangle *area)
{
+ GtkAllocation allocation;
GtkStateType state_type;
GtkShadowType shadow_type;
- GdkRectangle intersection;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (range);
+ GdkRectangle intersection;
+ GdkWindow *window;
gfloat arrow_scaling;
GdkRectangle *rect;
gint arrow_x;
@@ -1739,8 +1745,10 @@ draw_stepper (GtkRange *range,
if (!gdk_rectangle_intersect (area, rect, &intersection))
return;
- intersection.x += widget->allocation.x;
- intersection.y += widget->allocation.y;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ intersection.x += allocation.x;
+ intersection.y += allocation.y;
if ((!range->inverted && (arrow_type == GTK_ARROW_DOWN ||
arrow_type == GTK_ARROW_RIGHT)) ||
@@ -1768,13 +1776,15 @@ draw_stepper (GtkRange *range,
else
shadow_type = GTK_SHADOW_OUT;
- gtk_paint_box (widget->style,
- widget->window,
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+
+ gtk_paint_box (style, window,
state_type, shadow_type,
&intersection, widget,
gtk_range_get_stepper_detail (range, stepper),
- widget->allocation.x + rect->x,
- widget->allocation.y + rect->y,
+ allocation.x + rect->x,
+ allocation.y + rect->y,
rect->width,
rect->height);
@@ -1782,8 +1792,8 @@ draw_stepper (GtkRange *range,
arrow_width = rect->width * arrow_scaling;
arrow_height = rect->height * arrow_scaling;
- arrow_x = widget->allocation.x + rect->x + (rect->width - arrow_width) / 2;
- arrow_y = widget->allocation.y + rect->y + (rect->height - arrow_height) / 2;
+ arrow_x = allocation.x + rect->x + (rect->width - arrow_width) / 2;
+ arrow_y = allocation.y + rect->y + (rect->height - arrow_height) / 2;
if (clicked && arrow_sensitive)
{
@@ -1797,9 +1807,8 @@ draw_stepper (GtkRange *range,
arrow_x += arrow_displacement_x;
arrow_y += arrow_displacement_y;
}
-
- gtk_paint_arrow (widget->style,
- widget->window,
+
+ gtk_paint_arrow (style, window,
state_type, shadow_type,
&intersection, widget,
gtk_range_get_stepper_detail (range, stepper),
@@ -1812,12 +1821,15 @@ static gboolean
gtk_range_expose (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
GtkRange *range = GTK_RANGE (widget);
gboolean sensitive;
GtkStateType state;
GtkShadowType shadow_type;
+ GtkStyle *style;
GdkRectangle expose_area; /* Relative to widget->allocation */
GdkRectangle area;
+ GdkWindow *window;
gint focus_line_width = 0;
gint focus_padding = 0;
gboolean touchscreen;
@@ -1825,21 +1837,27 @@ gtk_range_expose (GtkWidget *widget,
g_object_get (gtk_widget_get_settings (widget),
"gtk-touchscreen-mode", &touchscreen,
NULL);
+
+ style = gtk_widget_get_style (widget);
if (gtk_widget_get_can_focus (GTK_WIDGET (range)))
gtk_widget_style_get (GTK_WIDGET (range),
"focus-line-width", &focus_line_width,
"focus-padding", &focus_padding,
NULL);
+ window = gtk_widget_get_window (widget);
+
/* we're now exposing, so there's no need to force early repaints */
if (range->layout->repaint_id)
g_source_remove (range->layout->repaint_id);
range->layout->repaint_id = 0;
+ gtk_widget_get_allocation (widget, &allocation);
+
expose_area = event->area;
- expose_area.x -= widget->allocation.x;
- expose_area.y -= widget->allocation.y;
-
+ expose_area.x -= allocation.x;
+ expose_area.y -= allocation.y;
+
gtk_range_calc_marks (range);
gtk_range_calc_layout (range, range->adjustment->value);
@@ -1855,9 +1873,9 @@ gtk_range_expose (GtkWidget *widget,
if (gdk_rectangle_intersect (&expose_area, &range->range_rect,
&area))
{
- gint x = (widget->allocation.x + range->range_rect.x +
+ gint x = (allocation.x + range->range_rect.x +
focus_line_width + focus_padding);
- gint y = (widget->allocation.y + range->range_rect.y +
+ gint y = (allocation.y + range->range_rect.y +
focus_line_width + focus_padding);
gint width = (range->range_rect.width -
2 * (focus_line_width + focus_padding));
@@ -1868,8 +1886,8 @@ gtk_range_expose (GtkWidget *widget,
gint stepper_size;
gint stepper_spacing;
- area.x += widget->allocation.x;
- area.y += widget->allocation.y;
+ area.x += allocation.x;
+ area.y += allocation.y;
gtk_widget_style_get (GTK_WIDGET (range),
"trough-side-details", &trough_side_details,
@@ -1925,8 +1943,7 @@ gtk_range_expose (GtkWidget *widget,
if (! trough_side_details)
{
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style, window,
sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN,
&area, GTK_WIDGET(range), "trough",
@@ -1941,14 +1958,13 @@ gtk_range_expose (GtkWidget *widget,
if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
trough_change_pos_x = (range->layout->slider.x +
range->layout->slider.width / 2 -
- (x - widget->allocation.x));
+ (x - allocation.x));
else
trough_change_pos_y = (range->layout->slider.y +
range->layout->slider.height / 2 -
- (y - widget->allocation.y));
+ (y - allocation.y));
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style, window,
sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN,
&area, GTK_WIDGET (range),
@@ -1961,8 +1977,7 @@ gtk_range_expose (GtkWidget *widget,
else
trough_change_pos_x = 0;
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style, window,
sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_IN,
&area, GTK_WIDGET (range),
@@ -1989,7 +2004,7 @@ gtk_range_expose (GtkWidget *widget,
if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- fill_x = widget->allocation.x + range->layout->trough.x;
+ fill_x = allocation.x + range->layout->trough.x;
fill_width = (range->layout->slider.width +
(fill_level - range->adjustment->lower) /
(range->adjustment->upper -
@@ -2003,7 +2018,7 @@ gtk_range_expose (GtkWidget *widget,
}
else
{
- fill_y = widget->allocation.y + range->layout->trough.y;
+ fill_y = allocation.y + range->layout->trough.y;
fill_height = (range->layout->slider.height +
(fill_level - range->adjustment->lower) /
(range->adjustment->upper -
@@ -2021,8 +2036,7 @@ gtk_range_expose (GtkWidget *widget,
else
fill_detail = "trough-fill-level";
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style, window,
sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
GTK_SHADOW_OUT,
&area, GTK_WIDGET (range), fill_detail,
@@ -2031,10 +2045,11 @@ gtk_range_expose (GtkWidget *widget,
}
if (sensitive && gtk_widget_has_focus (widget))
- gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
+ gtk_paint_focus (style, window,
+ gtk_widget_get_state (widget),
&area, widget, "trough",
- widget->allocation.x + range->range_rect.x,
- widget->allocation.y + range->range_rect.y,
+ allocation.x + range->range_rect.x,
+ allocation.y + range->range_rect.y,
range->range_rect.width,
range->range_rect.height);
}
@@ -2065,18 +2080,18 @@ gtk_range_expose (GtkWidget *widget,
&range->layout->slider,
&area))
{
- area.x += widget->allocation.x;
- area.y += widget->allocation.y;
-
- gtk_paint_slider (widget->style,
- widget->window,
+ area.x += allocation.x;
+ area.y += allocation.y;
+
+ gtk_paint_slider (style,
+ window,
state,
shadow_type,
&area,
widget,
gtk_range_get_slider_detail (range),
- widget->allocation.x + range->layout->slider.x,
- widget->allocation.y + range->layout->slider.y,
+ allocation.x + range->layout->slider.x,
+ allocation.y + range->layout->slider.y,
range->layout->slider.width,
range->layout->slider.height,
range->orientation);
@@ -2349,15 +2364,17 @@ gtk_range_button_press (GtkWidget *widget,
range->layout->mouse_location == MOUSE_STEPPER_D) &&
(event->button == 1 || event->button == 2 || event->button == 3))
{
+ GtkAllocation allocation;
GdkRectangle *stepper_area;
GtkScrollType scroll;
range_grab_add (range, device, range->layout->mouse_location, event->button);
stepper_area = get_area (range, range->layout->mouse_location);
+ gtk_widget_get_allocation (widget, &allocation);
gtk_widget_queue_draw_area (widget,
- widget->allocation.x + stepper_area->x,
- widget->allocation.y + stepper_area->y,
+ allocation.x + stepper_area->x,
+ allocation.y + stepper_area->y,
stepper_area->width,
stepper_area->height);
@@ -2739,10 +2756,11 @@ static gboolean
force_repaint (gpointer data)
{
GtkRange *range = GTK_RANGE (data);
+ GtkWidget *widget = GTK_WIDGET (range);
range->layout->repaint_id = 0;
- if (gtk_widget_is_drawable (GTK_WIDGET (range)))
- gdk_window_process_updates (GTK_WIDGET (range)->window, FALSE);
+ if (gtk_widget_is_drawable (widget))
+ gdk_window_process_updates (gtk_widget_get_window (widget), FALSE);
return FALSE;
}
@@ -3110,6 +3128,7 @@ gtk_range_get_props (GtkRange *range,
static gboolean
gtk_range_update_mouse_location (GtkRange *range)
{
+ GtkAllocation allocation;
gint x, y;
MouseLocation old;
GtkWidget *widget;
@@ -3121,6 +3140,8 @@ gtk_range_update_mouse_location (GtkRange *range)
x = range->layout->mouse_x;
y = range->layout->mouse_y;
+ gtk_widget_get_allocation (widget, &allocation);
+
if (range->layout->grab_location != MOUSE_OUTSIDE)
range->layout->mouse_location = range->layout->grab_location;
else if (POINT_IN_RECT (x, y, range->layout->stepper_a))
@@ -3135,7 +3156,7 @@ gtk_range_update_mouse_location (GtkRange *range)
range->layout->mouse_location = MOUSE_SLIDER;
else if (POINT_IN_RECT (x, y, range->layout->trough))
range->layout->mouse_location = MOUSE_TROUGH;
- else if (POINT_IN_RECT (x, y, widget->allocation))
+ else if (POINT_IN_RECT (x, y, allocation))
range->layout->mouse_location = MOUSE_WIDGET;
else
range->layout->mouse_location = MOUSE_OUTSIDE;
@@ -3153,6 +3174,7 @@ clamp_dimensions (GtkWidget *widget,
GtkBorder *border,
gboolean border_expands_horizontally)
{
+ GtkAllocation allocation;
gint extra, shortage;
g_return_if_fail (rect->x == 0);
@@ -3160,9 +3182,11 @@ clamp_dimensions (GtkWidget *widget,
g_return_if_fail (rect->width >= 0);
g_return_if_fail (rect->height >= 0);
+ gtk_widget_get_allocation (widget, &allocation);
+
/* Width */
-
- extra = widget->allocation.width - border->left - border->right - rect->width;
+
+ extra = allocation.width - border->left - border->right - rect->width;
if (extra > 0)
{
if (border_expands_horizontally)
@@ -3177,10 +3201,10 @@ clamp_dimensions (GtkWidget *widget,
}
/* See if we can fit rect, if not kill the border */
- shortage = rect->width - widget->allocation.width;
+ shortage = rect->width - allocation.width;
if (shortage > 0)
{
- rect->width = widget->allocation.width;
+ rect->width = allocation.width;
/* lose the border */
border->left = 0;
border->right = 0;
@@ -3188,8 +3212,7 @@ clamp_dimensions (GtkWidget *widget,
else
{
/* See if we can fit rect with borders */
- shortage = rect->width + border->left + border->right -
- widget->allocation.width;
+ shortage = rect->width + border->left + border->right - allocation.width;
if (shortage > 0)
{
/* Shrink borders */
@@ -3199,8 +3222,8 @@ clamp_dimensions (GtkWidget *widget,
}
/* Height */
-
- extra = widget->allocation.height - border->top - border->bottom - rect->height;
+
+ extra = allocation.height - border->top - border->bottom - rect->height;
if (extra > 0)
{
if (border_expands_horizontally)
@@ -3216,10 +3239,10 @@ clamp_dimensions (GtkWidget *widget,
}
/* See if we can fit rect, if not kill the border */
- shortage = rect->height - widget->allocation.height;
+ shortage = rect->height - allocation.height;
if (shortage > 0)
{
- rect->height = widget->allocation.height;
+ rect->height = allocation.height;
/* lose the border */
border->top = 0;
border->bottom = 0;
@@ -3227,8 +3250,7 @@ clamp_dimensions (GtkWidget *widget,
else
{
/* See if we can fit rect with borders */
- shortage = rect->height + border->top + border->bottom -
- widget->allocation.height;
+ shortage = rect->height + border->top + border->bottom - allocation.height;
if (shortage > 0)
{
/* Shrink borders */
diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c
index 612a8ec..31910b9 100644
--- a/gtk/gtkrecentchooserdefault.c
+++ b/gtk/gtkrecentchooserdefault.c
@@ -757,7 +757,8 @@ set_busy_cursor (GtkRecentChooserDefault *impl,
if (show_busy_cursor)
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
- gdk_window_set_cursor (GTK_WIDGET (toplevel)->window, cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (toplevel)),
+ cursor);
gdk_display_flush (display);
if (cursor)
@@ -936,7 +937,7 @@ set_default_size (GtkRecentChooserDefault *impl)
widget = GTK_WIDGET (impl);
/* Size based on characters and the icon size */
- font_size = pango_font_description_get_size (widget->style->font_desc);
+ font_size = pango_font_description_get_size (gtk_widget_get_style (widget)->font_desc);
font_size = PANGO_PIXELS (font_size);
width = impl->icon_size + font_size * NUM_CHARS;
@@ -949,7 +950,8 @@ set_default_size (GtkRecentChooserDefault *impl)
/* ... but no larger than the monitor */
screen = gtk_widget_get_screen (widget);
- monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+ monitor_num = gdk_screen_get_monitor_at_window (screen,
+ gtk_widget_get_window (widget));
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
@@ -1831,6 +1833,7 @@ popup_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (user_data);
GdkScreen *screen = gtk_widget_get_screen (widget);
GtkRequisition req;
@@ -1840,12 +1843,14 @@ popup_position_func (GtkMenu *menu,
if (G_UNLIKELY (!gtk_widget_get_realized (widget)))
return;
- gdk_window_get_origin (widget->window, x, y);
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ x, y);
gtk_widget_size_request (GTK_WIDGET (menu), &req);
- *x += (widget->allocation.width - req.width) / 2;
- *y += (widget->allocation.height - req.height) / 2;
+ gtk_widget_get_allocation (widget, &allocation);
+ *x += (allocation.width - req.width) / 2;
+ *y += (allocation.height - req.height) / 2;
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num);
diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c
index 1e32dc6..a88965b 100644
--- a/gtk/gtkruler.c
+++ b/gtk/gtkruler.c
@@ -189,8 +189,10 @@ gtk_ruler_class_init (GtkRulerClass *class)
static void
gtk_ruler_init (GtkRuler *ruler)
{
- GtkWidget *widget = GTK_WIDGET (ruler);
+ GtkRequisition requisition;
GtkRulerPriv *priv;
+ GtkStyle *style;
+ GtkWidget *widget = GTK_WIDGET (ruler);
ruler->priv = G_TYPE_INSTANCE_GET_PRIVATE (ruler,
GTK_TYPE_RULER,
@@ -199,8 +201,10 @@ gtk_ruler_init (GtkRuler *ruler)
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
- widget->requisition.width = widget->style->xthickness * 2 + 1;
- widget->requisition.height = widget->style->ythickness * 2 + RULER_WIDTH;
+ style = gtk_widget_get_style (widget);
+ requisition.width = style->xthickness * 2 + 1;
+ requisition.height = style->ythickness * 2 + RULER_WIDTH;
+ _gtk_widget_set_requisition (widget, &requisition);
priv->backing_store = NULL;
priv->xsrc = 0;
@@ -460,7 +464,9 @@ gtk_ruler_draw_pos (GtkRuler *ruler)
static void
gtk_ruler_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkRuler *ruler;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -468,11 +474,13 @@ gtk_ruler_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -483,11 +491,14 @@ gtk_ruler_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, ruler);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, ruler);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_ACTIVE);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window, GTK_STATE_ACTIVE);
gtk_ruler_make_pixmap (ruler);
}
@@ -513,16 +524,19 @@ gtk_ruler_size_request (GtkWidget *widget,
{
GtkRuler *ruler = GTK_RULER (widget);
GtkRulerPriv *priv = ruler->priv;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- requisition->width = widget->style->xthickness * 2 + 1;
- requisition->height = widget->style->ythickness * 2 + RULER_WIDTH;
+ requisition->width = style->xthickness * 2 + 1;
+ requisition->height = style->ythickness * 2 + RULER_WIDTH;
}
else
{
- requisition->width = widget->style->xthickness * 2 + RULER_WIDTH;
- requisition->height = widget->style->ythickness * 2 + 1;
+ requisition->width = style->xthickness * 2 + RULER_WIDTH;
+ requisition->height = style->ythickness * 2 + 1;
}
}
@@ -532,11 +546,11 @@ gtk_ruler_size_allocate (GtkWidget *widget,
{
GtkRuler *ruler = GTK_RULER (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
@@ -548,6 +562,7 @@ static gboolean
gtk_ruler_motion_notify (GtkWidget *widget,
GdkEventMotion *event)
{
+ GtkAllocation allocation;
GtkRuler *ruler = GTK_RULER (widget);
GtkRulerPriv *priv = ruler->priv;
gint x;
@@ -557,10 +572,11 @@ gtk_ruler_motion_notify (GtkWidget *widget,
x = event->x;
y = event->y;
+ gtk_widget_get_allocation (widget, &allocation);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
- priv->position = priv->lower + ((priv->upper - priv->lower) * x) / widget->allocation.width;
+ priv->position = priv->lower + ((priv->upper - priv->lower) * x) / allocation.width;
else
- priv->position = priv->lower + ((priv->upper - priv->lower) * y) / widget->allocation.height;
+ priv->position = priv->lower + ((priv->upper - priv->lower) * y) / allocation.height;
g_object_notify (G_OBJECT (ruler), "position");
@@ -582,8 +598,8 @@ gtk_ruler_expose (GtkWidget *widget,
cairo_t *cr;
gtk_ruler_draw_ticks (ruler);
-
- cr = gdk_cairo_create (widget->window);
+
+ cr = gdk_cairo_create (gtk_widget_get_window (widget));
gdk_cairo_set_source_pixmap (cr, priv->backing_store, 0, 0);
gdk_cairo_rectangle (cr, &event->area);
cairo_fill (cr);
@@ -598,6 +614,7 @@ gtk_ruler_expose (GtkWidget *widget,
static void
gtk_ruler_make_pixmap (GtkRuler *ruler)
{
+ GtkAllocation allocation;
GtkRulerPriv *priv = ruler->priv;
GtkWidget *widget;
gint width;
@@ -605,19 +622,21 @@ gtk_ruler_make_pixmap (GtkRuler *ruler)
widget = GTK_WIDGET (ruler);
+ gtk_widget_get_allocation (widget, &allocation);
+
if (priv->backing_store)
{
gdk_drawable_get_size (priv->backing_store, &width, &height);
- if ((width == widget->allocation.width) &&
- (height == widget->allocation.height))
+ if ((width == allocation.width) &&
+ (height == allocation.height))
return;
g_object_unref (priv->backing_store);
}
- priv->backing_store = gdk_pixmap_new (widget->window,
- widget->allocation.width,
- widget->allocation.height,
+ priv->backing_store = gdk_pixmap_new (gtk_widget_get_window (widget),
+ allocation.width,
+ allocation.height,
-1);
priv->xsrc = 0;
@@ -627,8 +646,10 @@ gtk_ruler_make_pixmap (GtkRuler *ruler)
static void
gtk_ruler_real_draw_ticks (GtkRuler *ruler)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (ruler);
GtkRulerPriv *priv = ruler->priv;
+ GtkStyle *style;
cairo_t *cr;
gint i, j;
gint width, height;
@@ -652,8 +673,11 @@ gtk_ruler_real_draw_ticks (GtkRuler *ruler)
if (!gtk_widget_is_drawable (widget))
return;
- xthickness = widget->style->xthickness;
- ythickness = widget->style->ythickness;
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
layout = gtk_widget_create_pango_layout (widget, "012456789");
pango_layout_get_extents (layout, &ink_rect, &logical_rect);
@@ -663,34 +687,34 @@ gtk_ruler_real_draw_ticks (GtkRuler *ruler)
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- width = widget->allocation.width;
- height = widget->allocation.height - ythickness * 2;
+ width = allocation.width;
+ height = allocation.height - ythickness * 2;
}
else
{
- width = widget->allocation.height;
- height = widget->allocation.width - ythickness * 2;
+ width = allocation.height;
+ height = allocation.width - ythickness * 2;
}
#define DETAILE(private) (priv->orientation == GTK_ORIENTATION_HORIZONTAL ? "hruler" : "vruler");
- gtk_paint_box (widget->style, priv->backing_store,
+ gtk_paint_box (style, priv->backing_store,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
NULL, widget,
priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
"hruler" : "vruler",
0, 0,
- widget->allocation.width, widget->allocation.height);
+ allocation.width, allocation.height);
cr = gdk_cairo_create (priv->backing_store);
- gdk_cairo_set_source_color (cr, &widget->style->fg[widget->state]);
+ gdk_cairo_set_source_color (cr, &style->fg[gtk_widget_get_state (widget)]);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
cairo_rectangle (cr,
xthickness,
height + ythickness,
- widget->allocation.width - 2 * xthickness,
+ allocation.width - 2 * xthickness,
1);
}
else
@@ -699,7 +723,7 @@ gtk_ruler_real_draw_ticks (GtkRuler *ruler)
height + xthickness,
ythickness,
1,
- widget->allocation.height - 2 * ythickness);
+ allocation.height - 2 * ythickness);
}
upper = priv->upper / priv->metric->pixels_per_unit;
@@ -797,7 +821,7 @@ gtk_ruler_real_draw_ticks (GtkRuler *ruler)
pango_layout_set_text (layout, unit_str, -1);
pango_layout_get_extents (layout, &logical_rect, NULL);
- gtk_paint_layout (widget->style,
+ gtk_paint_layout (style,
priv->backing_store,
gtk_widget_get_state (widget),
FALSE,
@@ -814,7 +838,7 @@ gtk_ruler_real_draw_ticks (GtkRuler *ruler)
pango_layout_set_text (layout, unit_str + j, 1);
pango_layout_get_extents (layout, NULL, &logical_rect);
- gtk_paint_layout (widget->style,
+ gtk_paint_layout (style,
priv->backing_store,
gtk_widget_get_state (widget),
FALSE,
@@ -840,8 +864,10 @@ out:
static void
gtk_ruler_real_draw_pos (GtkRuler *ruler)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (ruler);
GtkRulerPriv *priv = ruler->priv;
+ GtkStyle *style;
gint x, y;
gint width, height;
gint bs_width, bs_height;
@@ -851,10 +877,13 @@ gtk_ruler_real_draw_pos (GtkRuler *ruler)
if (gtk_widget_is_drawable (widget))
{
- xthickness = widget->style->xthickness;
- ythickness = widget->style->ythickness;
- width = widget->allocation.width;
- height = widget->allocation.height;
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
+ xthickness = style->xthickness;
+ ythickness = style->ythickness;
+ width = allocation.width;
+ height = allocation.height;
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -875,11 +904,15 @@ gtk_ruler_real_draw_pos (GtkRuler *ruler)
if ((bs_width > 0) && (bs_height > 0))
{
- cairo_t *cr = gdk_cairo_create (widget->window);
+ GdkWindow *window;
+
+ window = gtk_widget_get_window (widget);
+
+ cairo_t *cr = gdk_cairo_create (window);
/* If a backing store exists, restore the ruler */
if (priv->backing_store) {
- cairo_t *cr = gdk_cairo_create (widget->window);
+ cairo_t *cr = gdk_cairo_create (window);
gdk_cairo_set_source_pixmap (cr, priv->backing_store, 0, 0);
cairo_rectangle (cr, priv->xsrc, priv->ysrc, bs_width, bs_height);
@@ -903,7 +936,7 @@ gtk_ruler_real_draw_pos (GtkRuler *ruler)
y = ROUND ((priv->position - priv->lower) * increment) + (ythickness - bs_height) / 2 - 1;
}
- gdk_cairo_set_source_color (cr, &widget->style->fg[widget->state]);
+ gdk_cairo_set_source_color (cr, &style->fg[gtk_widget_get_state (widget)]);
cairo_move_to (cr, x, y);
diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c
index eb930ba..d1ff870 100644
--- a/gtk/gtkscale.c
+++ b/gtk/gtkscale.c
@@ -947,6 +947,7 @@ find_next_pos (GtkWidget *widget,
GtkPositionType pos,
gint match)
{
+ GtkAllocation allocation;
GSList *m;
gint i;
@@ -958,10 +959,11 @@ find_next_pos (GtkWidget *widget,
return marks[i];
}
+ gtk_widget_get_allocation (widget, &allocation);
if (pos == GTK_POS_TOP || pos == GTK_POS_BOTTOM)
- return widget->allocation.width;
+ return allocation.width;
else
- return widget->allocation.height;
+ return allocation.height;
}
static gboolean
@@ -972,6 +974,8 @@ gtk_scale_expose (GtkWidget *widget,
GtkScalePriv *priv = scale->priv;
GtkRange *range = GTK_RANGE (scale);
GtkStateType state_type;
+ GtkStyle *style;
+ GdkWindow *window;
gint n_marks;
gint *marks;
gint focus_padding;
@@ -979,6 +983,7 @@ gtk_scale_expose (GtkWidget *widget,
gint value_spacing;
gint min_sep = 4;
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"focus-padding", &focus_padding,
"slider-width", &slider_width,
@@ -990,12 +995,15 @@ gtk_scale_expose (GtkWidget *widget,
*/
GTK_WIDGET_CLASS (gtk_scale_parent_class)->expose_event (widget, event);
+ window = gtk_widget_get_window (widget);
+
state_type = GTK_STATE_NORMAL;
if (!gtk_widget_is_sensitive (widget))
state_type = GTK_STATE_INSENSITIVE;
if (priv->marks)
{
+ GtkAllocation allocation;
gint i;
gint x1, x2, x3, y1, y2, y3;
PangoLayout *layout;
@@ -1006,34 +1014,35 @@ gtk_scale_expose (GtkWidget *widget,
n_marks = _gtk_range_get_stop_positions (range, &marks);
layout = gtk_widget_create_pango_layout (widget, NULL);
+ gtk_widget_get_allocation (widget, &allocation);
if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
- min_pos_before = min_pos_after = widget->allocation.x;
+ min_pos_before = min_pos_after = allocation.x;
else
- min_pos_before = min_pos_after = widget->allocation.y;
+ min_pos_before = min_pos_after = allocation.y;
for (m = priv->marks, i = 0; m; m = m->next, i++)
{
GtkScaleMark *mark = m->data;
if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
{
- x1 = widget->allocation.x + marks[i];
+ x1 = allocation.x + marks[i];
if (mark->position == GTK_POS_TOP)
{
- y1 = widget->allocation.y + range->range_rect.y;
+ y1 = allocation.y + range->range_rect.y;
y2 = y1 - slider_width / 2;
min_pos = min_pos_before;
- max_pos = widget->allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 1) - min_sep;
+ max_pos = allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 1) - min_sep;
}
else
{
- y1 = widget->allocation.y + range->range_rect.y + range->range_rect.height;
+ y1 = allocation.y + range->range_rect.y + range->range_rect.height;
y2 = y1 + slider_width / 2;
min_pos = min_pos_after;
- max_pos = widget->allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 0) - min_sep;
+ max_pos = allocation.x + find_next_pos (widget, m, marks + i, GTK_POS_TOP, 0) - min_sep;
}
- gtk_paint_vline (widget->style, widget->window, state_type,
+ gtk_paint_vline (style, window, state_type,
NULL, widget, "scale-mark", y1, y2, x1);
if (mark->markup)
@@ -1046,8 +1055,8 @@ gtk_scale_expose (GtkWidget *widget,
x3 = min_pos;
if (x3 + logical_rect.width > max_pos)
x3 = max_pos - logical_rect.width;
- if (x3 < widget->allocation.x)
- x3 = widget->allocation.x;
+ if (x3 < allocation.x)
+ x3 = allocation.x;
if (mark->position == GTK_POS_TOP)
{
y3 = y2 - value_spacing - logical_rect.height;
@@ -1059,7 +1068,7 @@ gtk_scale_expose (GtkWidget *widget,
min_pos_after = x3 + logical_rect.width + min_sep;
}
- gtk_paint_layout (widget->style, widget->window, state_type,
+ gtk_paint_layout (style, window, state_type,
FALSE, NULL, widget, "scale-mark",
x3, y3, layout);
}
@@ -1068,21 +1077,21 @@ gtk_scale_expose (GtkWidget *widget,
{
if (mark->position == GTK_POS_LEFT)
{
- x1 = widget->allocation.x + range->range_rect.x;
- x2 = widget->allocation.x + range->range_rect.x - slider_width / 2;
+ x1 = allocation.x + range->range_rect.x;
+ x2 = allocation.x + range->range_rect.x - slider_width / 2;
min_pos = min_pos_before;
- max_pos = widget->allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 1) - min_sep;
+ max_pos = allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 1) - min_sep;
}
else
{
- x1 = widget->allocation.x + range->range_rect.x + range->range_rect.width;
- x2 = widget->allocation.x + range->range_rect.x + range->range_rect.width + slider_width / 2;
+ x1 = allocation.x + range->range_rect.x + range->range_rect.width;
+ x2 = allocation.x + range->range_rect.x + range->range_rect.width + slider_width / 2;
min_pos = min_pos_after;
- max_pos = widget->allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 0) - min_sep;
+ max_pos = allocation.y + find_next_pos (widget, m, marks + i, GTK_POS_LEFT, 0) - min_sep;
}
- y1 = widget->allocation.y + marks[i];
+ y1 = allocation.y + marks[i];
- gtk_paint_hline (widget->style, widget->window, state_type,
+ gtk_paint_hline (style, window, state_type,
NULL, widget, "range-mark", x1, x2, y1);
if (mark->markup)
@@ -1095,8 +1104,8 @@ gtk_scale_expose (GtkWidget *widget,
y3 = min_pos;
if (y3 + logical_rect.height > max_pos)
y3 = max_pos - logical_rect.height;
- if (y3 < widget->allocation.y)
- y3 = widget->allocation.y;
+ if (y3 < allocation.y)
+ y3 = allocation.y;
if (mark->position == GTK_POS_LEFT)
{
x3 = x2 - value_spacing - logical_rect.width;
@@ -1108,7 +1117,7 @@ gtk_scale_expose (GtkWidget *widget,
min_pos_after = y3 + logical_rect.height + min_sep;
}
- gtk_paint_layout (widget->style, widget->window, state_type,
+ gtk_paint_layout (style, window, state_type,
FALSE, NULL, widget, "scale-mark",
x3, y3, layout);
}
@@ -1127,8 +1136,8 @@ gtk_scale_expose (GtkWidget *widget,
layout = gtk_scale_get_layout (scale);
gtk_scale_get_layout_offsets (scale, &x, &y);
- gtk_paint_layout (widget->style,
- widget->window,
+ gtk_paint_layout (style,
+ window,
state_type,
FALSE,
NULL,
@@ -1149,6 +1158,7 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale,
gint *y)
{
GtkScalePriv *priv = scale->priv;
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (scale);
GtkRange *range = GTK_RANGE (widget);
PangoLayout *layout = gtk_scale_get_layout (scale);
@@ -1167,6 +1177,8 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale,
pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+ gtk_widget_get_allocation (widget, &allocation);
+
if (range->orientation == GTK_ORIENTATION_HORIZONTAL)
{
switch (priv->value_pos)
@@ -1184,14 +1196,14 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale,
case GTK_POS_TOP:
*x = range->slider_start +
(range->slider_end - range->slider_start - logical_rect.width) / 2;
- *x = CLAMP (*x, 0, widget->allocation.width - logical_rect.width);
+ *x = CLAMP (*x, 0, allocation.width - logical_rect.width);
*y = range->range_rect.y - logical_rect.height - value_spacing;
break;
case GTK_POS_BOTTOM:
*x = range->slider_start +
(range->slider_end - range->slider_start - logical_rect.width) / 2;
- *x = CLAMP (*x, 0, widget->allocation.width - logical_rect.width);
+ *x = CLAMP (*x, 0, allocation.width - logical_rect.width);
*y = range->range_rect.y + range->range_rect.height + value_spacing;
break;
@@ -1207,13 +1219,13 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale,
case GTK_POS_LEFT:
*x = range->range_rect.x - logical_rect.width - value_spacing;
*y = range->slider_start + (range->slider_end - range->slider_start - logical_rect.height) / 2;
- *y = CLAMP (*y, 0, widget->allocation.height - logical_rect.height);
+ *y = CLAMP (*y, 0, allocation.height - logical_rect.height);
break;
case GTK_POS_RIGHT:
*x = range->range_rect.x + range->range_rect.width + value_spacing;
*y = range->slider_start + (range->slider_end - range->slider_start - logical_rect.height) / 2;
- *y = CLAMP (*y, 0, widget->allocation.height - logical_rect.height);
+ *y = CLAMP (*y, 0, allocation.height - logical_rect.height);
break;
case GTK_POS_TOP:
@@ -1231,8 +1243,8 @@ gtk_scale_real_get_layout_offsets (GtkScale *scale,
}
}
- *x += widget->allocation.x;
- *y += widget->allocation.y;
+ *x += allocation.x;
+ *y += allocation.y;
}
/**
diff --git a/gtk/gtkscalebutton.c b/gtk/gtkscalebutton.c
index 6e1cad9..151f10a 100644
--- a/gtk/gtkscalebutton.c
+++ b/gtk/gtkscalebutton.c
@@ -896,6 +896,7 @@ gtk_scale_popup (GtkWidget *widget,
GdkEvent *event,
guint32 time)
{
+ GtkAllocation allocation, dock_allocation, scale_allocation;
GtkScaleButton *button;
GtkScaleButtonPrivate *priv;
GtkAdjustment *adj;
@@ -913,13 +914,15 @@ gtk_scale_popup (GtkWidget *widget,
display = gtk_widget_get_display (widget);
screen = gtk_widget_get_screen (widget);
+ gtk_widget_get_allocation (widget, &allocation);
/* position roughly */
gtk_window_set_screen (GTK_WINDOW (priv->dock), screen);
- gdk_window_get_origin (widget->window, &x, &y);
- x += widget->allocation.x;
- y += widget->allocation.y;
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ &x, &y);
+ x += allocation.x;
+ y += allocation.y;
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
gtk_window_move (GTK_WINDOW (priv->dock), x, y - (SCALE_SIZE / 2));
@@ -928,13 +931,18 @@ gtk_scale_popup (GtkWidget *widget,
gtk_widget_show_all (priv->dock);
- gdk_window_get_origin (priv->dock->window, &dx, &dy);
- dx += priv->dock->allocation.x;
- dy += priv->dock->allocation.y;
+ gdk_window_get_origin (gtk_widget_get_window (priv->dock),
+ &dx, &dy);
+ gtk_widget_get_allocation (priv->dock, &dock_allocation);
+ dx += dock_allocation.x;
+ dy += dock_allocation.y;
- gdk_window_get_origin (priv->scale->window, &sx, &sy);
- sx += priv->scale->allocation.x;
- sy += priv->scale->allocation.y;
+
+ gdk_window_get_origin (gtk_widget_get_window (priv->scale),
+ &sx, &sy);
+ gtk_widget_get_allocation (priv->scale, &scale_allocation);
+ sx += scale_allocation.x;
+ sy += scale_allocation.y;
priv->timeout = TRUE;
@@ -945,11 +953,10 @@ gtk_scale_popup (GtkWidget *widget,
{
startoff = sy - dy;
- x += (widget->allocation.width - priv->dock->allocation.width) / 2;
+ x += (allocation.width - dock_allocation.width) / 2;
y -= startoff;
y -= GTK_RANGE (priv->scale)->min_slider_size / 2;
- m = priv->scale->allocation.height -
- GTK_RANGE (priv->scale)->min_slider_size;
+ m = scale_allocation.height - GTK_RANGE (priv->scale)->min_slider_size;
y -= m * (1.0 - v);
}
else
@@ -957,16 +964,16 @@ gtk_scale_popup (GtkWidget *widget,
startoff = sx - dx;
x -= startoff;
- y += (widget->allocation.height - priv->dock->allocation.height) / 2;
+ y += (allocation.height - dock_allocation.height) / 2;
x -= GTK_RANGE (priv->scale)->min_slider_size / 2;
- m = priv->scale->allocation.width -
- GTK_RANGE (priv->scale)->min_slider_size;
+ m = scale_allocation.width - GTK_RANGE (priv->scale)->min_slider_size;
x -= m * v;
}
/* Make sure the dock stays inside the monitor */
if (event->type == GDK_BUTTON_PRESS)
{
+ GtkAllocation d_allocation;
int monitor;
GdkEventButton *button_event = (GdkEventButton *) event;
GdkRectangle rect;
@@ -986,14 +993,15 @@ gtk_scale_popup (GtkWidget *widget,
/* Move the dock, but set is_moved so we
* don't forward the first click later on,
* as it could make the scale go to the bottom */
+ gtk_widget_get_allocation (d, &d_allocation);
if (y < rect.y)
{
y = rect.y;
is_moved = TRUE;
}
- else if (y + d->allocation.height > rect.height + rect.y)
+ else if (y + d_allocation.height > rect.height + rect.y)
{
- y = rect.y + rect.height - d->allocation.height;
+ y = rect.y + rect.height - d_allocation.height;
is_moved = TRUE;
}
@@ -1002,9 +1010,9 @@ gtk_scale_popup (GtkWidget *widget,
x = rect.x;
is_moved = TRUE;
}
- else if (x + d->allocation.width > rect.width + rect.x)
+ else if (x + d_allocation.width > rect.width + rect.x)
{
- x = rect.x + rect.width - d->allocation.width;
+ x = rect.x + rect.width - d_allocation.width;
is_moved = TRUE;
}
}
@@ -1030,7 +1038,7 @@ gtk_scale_popup (GtkWidget *widget,
/* grab focus */
gtk_device_grab_add (priv->dock, pointer, TRUE);
- if (gdk_device_grab (pointer, priv->dock->window,
+ if (gdk_device_grab (pointer, gtk_widget_get_window (priv->dock),
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK, NULL, time) != GDK_GRAB_SUCCESS)
@@ -1040,7 +1048,7 @@ gtk_scale_popup (GtkWidget *widget,
return FALSE;
}
- if (gdk_device_grab (keyboard, priv->dock->window,
+ if (gdk_device_grab (keyboard, gtk_widget_get_window (priv->dock),
GDK_OWNERSHIP_WINDOW, TRUE,
GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK,
NULL, time) != GDK_GRAB_SUCCESS)
@@ -1062,24 +1070,25 @@ gtk_scale_popup (GtkWidget *widget,
/* forward event to the slider */
e = (GdkEventButton *) gdk_event_copy ((GdkEvent *) event);
- e->window = priv->scale->window;
+ e->window = gtk_widget_get_window (priv->scale);
/* position: the X position isn't relevant, halfway will work just fine.
* The vertical position should be *exactly* in the middle of the slider
* of the scale; if we don't do that correctly, it'll move from its current
* position, which means a position change on-click, which is bad.
*/
+ gtk_widget_get_allocation (priv->scale, &scale_allocation);
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
{
- e->x = priv->scale->allocation.width / 2;
- m = priv->scale->allocation.height -
+ e->x = scale_allocation.width / 2;
+ m = scale_allocation.height -
GTK_RANGE (priv->scale)->min_slider_size;
e->y = ((1.0 - v) * m) + GTK_RANGE (priv->scale)->min_slider_size / 2;
}
else
{
- e->y = priv->scale->allocation.height / 2;
- m = priv->scale->allocation.width -
+ e->y = scale_allocation.height / 2;
+ m = scale_allocation.width -
GTK_RANGE (priv->scale)->min_slider_size;
e->x = (v * m) + GTK_RANGE (priv->scale)->min_slider_size / 2;
}
@@ -1319,7 +1328,7 @@ gtk_scale_button_release_grab (GtkScaleButton *button,
priv->timeout = FALSE;
e = (GdkEventButton *) gdk_event_copy ((GdkEvent *) event);
- e->window = GTK_WIDGET (button)->window;
+ e->window = gtk_widget_get_window (GTK_WIDGET (button));
e->type = GDK_BUTTON_RELEASE;
gtk_widget_event (GTK_WIDGET (button), (GdkEvent *) e);
e->window = event->window;
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 6bbe37b..910b8f5 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1045,19 +1045,24 @@ gtk_scrolled_window_paint (GtkWidget *widget,
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
{
+ GtkAllocation allocation;
GtkAllocation relative_allocation;
+ GtkStyle *style;
gboolean scrollbars_within_bevel;
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+
if (!scrollbars_within_bevel)
{
gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
- relative_allocation.x -= widget->style->xthickness;
- relative_allocation.y -= widget->style->ythickness;
- relative_allocation.width += 2 * widget->style->xthickness;
- relative_allocation.height += 2 * widget->style->ythickness;
+ relative_allocation.x -= style->xthickness;
+ relative_allocation.y -= style->ythickness;
+ relative_allocation.width += 2 * style->xthickness;
+ relative_allocation.height += 2 * style->ythickness;
}
else
{
@@ -1068,15 +1073,16 @@ gtk_scrolled_window_paint (GtkWidget *widget,
relative_allocation.x = border_width;
relative_allocation.y = border_width;
- relative_allocation.width = widget->allocation.width - 2 * border_width;
- relative_allocation.height = widget->allocation.height - 2 * border_width;
+ relative_allocation.width = allocation.width - 2 * border_width;
+ relative_allocation.height = allocation.height - 2 * border_width;
}
- gtk_paint_shadow (widget->style, widget->window,
+ gtk_paint_shadow (style,
+ gtk_widget_get_window (widget),
GTK_STATE_NORMAL, scrolled_window->shadow_type,
area, widget, "scrolled_window",
- widget->allocation.x + relative_allocation.x,
- widget->allocation.y + relative_allocation.y,
+ allocation.x + relative_allocation.x,
+ allocation.y + relative_allocation.y,
relative_allocation.width,
relative_allocation.height);
}
@@ -1253,8 +1259,10 @@ static void
gtk_scrolled_window_relative_allocation (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkAllocation widget_allocation;
GtkScrolledWindow *scrolled_window;
GtkScrolledWindowPrivate *priv;
+ GtkStyle *style;
gint scrollbar_spacing;
guint border_width;
@@ -1272,12 +1280,14 @@ gtk_scrolled_window_relative_allocation (GtkWidget *widget,
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
{
- allocation->x += widget->style->xthickness;
- allocation->y += widget->style->ythickness;
+ style = gtk_widget_get_style (widget);
+ allocation->x += style->xthickness;
+ allocation->y += style->ythickness;
}
-
- allocation->width = MAX (1, (gint)widget->allocation.width - allocation->x * 2);
- allocation->height = MAX (1, (gint)widget->allocation.height - allocation->y * 2);
+
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ allocation->width = MAX (1, (gint) widget_allocation.width - allocation->x * 2);
+ allocation->height = MAX (1, (gint) widget_allocation.height - allocation->y * 2);
if (scrolled_window->vscrollbar_visible)
{
@@ -1318,6 +1328,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
{
GtkScrolledWindow *scrolled_window;
GtkScrolledWindowPrivate *priv;
+ GtkStyle *style;
GtkBin *bin;
GtkAllocation relative_allocation;
GtkAllocation child_allocation;
@@ -1333,12 +1344,15 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
bin = GTK_BIN (scrolled_window);
scrollbar_spacing = _gtk_scrolled_window_get_scrollbar_spacing (scrolled_window);
+
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
priv = GTK_SCROLLED_WINDOW_GET_PRIVATE (scrolled_window);
border_width = gtk_container_get_border_width (GTK_CONTAINER (scrolled_window));
- widget->allocation = *allocation;
+
+ gtk_widget_set_allocation (widget, allocation);
if (scrolled_window->hscrollbar_policy == GTK_POLICY_ALWAYS)
scrolled_window->hscrollbar_visible = TRUE;
@@ -1414,7 +1428,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
relative_allocation.height +
scrollbar_spacing +
(scrolled_window->shadow_type == GTK_SHADOW_NONE ?
- 0 : widget->style->ythickness));
+ 0 : style->ythickness));
else
child_allocation.y = border_width;
@@ -1427,17 +1441,17 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
{
if (!scrollbars_within_bevel)
{
- child_allocation.x -= widget->style->xthickness;
- child_allocation.width += 2 * widget->style->xthickness;
+ child_allocation.x -= style->xthickness;
+ child_allocation.width += 2 * style->xthickness;
}
else if (GTK_CORNER_TOP_RIGHT == priv->real_window_placement ||
GTK_CORNER_TOP_LEFT == priv->real_window_placement)
{
- child_allocation.y -= widget->style->ythickness;
+ child_allocation.y -= style->ythickness;
}
else
{
- child_allocation.y += widget->style->ythickness;
+ child_allocation.y += style->ythickness;
}
}
@@ -1465,7 +1479,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
relative_allocation.width +
scrollbar_spacing +
(scrolled_window->shadow_type == GTK_SHADOW_NONE ?
- 0 : widget->style->xthickness));
+ 0 : style->xthickness));
else
child_allocation.x = border_width;
@@ -1479,17 +1493,17 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
{
if (!scrollbars_within_bevel)
{
- child_allocation.y -= widget->style->ythickness;
- child_allocation.height += 2 * widget->style->ythickness;
+ child_allocation.y -= style->ythickness;
+ child_allocation.height += 2 * style->ythickness;
}
else if (GTK_CORNER_BOTTOM_LEFT == priv->real_window_placement ||
GTK_CORNER_TOP_LEFT == priv->real_window_placement)
{
- child_allocation.x -= widget->style->xthickness;
+ child_allocation.x -= style->xthickness;
}
else
{
- child_allocation.x += widget->style->xthickness;
+ child_allocation.x += style->xthickness;
}
}
@@ -1679,7 +1693,7 @@ gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == NULL);
+ g_return_if_fail (gtk_widget_get_parent (child) == NULL);
bin = GTK_BIN (scrolled_window);
child_widget = gtk_bin_get_child (bin);
@@ -1759,6 +1773,7 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
GtkRequisition hscrollbar_requisition;
GtkRequisition vscrollbar_requisition;
GtkRequisition minimum_req, natural_req;
+ GtkStyle *style;
GtkWidget *child;
gint min_child_size, nat_child_size;
guint border_width;
@@ -1867,10 +1882,11 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
if (scrolled_window->shadow_type != GTK_SHADOW_NONE)
{
- minimum_req.width += 2 * GTK_WIDGET (widget)->style->xthickness;
- minimum_req.height += 2 * GTK_WIDGET (widget)->style->ythickness;
- natural_req.width += 2 * GTK_WIDGET (widget)->style->xthickness;
- natural_req.height += 2 * GTK_WIDGET (widget)->style->ythickness;
+ style = gtk_widget_get_style (GTK_WIDGET (widget));
+ minimum_req.width += 2 * style->xthickness;
+ minimum_req.height += 2 * style->ythickness;
+ natural_req.width += 2 * style->xthickness;
+ natural_req.height += 2 * style->ythickness;
}
if (orientation == GTK_ORIENTATION_HORIZONTAL)
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index 5d6ad03..74779a9 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -664,7 +664,7 @@ gtk_selection_owner_set_for_display (GdkDisplay *display,
if (widget == NULL)
window = NULL;
else
- window = widget->window;
+ window = gtk_widget_get_window (widget);
tmp_list = current_selections;
while (tmp_list)
@@ -719,8 +719,8 @@ gtk_selection_owner_set_for_display (GdkDisplay *display,
if (old_owner && old_owner != widget)
{
GdkEvent *event = gdk_event_new (GDK_SELECTION_CLEAR);
-
- event->selection.window = g_object_ref (old_owner->window);
+
+ event->selection.window = g_object_ref (gtk_widget_get_window (old_owner));
event->selection.selection = selection;
event->selection.time = time;
@@ -1103,7 +1103,7 @@ gtk_selection_convert (GtkWidget *widget,
/* Otherwise, we need to go through X */
current_retrievals = g_list_append (current_retrievals, info);
- gdk_selection_convert (widget->window, selection, target, time_);
+ gdk_selection_convert (gtk_widget_get_window (widget), selection, target, time_);
gdk_threads_add_timeout (1000,
(GSourceFunc) gtk_selection_retrieval_timeout, info);
@@ -2670,21 +2670,24 @@ gtk_selection_incr_timeout (GtkIncrInfo *info)
*************************************************************/
gboolean
-_gtk_selection_notify (GtkWidget *widget,
+_gtk_selection_notify (GtkWidget *widget,
GdkEventSelection *event)
{
GList *tmp_list;
GtkRetrievalInfo *info = NULL;
+ GdkWindow *window;
guchar *buffer = NULL;
gint length;
GdkAtom type;
gint format;
-
+
#ifdef DEBUG_SELECTION
g_message ("Initial receipt of selection %ld, target %ld (property = %ld)",
event->selection, event->target, event->property);
#endif
-
+
+ window = gtk_widget_get_window (widget);
+
tmp_list = current_retrievals;
while (tmp_list)
{
@@ -2698,7 +2701,7 @@ _gtk_selection_notify (GtkWidget *widget,
return FALSE;
if (event->property != GDK_NONE)
- length = gdk_selection_property_get (widget->window, &buffer,
+ length = gdk_selection_property_get (window, &buffer,
&type, &format);
else
length = 0; /* silence gcc */
@@ -2722,8 +2725,8 @@ _gtk_selection_notify (GtkWidget *widget,
info->notify_time = event->time;
info->idle_time = 0;
info->offset = 0; /* Mark as OK to proceed */
- gdk_window_set_events (widget->window,
- gdk_window_get_events (widget->window)
+ gdk_window_set_events (window,
+ gdk_window_get_events (window)
| GDK_PROPERTY_CHANGE_MASK);
}
else
@@ -2737,9 +2740,9 @@ _gtk_selection_notify (GtkWidget *widget,
type, format,
buffer, length, event->time);
}
-
- gdk_property_delete (widget->window, event->property);
-
+
+ gdk_property_delete (window, event->property);
+
g_free (buffer);
return TRUE;
@@ -2764,6 +2767,7 @@ _gtk_selection_property_notify (GtkWidget *widget,
{
GList *tmp_list;
GtkRetrievalInfo *info = NULL;
+ GdkWindow *window;
guchar *new_buffer;
int length;
GdkAtom type;
@@ -2800,11 +2804,12 @@ _gtk_selection_property_notify (GtkWidget *widget,
return FALSE;
info->idle_time = 0;
-
- length = gdk_selection_property_get (widget->window, &new_buffer,
+
+ window = gtk_widget_get_window (widget);
+ length = gdk_selection_property_get (window, &new_buffer,
&type, &format);
- gdk_property_delete (widget->window, event->atom);
-
+ gdk_property_delete (window, event->atom);
+
/* We could do a lot better efficiency-wise by paying attention to
what length was sent in the initial INCR transaction, instead of
doing memory allocation at every step. But its only guaranteed to
diff --git a/gtk/gtkseparator.c b/gtk/gtkseparator.c
index 45e93f3..f7d26ef 100644
--- a/gtk/gtkseparator.c
+++ b/gtk/gtkseparator.c
@@ -102,13 +102,15 @@ gtk_separator_init (GtkSeparator *separator)
{
GtkWidget *widget = GTK_WIDGET (separator);
GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (separator);
+ GtkRequisition requisition;
gtk_widget_set_has_window (GTK_WIDGET (separator), FALSE);
private->orientation = GTK_ORIENTATION_HORIZONTAL;
- widget->requisition.width = 1;
- widget->requisition.height = widget->style->ythickness;
+ requisition.width = 1;
+ requisition.height = gtk_widget_get_style (widget)->ythickness;
+ _gtk_widget_set_requisition (widget, &requisition);
}
static void
@@ -155,10 +157,12 @@ gtk_separator_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (widget);
+ GtkStyle *style;
gboolean wide_separators;
gint separator_width;
gint separator_height;
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"wide-separators", &wide_separators,
"separator-width", &separator_width,
@@ -173,14 +177,14 @@ gtk_separator_size_request (GtkWidget *widget,
if (wide_separators)
requisition->height = separator_height;
else
- requisition->height = widget->style->ythickness;
+ requisition->height = style->ythickness;
}
else
{
if (wide_separators)
requisition->width = separator_width;
else
- requisition->width = widget->style->xthickness;
+ requisition->width = style->xthickness;
}
}
@@ -189,6 +193,10 @@ gtk_separator_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GtkSeparatorPrivate *private = GTK_SEPARATOR_GET_PRIVATE (widget);
+ GtkAllocation allocation;
+ GtkStateType state;
+ GtkStyle *style;
+ GdkWindow *window;
gboolean wide_separators;
gint separator_width;
gint separator_height;
@@ -196,51 +204,52 @@ gtk_separator_expose (GtkWidget *widget,
if (!gtk_widget_is_drawable (widget))
return FALSE;
+ style = gtk_widget_get_style (widget);
gtk_widget_style_get (widget,
"wide-separators", &wide_separators,
"separator-width", &separator_width,
"separator-height", &separator_height,
NULL);
+ window = gtk_widget_get_window (widget);
+ state = gtk_widget_get_state (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
if (private->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (wide_separators)
- gtk_paint_box (widget->style, widget->window,
- gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT,
+ gtk_paint_box (style, window,
+ state, GTK_SHADOW_ETCHED_OUT,
&event->area, widget, "hseparator",
- widget->allocation.x,
- widget->allocation.y + (widget->allocation.height -
- separator_height) / 2,
- widget->allocation.width,
+ allocation.x,
+ allocation.y + (allocation.height - separator_height) / 2,
+ allocation.width,
separator_height);
else
- gtk_paint_hline (widget->style, widget->window,
- gtk_widget_get_state (widget),
+ gtk_paint_hline (style, window,
+ state,
&event->area, widget, "hseparator",
- widget->allocation.x,
- widget->allocation.x + widget->allocation.width - 1,
- widget->allocation.y + (widget->allocation.height -
- widget->style->ythickness) / 2);
+ allocation.x,
+ allocation.x + allocation.width - 1,
+ allocation.y + (allocation.height - style->ythickness) / 2);
}
else
{
if (wide_separators)
- gtk_paint_box (widget->style, widget->window,
- gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT,
+ gtk_paint_box (style, window,
+ state, GTK_SHADOW_ETCHED_OUT,
&event->area, widget, "vseparator",
- widget->allocation.x + (widget->allocation.width -
- separator_width) / 2,
- widget->allocation.y,
+ allocation.x + (allocation.width - separator_width) / 2,
+ allocation.y,
separator_width,
- widget->allocation.height);
+ allocation.height);
else
- gtk_paint_vline (widget->style, widget->window,
- gtk_widget_get_state (widget),
+ gtk_paint_vline (style, window,
+ state,
&event->area, widget, "vseparator",
- widget->allocation.y,
- widget->allocation.y + widget->allocation.height - 1,
- widget->allocation.x + (widget->allocation.width -
- widget->style->xthickness) / 2);
+ allocation.y,
+ allocation.y + allocation.height - 1,
+ allocation.x + (allocation.width - style->xthickness) / 2);
}
return FALSE;
diff --git a/gtk/gtkseparatortoolitem.c b/gtk/gtkseparatortoolitem.c
index e5a04db..a26dd4f 100644
--- a/gtk/gtkseparatortoolitem.c
+++ b/gtk/gtkseparatortoolitem.c
@@ -89,8 +89,10 @@ static gint
get_space_size (GtkToolItem *tool_item)
{
gint space_size = _gtk_toolbar_get_default_space_size();
- GtkWidget *parent = GTK_WIDGET (tool_item)->parent;
-
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
+
if (GTK_IS_TOOLBAR (parent))
{
gtk_widget_style_get (parent,
@@ -236,32 +238,36 @@ gtk_separator_tool_item_size_allocate (GtkWidget *widget,
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
GtkSeparatorToolItemPrivate *priv = separator->priv;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (priv->event_window,
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
}
static void
gtk_separator_tool_item_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
GtkSeparatorToolItemPrivate *priv = separator->priv;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_ONLY;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -270,14 +276,15 @@ gtk_separator_tool_item_realize (GtkWidget *widget)
GDK_BUTTON_RELEASE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
- 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);
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (priv->event_window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
}
static void
@@ -337,17 +344,21 @@ static gboolean
gtk_separator_tool_item_expose (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
GtkToolbar *toolbar = NULL;
GtkSeparatorToolItem *separator = GTK_SEPARATOR_TOOL_ITEM (widget);
GtkSeparatorToolItemPrivate *priv = separator->priv;
+ GtkWidget *parent;
if (priv->draw)
{
- if (GTK_IS_TOOLBAR (widget->parent))
- toolbar = GTK_TOOLBAR (widget->parent);
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_TOOLBAR (parent))
+ toolbar = GTK_TOOLBAR (parent);
+ gtk_widget_get_allocation (widget, &allocation);
_gtk_toolbar_paint_space_line (widget, toolbar,
- &(event->area), &widget->allocation);
+ &(event->area), &allocation);
}
return FALSE;
diff --git a/gtk/gtksizegroup.c b/gtk/gtksizegroup.c
index c1a8feb..f0496e5 100644
--- a/gtk/gtksizegroup.c
+++ b/gtk/gtksizegroup.c
@@ -184,13 +184,16 @@ add_widget_to_closure (GtkWidget *widget,
static void
real_queue_resize (GtkWidget *widget)
{
+ GtkWidget *parent;
+
GTK_PRIVATE_SET_FLAG (widget, GTK_ALLOC_NEEDED);
GTK_PRIVATE_SET_FLAG (widget, GTK_REQUEST_NEEDED);
GTK_PRIVATE_SET_FLAG (widget, GTK_WIDTH_REQUEST_NEEDED);
GTK_PRIVATE_SET_FLAG (widget, GTK_HEIGHT_REQUEST_NEEDED);
-
- if (widget->parent)
- _gtk_container_queue_resize (GTK_CONTAINER (widget->parent));
+
+ parent = gtk_widget_get_parent (widget);
+ if (parent)
+ _gtk_container_queue_resize (GTK_CONTAINER (parent));
else if (gtk_widget_is_toplevel (widget) && GTK_IS_CONTAINER (widget))
_gtk_container_queue_resize (GTK_CONTAINER (widget));
}
@@ -227,7 +230,7 @@ queue_resize_on_widget (GtkWidget *widget,
if (widget == parent && !check_siblings)
{
real_queue_resize (widget);
- parent = parent->parent;
+ parent = gtk_widget_get_parent (parent);
continue;
}
@@ -237,7 +240,7 @@ queue_resize_on_widget (GtkWidget *widget,
if (widget == parent)
real_queue_resize (widget);
- parent = parent->parent;
+ parent = gtk_widget_get_parent (parent);
continue;
}
@@ -300,8 +303,8 @@ queue_resize_on_widget (GtkWidget *widget,
g_slist_free (widgets);
g_slist_free (groups);
-
- parent = parent->parent;
+
+ parent = gtk_widget_get_parent (parent);
}
}
diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c
index 81c66f6..2900881 100644
--- a/gtk/gtksizerequest.c
+++ b/gtk/gtksizerequest.c
@@ -207,13 +207,16 @@ get_cache (GtkSizeRequest *widget,
static void
do_size_request (GtkWidget *widget)
{
+ GtkRequisition requisition;
+
if (GTK_WIDGET_REQUEST_NEEDED (widget))
{
gtk_widget_ensure_style (widget);
GTK_PRIVATE_UNSET_FLAG (widget, GTK_REQUEST_NEEDED);
+ gtk_widget_get_requisition (widget, &requisition);
g_signal_emit_by_name (widget,
"size-request",
- &widget->requisition);
+ &requisition);
}
}
@@ -262,15 +265,17 @@ compute_size_for_orientation (GtkSizeRequest *request,
if (!found_in_cache)
{
+ GtkRequisition requisition;
gint min_size = 0, nat_size = 0;
gint group_size, requisition_size;
/* Unconditional size request runs but is often unhandled. */
do_size_request (widget);
+ gtk_widget_get_requisition (widget, &requisition);
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
{
- requisition_size = widget->requisition.width;
+ requisition_size = requisition.width;
if (for_size < 0)
GTK_SIZE_REQUEST_GET_IFACE (request)->get_width (request, &min_size, &nat_size);
@@ -280,7 +285,7 @@ compute_size_for_orientation (GtkSizeRequest *request,
}
else
{
- requisition_size = widget->requisition.height;
+ requisition_size = requisition.height;
if (for_size < 0)
GTK_SIZE_REQUEST_GET_IFACE (request)->get_height (request, &min_size, &nat_size);
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index 08f0cd1..d561281 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -366,17 +366,21 @@ gtk_socket_get_plug_window (GtkSocket *socket)
static void
gtk_socket_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkSocket *socket = GTK_SOCKET (widget);
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -384,16 +388,18 @@ gtk_socket_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, socket);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, socket);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window, GTK_STATE_NORMAL);
_gtk_socket_windowing_realize_window (socket);
- gdk_window_add_filter (widget->window,
+ gdk_window_add_filter (window,
_gtk_socket_windowing_filter_func,
widget);
@@ -482,10 +488,10 @@ gtk_socket_size_allocate (GtkWidget *widget,
{
GtkSocket *socket = GTK_SOCKET (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
@@ -898,7 +904,9 @@ _gtk_socket_add_window (GtkSocket *socket,
if (need_reparent)
{
gdk_window_hide (socket->plug_window); /* Shouldn't actually be necessary for XEMBED, but just in case */
- gdk_window_reparent (socket->plug_window, widget->window, 0, 0);
+ gdk_window_reparent (socket->plug_window,
+ gtk_widget_get_window (widget),
+ 0, 0);
}
socket->have_size = FALSE;
@@ -1029,11 +1037,11 @@ _gtk_socket_advance_toplevel_focus (GtkSocket *socket,
if (window->focus_widget)
{
/* Wrapped off the end, clear the focus setting for the toplevel */
- parent = window->focus_widget->parent;
+ parent = gtk_widget_get_parent (window->focus_widget);
while (parent)
{
gtk_container_set_focus_child (GTK_CONTAINER (parent), NULL);
- parent = GTK_WIDGET (parent)->parent;
+ parent = gtk_widget_get_parent (parent);
}
gtk_window_set_focus (GTK_WINDOW (container), NULL);
diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c
index 330f327..d42183b 100644
--- a/gtk/gtkspinbutton.c
+++ b/gtk/gtkspinbutton.c
@@ -579,8 +579,11 @@ gtk_spin_button_unmap (GtkWidget *widget)
static void
gtk_spin_button_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GtkRequisition requisition;
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPriv *priv = spin_button->priv;
+ GtkStyle *style;
GdkWindowAttr attributes;
gint attributes_mask;
gboolean return_val;
@@ -603,18 +606,21 @@ gtk_spin_button_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- attributes.x = (widget->allocation.width - arrow_size -
- 2 * widget->style->xthickness);
- attributes.y = (widget->allocation.height -
- widget->requisition.height) / 2;
- attributes.width = arrow_size + 2 * widget->style->xthickness;
- attributes.height = widget->requisition.height;
+ style = gtk_widget_get_style (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_requisition (widget, &requisition);
- priv->panel = gdk_window_new (widget->window,
+ attributes.x = (allocation.width - arrow_size - 2 * style->xthickness);
+ attributes.y = (allocation.height - requisition.height) / 2;
+ attributes.width = arrow_size + 2 * style->xthickness;
+ attributes.height = requisition.height;
+
+ priv->panel = gdk_window_new (gtk_widget_get_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (priv->panel, widget);
- gtk_style_set_background (widget->style, priv->panel, GTK_STATE_NORMAL);
+ gtk_style_set_background (style,
+ priv->panel, GTK_STATE_NORMAL);
return_val = FALSE;
g_signal_emit (spin_button, spinbutton_signals[OUTPUT], 0, &return_val);
@@ -670,8 +676,11 @@ gtk_spin_button_size_request (GtkWidget *widget,
GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPriv *priv = spin_button->priv;
GtkEntry *entry = GTK_ENTRY (widget);
+ GtkStyle *style;
gint arrow_size;
+ style = gtk_widget_get_style (widget);
+
arrow_size = spin_button_get_arrow_size (spin_button);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->size_request (widget, requisition);
@@ -697,7 +706,7 @@ gtk_spin_button_size_request (GtkWidget *widget,
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context,
- widget->style->font_desc,
+ style->font_desc,
pango_context_get_language (context));
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
@@ -727,7 +736,7 @@ gtk_spin_button_size_request (GtkWidget *widget,
requisition->width = width + xborder * 2 + inner_border.left + inner_border.right;
}
- requisition->width += arrow_size + 2 * widget->style->xthickness;
+ requisition->width += arrow_size + 2 * style->xthickness;
}
static void
@@ -737,21 +746,23 @@ gtk_spin_button_size_allocate (GtkWidget *widget,
GtkSpinButton *spin = GTK_SPIN_BUTTON (widget);
GtkSpinButtonPriv *priv = spin->priv;
GtkAllocation panel_allocation;
+ GtkRequisition requisition;
gint arrow_size;
gint panel_width;
arrow_size = spin_button_get_arrow_size (spin);
- panel_width = arrow_size + 2 * widget->style->xthickness;
-
- widget->allocation = *allocation;
-
+ panel_width = arrow_size + 2 * gtk_widget_get_style (widget)->xthickness;
+
+ gtk_widget_set_allocation (widget, allocation);
+
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
panel_allocation.x = 0;
else
panel_allocation.x = allocation->width - panel_width;
+ gtk_widget_get_requisition (widget, &requisition);
panel_allocation.width = panel_width;
- panel_allocation.height = MIN (widget->requisition.height, allocation->height);
+ panel_allocation.height = MIN (requisition.height, allocation->height);
panel_allocation.y = 0;
@@ -799,7 +810,7 @@ gtk_spin_button_expose (GtkWidget *widget,
gdk_drawable_get_size (priv->panel, &width, &height);
- gtk_paint_box (widget->style, priv->panel,
+ gtk_paint_box (gtk_widget_get_style (widget), priv->panel,
state, shadow_type,
&event->area, widget, "spinbutton",
0, 0, width, height);
@@ -849,6 +860,8 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
GtkSpinButtonPriv *priv;
GtkStateType state_type;
GtkShadowType shadow_type;
+ GtkRequisition requisition;
+ GtkStyle *style;
GtkWidget *widget;
gint x;
gint y;
@@ -863,21 +876,25 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
if (gtk_widget_is_drawable (widget))
{
- width = spin_button_get_arrow_size (spin_button) + 2 * widget->style->xthickness;
+ style = gtk_widget_get_style (widget);
+
+ width = spin_button_get_arrow_size (spin_button) + 2 * style->xthickness;
+
+ gtk_widget_get_requisition (widget, &requisition);
if (arrow_type == GTK_ARROW_UP)
{
x = 0;
y = 0;
- height = widget->requisition.height / 2;
+ height = requisition.height / 2;
}
else
{
x = 0;
- y = widget->requisition.height / 2;
+ y = requisition.height / 2;
- height = (widget->requisition.height + 1) / 2;
+ height = (requisition.height + 1) / 2;
}
if (spin_button_at_limit (spin_button, arrow_type))
@@ -907,14 +924,14 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
shadow_type = GTK_SHADOW_OUT;
}
}
-
- gtk_paint_box (widget->style, priv->panel,
+
+ gtk_paint_box (style, priv->panel,
state_type, shadow_type,
area, widget,
(arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down",
x, y, width, height);
- height = widget->requisition.height;
+ height = requisition.height;
if (arrow_type == GTK_ARROW_DOWN)
{
@@ -944,7 +961,7 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button,
height = h;
width = w;
- gtk_paint_arrow (widget->style, priv->panel,
+ gtk_paint_arrow (style, priv->panel,
state_type, shadow_type,
area, widget, "spinbutton",
arrow_type, TRUE,
@@ -961,6 +978,7 @@ gtk_spin_button_enter_notify (GtkWidget *widget,
if (event->window == priv->panel)
{
+ GtkRequisition requisition;
GdkDevice *device;
gint x;
gint y;
@@ -968,7 +986,8 @@ gtk_spin_button_enter_notify (GtkWidget *widget,
device = gdk_event_get_device ((GdkEvent *) event);
gdk_window_get_device_position (priv->panel, device, &x, &y, NULL);
- if (y <= widget->requisition.height / 2)
+ gtk_widget_get_requisition (widget, &requisition);
+ if (y <= requisition.height / 2)
priv->in_child = GTK_ARROW_UP;
else
priv->in_child = GTK_ARROW_DOWN;
@@ -1042,7 +1061,8 @@ gtk_spin_button_style_set (GtkWidget *widget,
GtkSpinButtonPriv *priv = spin->priv;
if (previous_style && gtk_widget_get_realized (widget))
- gtk_style_set_background (widget->style, priv->panel, GTK_STATE_NORMAL);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ priv->panel, GTK_STATE_NORMAL);
GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->style_set (widget, previous_style);
}
@@ -1137,14 +1157,17 @@ gtk_spin_button_button_press (GtkWidget *widget,
{
if (event->window == priv->panel)
{
+ GtkRequisition requisition;
+
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
priv->button = event->button;
if (GTK_ENTRY (widget)->editable)
gtk_spin_button_update (spin);
-
- if (event->y <= widget->requisition.height / 2)
+
+ gtk_widget_get_requisition (widget, &requisition);
+ if (event->y <= requisition.height / 2)
{
if (event->button == 1)
start_spinning (spin, GTK_ARROW_UP, priv->adjustment->step_increment);
@@ -1188,12 +1211,16 @@ gtk_spin_button_button_release (GtkWidget *widget,
if (event->button == 3)
{
+ GtkRequisition requisition;
+
+ gtk_widget_get_requisition (widget, &requisition);
+
if (event->y >= 0 && event->x >= 0 &&
- event->y <= widget->requisition.height &&
- event->x <= arrow_size + 2 * widget->style->xthickness)
+ event->y <= requisition.height &&
+ event->x <= arrow_size + 2 * gtk_widget_get_style (widget)->xthickness)
{
if (click_child == GTK_ARROW_UP &&
- event->y <= widget->requisition.height / 2)
+ event->y <= requisition.height / 2)
{
gdouble diff;
@@ -1202,7 +1229,7 @@ gtk_spin_button_button_release (GtkWidget *widget,
gtk_spin_button_real_spin (spin, diff);
}
else if (click_child == GTK_ARROW_DOWN &&
- event->y > widget->requisition.height / 2)
+ event->y > requisition.height / 2)
{
gdouble diff;
@@ -1232,17 +1259,20 @@ gtk_spin_button_motion_notify (GtkWidget *widget,
if (event->window == priv->panel)
{
+ GtkRequisition requisition;
gint y = event->y;
gdk_event_request_motions (event);
-
- if (y <= widget->requisition.height / 2 &&
+
+ gtk_widget_get_requisition (widget, &requisition);
+
+ if (y <= requisition.height / 2 &&
priv->in_child == GTK_ARROW_DOWN)
{
priv->in_child = GTK_ARROW_UP;
gtk_widget_queue_draw (GTK_WIDGET (spin));
}
- else if (y > widget->requisition.height / 2 &&
+ else if (y > requisition.height / 2 &&
priv->in_child == GTK_ARROW_UP)
{
priv->in_child = GTK_ARROW_DOWN;
@@ -1475,7 +1505,7 @@ gtk_spin_button_get_text_area_size (GtkEntry *entry,
GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->get_text_area_size (entry, x, y, width, height);
arrow_size = spin_button_get_arrow_size (GTK_SPIN_BUTTON (entry));
- panel_width = arrow_size + 2 * GTK_WIDGET (entry)->style->xthickness;
+ panel_width = arrow_size + 2 * gtk_widget_get_style (GTK_WIDGET (entry))->xthickness;
if (width)
*width -= panel_width;
@@ -2221,9 +2251,12 @@ gtk_spin_button_get_wrap (GtkSpinButton *spin_button)
static gint
spin_button_get_arrow_size (GtkSpinButton *spin_button)
{
- gint size = pango_font_description_get_size (GTK_WIDGET (spin_button)->style->font_desc);
+ GtkStyle *style;
+ gint size;
gint arrow_size;
+ style = gtk_widget_get_style (GTK_WIDGET (spin_button));
+ size = pango_font_description_get_size (style->font_desc);
arrow_size = MAX (PANGO_PIXELS (size), MIN_ARROW_WIDTH);
return arrow_size - arrow_size % 2; /* force even */
diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c
index 6261d82..e25dc43 100644
--- a/gtk/gtkspinner.c
+++ b/gtk/gtkspinner.c
@@ -217,14 +217,16 @@ static gboolean
gtk_spinner_expose (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
GtkStateType state_type;
GtkSpinnerPrivate *priv;
int width, height;
priv = GTK_SPINNER (widget)->priv;
- width = widget->allocation.width;
- height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ width = allocation.width;
+ height = allocation.height;
if ((width < 12) || (height <12))
gtk_widget_set_size_request (widget, 12, 12);
@@ -233,8 +235,8 @@ gtk_spinner_expose (GtkWidget *widget,
if (!gtk_widget_is_sensitive (widget))
state_type = GTK_STATE_INSENSITIVE;
- gtk_paint_spinner (widget->style,
- widget->window,
+ gtk_paint_spinner (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
state_type,
&event->area,
widget,
@@ -473,6 +475,7 @@ gtk_spinner_accessible_image_get_size (AtkImage *image,
gint *width,
gint *height)
{
+ GtkAllocation allocation;
GtkWidget *widget;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (image));
@@ -482,8 +485,9 @@ gtk_spinner_accessible_image_get_size (AtkImage *image,
}
else
{
- *width = widget->allocation.width;
- *height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ *width = allocation.width;
+ *height = allocation.height;
}
}
diff --git a/gtk/gtkstatusbar.c b/gtk/gtkstatusbar.c
index ded0620..b521907 100644
--- a/gtk/gtkstatusbar.c
+++ b/gtk/gtkstatusbar.c
@@ -770,29 +770,32 @@ static void
get_grip_rect (GtkStatusbar *statusbar,
GdkRectangle *rect)
{
- GtkWidget *widget;
+ GtkAllocation allocation;
+ GtkStyle *style;
+ GtkWidget *widget = GTK_WIDGET (statusbar);
gint w, h;
-
- widget = GTK_WIDGET (statusbar);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
/* These are in effect the max/default size of the grip. */
w = 18;
h = 18;
- if (w > widget->allocation.width)
- w = widget->allocation.width;
+ if (w > allocation.width)
+ w = allocation.width;
+
+ if (h > allocation.height - style->ythickness)
+ h = allocation.height - style->ythickness;
- if (h > widget->allocation.height - widget->style->ythickness)
- h = widget->allocation.height - widget->style->ythickness;
-
rect->width = w;
rect->height = h;
- rect->y = widget->allocation.y + widget->allocation.height - h;
+ rect->y = allocation.y + allocation.height - h;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
- rect->x = widget->allocation.x + widget->allocation.width - w;
- else
- rect->x = widget->allocation.x + widget->style->xthickness;
+ rect->x = allocation.x + allocation.width - w;
+ else
+ rect->x = allocation.x + style->xthickness;
}
static void
@@ -850,9 +853,8 @@ gtk_statusbar_create_window (GtkStatusbar *statusbar)
attributes_mask = GDK_WA_X | GDK_WA_Y;
- priv->grip_window = gdk_window_new (widget->window,
- &attributes, attributes_mask);
-
+ priv->grip_window = gdk_window_new (gtk_widget_get_window (widget),
+ &attributes, attributes_mask);
gdk_window_set_user_data (priv->grip_window, widget);
gdk_window_raise (priv->grip_window);
@@ -980,6 +982,7 @@ gtk_statusbar_expose_event (GtkWidget *widget,
{
GtkStatusbar *statusbar = GTK_STATUSBAR (widget);
GtkStatusbarPriv *priv = statusbar->priv;
+ GtkStyle *style;
GdkRectangle rect;
GTK_WIDGET_CLASS (gtk_statusbar_parent_class)->expose_event (widget, event);
@@ -992,8 +995,9 @@ gtk_statusbar_expose_event (GtkWidget *widget,
get_grip_rect (statusbar, &rect);
- gtk_paint_resize_grip (widget->style,
- widget->window,
+ style = gtk_widget_get_style (widget);
+ gtk_paint_resize_grip (style,
+ gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
&event->area,
widget,
@@ -1003,8 +1007,8 @@ gtk_statusbar_expose_event (GtkWidget *widget,
/* don't draw grip over the frame, though you
* can click on the frame.
*/
- rect.width - widget->style->xthickness,
- rect.height - widget->style->ythickness);
+ rect.width - style->xthickness,
+ rect.height - style->ythickness);
}
return FALSE;
@@ -1116,10 +1120,11 @@ gtk_statusbar_size_allocate (GtkWidget *widget,
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
allocation->x -= rect.width;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
}
else
{
+ GtkAllocation child_allocation, frame_allocation;
GtkWidget *child;
/* Use the frame's child instead of priv->label directly, in case
@@ -1128,13 +1133,15 @@ gtk_statusbar_size_allocate (GtkWidget *widget,
*/
child = gtk_bin_get_child (GTK_BIN (priv->frame));
- if (child->allocation.width + rect.width > priv->frame->allocation.width)
+ gtk_widget_get_allocation (child, &child_allocation);
+ gtk_widget_get_allocation (priv->frame, &frame_allocation);
+ if (child_allocation.width + rect.width > frame_allocation.width)
{
/* shrink the label to make room for the grip */
- *allocation = child->allocation;
+ *allocation = child_allocation;
allocation->width = MAX (1, allocation->width - rect.width);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- allocation->x += child->allocation.width - allocation->width;
+ allocation->x += child_allocation.width - allocation->width;
gtk_widget_size_allocate (child, allocation);
}
diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c
index 2f04018..ce832f8 100644
--- a/gtk/gtkstatusicon.c
+++ b/gtk/gtkstatusicon.c
@@ -2524,6 +2524,7 @@ gtk_status_icon_position_menu (GtkMenu *menu,
gpointer user_data)
{
#ifdef GDK_WINDOWING_X11
+ GtkAllocation allocation;
GtkStatusIcon *status_icon;
GtkStatusIconPrivate *priv;
GtkTrayIcon *tray_icon;
@@ -2532,6 +2533,7 @@ gtk_status_icon_position_menu (GtkMenu *menu,
GtkTextDirection direction;
GtkRequisition menu_req;
GdkRectangle monitor;
+ GdkWindow *window;
gint monitor_num, height, width, xoffset, yoffset;
g_return_if_fail (GTK_IS_MENU (menu));
@@ -2547,30 +2549,33 @@ gtk_status_icon_position_menu (GtkMenu *menu,
screen = gtk_widget_get_screen (widget);
gtk_menu_set_screen (menu, screen);
- monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+ window = gtk_widget_get_window (widget);
+ monitor_num = gdk_screen_get_monitor_at_window (screen, window);
if (monitor_num < 0)
monitor_num = 0;
gtk_menu_set_monitor (menu, monitor_num);
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
- gdk_window_get_origin (widget->window, x, y);
-
+ gdk_window_get_origin (window,
+ x, y);
+
gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
+ gtk_widget_get_allocation (widget, &allocation);
if (_gtk_tray_icon_get_orientation (tray_icon) == GTK_ORIENTATION_VERTICAL)
{
width = 0;
- height = widget->allocation.height;
- xoffset = widget->allocation.width;
+ height = allocation.height;
+ xoffset = allocation.width;
yoffset = 0;
}
else
{
- width = widget->allocation.width;
+ width = allocation.width;
height = 0;
xoffset = 0;
- yoffset = widget->allocation.height;
+ yoffset = allocation.height;
}
if (direction == GTK_TEXT_DIR_RTL)
@@ -2661,6 +2666,7 @@ gtk_status_icon_get_geometry (GtkStatusIcon *status_icon,
GtkOrientation *orientation)
{
#ifdef GDK_WINDOWING_X11
+ GtkAllocation allocation;
GtkWidget *widget;
GtkStatusIconPrivate *priv;
gint x, y;
@@ -2675,11 +2681,14 @@ gtk_status_icon_get_geometry (GtkStatusIcon *status_icon,
if (area)
{
- gdk_window_get_origin (widget->window, &x, &y);
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ &x, &y);
+
+ gtk_widget_get_allocation (widget, &allocation);
area->x = x;
area->y = y;
- area->width = widget->allocation.width;
- area->height = widget->allocation.height;
+ area->width = allocation.width;
+ area->height = allocation.height;
}
if (orientation)
@@ -2961,7 +2970,7 @@ gtk_status_icon_get_x11_window_id (GtkStatusIcon *status_icon)
{
#ifdef GDK_WINDOWING_X11
gtk_widget_realize (GTK_WIDGET (status_icon->priv->tray_icon));
- return GDK_WINDOW_XID (GTK_WIDGET (status_icon->priv->tray_icon)->window);
+ return GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (status_icon->priv->tray_icon)));
#else
return 0;
#endif
diff --git a/gtk/gtkstyle.c b/gtk/gtkstyle.c
index d7d2ba4..af88854 100644
--- a/gtk/gtkstyle.c
+++ b/gtk/gtkstyle.c
@@ -5707,13 +5707,16 @@ get_insertion_cursor_color (GtkWidget *widget,
gboolean is_primary)
{
CursorInfo *cursor_info;
+ GtkStyle *style;
GdkColor *cursor_color;
- cursor_info = g_object_get_data (G_OBJECT (widget->style), "gtk-style-cursor-info");
+ style = gtk_widget_get_style (widget);
+
+ cursor_info = g_object_get_data (G_OBJECT (style), "gtk-style-cursor-info");
if (!cursor_info)
{
cursor_info = g_new0 (CursorInfo, 1);
- g_object_set_data (G_OBJECT (widget->style), I_("gtk-style-cursor-info"), cursor_info);
+ g_object_set_data (G_OBJECT (style), I_("gtk-style-cursor-info"), cursor_info);
cursor_info->for_type = G_TYPE_INVALID;
}
@@ -5737,7 +5740,7 @@ get_insertion_cursor_color (GtkWidget *widget,
}
else
{
- cursor_info->primary = widget->style->text[GTK_STATE_NORMAL];
+ cursor_info->primary = style->text[GTK_STATE_NORMAL];
}
gtk_widget_style_get (widget, "secondary-cursor-color", &cursor_color, NULL);
@@ -5750,7 +5753,7 @@ get_insertion_cursor_color (GtkWidget *widget,
{
/* text_aa is the average of text and base colors,
* in usual black-on-white case it's grey. */
- cursor_info->secondary = widget->style->text_aa[GTK_STATE_NORMAL];
+ cursor_info->secondary = style->text_aa[GTK_STATE_NORMAL];
}
}
@@ -5777,7 +5780,7 @@ _gtk_widget_get_cursor_color (GtkWidget *widget,
gdk_color_free (style_color);
}
else
- *color = widget->style->text[GTK_STATE_NORMAL];
+ *color = gtk_widget_get_style (widget)->text[GTK_STATE_NORMAL];
}
static void
diff --git a/gtk/gtktable.c b/gtk/gtktable.c
index e011611..5072822 100644
--- a/gtk/gtktable.c
+++ b/gtk/gtktable.c
@@ -598,8 +598,8 @@ gtk_table_attach (GtkTable *table,
g_return_if_fail (GTK_IS_TABLE (table));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == NULL);
-
+ g_return_if_fail (gtk_widget_get_parent (child) == NULL);
+
/* g_return_if_fail (left_attach >= 0); */
g_return_if_fail (left_attach < right_attach);
/* g_return_if_fail (top_attach >= 0); */
@@ -941,7 +941,7 @@ gtk_table_size_allocate (GtkWidget *widget,
{
GtkTable *table = GTK_TABLE (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
gtk_table_size_allocate_init (table);
gtk_table_size_allocate_pass1 (table);
@@ -1434,6 +1434,7 @@ static void
gtk_table_size_allocate_pass1 (GtkTable *table)
{
GtkTablePriv *priv = table->priv;
+ GtkAllocation allocation;
gint real_width;
gint real_height;
gint width, height;
@@ -1447,9 +1448,10 @@ gtk_table_size_allocate_pass1 (GtkTable *table)
* then we have to expand any expandable rows and columns
* to fill in the extra space.
*/
+ gtk_widget_get_allocation (GTK_WIDGET (table), &allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (table));
- real_width = GTK_WIDGET (table)->allocation.width - border_width * 2;
- real_height = GTK_WIDGET (table)->allocation.height - border_width * 2;
+ real_width = allocation.width - border_width * 2;
+ real_height = allocation.height - border_width * 2;
if (priv->homogeneous)
{
@@ -1646,6 +1648,7 @@ gtk_table_size_allocate_pass2 (GtkTable *table)
gint x, y;
gint row, col;
GtkAllocation allocation;
+ GtkAllocation table_allocation, widget_allocation;
GtkWidget *widget = GTK_WIDGET (table);
children = priv->children;
@@ -1661,9 +1664,10 @@ gtk_table_size_allocate_pass2 (GtkTable *table)
gtk_widget_get_child_requisition (child->widget, &child_requisition);
+ gtk_widget_get_allocation (GTK_WIDGET (table), &table_allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (table));
- x = GTK_WIDGET (table)->allocation.x + border_width;
- y = GTK_WIDGET (table)->allocation.y + border_width;
+ x = table_allocation.x + border_width;
+ y = table_allocation.y + border_width;
max_width = 0;
max_height = 0;
@@ -1715,10 +1719,11 @@ gtk_table_size_allocate_pass2 (GtkTable *table)
allocation.y = y + (max_height - allocation.height) / 2;
}
+ gtk_widget_get_allocation (widget, &widget_allocation);
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
- allocation.x = widget->allocation.x + widget->allocation.width
- - (allocation.x - widget->allocation.x) - allocation.width;
-
+ allocation.x = widget_allocation.x + widget_allocation.width
+ - (allocation.x - widget_allocation.x) - allocation.width;
+
gtk_widget_size_allocate (child->widget, &allocation);
}
}
diff --git a/gtk/gtktearoffmenuitem.c b/gtk/gtktearoffmenuitem.c
index 0a1de9a..234a705 100644
--- a/gtk/gtktearoffmenuitem.c
+++ b/gtk/gtktearoffmenuitem.c
@@ -90,19 +90,24 @@ static void
gtk_tearoff_menu_item_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
+ GtkStyle *style;
+ GtkWidget *parent;
guint border_width;
+ style = gtk_widget_get_style (widget);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- requisition->width = (border_width + widget->style->xthickness + BORDER_SPACING) * 2;
- requisition->height = (border_width + widget->style->ythickness) * 2;
+ requisition->width = (border_width + style->xthickness + BORDER_SPACING) * 2;
+ requisition->height = (border_width + style->ythickness) * 2;
- if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off)
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off)
{
requisition->height += ARROW_SIZE;
}
else
{
- requisition->height += widget->style->ythickness + 4;
+ requisition->height += style->ythickness + 4;
}
}
@@ -110,50 +115,61 @@ static void
gtk_tearoff_menu_item_paint (GtkWidget *widget,
GdkRectangle *area)
{
+ GtkAllocation allocation;
GtkMenuItem *menu_item;
GtkShadowType shadow_type;
+ GtkStateType state;
+ GtkStyle *style;
gint width, height;
gint x, y;
gint right_max;
guint border_width;
GtkArrowType arrow_type;
GtkTextDirection direction;
-
+ GtkWidget *parent;
+ GdkWindow *window;
+
if (gtk_widget_is_drawable (widget))
{
menu_item = GTK_MENU_ITEM (widget);
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
direction = gtk_widget_get_direction (widget);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_item));
- 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;
right_max = x + width;
- if (widget->state == GTK_STATE_PRELIGHT)
+ state = gtk_widget_get_state (widget);
+
+ if (state == GTK_STATE_PRELIGHT)
{
gint selected_shadow_type;
gtk_widget_style_get (widget,
"selected-shadow-type", &selected_shadow_type,
NULL);
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_paint_box (style,
+ window,
GTK_STATE_PRELIGHT,
selected_shadow_type,
area, widget, "menuitem",
x, y, width, height);
}
else
- gdk_window_clear_area (widget->window, area->x, area->y, area->width, area->height);
+ gdk_window_clear_area (window, area->x, area->y, area->width, area->height);
- if (GTK_IS_MENU (widget->parent) && GTK_MENU (widget->parent)->torn_off)
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_MENU (parent) && GTK_MENU (parent)->torn_off)
{
gint arrow_x;
- if (widget->state == GTK_STATE_PRELIGHT)
+ if (state == GTK_STATE_PRELIGHT)
shadow_type = GTK_SHADOW_IN;
else
shadow_type = GTK_SHADOW_OUT;
@@ -184,8 +200,8 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget,
}
- gtk_paint_arrow (widget->style, widget->window,
- widget->state, shadow_type,
+ gtk_paint_arrow (style, window,
+ state, shadow_type,
NULL, widget, "tearoffmenuitem",
arrow_type, FALSE,
arrow_x, y + height / 2 - 5,
@@ -204,10 +220,10 @@ gtk_tearoff_menu_item_paint (GtkWidget *widget,
x1 = right_max - x;
x2 = MAX (right_max - x - TEAR_LENGTH, 0);
}
-
- gtk_paint_hline (widget->style, widget->window, GTK_STATE_NORMAL,
+
+ gtk_paint_hline (style, window, GTK_STATE_NORMAL,
NULL, widget, "tearoffmenuitem",
- x1, x2, y + (height - widget->style->ythickness) / 2);
+ x1, x2, y + (height - style->ythickness) / 2);
x += 2 * TEAR_LENGTH;
}
}
@@ -225,12 +241,15 @@ gtk_tearoff_menu_item_expose (GtkWidget *widget,
static void
gtk_tearoff_menu_item_activate (GtkMenuItem *menu_item)
{
- if (GTK_IS_MENU (GTK_WIDGET (menu_item)->parent))
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (GTK_WIDGET (menu_item));
+ if (GTK_IS_MENU (parent))
{
- GtkMenu *menu = GTK_MENU (GTK_WIDGET (menu_item)->parent);
-
+ GtkMenu *menu = GTK_MENU (parent);
+
gtk_widget_queue_resize (GTK_WIDGET (menu_item));
- gtk_menu_set_tearoff_state (GTK_MENU (GTK_WIDGET (menu_item)->parent),
+ gtk_menu_set_tearoff_state (GTK_MENU (parent),
!menu->torn_off);
}
}
@@ -252,7 +271,11 @@ gtk_tearoff_menu_item_parent_set (GtkWidget *widget,
{
GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (widget);
GtkTearoffMenuItemPriv *priv = tearoff_menu_item->priv;
- GtkMenu *menu = GTK_IS_MENU (widget->parent) ? GTK_MENU (widget->parent) : NULL;
+ GtkMenu *menu;
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (widget);
+ menu = GTK_IS_MENU (parent) ? GTK_MENU (parent) : NULL;
if (previous)
g_signal_handlers_disconnect_by_func (previous,
diff --git a/gtk/gtktestutils.c b/gtk/gtktestutils.c
index 3a76d6b..cedb5e7 100644
--- a/gtk/gtktestutils.c
+++ b/gtk/gtktestutils.c
@@ -84,12 +84,16 @@ static GSList*
test_find_widget_input_windows (GtkWidget *widget,
gboolean input_only)
{
+ GdkWindow *window;
GList *node, *children;
GSList *matches = NULL;
gpointer udata;
- gdk_window_get_user_data (widget->window, &udata);
- if (udata == widget && (!input_only || (GDK_IS_WINDOW (widget->window) && gdk_window_is_input_only (GDK_WINDOW (widget->window)))))
- matches = g_slist_prepend (matches, widget->window);
+
+ window = gtk_widget_get_window (widget);
+
+ gdk_window_get_user_data (window, &udata);
+ if (udata == widget && (!input_only || (GDK_IS_WINDOW (window) && gdk_window_is_input_only (GDK_WINDOW (window)))))
+ matches = g_slist_prepend (matches, window);
children = gdk_window_get_children (gtk_widget_get_parent_window (widget));
for (node = children; node; node = node->next)
{
@@ -272,13 +276,19 @@ widget_geo_dist (GtkWidget *a,
GtkWidget *b,
GtkWidget *base)
{
+ GtkAllocation allocation;
int ax0, ay0, ax1, ay1, bx0, by0, bx1, by1, xdist = 0, ydist = 0;
+
+ gtk_widget_get_allocation (a, &allocation);
if (!gtk_widget_translate_coordinates (a, base, 0, 0, &ax0, &ay0) ||
- !gtk_widget_translate_coordinates (a, base, a->allocation.width, a->allocation.height, &ax1, &ay1))
+ !gtk_widget_translate_coordinates (a, base, allocation.width, allocation.height, &ax1, &ay1))
return -G_MAXINT;
+
+ gtk_widget_get_allocation (b, &allocation);
if (!gtk_widget_translate_coordinates (b, base, 0, 0, &bx0, &by0) ||
- !gtk_widget_translate_coordinates (b, base, b->allocation.width, b->allocation.height, &bx1, &by1))
+ !gtk_widget_translate_coordinates (b, base, allocation.width, allocation.height, &bx1, &by1))
return +G_MAXINT;
+
if (bx0 >= ax1)
xdist = bx0 - ax1;
else if (ax0 >= bx1)
@@ -287,6 +297,7 @@ widget_geo_dist (GtkWidget *a,
ydist = by0 - ay1;
else if (ay0 >= by1)
ydist = ay0 - by1;
+
return xdist + ydist;
}
@@ -329,7 +340,7 @@ gtk_test_find_sibling (GtkWidget *base_widget,
/* find all sibling candidates */
while (tmpwidget)
{
- tmpwidget = tmpwidget->parent;
+ tmpwidget = gtk_widget_get_parent (tmpwidget);
siblings = g_list_concat (siblings, test_list_descendants (tmpwidget, widget_type));
}
/* sort them by distance to base_widget */
diff --git a/gtk/gtktextdisplay.c b/gtk/gtktextdisplay.c
index 51e8adc..45b6fd9 100644
--- a/gtk/gtktextdisplay.c
+++ b/gtk/gtktextdisplay.c
@@ -179,6 +179,7 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer,
PangoLayoutRun *run)
{
GtkTextRenderer *text_renderer = GTK_TEXT_RENDERER (renderer);
+ GtkStyle *style;
GdkColor *bg_color, *fg_color, *underline_color;
GtkTextAppearance *appearance;
@@ -194,15 +195,16 @@ gtk_text_renderer_prepare_run (PangoRenderer *renderer,
text_renderer_set_gdk_color (text_renderer, PANGO_RENDER_PART_BACKGROUND, bg_color);
+ style = gtk_widget_get_style (text_renderer->widget);
if (text_renderer->state == SELECTED)
{
if (gtk_widget_has_focus (text_renderer->widget))
- fg_color = &text_renderer->widget->style->text[GTK_STATE_SELECTED];
+ fg_color = &style->text[GTK_STATE_SELECTED];
else
- fg_color = &text_renderer->widget->style->text[GTK_STATE_ACTIVE];
+ fg_color = &style->text[GTK_STATE_ACTIVE];
}
else if (text_renderer->state == CURSOR && gtk_widget_has_focus (text_renderer->widget))
- fg_color = &text_renderer->widget->style->base[GTK_STATE_NORMAL];
+ fg_color = &style->base[GTK_STATE_NORMAL];
else
fg_color = &appearance->fg_color;
@@ -352,20 +354,22 @@ gtk_text_renderer_draw_shape (PangoRenderer *renderer,
int y)
{
GtkTextRenderer *text_renderer = GTK_TEXT_RENDERER (renderer);
+ GtkStyle *style;
GdkColor *fg;
+ style = gtk_widget_get_style (text_renderer->widget);
if (text_renderer->state == SELECTED)
{
if (gtk_widget_has_focus (text_renderer->widget))
- fg = &text_renderer->widget->style->text[GTK_STATE_SELECTED];
+ fg = &style->text[GTK_STATE_SELECTED];
else
- fg = &text_renderer->widget->style->text[GTK_STATE_SELECTED];
+ fg = &style->text[GTK_STATE_SELECTED];
}
else if (text_renderer->state == CURSOR && gtk_widget_has_focus (text_renderer->widget))
- fg = &text_renderer->widget->style->base[GTK_STATE_NORMAL];
+ fg = &style->base[GTK_STATE_NORMAL];
else
- fg = &text_renderer->widget->style->text[GTK_STATE_NORMAL];
-
+ fg = &style->text[GTK_STATE_NORMAL];
+
if (attr->data == NULL)
{
/* This happens if we have an empty widget anchor. Draw
@@ -548,6 +552,7 @@ render_para (GtkTextRenderer *text_renderer,
int selection_start_index,
int selection_end_index)
{
+ GtkStyle *style;
PangoLayout *layout = line_display->layout;
int byte_offset = 0;
PangoLayoutIter *iter;
@@ -555,9 +560,10 @@ render_para (GtkTextRenderer *text_renderer,
int screen_width;
GdkColor *selection;
gint state;
-
gboolean first = TRUE;
+ style = gtk_widget_get_style (text_renderer->widget);
+
iter = pango_layout_get_iter (layout);
pango_layout_iter_get_layout_extents (iter, NULL, &layout_logical);
@@ -574,7 +580,7 @@ render_para (GtkTextRenderer *text_renderer,
else
state = GTK_STATE_ACTIVE;
- selection = &text_renderer->widget->style->base [state];
+ selection = &style->base [state];
do
{
@@ -763,8 +769,12 @@ render_para (GtkTextRenderer *text_renderer,
/* draw text under the cursor if any */
if (!line_display->cursor_at_line_end)
{
- gdk_cairo_set_source_color (cr,
- &text_renderer->widget->style->base[text_renderer->widget->state]);
+ GtkStateType state;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (text_renderer->widget);
+ state = gtk_widget_get_state (text_renderer->widget);
+ gdk_cairo_set_source_color (cr, &style->base[state]);
text_renderer_set_state (text_renderer, CURSOR);
@@ -846,7 +856,8 @@ gtk_text_layout_draw (GtkTextLayout *layout,
cairo_rectangle (cr, x, y, width, height);
cairo_clip (cr);
- gdk_cairo_set_source_color (cr, &widget->style->text[widget->state]);
+ gdk_cairo_set_source_color (cr,
+ >k_widget_get_style (widget)->text[gtk_widget_get_state (widget)]);
text_renderer = get_text_renderer ();
text_renderer_begin (text_renderer, widget, cr);
diff --git a/gtk/gtktextutil.c b/gtk/gtktextutil.c
index d335120..af869b9 100644
--- a/gtk/gtktextutil.c
+++ b/gtk/gtktextutil.c
@@ -208,6 +208,8 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
gchar *text,
gsize len)
{
+ GtkStyle *style;
+ GtkStateType state;
GdkDrawable *drawable = NULL;
PangoContext *context;
PangoLayout *layout;
@@ -236,16 +238,18 @@ _gtk_text_util_create_drag_icon (GtkWidget *widget,
pixmap_width = layout_width / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2;
pixmap_height = layout_height / PANGO_SCALE + DRAG_ICON_LAYOUT_BORDER * 2;
- drawable = gdk_pixmap_new (widget->window,
+ drawable = gdk_pixmap_new (gtk_widget_get_window (widget),
pixmap_width + 2,
pixmap_height + 2,
-1);
cr = gdk_cairo_create (drawable);
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
- gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_color (cr, &style->base [state]);
cairo_paint (cr);
- gdk_cairo_set_source_color (cr, &widget->style->text [gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_color (cr, &style->text [state]);
cairo_move_to (cr, 1 + DRAG_ICON_LAYOUT_BORDER, 1 + DRAG_ICON_LAYOUT_BORDER);
pango_cairo_show_layout (cr, layout);
@@ -280,9 +284,11 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
GtkTextIter *start,
GtkTextIter *end)
{
+ GtkAllocation allocation;
GdkDrawable *drawable = NULL;
gint pixmap_height, pixmap_width;
gint layout_width, layout_height;
+ GtkStyle *widget_style;
GtkTextBuffer *new_buffer;
GtkTextLayout *layout;
GtkTextAttributes *style;
@@ -295,6 +301,8 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
g_return_val_if_fail (start != NULL, NULL);
g_return_val_if_fail (end != NULL, NULL);
+ widget_style = gtk_widget_get_style (widget);
+
new_buffer = gtk_text_buffer_new (gtk_text_buffer_get_tag_table (buffer));
gtk_text_buffer_get_start_iter (new_buffer, &iter);
@@ -316,13 +324,14 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
style = gtk_text_attributes_new ();
- layout_width = widget->allocation.width;
+ gtk_widget_get_allocation (widget, &allocation);
+ layout_width = allocation.width;
if (GTK_IS_TEXT_VIEW (widget))
{
gtk_widget_ensure_style (widget);
gtk_text_view_set_attributes_from_style (GTK_TEXT_VIEW (widget),
- style, widget->style);
+ style, widget_style);
layout_width = layout_width
- gtk_text_view_get_border_window_size (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_LEFT)
@@ -348,12 +357,12 @@ _gtk_text_util_create_rich_drag_icon (GtkWidget *widget,
pixmap_width = layout_width + DRAG_ICON_LAYOUT_BORDER * 2;
pixmap_height = layout_height + DRAG_ICON_LAYOUT_BORDER * 2;
- drawable = gdk_pixmap_new (widget->window,
+ drawable = gdk_pixmap_new (gtk_widget_get_window (widget),
pixmap_width + 2, pixmap_height + 2, -1);
cr = gdk_cairo_create (drawable);
- gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_color (cr, &widget_style->base [gtk_widget_get_state (widget)]);
cairo_paint (cr);
gtk_text_layout_draw (layout, widget, drawable,
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index e471b65..1e768b3 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -2055,6 +2055,7 @@ gtk_text_view_queue_scroll (GtkTextView *text_view,
static gboolean
gtk_text_view_flush_scroll (GtkTextView *text_view)
{
+ GtkAllocation allocation;
GtkTextIter iter;
GtkTextPendingScroll *scroll;
gboolean retval;
@@ -2085,10 +2086,11 @@ gtk_text_view_flush_scroll (GtkTextView *text_view)
* the screen.
*/
DV(g_print (">Validating scroll destination ("G_STRLOC")\n"));
+ gtk_widget_get_allocation (widget, &allocation);
gtk_text_layout_validate_yrange (text_view->priv->layout, &iter,
- - (widget->allocation.height * 2),
- widget->allocation.height * 2);
-
+ -(allocation.height * 2),
+ allocation.height * 2);
+
DV(g_print (">Done validating scroll destination ("G_STRLOC")\n"));
/* Ensure we have updated width/height */
@@ -3486,6 +3488,7 @@ static void
gtk_text_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkAllocation widget_allocation;
GtkTextView *text_view;
GtkTextViewPrivate *priv;
GtkTextIter first_para;
@@ -3507,17 +3510,18 @@ gtk_text_view_size_allocate (GtkWidget *widget,
DV(g_print(G_STRLOC"\n"));
+ gtk_widget_get_allocation (widget, &widget_allocation);
size_changed =
- widget->allocation.width != allocation->width ||
- widget->allocation.height != allocation->height;
+ widget_allocation.width != allocation->width ||
+ widget_allocation.height != allocation->height;
border_width = gtk_container_get_border_width (GTK_CONTAINER (text_view));
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
}
@@ -3668,7 +3672,7 @@ gtk_text_view_size_allocate (GtkWidget *widget,
* be invalidated
*/
if (size_changed && gtk_widget_get_realized (widget))
- gdk_window_invalidate_rect (widget->window, NULL, FALSE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE);
}
static void
@@ -3963,7 +3967,7 @@ changed_handler (GtkTextLayout *layout,
GtkRequisition old_req;
GtkRequisition new_req;
- old_req = widget->requisition;
+ gtk_widget_get_requisition (widget, &old_req);
/* Use this instead of gtk_widget_size_request wrapper
* to avoid the optimization which just returns widget->requisition
@@ -3982,8 +3986,10 @@ changed_handler (GtkTextLayout *layout,
static void
gtk_text_view_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkTextView *text_view;
GtkTextViewPrivate *priv;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
GSList *tmp_list;
@@ -3993,11 +3999,13 @@ gtk_text_view_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -4005,15 +4013,16 @@ gtk_text_view_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
/* must come before text_window_realize calls */
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
- gdk_window_set_background (widget->window,
- &widget->style->bg[gtk_widget_get_state (widget)]);
+ gdk_window_set_background (window,
+ >k_widget_get_style (widget)->bg[gtk_widget_get_state (widget)]);
text_window_realize (priv->text_window, widget);
@@ -4098,32 +4107,37 @@ gtk_text_view_unrealize (GtkWidget *widget)
static void
gtk_text_view_set_background (GtkTextView *text_view)
{
+ GtkStyle *style;
+ GtkStateType state;
GtkWidget *widget;
GtkTextViewPrivate *priv;
widget = GTK_WIDGET (text_view);
priv = text_view->priv;
- gdk_window_set_background (widget->window,
- &widget->style->bg[gtk_widget_get_state (widget)]);
-
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+
+ gdk_window_set_background (gtk_widget_get_window (widget),
+ &style->bg[state]);
+
gdk_window_set_background (priv->text_window->bin_window,
- &widget->style->base[gtk_widget_get_state (widget)]);
-
+ &style->base[state]);
+
if (priv->left_window)
gdk_window_set_background (priv->left_window->bin_window,
- &widget->style->bg[gtk_widget_get_state (widget)]);
+ &style->bg[state]);
if (priv->right_window)
gdk_window_set_background (priv->right_window->bin_window,
- &widget->style->bg[gtk_widget_get_state (widget)]);
-
+ &style->bg[state]);
+
if (priv->top_window)
gdk_window_set_background (priv->top_window->bin_window,
- &widget->style->bg[gtk_widget_get_state (widget)]);
-
+ &style->bg[state]);
+
if (priv->bottom_window)
gdk_window_set_background (priv->bottom_window->bin_window,
- &widget->style->bg[gtk_widget_get_state (widget)]);
+ &style->bg[state]);
}
static void
@@ -4146,9 +4160,8 @@ gtk_text_view_style_set (GtkWidget *widget,
{
gtk_text_view_set_attributes_from_style (text_view,
priv->layout->default_style,
- widget->style);
-
-
+ gtk_widget_get_style (widget));
+
ltr_context = gtk_widget_create_pango_context (widget);
pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR);
rtl_context = gtk_widget_create_pango_context (widget);
@@ -4855,7 +4868,7 @@ gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
gtk_text_view_paint (widget, &event->area, event);
}
- if (event->window == widget->window)
+ if (event->window == gtk_widget_get_window (widget))
gtk_text_view_draw_focus (widget);
/* Propagate exposes to all unanchored children.
@@ -4883,6 +4896,8 @@ gtk_text_view_expose_event (GtkWidget *widget, GdkEventExpose *event)
static void
gtk_text_view_draw_focus (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
gboolean interior_focus;
/* We clear the focus if we are in interior focus mode. */
@@ -4892,17 +4907,21 @@ gtk_text_view_draw_focus (GtkWidget *widget)
if (gtk_widget_is_drawable (widget))
{
+ window = gtk_widget_get_window (widget);
+
if (gtk_widget_has_focus (widget) && !interior_focus)
- {
- gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
+ {
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_paint_focus (gtk_widget_get_style (widget),
+ window,
+ gtk_widget_get_state (widget),
NULL, widget, "textview",
0, 0,
- widget->allocation.width,
- widget->allocation.height);
+ allocation.width, allocation.height);
}
else
{
- gdk_window_clear (widget->window);
+ gdk_window_clear (window);
}
}
}
@@ -6719,7 +6738,8 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
gtk_widget_ensure_style (widget);
gtk_text_view_set_attributes_from_style (text_view,
- style, widget->style);
+ style,
+ gtk_widget_get_style (widget));
style->pixels_above_lines = priv->pixels_above_lines;
style->pixels_below_lines = priv->pixels_below_lines;
@@ -7488,14 +7508,15 @@ typedef struct
/* The window to which widget->window is relative */
#define ALLOCATION_WINDOW(widget) \
- (!gtk_widget_get_has_window (widget) ? \
- (widget)->window : \
- gdk_window_get_parent ((widget)->window))
+ (!gtk_widget_get_has_window (widget) ? \
+ gtk_widget_get_window (widget) : \
+ gdk_window_get_parent (gtk_widget_get_window (widget)))
static void
adjust_allocation_recurse (GtkWidget *widget,
gpointer data)
{
+ GtkAllocation allocation;
ScrollData *scroll_data = data;
/* Need to really size allocate instead of just poking
@@ -7506,7 +7527,9 @@ adjust_allocation_recurse (GtkWidget *widget,
{
if (gtk_widget_get_visible (widget))
{
- GdkRectangle tmp_rectangle = widget->allocation;
+ GdkRectangle tmp_rectangle;
+
+ tmp_rectangle = allocation;
tmp_rectangle.x += scroll_data->dx;
tmp_rectangle.y += scroll_data->dy;
@@ -7517,9 +7540,10 @@ adjust_allocation_recurse (GtkWidget *widget,
{
if (ALLOCATION_WINDOW (widget) == scroll_data->window)
{
- widget->allocation.x += scroll_data->dx;
- widget->allocation.y += scroll_data->dy;
-
+ allocation.x += scroll_data->dx;
+ allocation.y += scroll_data->dy;
+ gtk_widget_set_allocation (widget, &allocation);
+
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
adjust_allocation_recurse,
@@ -8064,6 +8088,7 @@ popup_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkTextView *text_view;
GtkWidget *widget;
GdkRectangle cursor_rect;
@@ -8082,7 +8107,8 @@ popup_position_func (GtkMenu *menu,
screen = gtk_widget_get_screen (widget);
- gdk_window_get_origin (widget->window, &root_x, &root_y);
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ &root_x, &root_y);
gtk_text_buffer_get_iter_at_mark (get_buffer (text_view),
&iter,
@@ -8096,6 +8122,8 @@ popup_position_func (GtkMenu *menu,
gtk_widget_size_request (text_view->priv->popup_menu, &req);
+ gtk_widget_get_allocation (widget, &allocation);
+
/* can't use rectangle_intersect since cursor rect can have 0 width */
if (cursor_rect.x >= onscreen_rect.x &&
cursor_rect.x < onscreen_rect.x + onscreen_rect.width &&
@@ -8112,14 +8140,14 @@ popup_position_func (GtkMenu *menu,
}
else
{
- /* Just center the menu, since cursor is offscreen. */
- *x = root_x + (widget->allocation.width / 2 - req.width / 2);
- *y = root_y + (widget->allocation.height / 2 - req.height / 2);
+ /* Just center the menu, since cursor is offscreen. */
+ *x = root_x + (allocation.width / 2 - req.width / 2);
+ *y = root_y + (allocation.height / 2 - req.height / 2);
}
-
+
/* Ensure sanity */
- *x = CLAMP (*x, root_x, (root_x + widget->allocation.width));
- *y = CLAMP (*y, root_y, (root_y + widget->allocation.height));
+ *x = CLAMP (*x, root_x, (root_x + allocation.width));
+ *y = CLAMP (*y, root_y, (root_y + allocation.height));
monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
gtk_menu_set_monitor (menu, monitor_num);
@@ -8381,6 +8409,7 @@ static void
text_window_realize (GtkTextWindow *win,
GtkWidget *widget)
{
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
GdkCursor *cursor;
@@ -8397,9 +8426,10 @@ text_window_realize (GtkTextWindow *win,
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- win->window = gdk_window_new (widget->window,
- &attributes,
- attributes_mask);
+ window = gtk_widget_get_window (widget);
+
+ win->window = gdk_window_new (window,
+ &attributes, attributes_mask);
gdk_window_set_back_pixmap (win->window, NULL, FALSE);
@@ -8432,7 +8462,7 @@ text_window_realize (GtkTextWindow *win,
if (gtk_widget_is_sensitive (widget))
{
/* I-beam cursor */
- cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (widget->window),
+ cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (window),
GDK_XTERM);
gdk_window_set_cursor (win->bin_window, cursor);
gdk_cursor_unref (cursor);
@@ -8443,12 +8473,12 @@ text_window_realize (GtkTextWindow *win,
gdk_window_set_background (win->bin_window,
- &widget->style->base[gtk_widget_get_state (widget)]);
+ >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
}
else
{
gdk_window_set_background (win->bin_window,
- &widget->style->bg[gtk_widget_get_state (widget)]);
+ >k_widget_get_style (widget)->bg[gtk_widget_get_state (widget)]);
}
g_object_set_qdata (G_OBJECT (win->window),
@@ -8678,7 +8708,7 @@ gtk_text_view_get_window (GtkTextView *text_view,
switch (win)
{
case GTK_TEXT_WINDOW_WIDGET:
- return GTK_WIDGET (text_view)->window;
+ return gtk_widget_get_window (GTK_WIDGET (text_view));
break;
case GTK_TEXT_WINDOW_TEXT:
@@ -8744,7 +8774,7 @@ gtk_text_view_get_window_type (GtkTextView *text_view,
g_return_val_if_fail (GTK_IS_TEXT_VIEW (text_view), 0);
g_return_val_if_fail (GDK_IS_WINDOW (window), 0);
- if (window == GTK_WIDGET (text_view)->window)
+ if (window == gtk_widget_get_window (GTK_WIDGET (text_view)))
return GTK_TEXT_WINDOW_WIDGET;
win = g_object_get_qdata (G_OBJECT (window),
@@ -9348,7 +9378,7 @@ gtk_text_view_add_child_at_anchor (GtkTextView *text_view,
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (GTK_IS_TEXT_CHILD_ANCHOR (anchor));
- g_return_if_fail (child->parent == NULL);
+ g_return_if_fail (gtk_widget_get_parent (child) == NULL);
gtk_text_view_ensure_layout (text_view);
@@ -9397,7 +9427,7 @@ gtk_text_view_add_child_in_window (GtkTextView *text_view,
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == NULL);
+ g_return_if_fail (gtk_widget_get_parent (child) == NULL);
vc = text_view_child_new_window (child, which_window,
xpos, ypos);
@@ -9427,7 +9457,7 @@ gtk_text_view_move_child (GtkTextView *text_view,
g_return_if_fail (GTK_IS_TEXT_VIEW (text_view));
g_return_if_fail (GTK_IS_WIDGET (child));
- g_return_if_fail (child->parent == (GtkWidget*) text_view);
+ g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (text_view));
vc = g_object_get_data (G_OBJECT (child),
"gtk-text-view-child");
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index d5a5afc..71431f1 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -741,23 +741,25 @@ gtk_toolbar_unmap (GtkWidget *widget)
static void
gtk_toolbar_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
guint border_width;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
attributes.wclass = GDK_INPUT_ONLY;
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - border_width * 2;
+ attributes.height = allocation.height - border_width * 2;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
@@ -765,11 +767,13 @@ gtk_toolbar_realize (GtkWidget *widget)
GDK_LEAVE_NOTIFY_MASK);
attributes_mask = GDK_WA_X | GDK_WA_Y;
-
- widget->window = gtk_widget_get_parent_window (widget);
- g_object_ref (widget->window);
- widget->style = gtk_style_attach (widget->style, widget->window);
-
+
+ window = gtk_widget_get_parent_window (widget);
+ gtk_widget_set_window (widget, window);
+ g_object_ref (window);
+
+ gtk_widget_style_attach (widget);
+
priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget),
&attributes, attributes_mask);
gdk_window_set_user_data (priv->event_window, toolbar);
@@ -794,9 +798,9 @@ static gint
gtk_toolbar_expose (GtkWidget *widget,
GdkEventExpose *event)
{
+ GtkAllocation allocation;
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
-
GList *list;
guint border_width;
@@ -804,15 +808,16 @@ gtk_toolbar_expose (GtkWidget *widget,
if (gtk_widget_is_drawable (widget))
{
- gtk_paint_box (widget->style,
- widget->window,
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_paint_box (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
gtk_widget_get_state (widget),
get_shadow_type (toolbar),
&event->area, widget, "toolbar",
- border_width + widget->allocation.x,
- border_width + widget->allocation.y,
- widget->allocation.width - 2 * border_width,
- widget->allocation.height - 2 * border_width);
+ border_width + allocation.x,
+ border_width + allocation.y,
+ allocation.width - 2 * border_width,
+ allocation.height - 2 * border_width);
}
for (list = priv->content; list != NULL; list = list->next)
@@ -946,8 +951,11 @@ gtk_toolbar_size_request (GtkWidget *widget,
if (get_shadow_type (toolbar) != GTK_SHADOW_NONE)
{
- requisition->width += 2 * widget->style->xthickness;
- requisition->height += 2 * widget->style->ythickness;
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (widget);
+ requisition->width += 2 * style->xthickness;
+ requisition->height += 2 * style->ythickness;
}
toolbar->button_maxw = max_homogeneous_child_width;
@@ -1149,8 +1157,10 @@ rect_within (GtkAllocation *a1,
static void
gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (toolbar);
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
+ GtkStyle *style;
GList *list;
gint cur_x;
gint cur_y;
@@ -1170,25 +1180,28 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
if (!priv->idle_id)
priv->idle_id = gdk_threads_add_idle (slide_idle_handler, toolbar);
-
+
+ gtk_widget_get_allocation (widget, &allocation);
+ style = gtk_widget_get_style (widget);
+
rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL);
vertical = (toolbar->orientation == GTK_ORIENTATION_VERTICAL);
border_width = get_internal_padding (toolbar) + gtk_container_get_border_width (GTK_CONTAINER (toolbar));
if (rtl)
{
- cur_x = widget->allocation.width - border_width - widget->style->xthickness;
- cur_y = widget->allocation.height - border_width - widget->style->ythickness;
+ cur_x = allocation.width - border_width - style->xthickness;
+ cur_y = allocation.height - border_width - style->ythickness;
}
else
{
- cur_x = border_width + widget->style->xthickness;
- cur_y = border_width + widget->style->ythickness;
+ cur_x = border_width + style->xthickness;
+ cur_y = border_width + style->ythickness;
}
-
- cur_x += widget->allocation.x;
- cur_y += widget->allocation.y;
-
+
+ cur_x += allocation.x;
+ cur_y += allocation.y;
+
for (list = priv->content; list != NULL; list = list->next)
{
ToolbarContent *content = list->data;
@@ -1200,7 +1213,7 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
toolbar_content_get_allocation (content, &item_allocation);
if ((state == NORMAL &&
- rect_within (&item_allocation, &(widget->allocation))) ||
+ rect_within (&item_allocation, &allocation)) ||
state == OVERFLOWN)
{
new_start_allocation = item_allocation;
@@ -1212,15 +1225,15 @@ gtk_toolbar_begin_sliding (GtkToolbar *toolbar)
if (vertical)
{
- new_start_allocation.width = widget->allocation.width -
- 2 * border_width - 2 * widget->style->xthickness;
+ new_start_allocation.width = allocation.width -
+ 2 * border_width - 2 * style->xthickness;
new_start_allocation.height = 0;
}
else
{
new_start_allocation.width = 0;
- new_start_allocation.height = widget->allocation.height -
- 2 * border_width - 2 * widget->style->ythickness;
+ new_start_allocation.height = allocation.height -
+ 2 * border_width - 2 * style->ythickness;
}
}
@@ -1281,7 +1294,8 @@ static void
remove_item (GtkWidget *menu_item,
gpointer data)
{
- gtk_container_remove (GTK_CONTAINER (menu_item->parent), menu_item);
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (menu_item)),
+ menu_item);
}
static void
@@ -1369,11 +1383,13 @@ static void
gtk_toolbar_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkAllocation widget_allocation;
GtkToolbar *toolbar = GTK_TOOLBAR (widget);
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
GtkAllocation *allocations;
ItemState *new_states;
GtkAllocation arrow_allocation;
+ GtkStyle *style;
gint arrow_size;
gint size, pos, short_size;
GList *list;
@@ -1390,20 +1406,23 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
gdouble elapsed;
GtkAllocation item_area;
GtkShadowType shadow_type;
-
+
+ style = gtk_widget_get_style (widget);
+
+ gtk_widget_get_allocation (widget, &widget_allocation);
size_changed = FALSE;
- if (widget->allocation.x != allocation->x ||
- widget->allocation.y != allocation->y ||
- widget->allocation.width != allocation->width ||
- widget->allocation.height != allocation->height)
+ if (widget_allocation.x != allocation->x ||
+ widget_allocation.y != allocation->y ||
+ widget_allocation.width != allocation->width ||
+ widget_allocation.height != allocation->height)
{
size_changed = TRUE;
}
if (size_changed)
gtk_toolbar_stop_sliding (toolbar);
-
- widget->allocation = *allocation;
+
+ gtk_widget_set_allocation (widget, allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (toolbar));
@@ -1431,8 +1450,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
if (shadow_type != GTK_SHADOW_NONE)
{
- available_size -= 2 * widget->style->xthickness;
- short_size -= 2 * widget->style->ythickness;
+ available_size -= 2 * style->xthickness;
+ short_size -= 2 * style->ythickness;
}
}
else
@@ -1443,8 +1462,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
if (shadow_type != GTK_SHADOW_NONE)
{
- available_size -= 2 * widget->style->ythickness;
- short_size -= 2 * widget->style->xthickness;
+ available_size -= 2 * style->ythickness;
+ short_size -= 2 * style->xthickness;
}
}
@@ -1620,8 +1639,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
if (shadow_type != GTK_SHADOW_NONE)
{
- allocations[i].x += widget->style->xthickness;
- allocations[i].y += widget->style->ythickness;
+ allocations[i].x += style->xthickness;
+ allocations[i].y += style->ythickness;
}
}
@@ -1632,8 +1651,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
if (shadow_type != GTK_SHADOW_NONE)
{
- arrow_allocation.x += widget->style->xthickness;
- arrow_allocation.y += widget->style->ythickness;
+ arrow_allocation.x += style->xthickness;
+ arrow_allocation.y += style->ythickness;
}
}
@@ -1641,8 +1660,8 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
item_area.y += allocation->y;
if (shadow_type != GTK_SHADOW_NONE)
{
- item_area.x += widget->style->xthickness;
- item_area.y += widget->style->ythickness;
+ item_area.x += style->xthickness;
+ item_area.y += style->ythickness;
}
/* did anything change? */
@@ -1771,8 +1790,10 @@ gtk_toolbar_style_set (GtkWidget *widget,
priv->max_homogeneous_pixels = -1;
if (gtk_widget_get_realized (widget))
- gtk_style_set_background (widget->style, widget->window, widget->state);
-
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (widget));
+
if (prev_style)
gtk_toolbar_update_button_relief (GTK_TOOLBAR (widget));
}
@@ -2532,6 +2553,7 @@ menu_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkToolbar *toolbar = GTK_TOOLBAR (user_data);
GtkToolbarPrivate *priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
GtkRequisition req;
@@ -2544,38 +2566,41 @@ menu_position_func (GtkMenu *menu,
gtk_widget_size_request (GTK_WIDGET (menu), &menu_req);
screen = gtk_widget_get_screen (GTK_WIDGET (menu));
- monitor_num = gdk_screen_get_monitor_at_window (screen, priv->arrow_button->window);
+ monitor_num = gdk_screen_get_monitor_at_window (screen,
+ gtk_widget_get_window (priv->arrow_button));
if (monitor_num < 0)
monitor_num = 0;
gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ gtk_widget_get_allocation (priv->arrow_button, &allocation);
+
gdk_window_get_origin (GTK_BUTTON (priv->arrow_button)->event_window, x, y);
if (toolbar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
- *x += priv->arrow_button->allocation.width - req.width;
+ *x += allocation.width - req.width;
else
*x += req.width - menu_req.width;
- if ((*y + priv->arrow_button->allocation.height + menu_req.height) <= monitor.y + monitor.height)
- *y += priv->arrow_button->allocation.height;
+ if ((*y + allocation.height + menu_req.height) <= monitor.y + monitor.height)
+ *y += allocation.height;
else if ((*y - menu_req.height) >= monitor.y)
*y -= menu_req.height;
- else if (monitor.y + monitor.height - (*y + priv->arrow_button->allocation.height) > *y)
- *y += priv->arrow_button->allocation.height;
+ else if (monitor.y + monitor.height - (*y + allocation.height) > *y)
+ *y += allocation.height;
else
*y -= menu_req.height;
}
else
{
if (gtk_widget_get_direction (GTK_WIDGET (toolbar)) == GTK_TEXT_DIR_LTR)
- *x += priv->arrow_button->allocation.width;
+ *x += allocation.width;
else
*x -= menu_req.width;
if (*y + menu_req.height > monitor.y + monitor.height &&
- *y + priv->arrow_button->allocation.height - monitor.y > monitor.y + monitor.height - *y)
- *y += priv->arrow_button->allocation.height - menu_req.height;
+ *y + allocation.height - monitor.y > monitor.y + monitor.height - *y)
+ *y += allocation.height - menu_req.height;
}
*push_in = FALSE;
@@ -2746,8 +2771,8 @@ gtk_toolbar_get_item_index (GtkToolbar *toolbar,
g_return_val_if_fail (GTK_IS_TOOLBAR (toolbar), -1);
g_return_val_if_fail (GTK_IS_TOOL_ITEM (item), -1);
- g_return_val_if_fail (GTK_WIDGET (item)->parent == GTK_WIDGET (toolbar), -1);
-
+ g_return_val_if_fail (gtk_widget_get_parent (GTK_WIDGET (item)) == GTK_WIDGET (toolbar), -1);
+
priv = GTK_TOOLBAR_GET_PRIVATE (toolbar);
n = 0;
@@ -3209,7 +3234,7 @@ calculate_max_homogeneous_pixels (GtkWidget *widget)
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context,
- widget->style->font_desc,
+ gtk_widget_get_style (widget)->font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
@@ -3557,6 +3582,9 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget,
const GdkRectangle *area,
const GtkAllocation *allocation)
{
+ GtkStateType state;
+ GtkStyle *style;
+ GdkWindow *window;
const double start_fraction = (SPACE_LINE_START / SPACE_LINE_DIVISION);
const double end_fraction = (SPACE_LINE_END / SPACE_LINE_DIVISION);
@@ -3566,6 +3594,10 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget,
orientation = toolbar? toolbar->orientation : GTK_ORIENTATION_HORIZONTAL;
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+ state = gtk_widget_get_state (widget);
+
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
gboolean wide_separators;
@@ -3577,20 +3609,20 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget,
NULL);
if (wide_separators)
- gtk_paint_box (widget->style, widget->window,
- gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT,
+ gtk_paint_box (style, window,
+ state, GTK_SHADOW_ETCHED_OUT,
area, widget, "vseparator",
allocation->x + (allocation->width - separator_width) / 2,
allocation->y + allocation->height * start_fraction,
separator_width,
allocation->height * (end_fraction - start_fraction));
else
- gtk_paint_vline (widget->style, widget->window,
- gtk_widget_get_state (widget), area, widget,
+ gtk_paint_vline (style, window,
+ state, area, widget,
"toolbar",
allocation->y + allocation->height * start_fraction,
allocation->y + allocation->height * end_fraction,
- allocation->x + (allocation->width - widget->style->xthickness) / 2);
+ allocation->x + (allocation->width - style->xthickness) / 2);
}
else
{
@@ -3603,20 +3635,20 @@ _gtk_toolbar_paint_space_line (GtkWidget *widget,
NULL);
if (wide_separators)
- gtk_paint_box (widget->style, widget->window,
- gtk_widget_get_state (widget), GTK_SHADOW_ETCHED_OUT,
+ gtk_paint_box (style, window,
+ state, GTK_SHADOW_ETCHED_OUT,
area, widget, "hseparator",
allocation->x + allocation->width * start_fraction,
allocation->y + (allocation->height - separator_height) / 2,
allocation->width * (end_fraction - start_fraction),
separator_height);
else
- gtk_paint_hline (widget->style, widget->window,
- gtk_widget_get_state (widget), area, widget,
+ gtk_paint_hline (style, window,
+ state, area, widget,
"toolbar",
allocation->x + allocation->width * start_fraction,
allocation->x + allocation->width * end_fraction,
- allocation->y + (allocation->height - widget->style->ythickness) / 2);
+ allocation->y + (allocation->height - style->ythickness) / 2);
}
}
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c
index d0c8503..83ed674 100644
--- a/gtk/gtktoolbutton.c
+++ b/gtk/gtktoolbutton.c
@@ -323,6 +323,7 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
guint icon_spacing;
GtkOrientation text_orientation = GTK_ORIENTATION_HORIZONTAL;
GtkSizeGroup *size_group = NULL;
+ GtkWidget *parent;
button->priv->contents_invalid = FALSE;
@@ -330,15 +331,17 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
"icon-spacing", &icon_spacing,
NULL);
- if (button->priv->icon_widget && button->priv->icon_widget->parent)
+ parent = gtk_widget_get_parent (button->priv->icon_widget);
+
+ if (button->priv->icon_widget && parent)
{
- gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
+ gtk_container_remove (GTK_CONTAINER (parent),
button->priv->icon_widget);
}
- if (button->priv->label_widget && button->priv->label_widget->parent)
+ if (button->priv->label_widget && parent)
{
- gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent),
+ gtk_container_remove (GTK_CONTAINER (parent),
button->priv->label_widget);
}
@@ -1193,9 +1196,12 @@ gtk_tool_button_set_icon_widget (GtkToolButton *button,
{
if (button->priv->icon_widget)
{
- if (button->priv->icon_widget->parent)
- gtk_container_remove (GTK_CONTAINER (button->priv->icon_widget->parent),
- button->priv->icon_widget);
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (button->priv->icon_widget);
+ if (parent)
+ gtk_container_remove (GTK_CONTAINER (parent),
+ button->priv->icon_widget);
g_object_unref (button->priv->icon_widget);
}
@@ -1234,10 +1240,13 @@ gtk_tool_button_set_label_widget (GtkToolButton *button,
{
if (button->priv->label_widget)
{
- if (button->priv->label_widget->parent)
- gtk_container_remove (GTK_CONTAINER (button->priv->label_widget->parent),
- button->priv->label_widget);
-
+ GtkWidget *parent;
+
+ parent = gtk_widget_get_parent (button->priv->label_widget);
+ if (parent)
+ gtk_container_remove (GTK_CONTAINER (parent),
+ button->priv->label_widget);
+
g_object_unref (button->priv->label_widget);
}
diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c
index 94b5ea8..20ad6d8 100644
--- a/gtk/gtktoolitem.c
+++ b/gtk/gtktoolitem.c
@@ -318,7 +318,7 @@ static void
gtk_tool_item_parent_set (GtkWidget *toolitem,
GtkWidget *prev_parent)
{
- if (GTK_WIDGET (toolitem)->parent != NULL)
+ if (gtk_widget_get_parent (GTK_WIDGET (toolitem)) != NULL)
gtk_tool_item_toolbar_reconfigured (GTK_TOOL_ITEM (toolitem));
}
@@ -398,6 +398,7 @@ gtk_tool_item_property_notify (GObject *object,
static void
create_drag_window (GtkToolItem *toolitem)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GdkWindowAttr attributes;
gint attributes_mask, border_width;
@@ -405,13 +406,15 @@ create_drag_window (GtkToolItem *toolitem)
g_return_if_fail (toolitem->priv->use_drag_window == TRUE);
widget = GTK_WIDGET (toolitem);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ gtk_widget_get_allocation (widget, &allocation);
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - border_width * 2;
+ attributes.height = allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_ONLY;
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
@@ -427,17 +430,19 @@ static void
gtk_tool_item_realize (GtkWidget *widget)
{
GtkToolItem *toolitem;
+ GdkWindow *window;
toolitem = GTK_TOOL_ITEM (widget);
gtk_widget_set_realized (widget, TRUE);
- 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);
if (toolitem->priv->use_drag_window)
create_drag_window(toolitem);
- widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_widget_style_attach (widget);
}
static void
@@ -517,17 +522,18 @@ gtk_tool_item_size_allocate (GtkWidget *widget,
gint border_width;
GtkWidget *child;
- child = gtk_bin_get_child (GTK_BIN (widget));
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (toolitem->priv->drag_window)
gdk_window_move_resize (toolitem->priv->drag_window,
- widget->allocation.x + border_width,
- widget->allocation.y + border_width,
- widget->allocation.width - border_width * 2,
- widget->allocation.height - border_width * 2);
-
+ allocation->x + border_width,
+ allocation->y + border_width,
+ allocation->width - border_width * 2,
+ allocation->height - border_width * 2);
+
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
child_allocation.x = allocation->x + border_width;
@@ -694,7 +700,7 @@ gtk_tool_item_get_ellipsize_mode (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return PANGO_ELLIPSIZE_NONE;
@@ -721,7 +727,7 @@ gtk_tool_item_get_icon_size (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ICON_SIZE_LARGE_TOOLBAR);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_ICON_SIZE_LARGE_TOOLBAR;
@@ -748,7 +754,7 @@ gtk_tool_item_get_orientation (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_ORIENTATION_HORIZONTAL;
@@ -791,7 +797,7 @@ gtk_tool_item_get_toolbar_style (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_TOOLBAR_ICONS);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_TOOLBAR_ICONS;
@@ -819,7 +825,7 @@ gtk_tool_item_get_relief_style (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_RELIEF_NONE);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_RELIEF_NONE;
@@ -846,7 +852,7 @@ gtk_tool_item_get_text_alignment (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return 0.5;
@@ -873,7 +879,7 @@ gtk_tool_item_get_text_orientation (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), GTK_ORIENTATION_HORIZONTAL);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return GTK_ORIENTATION_HORIZONTAL;
@@ -898,7 +904,7 @@ gtk_tool_item_get_text_size_group (GtkToolItem *tool_item)
g_return_val_if_fail (GTK_IS_TOOL_ITEM (tool_item), NULL);
- parent = GTK_WIDGET (tool_item)->parent;
+ parent = gtk_widget_get_parent (GTK_WIDGET (tool_item));
if (!parent || !GTK_IS_TOOL_SHELL (parent))
return NULL;
@@ -1325,14 +1331,16 @@ gtk_tool_item_get_proxy_menu_item (GtkToolItem *tool_item,
void
gtk_tool_item_rebuild_menu (GtkToolItem *tool_item)
{
+ GtkWidget *parent;
GtkWidget *widget;
-
+
g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
widget = GTK_WIDGET (tool_item);
- if (GTK_IS_TOOL_SHELL (widget->parent))
- gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (widget->parent));
+ parent = gtk_widget_get_parent (widget);
+ if (GTK_IS_TOOL_SHELL (parent))
+ gtk_tool_shell_rebuild_menu (GTK_TOOL_SHELL (parent));
}
/**
diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c
index a6b9721..26a0815 100644
--- a/gtk/gtktoolitemgroup.c
+++ b/gtk/gtktoolitemgroup.c
@@ -264,6 +264,7 @@ gtk_tool_item_group_header_expose_event_cb (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
+ GtkAllocation allocation;
GtkToolItemGroup *group = GTK_TOOL_ITEM_GROUP (data);
GtkToolItemGroupPrivate* priv = group->priv;
GtkExpanderStyle expander_style;
@@ -275,18 +276,20 @@ gtk_tool_item_group_header_expose_event_cb (GtkWidget *widget,
expander_style = priv->expander_style;
direction = gtk_widget_get_direction (widget);
+ gtk_widget_get_allocation (widget, &allocation);
if (GTK_ORIENTATION_VERTICAL == orientation)
{
if (GTK_TEXT_DIR_RTL == direction)
- x = widget->allocation.x + widget->allocation.width - priv->expander_size / 2;
+ x = allocation.x + allocation.width - priv->expander_size / 2;
else
- x = widget->allocation.x + priv->expander_size / 2;
- y = widget->allocation.y + widget->allocation.height / 2;
+ x = allocation.x + priv->expander_size / 2;
+
+ y = allocation.y + allocation.height / 2;
}
else
{
- x = widget->allocation.x + widget->allocation.width / 2;
- y = widget->allocation.y + priv->expander_size / 2;
+ x = allocation.x + allocation.width / 2;
+ y = allocation.y + priv->expander_size / 2;
/* Unfortunatly gtk_paint_expander() doesn't support rotated drawing
* modes. Luckily the following shady arithmetics produce the desired
@@ -294,8 +297,9 @@ gtk_tool_item_group_header_expose_event_cb (GtkWidget *widget,
expander_style = GTK_EXPANDER_EXPANDED - expander_style;
}
- gtk_paint_expander (widget->style, widget->window,
- priv->header->state,
+ gtk_paint_expander (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (priv->header),
&event->area, GTK_WIDGET (group),
"tool-palette-header", x, y,
expander_style);
@@ -1047,7 +1051,7 @@ gtk_tool_item_group_size_allocate (GtkWidget *widget,
gtk_tool_item_group_real_size_allocate (widget, allocation);
if (gtk_widget_get_mapped (widget))
- gdk_window_invalidate_rect (widget->window, NULL, FALSE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE);
}
static void
@@ -1056,6 +1060,7 @@ gtk_tool_item_group_set_focus_cb (GtkWidget *window,
gpointer user_data)
{
GtkAdjustment *adjustment;
+ GtkAllocation allocation, p_allocation;
GtkWidget *p;
/* Find this group's parent widget in the focused widget's anchestry. */
@@ -1071,26 +1076,27 @@ gtk_tool_item_group_set_focus_cb (GtkWidget *window,
/* Check that the focused widgets is fully visible within
* the group's parent widget and make it visible otherwise. */
- adjustment = gtk_tool_palette_get_hadjustment (GTK_TOOL_PALETTE (p));
adjustment = gtk_tool_palette_get_vadjustment (GTK_TOOL_PALETTE (p));
if (adjustment)
{
int y;
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (p, &p_allocation);
+
/* Handle vertical adjustment. */
if (gtk_widget_translate_coordinates
(widget, p, 0, 0, NULL, &y) && y < 0)
{
y += adjustment->value;
- gtk_adjustment_clamp_page (adjustment, y, y + widget->allocation.height);
+ gtk_adjustment_clamp_page (adjustment, y, y + allocation.height);
}
- else if (gtk_widget_translate_coordinates
- (widget, p, 0, widget->allocation.height, NULL, &y) &&
- y > p->allocation.height)
+ else if (gtk_widget_translate_coordinates (widget, p, 0, allocation.height, NULL, &y) &&
+ y > p_allocation.height)
{
y += adjustment->value;
- gtk_adjustment_clamp_page (adjustment, y - widget->allocation.height, y);
+ gtk_adjustment_clamp_page (adjustment, y - allocation.height, y);
}
}
@@ -1100,19 +1106,21 @@ gtk_tool_item_group_set_focus_cb (GtkWidget *window,
{
int x;
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (p, &p_allocation);
+
/* Handle horizontal adjustment. */
if (gtk_widget_translate_coordinates
(widget, p, 0, 0, &x, NULL) && x < 0)
{
x += adjustment->value;
- gtk_adjustment_clamp_page (adjustment, x, x + widget->allocation.width);
+ gtk_adjustment_clamp_page (adjustment, x, x + allocation.width);
}
- else if (gtk_widget_translate_coordinates
- (widget, p, widget->allocation.width, 0, &x, NULL) &&
- x > p->allocation.width)
+ else if (gtk_widget_translate_coordinates (widget, p, allocation.width, 0, &x, NULL) &&
+ x > p_allocation.width)
{
x += adjustment->value;
- gtk_adjustment_clamp_page (adjustment, x - widget->allocation.width, x);
+ gtk_adjustment_clamp_page (adjustment, x - allocation.width, x);
}
return;
@@ -1162,19 +1170,25 @@ gtk_tool_item_group_set_toplevel_window (GtkToolItemGroup *group,
static void
gtk_tool_item_group_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
GtkWidget *toplevel_window;
- gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ GdkWindow *window;
GdkWindowAttr attributes;
GdkDisplay *display;
+ gint attributes_mask;
guint border_width;
+ gtk_widget_set_realized (widget, TRUE);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - border_width * 2;
+ attributes.height = allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -1182,23 +1196,26 @@ gtk_tool_item_group_realize (GtkWidget *widget)
| GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_BUTTON_MOTION_MASK;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
- display = gdk_drawable_get_display (widget->window);
+ display = gdk_drawable_get_display (window);
if (gdk_display_supports_composite (display))
- gdk_window_set_composited (widget->window, TRUE);
+ gdk_window_set_composited (window, TRUE);
- gdk_window_set_user_data (widget->window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- gtk_widget_set_realized (widget, TRUE);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window, GTK_STATE_NORMAL);
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_set_parent_window,
- widget->window);
+ window);
gtk_widget_queue_resize_no_redraw (widget);
@@ -1701,7 +1718,7 @@ gtk_tool_item_group_set_label_widget (GtkToolItemGroup *group,
g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (group));
g_return_if_fail (label_widget == NULL || GTK_IS_WIDGET (label_widget));
- g_return_if_fail (label_widget == NULL || label_widget->parent == NULL);
+ g_return_if_fail (label_widget == NULL || gtk_widget_get_parent (label_widget) == NULL);
priv = group->priv;
@@ -1773,34 +1790,41 @@ gtk_tool_item_group_force_expose (GtkToolItemGroup *group)
if (gtk_widget_get_realized (priv->header))
{
+ GtkAllocation alignment_allocation;
GtkWidget *alignment = gtk_tool_item_group_get_alignment (group);
GdkRectangle area;
/* Find the header button's arrow area... */
- area.x = alignment->allocation.x;
- area.y = alignment->allocation.y + (alignment->allocation.height - priv->expander_size) / 2;
+ gtk_widget_get_allocation (alignment, &alignment_allocation);
+ area.x = alignment_allocation.x;
+ area.y = alignment_allocation.y + (alignment_allocation.height - priv->expander_size) / 2;
area.height = priv->expander_size;
area.width = priv->expander_size;
/* ... and invalidated it to get it animated. */
- gdk_window_invalidate_rect (priv->header->window, &area, TRUE);
+ gdk_window_invalidate_rect (gtk_widget_get_window (priv->header), &area, TRUE);
}
if (gtk_widget_get_realized (widget))
{
+ GtkAllocation allocation;
GtkWidget *parent = gtk_widget_get_parent (widget);
int x, y, width, height;
/* Find the tool item area button's arrow area... */
- width = widget->allocation.width;
- height = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ width = allocation.width;
+ height = allocation.height;
gtk_widget_translate_coordinates (widget, parent, 0, 0, &x, &y);
if (gtk_widget_get_visible (priv->header))
{
- height -= priv->header->allocation.height;
- y += priv->header->allocation.height;
+ GtkAllocation header_allocation;
+
+ gtk_widget_get_allocation (priv->header, &header_allocation);
+ height -= header_allocation.height;
+ y += header_allocation.height;
}
/* ... and invalidated it to get it animated. */
@@ -2202,17 +2226,17 @@ gtk_tool_item_group_get_drop_item (GtkToolItemGroup *group,
gint x,
gint y)
{
- GtkAllocation *allocation;
+ GtkAllocation allocation;
GtkOrientation orientation;
GList *it;
g_return_val_if_fail (GTK_IS_TOOL_ITEM_GROUP (group), NULL);
- allocation = >K_WIDGET (group)->allocation;
+ gtk_widget_get_allocation (GTK_WIDGET (group), &allocation);
orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group));
- g_return_val_if_fail (x >= 0 && x < allocation->width, NULL);
- g_return_val_if_fail (y >= 0 && y < allocation->height, NULL);
+ g_return_val_if_fail (x >= 0 && x < allocation.width, NULL);
+ g_return_val_if_fail (y >= 0 && y < allocation.height, NULL);
for (it = group->priv->children; it != NULL; it = it->next)
{
@@ -2223,13 +2247,13 @@ gtk_tool_item_group_get_drop_item (GtkToolItemGroup *group,
if (!item || !gtk_tool_item_group_is_item_visible (group, child))
continue;
- allocation = >K_WIDGET (item)->allocation;
+ gtk_widget_get_allocation (GTK_WIDGET (item), &allocation);
- x0 = x - allocation->x;
- y0 = y - allocation->y;
+ x0 = x - allocation.x;
+ y0 = y - allocation.y;
- if (x0 >= 0 && x0 < allocation->width &&
- y0 >= 0 && y0 < allocation->height)
+ if (x0 >= 0 && x0 < allocation.width &&
+ y0 >= 0 && y0 < allocation.height)
return item;
}
@@ -2288,46 +2312,51 @@ void
_gtk_tool_item_group_paint (GtkToolItemGroup *group,
cairo_t *cr)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (group);
GtkToolItemGroupPrivate* priv = group->priv;
- gdk_cairo_set_source_pixmap (cr, widget->window,
- widget->allocation.x,
- widget->allocation.y);
+ gtk_widget_get_allocation (widget, &allocation);
+
+ gdk_cairo_set_source_pixmap (cr, gtk_widget_get_window (widget),
+ allocation.x,
+ allocation.y);
if (priv->animation_timeout)
{
+ GtkAllocation header_allocation;
GtkOrientation orientation = gtk_tool_item_group_get_orientation (GTK_TOOL_SHELL (group));
cairo_pattern_t *mask;
gdouble v0, v1;
if (GTK_ORIENTATION_VERTICAL == orientation)
- v1 = widget->allocation.height;
+ v1 = allocation.height;
else
- v1 = widget->allocation.width;
+ v1 = allocation.width;
v0 = v1 - 256;
+ gtk_widget_get_allocation (priv->header, &header_allocation);
if (!gtk_widget_get_visible (priv->header))
v0 = MAX (v0, 0);
else if (GTK_ORIENTATION_VERTICAL == orientation)
- v0 = MAX (v0, priv->header->allocation.height);
+ v0 = MAX (v0, header_allocation.height);
else
- v0 = MAX (v0, priv->header->allocation.width);
+ v0 = MAX (v0, header_allocation.width);
v1 = MIN (v0 + 256, v1);
if (GTK_ORIENTATION_VERTICAL == orientation)
{
- v0 += widget->allocation.y;
- v1 += widget->allocation.y;
+ v0 += allocation.y;
+ v1 += allocation.y;
mask = cairo_pattern_create_linear (0.0, v0, 0.0, v1);
}
else
{
- v0 += widget->allocation.x;
- v1 += widget->allocation.x;
+ v0 += allocation.x;
+ v1 += allocation.x;
mask = cairo_pattern_create_linear (v0, 0.0, v1, 0.0);
}
diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c
index 76f4db9..15ecf3e 100644
--- a/gtk/gtktoolpalette.c
+++ b/gtk/gtktoolpalette.c
@@ -620,15 +620,18 @@ gtk_tool_palette_expose_event (GtkWidget *widget,
{
GtkToolPalette *palette = GTK_TOOL_PALETTE (widget);
GdkDisplay *display;
+ GdkWindow *window;
cairo_t *cr;
guint i;
- display = gdk_drawable_get_display (widget->window);
+ window = gtk_widget_get_window (widget);
+
+ display = gdk_drawable_get_display (window);
if (!gdk_display_supports_composite (display))
return FALSE;
- cr = gdk_cairo_create (widget->window);
+ cr = gdk_cairo_create (window);
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
@@ -652,17 +655,23 @@ gtk_tool_palette_expose_event (GtkWidget *widget,
static void
gtk_tool_palette_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GdkWindow *window;
GdkWindowAttr attributes;
- gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+ gint attributes_mask;
guint border_width;
+ gtk_widget_set_realized (widget, TRUE);
+
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+ gtk_widget_get_allocation (widget, &allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - border_width * 2;
+ attributes.height = allocation.height - border_width * 2;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -670,18 +679,19 @@ gtk_tool_palette_realize (GtkWidget *widget)
| GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK
| GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
| GDK_BUTTON_MOTION_MASK;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data (window, widget);
- gdk_window_set_user_data (widget->window, widget);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_style_attach (widget);
+ gtk_style_set_background (gtk_widget_get_style (widget),
+ window, GTK_STATE_NORMAL);
gtk_container_forall (GTK_CONTAINER (widget),
(GtkCallback) gtk_widget_set_parent_window,
- widget->window);
+ window);
gtk_widget_queue_resize_no_redraw (widget);
}
@@ -690,8 +700,11 @@ static void
gtk_tool_palette_adjustment_value_changed (GtkAdjustment *adjustment,
gpointer data)
{
+ GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (data);
- gtk_tool_palette_size_allocate (widget, &widget->allocation);
+
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_tool_palette_size_allocate (widget, &allocation);
}
static void
@@ -1554,13 +1567,17 @@ gtk_tool_palette_get_drop_item (GtkToolPalette *palette,
gint x,
gint y)
{
+ GtkAllocation allocation;
GtkToolItemGroup *group = gtk_tool_palette_get_drop_group (palette, x, y);
GtkWidget *widget = GTK_WIDGET (group);
if (group)
- return gtk_tool_item_group_get_drop_item (group,
- x - widget->allocation.x,
- y - widget->allocation.y);
+ {
+ gtk_widget_get_allocation (widget, &allocation);
+ return gtk_tool_item_group_get_drop_item (group,
+ x - allocation.x,
+ y - allocation.y);
+ }
return NULL;
}
@@ -1583,15 +1600,15 @@ gtk_tool_palette_get_drop_group (GtkToolPalette *palette,
gint x,
gint y)
{
- GtkAllocation *allocation;
+ GtkAllocation allocation;
guint i;
g_return_val_if_fail (GTK_IS_TOOL_PALETTE (palette), NULL);
- allocation = >K_WIDGET (palette)->allocation;
+ gtk_widget_get_allocation (GTK_WIDGET (palette), &allocation);
- g_return_val_if_fail (x >= 0 && x < allocation->width, NULL);
- g_return_val_if_fail (y >= 0 && y < allocation->height, NULL);
+ g_return_val_if_fail (x >= 0 && x < allocation.width, NULL);
+ g_return_val_if_fail (y >= 0 && y < allocation.height, NULL);
for (i = 0; i < palette->priv->groups->len; ++i)
{
@@ -1603,12 +1620,13 @@ gtk_tool_palette_get_drop_group (GtkToolPalette *palette,
continue;
widget = GTK_WIDGET (group->widget);
+ gtk_widget_get_allocation (widget, &allocation);
- x0 = x - widget->allocation.x;
- y0 = y - widget->allocation.y;
+ x0 = x - allocation.x;
+ y0 = y - allocation.y;
- if (x0 >= 0 && x0 < widget->allocation.width &&
- y0 >= 0 && y0 < widget->allocation.height)
+ if (x0 >= 0 && x0 < allocation.width &&
+ y0 >= 0 && y0 < allocation.height)
return GTK_TOOL_ITEM_GROUP (widget);
}
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index c75f251..698bd0d 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -113,6 +113,10 @@ gtk_tooltip_class_init (GtkTooltipClass *klass)
static void
gtk_tooltip_init (GtkTooltip *tooltip)
{
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (tooltip->window);
+
tooltip->timeout_id = 0;
tooltip->browse_mode_timeout_id = 0;
@@ -138,10 +142,8 @@ gtk_tooltip_init (GtkTooltip *tooltip)
tooltip->alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment),
- tooltip->window->style->ythickness,
- tooltip->window->style->ythickness,
- tooltip->window->style->xthickness,
- tooltip->window->style->xthickness);
+ style->ythickness, style->ythickness,
+ style->xthickness, style->xthickness);
gtk_container_add (GTK_CONTAINER (tooltip->window), tooltip->alignment);
gtk_widget_show (tooltip->alignment);
@@ -150,7 +152,7 @@ gtk_tooltip_init (GtkTooltip *tooltip)
g_signal_connect_swapped (tooltip->window, "expose-event",
G_CALLBACK (gtk_tooltip_paint_window), tooltip);
- tooltip->box = gtk_hbox_new (FALSE, tooltip->window->style->xthickness);
+ tooltip->box = gtk_hbox_new (FALSE, style->xthickness);
gtk_container_add (GTK_CONTAINER (tooltip->alignment), tooltip->box);
gtk_widget_show (tooltip->box);
@@ -498,13 +500,16 @@ gtk_tooltip_reset (GtkTooltip *tooltip)
static void
gtk_tooltip_window_style_set (GtkTooltip *tooltip)
{
+ GtkStyle *style;
+
+ style = gtk_widget_get_style (tooltip->window);
+
gtk_alignment_set_padding (GTK_ALIGNMENT (tooltip->alignment),
- tooltip->window->style->ythickness,
- tooltip->window->style->ythickness,
- tooltip->window->style->xthickness,
- tooltip->window->style->xthickness);
+ style->ythickness, style->ythickness,
+ style->xthickness, style->xthickness);
+
gtk_box_set_spacing (GTK_BOX (tooltip->box),
- tooltip->window->style->xthickness);
+ style->xthickness);
gtk_widget_queue_draw (tooltip->window);
}
@@ -512,16 +517,18 @@ gtk_tooltip_window_style_set (GtkTooltip *tooltip)
static gboolean
gtk_tooltip_paint_window (GtkTooltip *tooltip)
{
- gtk_paint_flat_box (tooltip->window->style,
- tooltip->window->window,
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (tooltip->window, &allocation);
+ gtk_paint_flat_box (gtk_widget_get_style (tooltip->window),
+ gtk_widget_get_window (tooltip->window),
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
NULL,
tooltip->window,
"tooltip",
0, 0,
- tooltip->window->allocation.width,
- tooltip->window->allocation.height);
+ allocation.width, allocation.height);
return FALSE;
}
@@ -550,6 +557,7 @@ static void
child_location_foreach (GtkWidget *child,
gpointer data)
{
+ GtkAllocation child_allocation;
gint x, y;
struct ChildLocation *child_loc = data;
@@ -557,6 +565,8 @@ child_location_foreach (GtkWidget *child,
if (!gtk_widget_is_drawable (child))
return;
+ gtk_widget_get_allocation (child, &child_allocation);
+
x = 0;
y = 0;
@@ -572,17 +582,17 @@ child_location_foreach (GtkWidget *child,
#ifdef DEBUG_TOOLTIP
g_print ("candidate: %s alloc=[(%d,%d) %dx%d] (%d, %d)->(%d, %d)\n",
gtk_widget_get_name (child),
- child->allocation.x,
- child->allocation.y,
- child->allocation.width,
- child->allocation.height,
+ child_allocation.x,
+ child_allocation.y,
+ child_allocation.width,
+ child_allocation.height,
child_loc->x, child_loc->y,
x, y);
#endif /* DEBUG_TOOLTIP */
/* (x, y) relative to child's allocation. */
- if (x >= 0 && x < child->allocation.width
- && y >= 0 && y < child->allocation.height)
+ if (x >= 0 && x < child_allocation.width
+ && y >= 0 && y < child_allocation.height)
{
if (GTK_IS_CONTAINER (child))
{
@@ -619,22 +629,28 @@ window_to_alloc (GtkWidget *dest_widget,
gint *dest_x,
gint *dest_y)
{
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (dest_widget, &allocation);
+
/* Translate from window relative to allocation relative */
- if (gtk_widget_get_has_window (dest_widget) && dest_widget->parent)
+ if (gtk_widget_get_has_window (dest_widget) &&
+ gtk_widget_get_parent (dest_widget))
{
gint wx, wy;
- gdk_window_get_position (dest_widget->window, &wx, &wy);
+ gdk_window_get_position (gtk_widget_get_window (dest_widget),
+ &wx, &wy);
/* Offset coordinates if widget->window is smaller than
* widget->allocation.
*/
- src_x += wx - dest_widget->allocation.x;
- src_y += wy - dest_widget->allocation.y;
+ src_x += wx - allocation.x;
+ src_y += wy - allocation.y;
}
else
{
- src_x -= dest_widget->allocation.x;
- src_y -= dest_widget->allocation.y;
+ src_x -= allocation.x;
+ src_y -= allocation.y;
}
if (dest_x)
@@ -677,7 +693,7 @@ _gtk_widget_find_at_coords (GdkWindow *window,
* coordinates stay relative to the current window.
* We end up with window == widget->window, coordinates relative to that.
*/
- while (window && window != event_widget->window)
+ while (window && window != gtk_widget_get_window (event_widget))
{
gdouble px, py;
@@ -747,6 +763,7 @@ find_topmost_widget_coords_from_event (GdkEvent *event,
gint *x,
gint *y)
{
+ GtkAllocation allocation;
gint tx, ty;
gdouble dx, dy;
GtkWidget *tmp;
@@ -760,8 +777,9 @@ find_topmost_widget_coords_from_event (GdkEvent *event,
return NULL;
/* Make sure the pointer can actually be on the widget returned. */
- if (tx < 0 || tx >= tmp->allocation.width ||
- ty < 0 || ty >= tmp->allocation.height)
+ gtk_widget_get_allocation (tmp, &allocation);
+ if (tx < 0 || tx >= allocation.width ||
+ ty < 0 || ty >= allocation.height)
return NULL;
if (x)
@@ -842,7 +860,7 @@ gtk_tooltip_run_requery (GtkWidget **widget,
if (!return_value)
{
- GtkWidget *parent = (*widget)->parent;
+ GtkWidget *parent = gtk_widget_get_parent (*widget);
if (parent)
gtk_widget_translate_coordinates (*widget, parent, *x, *y, x, y);
@@ -867,6 +885,7 @@ static void
get_bounding_box (GtkWidget *widget,
GdkRectangle *bounds)
{
+ GtkAllocation allocation;
GdkWindow *window;
gint x, y;
gint w, h;
@@ -879,10 +898,11 @@ get_bounding_box (GtkWidget *widget,
if (window == NULL)
window = gtk_widget_get_window (widget);
- x = widget->allocation.x;
- y = widget->allocation.y;
- w = widget->allocation.width;
- h = widget->allocation.height;
+ gtk_widget_get_allocation (widget, &allocation);
+ x = allocation.x;
+ y = allocation.y;
+ w = allocation.width;
+ h = allocation.height;
gdk_window_get_root_coords (window, x, y, &x1, &y1);
gdk_window_get_root_coords (window, x + w, y, &x2, &y2);
@@ -1276,7 +1296,8 @@ _gtk_tooltip_focus_in (GtkWidget *widget)
tooltip->keyboard_widget = g_object_ref (widget);
- gdk_window_get_device_position (widget->window, device, &x, &y, NULL);
+ gdk_window_get_device_position (gtk_widget_get_window (widget),
+ device, &x, &y, NULL);
return_value = gtk_tooltip_run_requery (&widget, tooltip, &x, &y);
if (!return_value)
@@ -1376,7 +1397,7 @@ _gtk_tooltip_hide (GtkWidget *widget)
toplevel = gtk_widget_get_toplevel (widget);
if (widget == tooltip->tooltip_widget
- || toplevel->window == tooltip->toplevel_window)
+ || gtk_widget_get_window (toplevel) == tooltip->toplevel_window)
gtk_tooltip_hide_tooltip (tooltip);
}
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 7bbb4e4..15040d1 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -1776,25 +1776,30 @@ gtk_tree_view_map (GtkWidget *widget)
gtk_tree_view_map_buttons (tree_view);
- gdk_window_show (widget->window);
+ gdk_window_show (gtk_widget_get_window (widget));
}
static void
gtk_tree_view_realize (GtkWidget *widget)
{
+ GtkAllocation allocation;
+ GtkStyle *style;
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
- GList *tmp_list;
+ GdkWindow *window;
GdkWindowAttr attributes;
+ GList *tmp_list;
gint attributes_mask;
gtk_widget_set_realized (widget, TRUE);
+ gtk_widget_get_allocation (widget, &allocation);
+
/* Make the main, clipping window */
attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ attributes.x = allocation.x;
+ attributes.y = allocation.y;
+ attributes.width = allocation.width;
+ attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -1802,15 +1807,18 @@ gtk_tree_view_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, widget);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, widget);
+
+ gtk_widget_get_allocation (widget, &allocation);
/* Make the window for the tree */
attributes.x = 0;
attributes.y = TREE_VIEW_HEADER_HEIGHT (tree_view);
- attributes.width = MAX (tree_view->priv->width, widget->allocation.width);
- attributes.height = widget->allocation.height;
+ attributes.width = MAX (tree_view->priv->width, allocation.width);
+ attributes.height = allocation.height;
attributes.event_mask = (GDK_EXPOSURE_MASK |
GDK_SCROLL_MASK |
GDK_POINTER_MOTION_MASK |
@@ -1820,14 +1828,16 @@ gtk_tree_view_realize (GtkWidget *widget)
GDK_BUTTON_RELEASE_MASK |
gtk_widget_get_events (widget));
- tree_view->priv->bin_window = gdk_window_new (widget->window,
+ tree_view->priv->bin_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (tree_view->priv->bin_window, widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
/* Make the column header window */
attributes.x = 0;
attributes.y = 0;
- attributes.width = MAX (tree_view->priv->width, widget->allocation.width);
+ attributes.width = MAX (tree_view->priv->width, allocation.width);
attributes.height = tree_view->priv->header_height;
attributes.event_mask = (GDK_EXPOSURE_MASK |
GDK_SCROLL_MASK |
@@ -1839,15 +1849,17 @@ gtk_tree_view_realize (GtkWidget *widget)
GDK_KEY_RELEASE_MASK |
gtk_widget_get_events (widget));
- tree_view->priv->header_window = gdk_window_new (widget->window,
+ tree_view->priv->header_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (tree_view->priv->header_window, widget);
/* Add them all up. */
- widget->style = gtk_style_attach (widget->style, widget->window);
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_background (tree_view->priv->bin_window, &widget->style->base[widget->state]);
- gtk_style_set_background (widget->style, tree_view->priv->header_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ gdk_window_set_back_pixmap (window, NULL, FALSE);
+ style = gtk_widget_get_style (widget);
+ gdk_window_set_background (tree_view->priv->bin_window,
+ &style->base[gtk_widget_get_state (widget)]);
+ gtk_style_set_background (style, tree_view->priv->header_window, GTK_STATE_NORMAL);
tmp_list = tree_view->priv->children;
while (tmp_list)
@@ -2104,14 +2116,16 @@ invalidate_column (GtkTreeView *tree_view,
GtkTreeViewColumn *tmpcolumn = list->data;
if (tmpcolumn == column)
{
+ GtkAllocation allocation;
GdkRectangle invalid_rect;
-
+
+ gtk_widget_get_allocation (widget, &allocation);
invalid_rect.x = column_offset;
invalid_rect.y = 0;
invalid_rect.width = column->width;
- invalid_rect.height = widget->allocation.height;
-
- gdk_window_invalidate_rect (widget->window, &invalid_rect, TRUE);
+ invalid_rect.height = allocation.height;
+
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), &invalid_rect, TRUE);
break;
}
@@ -2181,6 +2195,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
GList *list, *first_column, *last_column;
GtkTreeViewColumn *column;
GtkAllocation allocation;
+ GtkAllocation widget_allocation;
gint width = 0;
gint extra, extra_per_column, extra_for_last;
gint full_requested_width = 0;
@@ -2234,14 +2249,15 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
tree_view->priv->post_validation_flag = FALSE;
+ gtk_widget_get_allocation (widget, &widget_allocation);
if (!update_expand)
{
extra = tree_view->priv->last_extra_space;
- extra_for_last = MAX (widget->allocation.width - full_requested_width - extra, 0);
+ extra_for_last = MAX (widget_allocation.width - full_requested_width - extra, 0);
}
else
{
- extra = MAX (widget->allocation.width - full_requested_width, 0);
+ extra = MAX (widget_allocation.width - full_requested_width, 0);
extra_for_last = 0;
tree_view->priv->last_extra_space = extra;
@@ -2352,15 +2368,18 @@ static void
gtk_tree_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkAllocation widget_allocation;
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GList *tmp_list;
gboolean width_changed = FALSE;
- gint old_width = widget->allocation.width;
+ gint old_width;
- if (allocation->width != widget->allocation.width)
+ gtk_widget_get_allocation (widget, &widget_allocation);
+ old_width = widget_allocation.width;
+ if (allocation->width != widget_allocation.width)
width_changed = TRUE;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
tmp_list = tree_view->priv->children;
@@ -2439,7 +2458,7 @@ gtk_tree_view_size_allocate (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_move_resize (widget->window,
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x, allocation->y,
allocation->width, allocation->height);
gdk_window_move_resize (tree_view->priv->header_window,
@@ -2893,6 +2912,7 @@ gtk_tree_view_button_press (GtkWidget *widget,
column->resizable &&
column->window)
{
+ GtkAllocation button_allocation;
gpointer drag_data;
if (event->type == GDK_2BUTTON_PRESS &&
@@ -2922,8 +2942,9 @@ gtk_tree_view_button_press (GtkWidget *widget,
0, 0, NULL, NULL,
drag_data);
+ gtk_widget_get_allocation (column->button, &button_allocation);
tree_view->priv->drag_pos = i;
- tree_view->priv->x_drag = column->button->allocation.x + (rtl ? 0 : column->button->allocation.width);
+ tree_view->priv->x_drag = button_allocation.x + (rtl ? 0 : button_allocation.width);
if (!gtk_widget_has_focus (widget))
gtk_widget_grab_focus (widget);
@@ -3397,12 +3418,20 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
arrow_type = DRAG_COLUMN_WINDOW_STATE_ORIGINAL;
else if (reorder->left_column || reorder->right_column)
{
+ GtkAllocation left_allocation, right_allocation;
GdkRectangle visible_rect;
+
gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
if (reorder->left_column)
- x = reorder->left_column->button->allocation.x + reorder->left_column->button->allocation.width;
+ {
+ gtk_widget_get_allocation (reorder->left_column->button, &left_allocation);
+ x = left_allocation.x + left_allocation.width;
+ }
else
- x = reorder->right_column->button->allocation.x;
+ {
+ gtk_widget_get_allocation (reorder->right_column->button, &right_allocation);
+ x = right_allocation.x;
+ }
if (x < visible_rect.x)
arrow_type = DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT;
@@ -3417,6 +3446,8 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
{
if (tree_view->priv->drag_column_window_state != DRAG_COLUMN_WINDOW_STATE_ORIGINAL)
{
+ GtkAllocation drag_allocation;
+
if (tree_view->priv->drag_highlight_window)
{
gdk_window_set_user_data (tree_view->priv->drag_highlight_window,
@@ -3428,8 +3459,9 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.x = tree_view->priv->drag_column_x;
attributes.y = 0;
- width = attributes.width = tree_view->priv->drag_column->button->allocation.width;
- height = attributes.height = tree_view->priv->drag_column->button->allocation.height;
+ gtk_widget_get_allocation (tree_view->priv->drag_column->button, &drag_allocation);
+ width = attributes.width = drag_allocation.width;
+ height = attributes.height = drag_allocation.height;
attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
attributes.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view));
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
@@ -3455,19 +3487,23 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
}
else if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW)
{
+ GtkAllocation button_allocation;
+
width = tree_view->priv->expander_size;
/* Get x, y, width, height of arrow */
gdk_window_get_origin (tree_view->priv->header_window, &x, &y);
if (reorder->left_column)
{
- x += reorder->left_column->button->allocation.x + reorder->left_column->button->allocation.width - width/2;
- height = reorder->left_column->button->allocation.height;
+ gtk_widget_get_allocation (reorder->left_column->button, &button_allocation);
+ x += button_allocation.x + button_allocation.width - width/2;
+ height = button_allocation.height;
}
else
{
- x += reorder->right_column->button->allocation.x - width/2;
- height = reorder->right_column->button->allocation.height;
+ gtk_widget_get_allocation (reorder->right_column->button, &button_allocation);
+ x += button_allocation.x - width/2;
+ height = button_allocation.height;
}
y -= tree_view->priv->expander_size/2; /* The arrow takes up only half the space */
height += tree_view->priv->expander_size;
@@ -3522,18 +3558,30 @@ gtk_tree_view_motion_draw_column_motion_arrow (GtkTreeView *tree_view)
else if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_LEFT ||
arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
{
+ GtkAllocation allocation;
+
width = tree_view->priv->expander_size;
/* Get x, y, width, height of arrow */
width = width/2; /* remember, the arrow only takes half the available width */
- gdk_window_get_origin (widget->window, &x, &y);
+ gdk_window_get_origin (gtk_widget_get_window (widget),
+ &x, &y);
if (arrow_type == DRAG_COLUMN_WINDOW_STATE_ARROW_RIGHT)
- x += widget->allocation.width - width;
+ {
+ gtk_widget_get_allocation (widget, &allocation);
+ x += allocation.width - width;
+ }
if (reorder->left_column)
- height = reorder->left_column->button->allocation.height;
+ {
+ gtk_widget_get_allocation (reorder->left_column->button, &allocation);
+ height = allocation.height;
+ }
else
- height = reorder->right_column->button->allocation.height;
+ {
+ gtk_widget_get_allocation (reorder->right_column->button, &allocation);
+ height = allocation.height;
+ }
y -= tree_view->priv->expander_size;
height += 2*tree_view->priv->expander_size;
@@ -3613,7 +3661,7 @@ gtk_tree_view_motion_resize_column (GtkWidget *widget,
column = gtk_tree_view_get_column (tree_view, tree_view->priv->drag_pos);
- if (event->is_hint || event->window != widget->window)
+ if (event->is_hint || event->window != gtk_widget_get_window (widget))
gtk_widget_get_pointer (widget, &x, NULL);
else
x = event->x;
@@ -3717,6 +3765,7 @@ static gboolean
gtk_tree_view_motion_drag_column (GtkWidget *widget,
GdkEventMotion *event)
{
+ GtkAllocation allocation, button_allocation;
GtkTreeView *tree_view = (GtkTreeView *) widget;
GtkTreeViewColumn *column = tree_view->priv->drag_column;
gint x, y;
@@ -3728,8 +3777,10 @@ gtk_tree_view_motion_drag_column (GtkWidget *widget,
/* Handle moving the header */
gdk_window_get_position (tree_view->priv->drag_window, &x, &y);
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (column->button, &button_allocation);
x = CLAMP (x + (gint)event->x - column->drag_x, 0,
- MAX (tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.width) - column->button->allocation.width);
+ MAX (tree_view->priv->width, allocation.width) - button_allocation.width);
gdk_window_move (tree_view->priv->drag_window, x, y);
/* autoscroll, if needed */
@@ -4048,6 +4099,7 @@ static void
gtk_tree_view_paint_rubber_band (GtkTreeView *tree_view,
GdkRectangle *area)
{
+ GtkStyle *style;
cairo_t *cr;
GdkRectangle rect;
GdkRectangle rubber_rect;
@@ -4063,10 +4115,12 @@ gtk_tree_view_paint_rubber_band (GtkTreeView *tree_view,
cr = gdk_cairo_create (tree_view->priv->bin_window);
cairo_set_line_width (cr, 1.0);
+ style = gtk_widget_get_style (GTK_WIDGET (tree_view));
+
cairo_set_source_rgba (cr,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].red / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].green / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].blue / 65535.,
+ style->fg[GTK_STATE_NORMAL].red / 65535.,
+ style->fg[GTK_STATE_NORMAL].green / 65535.,
+ style->fg[GTK_STATE_NORMAL].blue / 65535.,
.25);
gdk_cairo_rectangle (cr, &rect);
@@ -4074,9 +4128,9 @@ gtk_tree_view_paint_rubber_band (GtkTreeView *tree_view,
cairo_paint (cr);
cairo_set_source_rgb (cr,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].red / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].green / 65535.,
- GTK_WIDGET (tree_view)->style->fg[GTK_STATE_NORMAL].blue / 65535.);
+ style->fg[GTK_STATE_NORMAL].red / 65535.,
+ style->fg[GTK_STATE_NORMAL].green / 65535.,
+ style->fg[GTK_STATE_NORMAL].blue / 65535.);
cairo_rectangle (cr,
rubber_rect.x + 0.5, rubber_rect.y + 0.5,
@@ -4248,7 +4302,7 @@ gtk_tree_view_draw_line (GtkTreeView *tree_view,
case GTK_TREE_VIEW_FOREGROUND_LINE:
cairo_set_line_width (cr, 1.0);
gdk_cairo_set_source_color (cr,
- >K_WIDGET (tree_view)->style->fg[gtk_widget_get_state (GTK_WIDGET (tree_view))]);
+ >k_widget_get_style (GTK_WIDGET (tree_view))->fg[gtk_widget_get_state (GTK_WIDGET (tree_view))]);
break;
}
@@ -4305,6 +4359,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
{
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GtkTreePath *path;
+ GtkStyle *style;
GtkRBTree *tree;
GList *list;
GtkRBNode *node;
@@ -4362,6 +4417,8 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
validate_visible_area (tree_view);
+ style = gtk_widget_get_style (widget);
+
new_y = TREE_WINDOW_Y_TO_RBTREE_Y (tree_view, event->area.y);
if (new_y < 0)
@@ -4372,9 +4429,9 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
if (tree_view->priv->height < bin_window_height)
{
- gtk_paint_flat_box (widget->style,
+ gtk_paint_flat_box (style,
event->window,
- widget->state,
+ gtk_widget_get_state (widget),
GTK_SHADOW_NONE,
&event->area,
widget,
@@ -4611,7 +4668,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
g_assert (detail);
- if (widget->state == GTK_STATE_INSENSITIVE)
+ if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE)
state = GTK_STATE_INSENSITIVE;
else if (flags & GTK_CELL_RENDERER_SELECTED)
state = GTK_STATE_SELECTED;
@@ -4638,7 +4695,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
else
g_snprintf (new_detail, 128, "%s_middle", detail);
- gtk_paint_flat_box (widget->style,
+ gtk_paint_flat_box (style,
event->window,
state,
GTK_SHADOW_NONE,
@@ -4652,7 +4709,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
}
else
{
- gtk_paint_flat_box (widget->style,
+ gtk_paint_flat_box (style,
event->window,
state,
GTK_SHADOW_NONE,
@@ -4686,7 +4743,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
expander_cell_width = cell_area.width;
if (is_separator)
- gtk_paint_hline (widget->style,
+ gtk_paint_hline (style,
event->window,
state,
&cell_area,
@@ -4721,7 +4778,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
else
{
if (is_separator)
- gtk_paint_hline (widget->style,
+ gtk_paint_hline (style,
event->window,
state,
&cell_area,
@@ -4876,7 +4933,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
&width, NULL);
if (row_ending_details)
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
gtk_widget_get_state (widget),
&event->area,
@@ -4889,7 +4946,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
width, ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node))
- focus_line_width + 1);
else
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
gtk_widget_get_state (widget),
&event->area,
@@ -4943,7 +5000,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
}
if (row_ending_details)
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
focus_rect_state,
&event->area,
@@ -4954,7 +5011,7 @@ gtk_tree_view_bin_expose (GtkWidget *widget,
0, tmp_y,
width, tmp_height);
else
- gtk_paint_focus (widget->style,
+ gtk_paint_focus (style,
tree_view->priv->bin_window,
focus_rect_state,
&event->area,
@@ -5381,11 +5438,17 @@ gtk_tree_view_key_press (GtkWidget *widget,
column->resized_width = 0;
if (column->min_width == -1)
- column->resized_width = MAX (column->button->requisition.width,
- column->resized_width);
+ {
+ GtkRequisition button_requisition;
+ gtk_widget_get_requisition (column->button, &button_requisition);
+ column->resized_width = MAX (button_requisition.width,
+ column->resized_width);
+ }
else
- column->resized_width = MAX (column->min_width,
- column->resized_width);
+ {
+ column->resized_width = MAX (column->min_width,
+ column->resized_width);
+ }
if (column->max_width != -1)
column->resized_width = MIN (column->resized_width,
@@ -5504,7 +5567,7 @@ gtk_tree_view_key_press (GtkWidget *widget,
old_text = g_strdup (gtk_entry_get_text (GTK_ENTRY (tree_view->priv->search_entry)));
new_event = gdk_event_copy ((GdkEvent *) event);
g_object_unref (((GdkEventKey *) new_event)->window);
- ((GdkEventKey *) new_event)->window = g_object_ref (tree_view->priv->search_window->window);
+ ((GdkEventKey *) new_event)->window = g_object_ref (gtk_widget_get_window (tree_view->priv->search_window));
gtk_widget_realize (tree_view->priv->search_window);
popup_menu_id = g_signal_connect (tree_view->priv->search_entry,
@@ -5663,15 +5726,17 @@ gtk_tree_view_node_queue_redraw (GtkTreeView *tree_view,
GtkRBTree *tree,
GtkRBNode *node)
{
+ GtkAllocation allocation;
gint y;
y = _gtk_rbtree_node_find_offset (tree, node)
- tree_view->priv->vadjustment->value
+ TREE_VIEW_HEADER_HEIGHT (tree_view);
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
gtk_widget_queue_draw_area (GTK_WIDGET (tree_view),
0, y,
- GTK_WIDGET (tree_view)->allocation.width,
+ allocation.width,
GTK_RBNODE_GET_HEIGHT (node));
}
@@ -5829,6 +5894,7 @@ validate_row (GtkTreeView *tree_view,
static void
validate_visible_area (GtkTreeView *tree_view)
{
+ GtkAllocation allocation;
GtkTreePath *path = NULL;
GtkTreePath *above_path = NULL;
GtkTreeIter iter;
@@ -5847,7 +5913,8 @@ validate_visible_area (GtkTreeView *tree_view)
tree_view->priv->scroll_to_path == NULL)
return;
- total_height = GTK_WIDGET (tree_view)->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
+ total_height = allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
if (total_height == 0)
return;
@@ -8058,14 +8125,17 @@ gtk_tree_view_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
+ GtkStyle *style;
GList *list;
GtkTreeViewColumn *column;
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_background (tree_view->priv->bin_window, &widget->style->base[widget->state]);
- gtk_style_set_background (widget->style, tree_view->priv->header_window, GTK_STATE_NORMAL);
+ gdk_window_set_back_pixmap (gtk_widget_get_window (widget), NULL, FALSE);
+ style = gtk_widget_get_style (widget);
+ gdk_window_set_background (tree_view->priv->bin_window,
+ &style->base[gtk_widget_get_state (widget)]);
+ gtk_style_set_background (style, tree_view->priv->header_window, GTK_STATE_NORMAL);
gtk_tree_view_set_grid_lines (tree_view, tree_view->priv->grid_lines);
gtk_tree_view_set_enable_tree_lines (tree_view, tree_view->priv->tree_lines_enabled);
@@ -8928,13 +8998,15 @@ gtk_tree_view_clamp_column_visible (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
gboolean focus_to_cell)
{
+ GtkAllocation allocation;
gint x, width;
if (column == NULL)
return;
- x = column->button->allocation.x;
- width = column->button->allocation.width;
+ gtk_widget_get_allocation (column->button, &allocation);
+ x = allocation.x;
+ width = allocation.width;
if (width > tree_view->priv->hadjustment->page_size)
{
@@ -9295,10 +9367,13 @@ gtk_tree_view_set_column_drag_info (GtkTreeView *tree_view,
reorder->left_align = left;
if (tmp_list->next != NULL)
{
+ GtkAllocation right_allocation, left_allocation;
+
g_assert (tmp_list->next->data);
- left = reorder->right_align = (reorder->right_column->button->allocation.x +
- reorder->right_column->button->allocation.width +
- ((GtkTreeViewColumnReorder *)tmp_list->next->data)->left_column->button->allocation.x)/2;
+
+ gtk_widget_get_allocation (reorder->right_column->button, &right_allocation);
+ gtk_widget_get_allocation (((GtkTreeViewColumnReorder *)tmp_list->next->data)->left_column->button, &left_allocation);
+ left = reorder->right_align = (right_allocation.x + right_allocation.width + left_allocation.x) / 2;
}
else
{
@@ -9317,6 +9392,7 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
{
GdkEvent *send_event;
GtkAllocation allocation;
+ GtkAllocation button_allocation;
gint x, y, width, height;
GdkScreen *screen = gtk_widget_get_screen (GTK_WIDGET (tree_view));
GdkDisplay *display = gdk_screen_get_display (screen);
@@ -9334,12 +9410,14 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
GdkWindowAttr attributes;
guint attributes_mask;
+ gtk_widget_get_allocation (column->button, &button_allocation);
+
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.x = column->button->allocation.x;
+ attributes.x = button_allocation.x;
attributes.y = 0;
- attributes.width = column->button->allocation.width;
- attributes.height = column->button->allocation.height;
+ attributes.width = button_allocation.width;
+ attributes.height = button_allocation.height;
attributes.visual = gtk_widget_get_visual (GTK_WIDGET (tree_view));
attributes.colormap = gtk_widget_get_colormap (GTK_WIDGET (tree_view));
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK;
@@ -9390,8 +9468,9 @@ _gtk_tree_view_column_start_drag (GtkTreeView *tree_view,
gtk_widget_set_parent (column->button, GTK_WIDGET (tree_view));
g_object_unref (column->button);
- tree_view->priv->drag_column_x = column->button->allocation.x;
- allocation = column->button->allocation;
+ gtk_widget_get_allocation (column->button, &button_allocation);
+ tree_view->priv->drag_column_x = button_allocation.x;
+ allocation = button_allocation;
allocation.x = 0;
gtk_widget_size_allocate (column->button, &allocation);
gtk_widget_set_parent_window (column->button, tree_view->priv->drag_window);
@@ -9422,13 +9501,15 @@ gtk_tree_view_queue_draw_arrow (GtkTreeView *tree_view,
GtkRBNode *node,
const GdkRectangle *clip_rect)
{
+ GtkAllocation allocation;
GdkRectangle rect;
if (!gtk_widget_get_realized (GTK_WIDGET (tree_view)))
return;
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
rect.x = 0;
- rect.width = MAX (tree_view->priv->expander_size, MAX (tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.width));
+ rect.width = MAX (tree_view->priv->expander_size, MAX (tree_view->priv->width, allocation.width));
rect.y = BACKGROUND_FIRST_PIXEL (tree_view, tree, node);
rect.height = ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node));
@@ -9453,13 +9534,15 @@ _gtk_tree_view_queue_draw_node (GtkTreeView *tree_view,
GtkRBNode *node,
const GdkRectangle *clip_rect)
{
+ GtkAllocation allocation;
GdkRectangle rect;
if (!gtk_widget_get_realized (GTK_WIDGET (tree_view)))
return;
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
rect.x = 0;
- rect.width = MAX (tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.width);
+ rect.width = MAX (tree_view->priv->width, allocation.width);
rect.y = BACKGROUND_FIRST_PIXEL (tree_view, tree, node);
rect.height = ROW_HEIGHT (tree_view, BACKGROUND_HEIGHT (node));
@@ -9558,7 +9641,7 @@ gtk_tree_view_draw_arrow (GtkTreeView *tree_view,
else
expander_style = GTK_EXPANDER_COLLAPSED;
- gtk_paint_expander (widget->style,
+ gtk_paint_expander (gtk_widget_get_style (widget),
tree_view->priv->bin_window,
state,
&area,
@@ -10329,21 +10412,24 @@ send_focus_change (GtkWidget *widget,
{
GdkDevice *dev = d->data;
GdkEvent *fevent;
+ GdkWindow *window;
if (dev->source != GDK_SOURCE_KEYBOARD)
continue;
+ window = gtk_widget_get_window (widget);
+
/* Skip non-master keyboards that haven't
* selected for events from this window
*/
if (gdk_device_get_device_type (dev) != GDK_DEVICE_TYPE_MASTER &&
- !gdk_window_get_device_events (widget->window, dev))
+ !gdk_window_get_device_events (window, dev))
continue;
fevent = gdk_event_new (GDK_FOCUS_CHANGE);
fevent->focus_change.type = GDK_FOCUS_CHANGE;
- fevent->focus_change.window = g_object_ref (widget->window);
+ fevent->focus_change.window = g_object_ref (window);
fevent->focus_change.in = in;
gdk_event_set_device (fevent, device);
@@ -10532,6 +10618,8 @@ gtk_tree_view_new_column_width (GtkTreeView *tree_view,
gint i,
gint *x)
{
+ GtkAllocation allocation;
+ GtkRequisition button_requisition;
GtkTreeViewColumn *column;
gint width;
gboolean rtl;
@@ -10541,20 +10629,23 @@ gtk_tree_view_new_column_width (GtkTreeView *tree_view,
*/
rtl = (gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL);
column = g_list_nth (tree_view->priv->columns, i)->data;
- width = rtl ? (column->button->allocation.x + column->button->allocation.width - *x) : (*x - column->button->allocation.x);
-
+ gtk_widget_get_allocation (column->button, &allocation);
+ width = rtl ? (allocation.x + allocation.width - *x) : (*x - allocation.x);
+
/* Clamp down the value */
if (column->min_width == -1)
- width = MAX (column->button->requisition.width,
- width);
+ {
+ gtk_widget_get_requisition (column->button, &button_requisition);
+ width = MAX (button_requisition.width, width);
+ }
else
width = MAX (column->min_width,
width);
if (column->max_width != -1)
width = MIN (width, column->max_width);
- *x = rtl ? (column->button->allocation.x + column->button->allocation.width - width) : (column->button->allocation.x + width);
-
+ *x = rtl ? (allocation.x + allocation.width - width) : (allocation.x + width);
+
return width;
}
@@ -10572,25 +10663,27 @@ typedef struct
/* The window to which widget->window is relative */
#define ALLOCATION_WINDOW(widget) \
- (!gtk_widget_get_has_window (widget) ? \
- (widget)->window : \
- gdk_window_get_parent ((widget)->window))
+ (!gtk_widget_get_has_window (widget) ? \
+ gtk_widget_get_window (widget) : \
+ gdk_window_get_parent (gtk_widget_get_window (widget)))
static void
adjust_allocation_recurse (GtkWidget *widget,
gpointer data)
{
+ GtkAllocation allocation;
ScrollData *scroll_data = data;
/* Need to really size allocate instead of just poking
* into widget->allocation if the widget is not realized.
* FIXME someone figure out why this was.
*/
+ gtk_widget_get_allocation (widget, &allocation);
if (!gtk_widget_get_realized (widget))
{
if (gtk_widget_get_visible (widget))
{
- GdkRectangle tmp_rectangle = widget->allocation;
+ GdkRectangle tmp_rectangle = allocation;
tmp_rectangle.x += scroll_data->dx;
tmp_rectangle.y += scroll_data->dy;
@@ -10601,9 +10694,10 @@ adjust_allocation_recurse (GtkWidget *widget,
{
if (ALLOCATION_WINDOW (widget) == scroll_data->window)
{
- widget->allocation.x += scroll_data->dx;
- widget->allocation.y += scroll_data->dy;
-
+ allocation.x += scroll_data->dx;
+ allocation.y += scroll_data->dy;
+ gtk_widget_set_allocation (widget, &allocation);
+
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
adjust_allocation_recurse,
@@ -11021,6 +11115,7 @@ gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
gint x, y;
GList *list;
GtkTreeViewColumn *column;
+ GtkAllocation allocation;
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
@@ -11039,7 +11134,10 @@ gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
gdk_window_get_position (tree_view->priv->bin_window, &x, &y);
if (headers_visible)
{
- gdk_window_move_resize (tree_view->priv->bin_window, x, y + TREE_VIEW_HEADER_HEIGHT (tree_view), tree_view->priv->width, GTK_WIDGET (tree_view)->allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
+ gdk_window_move_resize (tree_view->priv->bin_window,
+ x, y + TREE_VIEW_HEADER_HEIGHT (tree_view),
+ tree_view->priv->width, allocation.height - + TREE_VIEW_HEADER_HEIGHT (tree_view));
if (gtk_widget_get_mapped (GTK_WIDGET (tree_view)))
gtk_tree_view_map_buttons (tree_view);
@@ -11057,8 +11155,9 @@ gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
}
}
- tree_view->priv->vadjustment->page_size = GTK_WIDGET (tree_view)->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
- tree_view->priv->vadjustment->page_increment = (GTK_WIDGET (tree_view)->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view)) / 2;
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
+ tree_view->priv->vadjustment->page_size = allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
+ tree_view->priv->vadjustment->page_increment = (allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view)) / 2;
tree_view->priv->vadjustment->lower = 0;
tree_view->priv->vadjustment->upper = tree_view->priv->height;
gtk_adjustment_changed (tree_view->priv->vadjustment);
@@ -12946,6 +13045,7 @@ gtk_tree_view_get_cell_area (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
GdkRectangle *rect)
{
+ GtkAllocation allocation;
GtkRBTree *tree = NULL;
GtkRBNode *node = NULL;
gint vertical_separator;
@@ -12969,8 +13069,9 @@ gtk_tree_view_get_cell_area (GtkTreeView *tree_view,
if (column)
{
- rect->x = column->button->allocation.x + horizontal_separator/2;
- rect->width = column->button->allocation.width - horizontal_separator;
+ gtk_widget_get_allocation (column->button, &allocation);
+ rect->x = allocation.x + horizontal_separator/2;
+ rect->width = allocation.width - horizontal_separator;
}
if (path)
@@ -13081,6 +13182,7 @@ void
gtk_tree_view_get_visible_rect (GtkTreeView *tree_view,
GdkRectangle *visible_rect)
{
+ GtkAllocation allocation;
GtkWidget *widget;
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
@@ -13089,10 +13191,11 @@ gtk_tree_view_get_visible_rect (GtkTreeView *tree_view,
if (visible_rect)
{
+ gtk_widget_get_allocation (widget, &allocation);
visible_rect->x = tree_view->priv->hadjustment->value;
visible_rect->y = tree_view->priv->vadjustment->value;
- visible_rect->width = widget->allocation.width;
- visible_rect->height = widget->allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
+ visible_rect->width = allocation.width;
+ visible_rect->height = allocation.height - TREE_VIEW_HEADER_HEIGHT (tree_view);
}
}
@@ -13711,6 +13814,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
GtkTreeIter iter;
GtkRBTree *tree;
GtkRBNode *node;
+ GtkStyle *style;
gint cell_offset;
GList *list;
GdkRectangle background_area;
@@ -13747,7 +13851,9 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
&iter,
path))
return NULL;
-
+
+ style = gtk_widget_get_style (widget);
+
is_separator = row_is_separator (tree_view, &iter, NULL);
cell_offset = x;
@@ -13769,7 +13875,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
expose_area.height = background_area.height + 2;
cr = gdk_cairo_create (drawable);
- gdk_cairo_set_source_color (cr, &widget->style->base [gtk_widget_get_state (widget)]);
+ gdk_cairo_set_source_color (cr, &style->base [gtk_widget_get_state (widget)]);
cairo_paint (cr);
rtl = gtk_widget_get_direction (GTK_WIDGET (tree_view)) == GTK_TEXT_DIR_RTL;
@@ -13818,7 +13924,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView *tree_view,
if (gtk_tree_view_column_cell_is_visible (column))
{
if (is_separator)
- gtk_paint_hline (widget->style,
+ gtk_paint_hline (style,
drawable,
GTK_STATE_NORMAL,
&cell_area,
@@ -14197,7 +14303,7 @@ gtk_tree_view_search_position_func (GtkTreeView *tree_view,
gint x, y;
gint tree_x, tree_y;
gint tree_width, tree_height;
- GdkWindow *tree_window = GTK_WIDGET (tree_view)->window;
+ GdkWindow *tree_window = gtk_widget_get_window (GTK_WIDGET (tree_view));
GdkScreen *screen = gdk_drawable_get_screen (tree_window);
GtkRequisition requisition;
gint monitor_num;
@@ -15119,8 +15225,9 @@ gtk_tree_view_state_changed (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
- gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
- gdk_window_set_background (tree_view->priv->bin_window, &widget->style->base[widget->state]);
+ gdk_window_set_back_pixmap (gtk_widget_get_window (widget), NULL, FALSE);
+ gdk_window_set_background (tree_view->priv->bin_window,
+ >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]);
}
gtk_widget_queue_draw (widget);
@@ -15449,6 +15556,7 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView *tree_view,
GtkTreeViewColumn *column,
GtkCellRenderer *cell)
{
+ GtkAllocation allocation;
GdkRectangle rect;
g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
@@ -15489,8 +15597,9 @@ gtk_tree_view_set_tooltip_cell (GtkTreeView *tree_view,
}
else
{
+ gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
rect.x = 0;
- rect.width = GTK_WIDGET (tree_view)->allocation.width;
+ rect.width = allocation.width;
}
/* Determine y values. */
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 7f75f2c..ebc054d 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -1265,6 +1265,7 @@ gtk_tree_view_column_setup_sort_column_id_callback (GtkTreeViewColumn *tree_colu
void
_gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
{
+ GtkAllocation allocation;
GtkTreeView *tree_view;
GdkWindowAttr attr;
guint attributes_mask;
@@ -1300,7 +1301,8 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
attr.width = TREE_VIEW_DRAG_WIDTH;
attr.height = tree_view->priv->header_height;
- attr.x = (column->button->allocation.x + (rtl ? 0 : column->button->allocation.width)) - TREE_VIEW_DRAG_WIDTH / 2;
+ gtk_widget_get_allocation (column->button, &allocation);
+ attr.x = (allocation.x + (rtl ? 0 : allocation.width)) - TREE_VIEW_DRAG_WIDTH / 2;
column->window = gdk_window_new (tree_view->priv->header_window,
&attr, attributes_mask);
gdk_window_set_user_data (column->window, tree_view);
@@ -3505,7 +3507,7 @@ _gtk_tree_view_column_cell_draw_focus (GtkTreeViewColumn *tree_column,
cell_state = flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
(flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
(flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL));
- gtk_paint_focus (tree_column->tree_view->style,
+ gtk_paint_focus (gtk_widget_get_style (tree_column->tree_view),
window,
cell_state,
cell_area,
diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c
index 0fb76e3..04c9517 100644
--- a/gtk/gtkuimanager.c
+++ b/gtk/gtkuimanager.c
@@ -2395,7 +2395,7 @@ update_node (GtkUIManager *self,
}
gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
- gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
info->proxy);
g_object_unref (info->proxy);
info->proxy = NULL;
@@ -2506,14 +2506,14 @@ update_node (GtkUIManager *self,
{
if (info->proxy)
{
- gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
info->proxy);
g_object_unref (info->proxy);
info->proxy = NULL;
}
if (info->extra)
{
- gtk_container_remove (GTK_CONTAINER (info->extra->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)),
info->extra);
g_object_unref (info->extra);
info->extra = NULL;
@@ -2553,14 +2553,14 @@ update_node (GtkUIManager *self,
{
if (info->proxy)
{
- gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
info->proxy);
g_object_unref (info->proxy);
info->proxy = NULL;
}
if (info->extra)
{
- gtk_container_remove (GTK_CONTAINER (info->extra->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->extra)),
info->extra);
g_object_unref (info->extra);
info->extra = NULL;
@@ -2603,7 +2603,7 @@ update_node (GtkUIManager *self,
G_CALLBACK (update_smart_separators),
NULL);
gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
- gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
info->proxy);
g_object_unref (info->proxy);
info->proxy = NULL;
@@ -2661,7 +2661,7 @@ update_node (GtkUIManager *self,
G_CALLBACK (update_smart_separators),
NULL);
gtk_activatable_set_related_action (GTK_ACTIVATABLE (info->proxy), NULL);
- gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
info->proxy);
g_object_unref (info->proxy);
info->proxy = NULL;
@@ -2707,7 +2707,7 @@ update_node (GtkUIManager *self,
if (GTK_IS_SEPARATOR_TOOL_ITEM (info->proxy))
{
- gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
info->proxy);
g_object_unref (info->proxy);
info->proxy = NULL;
@@ -2742,7 +2742,7 @@ update_node (GtkUIManager *self,
if (GTK_IS_SEPARATOR_MENU_ITEM (info->proxy))
{
- gtk_container_remove (GTK_CONTAINER (info->proxy->parent),
+ gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (info->proxy)),
info->proxy);
g_object_unref (info->proxy);
info->proxy = NULL;
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 71fd7b1..f244742 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -377,10 +377,12 @@ viewport_get_view_allocation (GtkViewport *viewport,
GtkAllocation *view_allocation)
{
GtkViewportPriv *priv = viewport->priv;
+ GtkStyle *style;
GtkWidget *widget = GTK_WIDGET (viewport);
- GtkAllocation *allocation = &widget->allocation;
+ GtkAllocation allocation;
guint border_width;
+ gtk_widget_get_allocation (widget, &allocation);
border_width = gtk_container_get_border_width (GTK_CONTAINER (viewport));
view_allocation->x = 0;
@@ -388,12 +390,13 @@ viewport_get_view_allocation (GtkViewport *viewport,
if (priv->shadow_type != GTK_SHADOW_NONE)
{
- view_allocation->x = widget->style->xthickness;
- view_allocation->y = widget->style->ythickness;
+ style = gtk_widget_get_style (widget);
+ view_allocation->x = style->xthickness;
+ view_allocation->y = style->ythickness;
}
- view_allocation->width = MAX (1, allocation->width - view_allocation->x * 2 - border_width * 2);
- view_allocation->height = MAX (1, allocation->height - view_allocation->y * 2 - border_width * 2);
+ view_allocation->width = MAX (1, allocation.width - view_allocation->x * 2 - border_width * 2);
+ view_allocation->height = MAX (1, allocation.height - view_allocation->y * 2 - border_width * 2);
}
static void
@@ -588,19 +591,24 @@ gtk_viewport_set_shadow_type (GtkViewport *viewport,
GtkShadowType type)
{
GtkViewportPriv *priv;
+ GtkAllocation allocation;
+ GtkWidget *widget;
g_return_if_fail (GTK_IS_VIEWPORT (viewport));
+ widget = GTK_WIDGET (viewport);
priv = viewport->priv;
if ((GtkShadowType) priv->shadow_type != type)
{
priv->shadow_type = type;
- if (gtk_widget_get_visible (GTK_WIDGET (viewport)))
+ if (gtk_widget_get_visible (widget))
{
- gtk_widget_size_allocate (GTK_WIDGET (viewport), &(GTK_WIDGET (viewport)->allocation));
- gtk_widget_queue_draw (GTK_WIDGET (viewport));
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_size_allocate (widget, &allocation);
+ gtk_widget_set_allocation (widget, &allocation);
+ gtk_widget_queue_draw (widget);
}
g_object_notify (G_OBJECT (viewport), "shadow-type");
@@ -668,8 +676,11 @@ gtk_viewport_realize (GtkWidget *widget)
GtkBin *bin = GTK_BIN (widget);
GtkAdjustment *hadjustment = gtk_viewport_get_hadjustment (viewport);
GtkAdjustment *vadjustment = gtk_viewport_get_vadjustment (viewport);
+ GtkAllocation allocation;
GtkAllocation view_allocation;
+ GtkStyle *style;
GtkWidget *child;
+ GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
gint event_mask;
@@ -679,10 +690,12 @@ gtk_viewport_realize (GtkWidget *widget)
gtk_widget_set_realized (widget, TRUE);
- attributes.x = widget->allocation.x + border_width;
- attributes.y = widget->allocation.y + border_width;
- attributes.width = widget->allocation.width - border_width * 2;
- attributes.height = widget->allocation.height - border_width * 2;
+ gtk_widget_get_allocation (widget, &allocation);
+
+ attributes.x = allocation.x + border_width;
+ attributes.y = allocation.y + border_width;
+ attributes.width = allocation.width - border_width * 2;
+ attributes.height = allocation.height - border_width * 2;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -695,9 +708,10 @@ gtk_viewport_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
- widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
- &attributes, attributes_mask);
- gdk_window_set_user_data (widget->window, viewport);
+ window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes, attributes_mask);
+ gtk_widget_set_window (widget, window);
+ gdk_window_set_user_data (window, viewport);
viewport_get_view_allocation (viewport, &view_allocation);
@@ -707,7 +721,8 @@ gtk_viewport_realize (GtkWidget *widget)
attributes.height = view_allocation.height;
attributes.event_mask = 0;
- priv->view_window = gdk_window_new (widget->window, &attributes, attributes_mask);
+ priv->view_window = gdk_window_new (window,
+ &attributes, attributes_mask);
gdk_window_set_user_data (priv->view_window, viewport);
gdk_window_set_back_pixmap (priv->view_window, NULL, FALSE);
@@ -726,13 +741,14 @@ gtk_viewport_realize (GtkWidget *widget)
if (child)
gtk_widget_set_parent_window (child, priv->bin_window);
- widget->style = gtk_style_attach (widget->style, widget->window);
- gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL);
+ gtk_widget_style_attach (widget);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style, priv->bin_window, GTK_STATE_NORMAL);
/* Call paint here to allow a theme to set the background without flashing
*/
- gtk_paint_flat_box(widget->style, priv->bin_window, GTK_STATE_NORMAL,
+ gtk_paint_flat_box(style, priv->bin_window, GTK_STATE_NORMAL,
GTK_SHADOW_NONE,
NULL, widget, "viewportbin",
0, 0, -1, -1);
@@ -767,7 +783,8 @@ gtk_viewport_paint (GtkWidget *widget,
GtkViewport *viewport = GTK_VIEWPORT (widget);
GtkViewportPriv *priv = viewport->priv;
- gtk_paint_shadow (widget->style, widget->window,
+ gtk_paint_shadow (gtk_widget_get_style (widget),
+ gtk_widget_get_window (widget),
GTK_STATE_NORMAL, priv->shadow_type,
area, widget, "viewport",
0, 0, -1, -1);
@@ -785,11 +802,11 @@ gtk_viewport_expose (GtkWidget *widget,
viewport = GTK_VIEWPORT (widget);
GtkViewportPriv *priv = viewport->priv;
- if (event->window == widget->window)
+ if (event->window == gtk_widget_get_window (widget))
gtk_viewport_paint (widget, &event->area);
else if (event->window == priv->bin_window)
{
- gtk_paint_flat_box(widget->style, priv->bin_window,
+ gtk_paint_flat_box(gtk_widget_get_style (widget), priv->bin_window,
GTK_STATE_NORMAL, GTK_SHADOW_NONE,
&event->area, widget, "viewportbin",
0, 0, -1, -1);
@@ -820,6 +837,7 @@ static void
gtk_viewport_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkAllocation widget_allocation;
GtkViewport *viewport = GTK_VIEWPORT (widget);
GtkViewportPriv *priv = viewport->priv;
GtkBin *bin = GTK_BIN (widget);
@@ -835,14 +853,15 @@ gtk_viewport_size_allocate (GtkWidget *widget,
/* If our size changed, and we have a shadow, queue a redraw on widget->window to
* redraw the shadow correctly.
*/
+ gtk_widget_get_allocation (widget, &widget_allocation);
if (gtk_widget_get_mapped (widget) &&
priv->shadow_type != GTK_SHADOW_NONE &&
- (widget->allocation.width != allocation->width ||
- widget->allocation.height != allocation->height))
- gdk_window_invalidate_rect (widget->window, NULL, FALSE);
-
- widget->allocation = *allocation;
-
+ (widget_allocation.width != allocation->width ||
+ widget_allocation.height != allocation->height))
+ gdk_window_invalidate_rect (gtk_widget_get_window (widget), NULL, FALSE);
+
+ gtk_widget_set_allocation (widget, allocation);
+
viewport_set_hadjustment_values (viewport, &hadjustment_value_changed);
viewport_set_vadjustment_values (viewport, &vadjustment_value_changed);
@@ -853,7 +872,8 @@ gtk_viewport_size_allocate (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
GtkAllocation view_allocation;
- gdk_window_move_resize (widget->window,
+
+ gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x + border_width,
allocation->y + border_width,
allocation->width - border_width * 2,
@@ -921,11 +941,15 @@ gtk_viewport_style_set (GtkWidget *widget,
if (gtk_widget_get_realized (widget) &&
gtk_widget_get_has_window (widget))
{
+ GtkStyle *style;
GtkViewport *viewport = GTK_VIEWPORT (widget);
GtkViewportPriv *priv = viewport->priv;
- gtk_style_set_background (widget->style, priv->bin_window, GTK_STATE_NORMAL);
- gtk_style_set_background (widget->style, widget->window, widget->state);
+ style = gtk_widget_get_style (widget);
+ gtk_style_set_background (style, priv->bin_window, GTK_STATE_NORMAL);
+ gtk_style_set_background (style,
+ gtk_widget_get_window (widget),
+ gtk_widget_get_state (widget));
}
}
@@ -945,6 +969,7 @@ gtk_viewport_get_size (GtkSizeRequest *widget,
{
GtkViewport *viewport = GTK_VIEWPORT (widget);
GtkViewportPriv *priv = viewport->priv;
+ GtkStyle *style;
GtkWidget *child;
gint child_min, child_nat;
gint minimum, natural;
@@ -958,10 +983,11 @@ gtk_viewport_get_size (GtkSizeRequest *widget,
if (priv->shadow_type != GTK_SHADOW_NONE)
{
+ style = gtk_widget_get_style (GTK_WIDGET (widget));
if (orientation == GTK_ORIENTATION_HORIZONTAL)
- minimum += 2 * GTK_WIDGET (widget)->style->xthickness;
+ minimum += 2 * style->xthickness;
else
- minimum += 2 * GTK_WIDGET (widget)->style->ythickness;
+ minimum += 2 * style->ythickness;
}
natural = minimum;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 8e062c0..cb96af6 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -4261,7 +4261,7 @@ static void
gtk_widget_real_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget) &&
gtk_widget_get_has_window (widget))
@@ -11450,7 +11450,7 @@ gtk_widget_set_allocation (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (allocation != NULL);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
}
/**
diff --git a/gtk/gtkwin32embedwidget.c b/gtk/gtkwin32embedwidget.c
index c8d892f..56da951 100644
--- a/gtk/gtkwin32embedwidget.c
+++ b/gtk/gtkwin32embedwidget.c
@@ -239,8 +239,8 @@ gtk_win32_embed_widget_realize (GtkWidget *widget)
/* Enable tab to focus the widget */
styles = GetWindowLongPtr(GDK_WINDOW_HWND (widget->window), GWL_STYLE);
SetWindowLongPtrW(GDK_WINDOW_HWND (widget->window), GWL_STYLE, styles | WS_TABSTOP);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
+
+ gtk_widget_style_attach (widget);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
}
@@ -292,7 +292,7 @@ gtk_win32_embed_widget_size_allocate (GtkWidget *widget,
GtkBin *bin = GTK_BIN (widget);
GtkWidget *child;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
if (gtk_widget_get_realized (widget))
gdk_window_move_resize (widget->window,
diff --git a/gtk/gtkwindow-decorate.c b/gtk/gtkwindow-decorate.c
index 010b76e..9aa2dd8 100644
--- a/gtk/gtkwindow-decorate.c
+++ b/gtk/gtkwindow-decorate.c
@@ -816,7 +816,7 @@ gtk_decorated_window_move_resize_window (GtkWindow *window,
gint width,
gint height)
{
- gdk_window_move_resize (GTK_WIDGET (window)->window,
+ gdk_window_move_resize (gtk_widget_get_window (GTK_WIDGET (window)),
x, y, width, height);
}
#endif
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index f2230c9..ea2a22a 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4825,8 +4825,8 @@ gtk_window_realize (GtkWidget *widget)
gdk_window_enable_synchronized_configure (widget->window);
gdk_window_set_user_data (widget->window, window);
-
- widget->style = gtk_style_attach (widget->style, widget->window);
+
+ gtk_widget_style_attach (widget);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
if (window->frame)
gtk_style_set_background (widget->style, window->frame, GTK_STATE_NORMAL);
@@ -4935,7 +4935,7 @@ gtk_window_size_allocate (GtkWidget *widget,
guint border_width;
window = GTK_WINDOW (widget);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
child = gtk_bin_get_child (&(window->bin));
if (child && gtk_widget_get_visible (child))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]