[gtk+/refactor] Use accessor functions to access GtkWidget
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor] Use accessor functions to access GtkWidget
- Date: Mon, 9 Aug 2010 11:24:44 +0000 (UTC)
commit e701d21dd8e2d938875c69f319b2d22e35ad73af
Author: Javier Jardón <jjardon gnome org>
Date: Mon Aug 9 13:12:50 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 | 106 ++++++++-----
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 | 219 +++++++++++++++----------
gtk/gtkimage.c | 39 +++--
gtk/gtkimagemenuitem.c | 51 ++++---
gtk/gtkinfobar.c | 17 +-
gtk/gtkinvisible.c | 17 +-
gtk/gtkitem.c | 29 ++--
gtk/gtklabel.c | 125 ++++++++------
gtk/gtklayout.c | 54 ++++---
gtk/gtklinkbutton.c | 10 +-
gtk/gtkmain.c | 6 +-
gtk/gtkmenu.c | 358 +++++++++++++++++++++++++----------------
gtk/gtkmenubar.c | 35 +++--
46 files changed, 1752 insertions(+), 1138 deletions(-)
---
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index f81d1eb..85c8014 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -1942,7 +1942,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 7da60bf..c499c87 100644
--- a/gtk/gtkarrow.c
+++ b/gtk/gtkarrow.c
@@ -273,8 +273,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;
@@ -285,11 +287,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;
@@ -302,14 +305,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;
@@ -321,8 +324,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 46c5211..42527df 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 a164caf..c0361f2 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 96382fa..d4121b3 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -805,6 +805,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;
@@ -824,14 +825,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 */
@@ -1037,26 +1042,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);
}
@@ -1309,7 +1320,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);
@@ -1324,6 +1335,7 @@ popup_position_func (GtkMenu *menu,
gboolean *push_in,
gpointer user_data)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GtkRequisition req;
gint root_x, root_y;
@@ -1333,13 +1345,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);
@@ -1848,6 +1862,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 ();
@@ -1888,8 +1903,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)
@@ -1897,7 +1914,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 fc0cf13..be8b697 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 ce49601..10fc4a3 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -413,7 +413,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;
@@ -421,6 +423,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));
@@ -437,10 +440,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) |
@@ -451,14 +456,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
@@ -480,6 +486,7 @@ static void
get_expander_bounds (GtkExpander *expander,
GdkRectangle *rect)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GtkExpanderPrivate *priv;
gint border_width;
@@ -493,6 +500,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,
@@ -505,20 +514,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;
@@ -566,7 +575,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,
@@ -606,14 +615,12 @@ gtk_expander_size_allocate (GtkWidget *widget,
ltr = gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL;
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 -
@@ -650,8 +657,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;
@@ -692,6 +699,7 @@ gtk_expander_unmap (GtkWidget *widget)
static void
gtk_expander_paint_prelight (GtkExpander *expander)
{
+ GtkAllocation allocation;
GtkWidget *widget;
GtkContainer *container;
GtkExpanderPrivate *priv;
@@ -715,13 +723,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;
@@ -729,7 +744,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",
@@ -748,7 +764,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;
@@ -756,8 +772,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,
@@ -802,6 +818,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;
@@ -814,8 +834,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)
{
@@ -824,7 +844,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;
}
@@ -843,8 +863,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);
}
@@ -918,12 +940,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
@@ -1500,14 +1525,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)
@@ -1542,7 +1568,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;
@@ -1880,7 +1906,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 9100ea6..3945d4d 100644
--- a/gtk/gtkfilechooserdefault.c
+++ b/gtk/gtkfilechooserdefault.c
@@ -4102,6 +4102,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;
@@ -4110,12 +4111,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);
@@ -6005,22 +6007,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)
@@ -7803,11 +7807,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);
@@ -7820,7 +7827,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 c62df31..e4f367f 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -1326,20 +1326,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);
@@ -1347,16 +1349,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 |
@@ -1366,12 +1371,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);
}
@@ -1395,11 +1401,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);
@@ -1410,11 +1421,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);
@@ -1484,11 +1500,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,
@@ -1601,53 +1617,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,
@@ -1696,6 +1708,7 @@ static gboolean
gtk_icon_view_motion (GtkWidget *widget,
GdkEventMotion *event)
{
+ GtkAllocation allocation;
GtkIconView *icon_view;
gint abs_y;
@@ -1712,12 +1725,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;
@@ -2687,6 +2702,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;
@@ -2696,7 +2713,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;
@@ -2704,7 +2721,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);
@@ -2725,7 +2742,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;
}
@@ -2802,9 +2821,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;
@@ -2864,14 +2885,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)
{
@@ -3161,13 +3184,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);
@@ -3176,7 +3202,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;
@@ -3189,7 +3215,7 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
#ifdef DEBUG_ICON_VIEW
gdk_draw_rectangle (drawable,
- GTK_WIDGET (icon_view)->style->black_gc,
+ style->black_gc,
FALSE,
x, y,
item->width, item->height);
@@ -3197,12 +3223,12 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
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);
@@ -3219,7 +3245,7 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
#ifdef DEBUG_ICON_VIEW
gdk_draw_rectangle (drawable,
- GTK_WIDGET (icon_view)->style->black_gc,
+ style->black_gc,
FALSE,
x - item->x + cell_area.x,
y - item->y + cell_area.y,
@@ -3228,7 +3254,7 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
gtk_icon_view_get_cell_box (icon_view, item, info, &box);
gdk_draw_rectangle (drawable,
- GTK_WIDGET (icon_view)->style->black_gc,
+ style->black_gc,
FALSE,
x - item->x + box.x,
y - item->y + box.y,
@@ -3240,12 +3266,12 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
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++)
@@ -3266,11 +3292,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,
@@ -3284,11 +3310,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,
@@ -3321,7 +3347,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.,
@@ -4390,18 +4416,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);
@@ -4420,24 +4449,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);
@@ -4454,32 +4484,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);
@@ -6585,11 +6619,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);
@@ -7490,8 +7527,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);
@@ -8653,6 +8689,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;
@@ -8668,6 +8705,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)
@@ -8675,8 +8714,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 cd16a9c..9311a00 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -1660,13 +1660,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;
@@ -1931,7 +1933,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;
@@ -1951,8 +1955,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);
@@ -1961,10 +1967,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;
@@ -2061,7 +2066,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,
@@ -2170,8 +2175,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),
@@ -2188,7 +2193,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);
@@ -2203,7 +2208,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)
{
@@ -2228,8 +2233,8 @@ gtk_image_expose (GtkWidget *widget,
break;
case GTK_IMAGE_IMAGE:
- gdk_draw_image (widget->window,
- widget->style->black_gc,
+ gdk_draw_image (gtk_widget_get_window (widget),
+ gtk_widget_get_style (widget)->black_gc,
priv->data.image.image,
image_bound.x - x, image_bound.y - y,
image_bound.x, image_bound.y,
@@ -2426,7 +2431,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 2f4c91e..23e7184 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -1493,7 +1493,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;
@@ -1502,10 +1502,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 */
@@ -3015,7 +3015,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);
@@ -3131,7 +3132,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);
@@ -3175,6 +3177,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);
@@ -3230,9 +3233,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);
@@ -3247,17 +3251,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 */
@@ -3339,7 +3342,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);
@@ -3829,6 +3832,7 @@ get_layout_location (GtkLabel *label,
gint *xp,
gint *yp)
{
+ GtkAllocation allocation;
GtkMisc *misc;
GtkWidget *widget;
GtkLabelPriv *priv;
@@ -3865,13 +3869,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
@@ -3888,15 +3893,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;
@@ -3913,6 +3912,7 @@ draw_insertion_cursor (GtkLabel *label,
gboolean draw_arrow)
{
GtkWidget *widget = GTK_WIDGET (label);
+ GtkAllocation allocation;
GtkTextDirection text_dir;
if (direction == PANGO_DIRECTION_LTR)
@@ -3920,8 +3920,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);
}
@@ -4063,6 +4064,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);
@@ -4072,8 +4075,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,
@@ -4109,21 +4115,21 @@ gtk_label_expose (GtkWidget *widget,
* region
*/
- gdk_gc_set_clip_region (widget->style->black_gc, clip);
+ gdk_gc_set_clip_region (style->black_gc, clip);
state = GTK_STATE_SELECTED;
if (!gtk_widget_has_focus (widget))
state = GTK_STATE_ACTIVE;
- gdk_draw_layout_with_colors (widget->window,
- widget->style->black_gc,
+ gdk_draw_layout_with_colors (window,
+ style->black_gc,
x, y,
priv->layout,
- &widget->style->text[state],
- &widget->style->base[state]);
+ &style->text[state],
+ &style->base[state]);
- gdk_gc_set_clip_region (widget->style->black_gc, NULL);
+ gdk_gc_set_clip_region (style->black_gc, NULL);
cairo_region_destroy (clip);
}
else if (info)
@@ -4153,7 +4159,7 @@ gtk_label_expose (GtkWidget *widget,
x, y,
range,
1);
- gdk_gc_set_clip_region (widget->style->black_gc, clip);
+ gdk_gc_set_clip_region (style->black_gc, clip);
gtk_label_get_link_colors (widget, &link_color, &visited_link_color);
if (active_link->visited)
@@ -4161,11 +4167,11 @@ 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];
- gdk_draw_layout_with_colors (widget->window,
- widget->style->black_gc,
+ base_color = &style->base[GTK_STATE_PRELIGHT];
+ gdk_draw_layout_with_colors (window,
+ style->black_gc,
x, y,
priv->layout,
text_color,
@@ -4173,7 +4179,7 @@ gtk_label_expose (GtkWidget *widget,
gdk_color_free (link_color);
gdk_color_free (visited_link_color);
- gdk_gc_set_clip_region (widget->style->black_gc, NULL);
+ gdk_gc_set_clip_region (style->black_gc, NULL);
cairo_region_destroy (clip);
}
@@ -4188,7 +4194,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);
@@ -4383,6 +4389,7 @@ window_to_layout_coords (GtkLabel *label,
gint *x,
gint *y)
{
+ GtkAllocation allocation;
gint lx, ly;
GtkWidget *widget;
@@ -4390,16 +4397,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 */
}
}
@@ -5023,6 +5032,7 @@ static void
gtk_label_create_window (GtkLabel *label)
{
GtkLabelPriv *priv = label->priv;
+ GtkAllocation allocation;
GtkWidget *widget;
GdkWindowAttr attributes;
gint attributes_mask;
@@ -5034,10 +5044,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;
@@ -5057,7 +5069,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);
@@ -6093,6 +6105,7 @@ popup_position_func (GtkMenu *menu,
{
GtkLabel *label;
GtkWidget *widget;
+ GtkAllocation allocation;
GtkRequisition req;
GdkScreen *screen;
@@ -6102,15 +6115,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 cf3cd53..6a6007d 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1542,7 +1542,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) &&
@@ -2410,8 +2410,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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]