[gtk+/refactor: 37/106] Use GtkBin accessors
- From: Javier Jardón <jjardon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/refactor: 37/106] Use GtkBin accessors
- Date: Tue, 13 Jul 2010 17:45:07 +0000 (UTC)
commit 4427760bcc330f60ec5778be04274f9f8073a84d
Author: Javier Jardón <jjardon gnome org>
Date: Mon May 24 22:31:36 2010 +0200
Use GtkBin accessors
demos/gtk-demo/changedisplay.c | 2 +-
demos/gtk-demo/combobox.c | 2 +-
docs/tools/widgets.c | 4 +-
gtk/gtkalignment.c | 23 +++++---
gtk/gtkaspectframe.c | 6 +-
gtk/gtkbutton.c | 27 +++++----
gtk/gtkcellrenderercombo.c | 2 +-
gtk/gtkcheckbutton.c | 24 +++++---
gtk/gtkcombobox.c | 116 ++++++++++++++++++++++---------------
gtk/gtkcomboboxentry.c | 32 +++++++---
gtk/gtkeventbox.c | 16 +++--
gtk/gtkexpander.c | 34 +++++++----
gtk/gtkframe.c | 22 +++++---
gtk/gtkhandlebox.c | 58 +++++++++++-------
gtk/gtkmenu.c | 12 ++--
gtk/gtkmenuitem.c | 82 ++++++++++++++++-----------
gtk/gtkmenutoolbutton.c | 2 +-
gtk/gtknotebook.c | 7 +-
gtk/gtkoffscreenwindow.c | 18 ++++--
gtk/gtkplug.c | 20 ++++--
gtk/gtkprintunixdialog.c | 4 +-
gtk/gtkradiobutton.c | 2 +-
gtk/gtkrecentchoosermenu.c | 2 +-
gtk/gtkscrolledwindow.c | 62 ++++++++++++--------
gtk/gtksocket.c | 6 +-
gtk/gtktogglebutton.c | 2 +-
gtk/gtktoolbutton.c | 8 ++-
gtk/gtktoolitem.c | 12 ++--
gtk/gtktreeviewcolumn.c | 4 +-
gtk/gtkviewport.c | 42 ++++++++-----
gtk/gtkwindow.c | 22 +++++---
gtk/tests/builder.c | 21 ++++---
gtk/tests/expander.c | 4 +-
gtk/tests/testing.c | 15 ++++-
modules/input/gtkimcontextxim.c | 2 +-
modules/other/gail/gailbutton.c | 2 +-
modules/other/gail/gaillabel.c | 2 +-
modules/other/gail/gailmenuitem.c | 2 +-
modules/other/gail/gailtoplevel.c | 11 ++-
tests/prop-editor.c | 6 +-
tests/testassistant.c | 4 +-
tests/testgtk.c | 16 +++--
tests/testmenubars.c | 10 ++-
tests/testmultidisplay.c | 2 +-
tests/testtreeflow.c | 2 +-
45 files changed, 475 insertions(+), 299 deletions(-)
---
diff --git a/demos/gtk-demo/changedisplay.c b/demos/gtk-demo/changedisplay.c
index b4bed3d..e12eb78 100644
--- a/demos/gtk-demo/changedisplay.c
+++ b/demos/gtk-demo/changedisplay.c
@@ -252,7 +252,7 @@ open_display_cb (GtkWidget *button,
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), display_entry);
gtk_widget_grab_focus (display_entry);
- gtk_widget_show_all (GTK_BIN (dialog)->child);
+ gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (dialog)));
while (!result)
{
diff --git a/demos/gtk-demo/combobox.c b/demos/gtk-demo/combobox.c
index f33d770..8f4348c 100644
--- a/demos/gtk-demo/combobox.c
+++ b/demos/gtk-demo/combobox.c
@@ -435,7 +435,7 @@ do_combobox (GtkWidget *do_widget)
entry = g_object_new (TYPE_MASK_ENTRY, NULL);
MASK_ENTRY (entry)->mask = "^([0-9]*|One|Two|2\302\275|Three)$";
- gtk_container_remove (GTK_CONTAINER (combo), GTK_BIN (combo)->child);
+ gtk_container_remove (GTK_CONTAINER (combo), gtk_bin_get_child (GTK_BIN (combo)));
gtk_container_add (GTK_CONTAINER (combo), entry);
}
diff --git a/docs/tools/widgets.c b/docs/tools/widgets.c
index 000e232..be4a378 100644
--- a/docs/tools/widgets.c
+++ b/docs/tools/widgets.c
@@ -279,13 +279,15 @@ create_combo_box_entry (void)
{
GtkWidget *widget;
GtkWidget *align;
+ GtkWidget *child;
gtk_rc_parse_string ("style \"combo-box-entry-style\" {\n"
" GtkComboBox::appears-as-list = 1\n"
"}\n"
"widget_class \"GtkComboBoxEntry\" style \"combo-box-entry-style\"\n" );
widget = gtk_combo_box_entry_new_text ();
- gtk_entry_set_text (GTK_ENTRY (GTK_BIN (widget)->child), "Combo Box Entry");
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ gtk_entry_set_text (GTK_ENTRY (child), "Combo Box Entry");
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_container_add (GTK_CONTAINER (align), widget);
diff --git a/gtk/gtkalignment.c b/gtk/gtkalignment.c
index 9f5f53e..060630c 100644
--- a/gtk/gtkalignment.c
+++ b/gtk/gtkalignment.c
@@ -428,6 +428,8 @@ gtk_alignment_set (GtkAlignment *alignment,
gfloat xscale,
gfloat yscale)
{
+ GtkWidget *child;
+
g_return_if_fail (GTK_IS_ALIGNMENT (alignment));
xalign = CLAMP (xalign, 0.0, 1.0);
@@ -463,8 +465,9 @@ gtk_alignment_set (GtkAlignment *alignment,
}
g_object_thaw_notify (G_OBJECT (alignment));
- if (GTK_BIN (alignment)->child)
- gtk_widget_queue_resize (GTK_BIN (alignment)->child);
+ child = gtk_bin_get_child (GTK_BIN (alignment));
+ if (child)
+ gtk_widget_queue_resize (child);
gtk_widget_queue_draw (GTK_WIDGET (alignment));
}
}
@@ -477,6 +480,7 @@ gtk_alignment_size_allocate (GtkWidget *widget,
GtkAlignment *alignment;
GtkBin *bin;
GtkAllocation child_allocation;
+ GtkWidget *bin_child;
gint width, height;
guint border_width;
gint padding_horizontal, padding_vertical;
@@ -488,10 +492,11 @@ gtk_alignment_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
alignment = GTK_ALIGNMENT (widget);
bin = GTK_BIN (widget);
-
- if (bin->child && gtk_widget_get_visible (bin->child))
+
+ bin_child = gtk_bin_get_child (bin);
+ if (bin_child && gtk_widget_get_visible (bin_child))
{
- GtkSizeRequest *child = GTK_SIZE_REQUEST (bin->child);
+ GtkSizeRequest *child = GTK_SIZE_REQUEST (bin_child);
gint child_nat_width;
gint child_nat_height;
gint child_width, child_height;
@@ -547,7 +552,7 @@ gtk_alignment_size_allocate (GtkWidget *widget,
child_allocation.y = alignment->yalign * (height - child_allocation.height) + allocation->y + border_width + priv->padding_top;
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ gtk_widget_size_allocate (bin_child, &child_allocation);
}
}
@@ -643,6 +648,7 @@ gtk_alignment_set_padding (GtkAlignment *alignment,
guint padding_right)
{
GtkAlignmentPrivate *priv;
+ GtkWidget *child;
g_return_if_fail (GTK_IS_ALIGNMENT (alignment));
@@ -674,8 +680,9 @@ gtk_alignment_set_padding (GtkAlignment *alignment,
g_object_thaw_notify (G_OBJECT (alignment));
/* Make sure that the widget and children are redrawn with the new setting: */
- if (GTK_BIN (alignment)->child)
- gtk_widget_queue_resize (GTK_BIN (alignment)->child);
+ child = gtk_bin_get_child (GTK_BIN (alignment));
+ if (child)
+ gtk_widget_queue_resize (child);
gtk_widget_queue_draw (GTK_WIDGET (alignment));
}
diff --git a/gtk/gtkaspectframe.c b/gtk/gtkaspectframe.c
index 2037cd5..f2eb19f 100644
--- a/gtk/gtkaspectframe.c
+++ b/gtk/gtkaspectframe.c
@@ -336,9 +336,11 @@ gtk_aspect_frame_compute_child_allocation (GtkFrame *frame,
GtkAspectFrame *aspect_frame = GTK_ASPECT_FRAME (frame);
GtkAspectFramePriv *priv = aspect_frame->priv;
GtkBin *bin = GTK_BIN (frame);
+ GtkWidget *child;
gdouble ratio;
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
GtkAllocation full_allocation;
@@ -346,7 +348,7 @@ gtk_aspect_frame_compute_child_allocation (GtkFrame *frame,
{
GtkRequisition child_requisition;
- gtk_widget_get_child_requisition (bin->child, &child_requisition);
+ gtk_widget_get_child_requisition (child, &child_requisition);
if (child_requisition.height != 0)
{
ratio = ((gdouble) child_requisition.width /
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 6af6f72..9785e8d 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -625,7 +625,7 @@ gtk_button_constructor (GType type,
static GType
gtk_button_child_type (GtkContainer *container)
{
- if (!GTK_BIN (container)->child)
+ if (!gtk_bin_get_child (GTK_BIN (container)))
return GTK_TYPE_WIDGET;
else
return G_TYPE_NONE;
@@ -798,6 +798,7 @@ static void
activatable_update_short_label (GtkButton *button,
GtkAction *action)
{
+ GtkWidget *child;
GtkWidget *image;
if (gtk_button_get_use_stock (button))
@@ -806,9 +807,10 @@ activatable_update_short_label (GtkButton *button,
image = gtk_button_get_image (button);
/* Dont touch custom child... */
+ child = gtk_bin_get_child (GTK_BIN (button));
if (GTK_IS_IMAGE (image) ||
- GTK_BIN (button)->child == NULL ||
- GTK_IS_LABEL (GTK_BIN (button)->child))
+ child == NULL ||
+ GTK_IS_LABEL (child))
{
gtk_button_set_label (button, gtk_action_get_short_label (action));
gtk_button_set_use_underline (button, TRUE);
@@ -975,6 +977,7 @@ gtk_button_construct_child (GtkButton *button)
{
GtkButtonPrivate *priv = GTK_BUTTON_GET_PRIVATE (button);
GtkStockItem item;
+ GtkWidget *child;
GtkWidget *label;
GtkWidget *box;
GtkWidget *align;
@@ -1001,9 +1004,9 @@ gtk_button_construct_child (GtkButton *button)
priv->image = NULL;
- if (GTK_BIN (button)->child)
- gtk_container_remove (GTK_CONTAINER (button),
- GTK_BIN (button)->child);
+ child = gtk_bin_get_child (GTK_BIN (button));
+ if (child)
+ gtk_container_remove (GTK_CONTAINER (button), child);
if (button->use_stock &&
button->label_text &&
@@ -1353,10 +1356,10 @@ gtk_button_update_image_spacing (GtkButton *button)
if (!button->constructed || !priv->image)
return;
- child = GTK_BIN (button)->child;
+ child = gtk_bin_get_child (GTK_BIN (button));
if (GTK_IS_ALIGNMENT (child))
{
- child = GTK_BIN (child)->child;
+ child = gtk_bin_get_child (GTK_BIN (child));
if (GTK_IS_BOX (child))
{
gtk_widget_style_get (GTK_WIDGET (button),
@@ -1434,6 +1437,7 @@ gtk_button_size_allocate (GtkWidget *widget,
{
GtkButton *button = GTK_BUTTON (widget);
GtkAllocation child_allocation;
+ GtkWidget *child;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
gint xthickness = GTK_WIDGET (widget)->style->xthickness;
@@ -1459,7 +1463,8 @@ gtk_button_size_allocate (GtkWidget *widget,
widget->allocation.width - border_width * 2,
widget->allocation.height - border_width * 2);
- if (GTK_BIN (button)->child && gtk_widget_get_visible (GTK_BIN (button)->child))
+ 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;
@@ -1504,7 +1509,7 @@ gtk_button_size_allocate (GtkWidget *widget,
child_allocation.y += child_displacement_y;
}
- gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
}
@@ -2166,7 +2171,7 @@ gtk_button_set_alignment (GtkButton *button,
priv->yalign = yalign;
priv->align_set = 1;
- maybe_set_alignment (button, GTK_BIN (button)->child);
+ maybe_set_alignment (button, gtk_bin_get_child (GTK_BIN (button)));
g_object_freeze_notify (G_OBJECT (button));
g_object_notify (G_OBJECT (button), "xalign");
diff --git a/gtk/gtkcellrenderercombo.c b/gtk/gtkcellrenderercombo.c
index 82f41d1..340a181 100644
--- a/gtk/gtkcellrenderercombo.c
+++ b/gtk/gtkcellrenderercombo.c
@@ -458,7 +458,7 @@ gtk_cell_renderer_combo_start_editing (GtkCellRenderer *cell,
g_object_get (cell_text, "text", &text, NULL);
if (text)
- gtk_entry_set_text (GTK_ENTRY (GTK_BIN (combo)->child),
+ gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo))),
text);
g_free (text);
}
diff --git a/gtk/gtkcheckbutton.c b/gtk/gtkcheckbutton.c
index 2f3f84f..2f1dae0 100644
--- a/gtk/gtkcheckbutton.c
+++ b/gtk/gtkcheckbutton.c
@@ -150,7 +150,7 @@ gtk_check_button_paint (GtkWidget *widget,
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
if (gtk_widget_has_focus (widget))
{
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
if (interior_focus && child && gtk_widget_get_visible (child))
gtk_paint_focus (widget->style, widget->window, gtk_widget_get_state (widget),
@@ -213,7 +213,7 @@ gtk_check_button_size_request (GtkWidget *widget,
_gtk_check_button_get_props (GTK_CHECK_BUTTON (widget),
&indicator_size, &indicator_spacing);
- child = GTK_BIN (widget)->child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
@@ -248,6 +248,7 @@ gtk_check_button_size_allocate (GtkWidget *widget,
if (toggle_button->draw_indicator)
{
+ GtkWidget *child;
gint indicator_size;
gint indicator_spacing;
gint focus_width;
@@ -264,13 +265,14 @@ gtk_check_button_size_allocate (GtkWidget *widget,
gdk_window_move_resize (button->event_window,
allocation->x, allocation->y,
allocation->width, allocation->height);
-
- if (GTK_BIN (button)->child && gtk_widget_get_visible (GTK_BIN (button)->child))
+
+ child = gtk_bin_get_child (GTK_BIN (button));
+ if (child && gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
- gtk_widget_get_child_requisition (GTK_BIN (button)->child, &child_requisition);
+ gtk_widget_get_child_requisition (child, &child_requisition);
child_allocation.width = MIN (child_requisition.width,
allocation->width -
@@ -291,7 +293,7 @@ gtk_check_button_size_allocate (GtkWidget *widget,
child_allocation.x = allocation->x + allocation->width
- (child_allocation.x - allocation->x + child_allocation.width);
- gtk_widget_size_allocate (GTK_BIN (button)->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
}
else
@@ -304,6 +306,7 @@ gtk_check_button_expose (GtkWidget *widget,
{
GtkToggleButton *toggle_button;
GtkBin *bin;
+ GtkWidget *child;
toggle_button = GTK_TOGGLE_BUTTON (widget);
bin = GTK_BIN (widget);
@@ -313,10 +316,11 @@ gtk_check_button_expose (GtkWidget *widget,
if (toggle_button->draw_indicator)
{
gtk_check_button_paint (widget, &event->area);
-
- if (bin->child)
+
+ child = gtk_bin_get_child (bin);
+ if (child)
gtk_container_propagate_expose (GTK_CONTAINER (widget),
- bin->child,
+ child,
event);
}
else if (GTK_WIDGET_CLASS (gtk_check_button_parent_class)->expose_event)
@@ -379,7 +383,7 @@ gtk_real_check_button_draw_indicator (GtkCheckButton *check_button,
x = widget->allocation.x + indicator_spacing + border_width;
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
- child = GTK_BIN (check_button)->child;
+ child = gtk_bin_get_child (GTK_BIN (check_button));
if (!interior_focus || !(child && gtk_widget_get_visible (child)))
x += focus_width + focus_pad;
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index 58e80d5..500662d 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1182,6 +1182,7 @@ gtk_combo_box_style_set (GtkWidget *widget,
{
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
GtkComboBoxPrivate *priv = combo_box->priv;
+ GtkWidget *child;
gtk_combo_box_check_appearance (combo_box);
@@ -1189,8 +1190,9 @@ gtk_combo_box_style_set (GtkWidget *widget,
gtk_cell_view_set_background_color (GTK_CELL_VIEW (priv->cell_view),
&widget->style->base[gtk_widget_get_state (widget)]);
- if (GTK_IS_ENTRY (GTK_BIN (combo_box)->child))
- g_object_set (GTK_BIN (combo_box)->child, "shadow-type",
+ child = gtk_bin_get_child (GTK_BIN (combo_box));
+ if (GTK_IS_ENTRY (child))
+ g_object_set (child, "shadow-type",
GTK_SHADOW_NONE == priv->shadow_type ?
GTK_SHADOW_IN : GTK_SHADOW_NONE, NULL);
}
@@ -1489,7 +1491,7 @@ gtk_combo_box_menu_position_below (GtkMenu *menu,
GdkRectangle monitor;
/* FIXME: is using the size request here broken? */
- child = GTK_BIN (combo_box)->child;
+ child = gtk_bin_get_child (GTK_BIN (combo_box));
sx = sy = 0;
@@ -1791,7 +1793,7 @@ update_menu_sensitivity (GtkComboBox *combo_box,
for (child = children; child; child = child->next)
{
item = GTK_WIDGET (child->data);
- cell_view = GTK_BIN (item)->child;
+ cell_view = gtk_bin_get_child (GTK_BIN (item));
if (!GTK_IS_CELL_VIEW (cell_view))
continue;
@@ -2175,7 +2177,7 @@ gtk_combo_box_size_request (GtkWidget *widget,
GtkComboBoxPrivate *priv = combo_box->priv;
/* common */
- gtk_widget_size_request (GTK_BIN (widget)->child, &bin_req);
+ gtk_widget_size_request (gtk_bin_get_child (GTK_BIN (widget)), &bin_req);
gtk_combo_box_remeasure (combo_box);
bin_req.width = MAX (bin_req.width, priv->width);
bin_req.height = MAX (bin_req.height, priv->height);
@@ -2186,7 +2188,7 @@ gtk_combo_box_size_request (GtkWidget *widget,
"arrow-size", &arrow_size,
NULL);
- font_desc = GTK_BIN (widget)->child->style->font_desc;
+ font_desc = gtk_bin_get_child (GTK_BIN (widget))->style->font_desc;
context = gtk_widget_get_pango_context (widget);
metrics = pango_context_get_metrics (context, font_desc,
pango_context_get_language (context));
@@ -2297,6 +2299,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
{
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
GtkComboBoxPrivate *priv = combo_box->priv;
+ GtkWidget *child_widget;
gint shadow_width, shadow_height;
gint focus_width, focus_pad;
GtkAllocation child;
@@ -2304,6 +2307,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
widget->allocation = *allocation;
+ child_widget = gtk_bin_get_child (GTK_BIN (widget));
gtk_widget_style_get (GTK_WIDGET (widget),
"focus-line-width", &focus_width,
@@ -2408,7 +2412,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
child.width = MAX (1, child.width);
child.height = MAX (1, child.height);
- gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
+ gtk_widget_size_allocate (child_widget, &child);
}
else
{
@@ -2422,7 +2426,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
child.width = allocation->width - req.width - 2 * shadow_width;
child.width = MAX (1, child.width);
child.height = MAX (1, child.height);
- gtk_widget_size_allocate (GTK_BIN (widget)->child, &child);
+ gtk_widget_size_allocate (child_widget, &child);
}
}
else
@@ -2488,7 +2492,7 @@ gtk_combo_box_size_allocate (GtkWidget *widget,
child.width = MAX (1, child.width);
child.height = MAX (1, child.height);
- gtk_widget_size_allocate (GTK_BIN (combo_box)->child, &child);
+ gtk_widget_size_allocate (child_widget, &child);
}
}
@@ -2543,6 +2547,7 @@ gtk_combo_box_forall (GtkContainer *container,
{
GtkComboBox *combo_box = GTK_COMBO_BOX (container);
GtkComboBoxPrivate *priv = combo_box->priv;
+ GtkWidget *child;
if (include_internals)
{
@@ -2552,8 +2557,9 @@ gtk_combo_box_forall (GtkContainer *container,
(* callback) (priv->cell_view_frame, callback_data);
}
- if (GTK_BIN (container)->child)
- (* callback) (GTK_BIN (container)->child, callback_data);
+ child = gtk_bin_get_child (GTK_BIN (container));
+ if (child)
+ (* callback) (child, callback_data);
}
static void
@@ -2603,7 +2609,8 @@ gtk_combo_box_expose_event (GtkWidget *widget,
}
gtk_container_propagate_expose (GTK_CONTAINER (widget),
- GTK_BIN (widget)->child, event);
+ gtk_bin_get_child (GTK_BIN (widget)),
+ event);
return FALSE;
}
@@ -2883,8 +2890,11 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
gboolean add_children)
{
GtkComboBoxPrivate *priv = combo_box->priv;
+ GtkWidget *child;
GtkWidget *menu;
+ child = gtk_bin_get_child (GTK_BIN (combo_box));
+
if (priv->cell_view)
{
priv->button = gtk_toggle_button_new ();
@@ -2894,7 +2904,7 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
g_signal_connect (priv->button, "toggled",
G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
gtk_widget_set_parent (priv->button,
- GTK_BIN (combo_box)->child->parent);
+ gtk_widget_get_parent (child));
priv->box = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (priv->button), priv->box);
@@ -2916,7 +2926,7 @@ gtk_combo_box_menu_setup (GtkComboBox *combo_box,
g_signal_connect (priv->button, "toggled",
G_CALLBACK (gtk_combo_box_button_toggled), combo_box);
gtk_widget_set_parent (priv->button,
- GTK_BIN (combo_box)->child->parent);
+ gtk_widget_get_parent (child));
priv->arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (priv->button), priv->arrow);
@@ -3259,7 +3269,7 @@ gtk_combo_box_menu_item_activate (GtkWidget *item,
GtkTreePath *path;
GtkTreeIter iter;
- cell_view = GTK_BIN (item)->child;
+ cell_view = gtk_bin_get_child (GTK_BIN (item));
g_return_if_fail (GTK_IS_CELL_VIEW (cell_view));
@@ -3440,6 +3450,7 @@ find_menu_by_path (GtkWidget *menu,
gboolean skip_first)
{
GList *i, *list;
+ GtkWidget *child;
GtkWidget *item;
GtkWidget *submenu;
GtkTreeRowReference *mref;
@@ -3451,6 +3462,7 @@ find_menu_by_path (GtkWidget *menu,
item = NULL;
for (i = list; i; i = i->next)
{
+ child = gtk_bin_get_child (i->data);
if (GTK_IS_SEPARATOR_MENU_ITEM (i->data))
{
mref = g_object_get_data (G_OBJECT (i->data), "gtk-combo-box-item-path");
@@ -3461,7 +3473,7 @@ find_menu_by_path (GtkWidget *menu,
else
mpath = gtk_tree_row_reference_get_path (mref);
}
- else if (GTK_IS_CELL_VIEW (GTK_BIN (i->data)->child))
+ else if (GTK_IS_CELL_VIEW (child))
{
if (skip)
{
@@ -3469,7 +3481,7 @@ find_menu_by_path (GtkWidget *menu,
continue;
}
- mpath = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (GTK_BIN (i->data)->child));
+ mpath = gtk_cell_view_get_displayed_row (GTK_CELL_VIEW (child));
}
else
continue;
@@ -3580,7 +3592,7 @@ gtk_combo_box_menu_row_inserted (GtkTreeModel *model,
combo_box);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
- if (cell_view_is_sensitive (GTK_CELL_VIEW (GTK_BIN (item)->child)))
+ if (cell_view_is_sensitive (GTK_CELL_VIEW (gtk_bin_get_child (GTK_BIN (item)))))
{
gtk_widget_show (item);
gtk_widget_show (separator);
@@ -3747,11 +3759,13 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
GtkComboBoxPrivate *priv = combo_box->priv;
GtkTreeSelection *sel;
GtkStyle *style;
+ GtkWidget *child;
GtkWidget *widget = GTK_WIDGET (combo_box);
priv->button = gtk_toggle_button_new ();
+ child = gtk_bin_get_child (GTK_BIN (combo_box));
gtk_widget_set_parent (priv->button,
- GTK_BIN (combo_box)->child->parent);
+ gtk_widget_get_parent (child));
g_signal_connect (priv->button, "button-press-event",
G_CALLBACK (gtk_combo_box_list_button_pressed), combo_box);
g_signal_connect (priv->button, "toggled",
@@ -3784,9 +3798,9 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
gtk_event_box_set_visible_window (GTK_EVENT_BOX (combo_box->priv->cell_view_frame),
FALSE);
}
-
+
gtk_widget_set_parent (priv->cell_view_frame,
- GTK_BIN (combo_box)->child->parent);
+ gtk_widget_get_parent (child));
gtk_container_add (GTK_CONTAINER (priv->cell_view_frame), priv->box);
gtk_widget_show_all (priv->cell_view_frame);
@@ -4262,14 +4276,15 @@ pack_start_recurse (GtkWidget *menu,
gboolean expand)
{
GList *i, *list;
+ GtkWidget *child;
GtkWidget *submenu;
list = gtk_container_get_children (GTK_CONTAINER (menu));
for (i = list; i; i = i->next)
{
- if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
- gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
- cell, expand);
+ child = gtk_bin_get_child (GTK_BIN (i->data));
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (child),
+ cell, expand);
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
@@ -4316,14 +4331,15 @@ pack_end_recurse (GtkWidget *menu,
gboolean expand)
{
GList *i, *list;
+ GtkWidget *child;
GtkWidget *submenu;
list = gtk_container_get_children (GTK_CONTAINER (menu));
for (i = list; i; i = i->next)
{
- if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
- gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
- cell, expand);
+ child = gtk_bin_get_child (GTK_BIN (i->data));
+ gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (child),
+ cell, expand);
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
@@ -4385,13 +4401,14 @@ static void
clear_recurse (GtkWidget *menu)
{
GList *i, *list;
+ GtkWidget *child;
GtkWidget *submenu;
list = gtk_container_get_children (GTK_CONTAINER (menu));
for (i = list; i; i = i->next)
{
- if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
- gtk_cell_layout_clear (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child));
+ child = gtk_bin_get_child (GTK_BIN (i->data));
+ gtk_cell_layout_clear (GTK_CELL_LAYOUT (child));
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
@@ -4437,14 +4454,15 @@ add_attribute_recurse (GtkWidget *menu,
gint column)
{
GList *i, *list;
+ GtkWidget *child;
GtkWidget *submenu;
-
+
list = gtk_container_get_children (GTK_CONTAINER (menu));
for (i = list; i; i = i->next)
{
- if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
- gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
- cell, attribute, column);
+ child = gtk_bin_get_child (GTK_BIN (i->data));
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (child),
+ cell, attribute, column);
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
@@ -4520,7 +4538,7 @@ set_cell_data_func_recurse (GtkWidget *menu,
list = gtk_container_get_children (GTK_CONTAINER (menu));
for (i = list; i; i = i->next)
{
- cell_view = GTK_BIN (i->data)->child;
+ cell_view = gtk_bin_get_child (GTK_BIN (i->data));
if (GTK_IS_CELL_LAYOUT (cell_view))
{
/* Override sensitivity for inner nodes; we don't
@@ -4582,15 +4600,15 @@ clear_attributes_recurse (GtkWidget *menu,
GtkCellRenderer *cell)
{
GList *i, *list;
- GtkWidget *submenu;
-
+ GtkWidget *submenu;
+ GtkWidget *child;
+
list = gtk_container_get_children (GTK_CONTAINER (menu));
for (i = list; i; i = i->next)
{
- if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
- gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
- cell);
-
+ child = gtk_bin_get_child (GTK_BIN (i->data));
+ gtk_cell_layout_clear_attributes (GTK_CELL_LAYOUT (child), cell);
+
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
clear_attributes_recurse (submenu, cell);
@@ -4640,15 +4658,16 @@ reorder_recurse (GtkWidget *menu,
gint position)
{
GList *i, *list;
+ GtkWidget *child;
GtkWidget *submenu;
-
+
list = gtk_container_get_children (GTK_CONTAINER (menu));
for (i = list; i; i = i->next)
{
- if (GTK_IS_CELL_LAYOUT (GTK_BIN (i->data)->child))
- gtk_cell_layout_reorder (GTK_CELL_LAYOUT (GTK_BIN (i->data)->child),
- cell, position);
-
+ child = gtk_bin_get_child (GTK_BIN (i->data));
+ gtk_cell_layout_reorder (GTK_CELL_LAYOUT (child),
+ cell, position);
+
submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (i->data));
if (submenu != NULL)
reorder_recurse (submenu, cell, position);
@@ -5670,6 +5689,7 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
GdkEvent *event)
{
GtkComboBox *combo_box = GTK_COMBO_BOX (cell_editable);
+ GtkWidget *child;
combo_box->priv->is_cell_renderer = TRUE;
@@ -5683,11 +5703,13 @@ gtk_combo_box_start_editing (GtkCellEditable *cell_editable,
}
else
{
- g_signal_connect_object (GTK_BIN (combo_box)->child, "key-press-event",
+ child = gtk_bin_get_child (GTK_BIN (combo_box));
+
+ g_signal_connect_object (child, "key-press-event",
G_CALLBACK (gtk_cell_editable_key_press),
cell_editable, 0);
- gtk_widget_grab_focus (GTK_WIDGET (GTK_BIN (combo_box)->child));
+ gtk_widget_grab_focus (child);
gtk_widget_set_can_focus (combo_box->priv->button, FALSE);
}
diff --git a/gtk/gtkcomboboxentry.c b/gtk/gtkcomboboxentry.c
index 34a2f49..c0b3eaf 100644
--- a/gtk/gtkcomboboxentry.c
+++ b/gtk/gtkcomboboxentry.c
@@ -226,7 +226,10 @@ static void
gtk_combo_box_entry_remove (GtkContainer *container,
GtkWidget *child)
{
- if (child && child == GTK_BIN (container)->child)
+ GtkWidget *child_widget;
+
+ child_widget = gtk_bin_get_child (GTK_BIN (container));
+ if (child && child == child_widget)
{
g_signal_handlers_disconnect_by_func (child,
gtk_combo_box_entry_contents_changed,
@@ -248,7 +251,7 @@ gtk_combo_box_entry_active_changed (GtkComboBox *combo_box,
if (gtk_combo_box_get_active_iter (combo_box, &iter))
{
- GtkEntry *entry = GTK_ENTRY (GTK_BIN (combo_box)->child);
+ GtkEntry *entry = GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combo_box)));
if (entry)
{
@@ -276,13 +279,16 @@ has_frame_changed (GtkComboBoxEntry *entry_box,
GParamSpec *pspec,
gpointer data)
{
- if (GTK_BIN (entry_box)->child)
+ GtkWidget *child;
+
+ child = gtk_bin_get_child (GTK_BIN (entry_box));
+ if (child)
{
gboolean has_frame;
g_object_get (entry_box, "has-frame", &has_frame, NULL);
- gtk_entry_set_has_frame (GTK_ENTRY (GTK_BIN (entry_box)->child), has_frame);
+ gtk_entry_set_has_frame (GTK_ENTRY (child), has_frame);
}
}
@@ -405,9 +411,11 @@ gtk_combo_box_entry_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling)
{
GtkBin *entry_box = GTK_BIN (widget);
+ GtkWidget* child;
- if (entry_box->child)
- gtk_widget_grab_focus (entry_box->child);
+ child = gtk_bin_get_child (entry_box);
+ if (child)
+ gtk_widget_grab_focus (child);
return TRUE;
}
@@ -416,9 +424,11 @@ static void
gtk_combo_box_entry_grab_focus (GtkWidget *widget)
{
GtkBin *entry_box = GTK_BIN (widget);
+ GtkWidget *child;
- if (entry_box->child)
- gtk_widget_grab_focus (entry_box->child);
+ child = gtk_bin_get_child (entry_box);
+ if (child)
+ gtk_widget_grab_focus (child);
}
@@ -456,9 +466,11 @@ static gchar *
gtk_combo_box_entry_get_active_text (GtkComboBox *combo_box)
{
GtkBin *combo = GTK_BIN (combo_box);
+ GtkWidget *child;
- if (combo->child)
- return g_strdup (gtk_entry_get_text (GTK_ENTRY (combo->child)));
+ child = gtk_bin_get_child (combo);
+ if (child)
+ return g_strdup (gtk_entry_get_text (GTK_ENTRY (child)));
return NULL;
}
diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c
index 17045ff..3e575e1 100644
--- a/gtk/gtkeventbox.c
+++ b/gtk/gtkeventbox.c
@@ -484,16 +484,18 @@ gtk_event_box_size_request (GtkWidget *widget,
{
GtkBin *bin = GTK_BIN (widget);
guint border_width;
+ GtkWidget *child;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
requisition->width = border_width * 2;
requisition->height = border_width * 2;
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
- gtk_widget_size_request (bin->child, &child_requisition);
+ gtk_widget_size_request (child, &child_requisition);
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
@@ -508,7 +510,8 @@ gtk_event_box_size_allocate (GtkWidget *widget,
GtkAllocation child_allocation;
GtkEventBoxPrivate *priv;
guint border_width;
-
+ GtkWidget *child;
+
widget->allocation = *allocation;
bin = GTK_BIN (widget);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -544,9 +547,10 @@ gtk_event_box_size_allocate (GtkWidget *widget,
child_allocation.width,
child_allocation.height);
}
-
- if (bin->child)
- gtk_widget_size_allocate (bin->child, &child_allocation);
+
+ child = gtk_bin_get_child (bin);
+ if (child)
+ gtk_widget_size_allocate (child, &child_allocation);
}
static void
diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c
index 8610f0b..23def98 100644
--- a/gtk/gtkexpander.c
+++ b/gtk/gtkexpander.c
@@ -464,6 +464,7 @@ gtk_expander_size_request (GtkWidget *widget,
GtkExpander *expander;
GtkBin *bin;
GtkExpanderPrivate *priv;
+ GtkWidget *child;
gint border_width;
gint expander_size;
gint expander_spacing;
@@ -504,11 +505,12 @@ gtk_expander_size_request (GtkWidget *widget,
if (!interior_focus)
requisition->height += 2 * focus_width + 2 * focus_pad;
- if (bin->child && GTK_WIDGET_CHILD_VISIBLE (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (child && GTK_WIDGET_CHILD_VISIBLE (child))
{
GtkRequisition child_requisition;
- gtk_widget_size_request (bin->child, &child_requisition);
+ gtk_widget_size_request (child, &child_requisition);
requisition->width = MAX (requisition->width, child_requisition.width);
requisition->height += child_requisition.height + priv->spacing;
@@ -592,6 +594,7 @@ gtk_expander_size_allocate (GtkWidget *widget,
GtkBin *bin;
GtkExpanderPrivate *priv;
GtkRequisition child_requisition;
+ GtkWidget *child;
gboolean child_visible = FALSE;
guint border_width;
gint expander_size;
@@ -617,10 +620,12 @@ gtk_expander_size_allocate (GtkWidget *widget,
child_requisition.width = 0;
child_requisition.height = 0;
- if (bin->child && GTK_WIDGET_CHILD_VISIBLE (bin->child))
+
+ child = gtk_bin_get_child (bin);
+ if (child && GTK_WIDGET_CHILD_VISIBLE (child))
{
child_visible = TRUE;
- gtk_widget_get_child_requisition (bin->child, &child_requisition);
+ gtk_widget_get_child_requisition (child, &child_requisition);
}
widget->allocation = *allocation;
@@ -703,7 +708,7 @@ gtk_expander_size_allocate (GtkWidget *widget,
(!interior_focus ? 2 * focus_width + 2 * focus_pad : 0);
child_allocation.height = MAX (child_allocation.height, 1);
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
}
@@ -1257,9 +1262,11 @@ gtk_expander_forall (GtkContainer *container,
{
GtkBin *bin = GTK_BIN (container);
GtkExpanderPrivate *priv = GTK_EXPANDER (container)->priv;
+ GtkWidget *child;
- if (bin->child)
- (* callback) (bin->child, callback_data);
+ child = gtk_bin_get_child (bin);
+ if (child)
+ (* callback) (child, callback_data);
if (priv->label_widget)
(* callback) (priv->label_widget, callback_data);
@@ -1316,6 +1323,7 @@ static gboolean
gtk_expander_animation_timeout (GtkExpander *expander)
{
GtkExpanderPrivate *priv = expander->priv;
+ GtkWidget *child;
GdkRectangle area;
gboolean finish = FALSE;
@@ -1353,8 +1361,10 @@ gtk_expander_animation_timeout (GtkExpander *expander)
if (finish)
{
priv->animation_timeout = 0;
- if (GTK_BIN (expander)->child)
- gtk_widget_set_child_visible (GTK_BIN (expander)->child, priv->expanded);
+
+ 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));
}
@@ -1391,6 +1401,7 @@ gtk_expander_set_expanded (GtkExpander *expander,
gboolean expanded)
{
GtkExpanderPrivate *priv;
+ GtkWidget *child;
g_return_if_fail (GTK_IS_EXPANDER (expander));
@@ -1416,9 +1427,10 @@ gtk_expander_set_expanded (GtkExpander *expander,
priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED :
GTK_EXPANDER_COLLAPSED;
- if (GTK_BIN (expander)->child)
+ child = gtk_bin_get_child (GTK_BIN (expander));
+ if (child)
{
- gtk_widget_set_child_visible (GTK_BIN (expander)->child, priv->expanded);
+ gtk_widget_set_child_visible (child, priv->expanded);
gtk_widget_queue_resize (GTK_WIDGET (expander));
}
}
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index cb8ddd2..f5474ed 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -302,9 +302,11 @@ gtk_frame_forall (GtkContainer *container,
{
GtkBin *bin = GTK_BIN (container);
GtkFrame *frame = GTK_FRAME (container);
+ GtkWidget *child;
- if (bin->child)
- (* callback) (bin->child, callback_data);
+ child = gtk_bin_get_child (bin);
+ if (child)
+ (* callback) (child, callback_data);
if (frame->label_widget)
(* callback) (frame->label_widget, callback_data);
@@ -615,6 +617,7 @@ gtk_frame_size_allocate (GtkWidget *widget,
GtkFrame *frame = GTK_FRAME (widget);
GtkBin *bin = GTK_BIN (widget);
GtkAllocation new_allocation;
+ GtkWidget *child;
widget->allocation = *allocation;
@@ -633,9 +636,10 @@ gtk_frame_size_allocate (GtkWidget *widget,
#endif
)
gdk_window_invalidate_rect (widget->window, &widget->allocation, FALSE);
-
- if (bin->child && gtk_widget_get_visible (bin->child))
- gtk_widget_size_allocate (bin->child, &new_allocation);
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
+ gtk_widget_size_allocate (child, &new_allocation);
frame->child_allocation = new_allocation;
@@ -712,6 +716,7 @@ gtk_frame_get_size (GtkSizeRequest *request,
gint *natural_size)
{
GtkWidget *widget = GTK_WIDGET (request);
+ GtkWidget *child;
GtkFrame *frame = GTK_FRAME (widget);
GtkBin *bin = GTK_BIN (widget);
gint child_min, child_nat;
@@ -741,18 +746,19 @@ gtk_frame_get_size (GtkSizeRequest *request,
natural = 0;
}
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child),
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
&child_min, &child_nat);
minimum = MAX (minimum, child_min);
natural = MAX (natural, child_nat);
}
else
{
- gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child),
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
&child_min, &child_nat);
minimum += child_min;
natural += child_nat;
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index b51b062..d5f3a5e 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -348,16 +348,17 @@ gtk_handle_box_map (GtkWidget *widget)
{
GtkBin *bin;
GtkHandleBox *hb;
+ GtkWidget *child;
gtk_widget_set_mapped (widget, TRUE);
bin = GTK_BIN (widget);
hb = GTK_HANDLE_BOX (widget);
- if (bin->child &&
- gtk_widget_get_visible (bin->child) &&
- !gtk_widget_get_mapped (bin->child))
- gtk_widget_map (bin->child);
+ child = gtk_bin_get_child (bin);
+ if (gtk_widget_get_visible (child) &&
+ !gtk_widget_get_mapped (child))
+ gtk_widget_map (child);
if (hb->child_detached && !hb->float_window_mapped)
{
@@ -389,9 +390,10 @@ gtk_handle_box_unmap (GtkWidget *widget)
static void
gtk_handle_box_realize (GtkWidget *widget)
{
+ GtkHandleBox *hb;
+ GtkWidget *child;
GdkWindowAttr attributes;
gint attributes_mask;
- GtkHandleBox *hb;
hb = GTK_HANDLE_BOX (widget);
@@ -425,8 +427,10 @@ gtk_handle_box_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
hb->bin_window = gdk_window_new (widget->window, &attributes, attributes_mask);
gdk_window_set_user_data (hb->bin_window, widget);
- if (GTK_BIN (hb)->child)
- gtk_widget_set_parent_window (GTK_BIN (hb)->child, hb->bin_window);
+
+ child = gtk_bin_get_child (GTK_BIN (hb));
+ if (child)
+ gtk_widget_set_parent_window (child, hb->bin_window);
attributes.x = 0;
attributes.y = 0;
@@ -521,6 +525,7 @@ gtk_handle_box_size_request (GtkWidget *widget,
GtkBin *bin;
GtkHandleBox *hb;
GtkRequisition child_requisition;
+ GtkWidget *child;
gint handle_position;
bin = GTK_BIN (widget);
@@ -540,11 +545,12 @@ gtk_handle_box_size_request (GtkWidget *widget,
requisition->height = DRAG_HANDLE_SIZE;
}
+ child = gtk_bin_get_child (bin);
/* if our child is not visible, we still request its size, since we
* won't have any useful hint for our size otherwise.
*/
- if (bin->child)
- gtk_widget_size_request (bin->child, &child_requisition);
+ if (child)
+ gtk_widget_size_request (child, &child_requisition);
else
{
child_requisition.width = 0;
@@ -579,7 +585,7 @@ gtk_handle_box_size_request (GtkWidget *widget,
requisition->width += border_width * 2;
requisition->height += border_width * 2;
- if (bin->child)
+ if (child)
{
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
@@ -599,6 +605,7 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
GtkBin *bin;
GtkHandleBox *hb;
GtkRequisition child_requisition;
+ GtkWidget *child;
gint handle_position;
bin = GTK_BIN (widget);
@@ -606,8 +613,10 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
handle_position = effective_handle_position (hb);
- if (bin->child)
- gtk_widget_get_child_requisition (bin->child, &child_requisition);
+ child = gtk_bin_get_child (bin);
+
+ if (child)
+ gtk_widget_get_child_requisition (child, &child_requisition);
else
{
child_requisition.width = 0;
@@ -624,7 +633,7 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
widget->allocation.height);
- if (bin->child && gtk_widget_get_visible (bin->child))
+ if (gtk_widget_get_visible (child))
{
GtkAllocation child_allocation;
guint border_width;
@@ -686,7 +695,7 @@ gtk_handle_box_size_allocate (GtkWidget *widget,
widget->allocation.height);
}
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
}
@@ -955,7 +964,7 @@ gtk_handle_box_paint (GtkWidget *widget,
event ? &event->area : area,
handle_orientation);
- if (bin->child && gtk_widget_get_visible (bin->child))
+ if (gtk_widget_get_visible (gtk_bin_get_child (bin)))
GTK_WIDGET_CLASS (gtk_handle_box_parent_class)->expose_event (widget, event);
}
@@ -1044,7 +1053,7 @@ gtk_handle_box_button_press (GtkWidget *widget,
if (event->window != hb->bin_window)
return FALSE;
- child = GTK_BIN (hb)->child;
+ child = gtk_bin_get_child (GTK_BIN (hb));
if (child)
{
@@ -1163,6 +1172,7 @@ gtk_handle_box_motion (GtkWidget *widget,
GdkEventMotion *event)
{
GtkHandleBox *hb = GTK_HANDLE_BOX (widget);
+ GtkWidget *child;
gint new_x, new_y;
gint snap_edge;
gboolean is_snapped = FALSE;
@@ -1268,6 +1278,8 @@ gtk_handle_box_motion (GtkWidget *widget,
(float_pos2 + TOLERANCE > attach_pos2));
}
+ child = gtk_bin_get_child (GTK_BIN (hb));
+
if (is_snapped)
{
if (hb->child_detached)
@@ -1279,7 +1291,7 @@ gtk_handle_box_motion (GtkWidget *widget,
g_signal_emit (hb,
handle_box_signals[SIGNAL_CHILD_ATTACHED],
0,
- GTK_BIN (hb)->child);
+ child);
gtk_widget_queue_resize (widget);
}
@@ -1324,8 +1336,8 @@ gtk_handle_box_motion (GtkWidget *widget,
hb->child_detached = TRUE;
- if (GTK_BIN (hb)->child)
- gtk_widget_get_child_requisition (GTK_BIN (hb)->child, &child_requisition);
+ if (child)
+ gtk_widget_get_child_requisition (child, &child_requisition);
else
{
child_requisition.width = 0;
@@ -1357,7 +1369,7 @@ gtk_handle_box_motion (GtkWidget *widget,
g_signal_emit (hb,
handle_box_signals[SIGNAL_CHILD_DETACHED],
0,
- GTK_BIN (hb)->child);
+ child);
gtk_handle_box_draw_ghost (hb);
gtk_widget_queue_resize (widget);
@@ -1403,6 +1415,7 @@ gtk_handle_box_delete_event (GtkWidget *widget,
static void
gtk_handle_box_reattach (GtkHandleBox *hb)
{
+ GtkWidget *child;
GtkWidget *widget = GTK_WIDGET (hb);
if (hb->child_detached)
@@ -1413,11 +1426,12 @@ gtk_handle_box_reattach (GtkHandleBox *hb)
gdk_window_hide (hb->float_window);
gdk_window_reparent (hb->bin_window, widget->window, 0, 0);
- if (GTK_BIN (hb)->child)
+ child = gtk_bin_get_child (GTK_BIN (hb));
+ if (child)
g_signal_emit (hb,
handle_box_signals[SIGNAL_CHILD_ATTACHED],
0,
- GTK_BIN (hb)->child);
+ child);
}
hb->float_window_mapped = FALSE;
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 55497e3..3534937 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1783,7 +1783,7 @@ gtk_menu_popdown (GtkMenu *menu)
{
gtk_widget_set_size_request (menu->tearoff_window, -1, -1);
- if (GTK_BIN (menu->toplevel)->child)
+ if (gtk_bin_get_child (GTK_BIN (menu->toplevel)))
{
gtk_menu_reparent (menu, menu->tearoff_hbox, TRUE);
}
@@ -1843,7 +1843,7 @@ gtk_menu_get_active (GtkMenu *menu)
child = children->data;
children = children->next;
- if (GTK_BIN (child)->child)
+ if (gtk_bin_get_child (GTK_BIN (child)))
break;
child = NULL;
}
@@ -1869,7 +1869,7 @@ gtk_menu_set_active (GtkMenu *menu,
if (tmp_list)
{
child = tmp_list->data;
- if (GTK_BIN (child)->child)
+ if (gtk_bin_get_child (GTK_BIN (child)))
{
if (menu->old_active_menu_item)
g_object_unref (menu->old_active_menu_item);
@@ -2080,7 +2080,7 @@ gtk_menu_update_title (GtkMenu *menu)
attach_widget = gtk_menu_get_attach_widget (menu);
if (GTK_IS_MENU_ITEM (attach_widget))
{
- GtkWidget *child = GTK_BIN (attach_widget)->child;
+ GtkWidget *child = gtk_bin_get_child (GTK_BIN (attach_widget));
if (GTK_IS_LABEL (child))
title = gtk_label_get_text (GTK_LABEL (child));
}
@@ -3147,7 +3147,7 @@ get_accel_path (GtkWidget *menu_item,
{
*locked = TRUE;
- label = GTK_BIN (menu_item)->child;
+ label = gtk_bin_get_child (GTK_BIN (menu_item));
if (GTK_IS_ACCEL_LABEL (label))
{
@@ -3250,7 +3250,7 @@ gtk_menu_key_press (GtkWidget *widget,
/* Modify the accelerators */
if (can_change_accels &&
menu_shell->active_menu_item &&
- GTK_BIN (menu_shell->active_menu_item)->child && /* no separators */
+ gtk_bin_get_child (GTK_BIN (menu_shell->active_menu_item)) && /* no separators */
GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL && /* no submenus */
(delete || gtk_accelerator_valid (accel_key, accel_mods)))
{
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index 316c9c3..580cb02 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -628,7 +628,9 @@ gtk_menu_item_activatable_interface_init (GtkActivatableIface *iface)
static void
activatable_update_label (GtkMenuItem *menu_item, GtkAction *action)
{
- GtkWidget *child = GTK_BIN (menu_item)->child;
+ GtkWidget *child;
+
+ child = gtk_bin_get_child (GTK_BIN (menu_item));
if (GTK_IS_LABEL (child))
{
@@ -667,12 +669,11 @@ gtk_menu_item_sync_action_properties (GtkActivatable *activatable,
{
GtkMenuItem *menu_item = GTK_MENU_ITEM (activatable);
GtkMenuItemPrivate *priv = GET_PRIVATE (menu_item);
+ GtkWidget *label;
if (!priv->use_action_appearance || !action)
{
- GtkWidget *label = GTK_BIN (menu_item)->child;
-
- label = GTK_BIN (menu_item)->child;
+ label = gtk_bin_get_child (GTK_BIN (menu_item));
if (GTK_IS_ACCEL_LABEL (label))
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), GTK_WIDGET (menu_item));
@@ -688,7 +689,7 @@ gtk_menu_item_sync_action_properties (GtkActivatable *activatable,
if (priv->use_action_appearance)
{
- GtkWidget *label = GTK_BIN (menu_item)->child;
+ label = gtk_bin_get_child (GTK_BIN (menu_item));
/* make sure label is a label */
if (label && !GTK_IS_LABEL (label))
@@ -700,8 +701,6 @@ gtk_menu_item_sync_action_properties (GtkActivatable *activatable,
gtk_menu_item_ensure_label (menu_item);
gtk_menu_item_set_use_underline (menu_item, TRUE);
- label = GTK_BIN (menu_item)->child;
-
if (GTK_IS_ACCEL_LABEL (label) && gtk_action_get_accel_path (action))
{
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), NULL);
@@ -934,6 +933,7 @@ gtk_menu_item_size_request (GtkWidget *widget,
{
GtkMenuItem *menu_item;
GtkBin *bin;
+ GtkWidget *child;
guint accel_width;
guint horizontal_padding;
guint border_width;
@@ -972,11 +972,12 @@ gtk_menu_item_size_request (GtkWidget *widget,
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))
requisition->height += 2 * horizontal_padding;
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
- gtk_widget_size_request (bin->child, &child_requisition);
+ gtk_widget_size_request (child, &child_requisition);
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
@@ -1028,6 +1029,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
GtkTextDirection direction;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
+ GtkWidget *child;
g_return_if_fail (GTK_IS_MENU_ITEM (widget));
g_return_if_fail (allocation != NULL);
@@ -1050,7 +1052,8 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
widget->allocation = *allocation;
- if (bin->child)
+ child = gtk_bin_get_child (bin);
+ if (child)
{
GtkRequisition child_requisition;
guint horizontal_padding;
@@ -1091,7 +1094,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
child_allocation.x += widget->allocation.x;
child_allocation.y += widget->allocation.y;
- gtk_widget_get_child_requisition (bin->child, &child_requisition);
+ gtk_widget_get_child_requisition (child, &child_requisition);
if (menu_item->submenu && menu_item->show_submenu_indicator)
{
if (direction == GTK_TEXT_DIR_RTL)
@@ -1102,7 +1105,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
if (child_allocation.width < 1)
child_allocation.width = 1;
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
if (gtk_widget_get_realized (widget))
@@ -1185,6 +1188,7 @@ gtk_menu_item_paint (GtkWidget *widget,
GtkMenuItem *menu_item;
GtkStateType state_type;
GtkShadowType shadow_type, selected_shadow_type;
+ GtkWidget *child;
gint width, height;
gint x, y;
guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -1199,9 +1203,10 @@ gtk_menu_item_paint (GtkWidget *widget,
y = widget->allocation.y + border_width;
width = widget->allocation.width - border_width * 2;
height = widget->allocation.height - border_width * 2;
+
+ child = gtk_bin_get_child (GTK_BIN (menu_item));
- if ((state_type == GTK_STATE_PRELIGHT) &&
- (GTK_BIN (menu_item)->child))
+ if (child && state_type == GTK_STATE_PRELIGHT)
{
gtk_widget_style_get (widget,
"selected-shadow-type", &selected_shadow_type,
@@ -1233,9 +1238,9 @@ gtk_menu_item_paint (GtkWidget *widget,
"arrow-scaling", &arrow_scaling,
NULL);
- context = gtk_widget_get_pango_context (GTK_BIN (menu_item)->child);
+ context = gtk_widget_get_pango_context (child);
metrics = pango_context_get_metrics (context,
- GTK_WIDGET (GTK_BIN (menu_item)->child)->style->font_desc,
+ child->style->font_desc,
pango_context_get_language (context));
arrow_size = (PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
@@ -1269,7 +1274,7 @@ gtk_menu_item_paint (GtkWidget *widget,
arrow_x, arrow_y,
arrow_extent, arrow_extent);
}
- else if (!GTK_BIN (menu_item)->child)
+ else if (!child)
{
gboolean wide_separators;
gint separator_height;
@@ -1448,11 +1453,14 @@ static void
gtk_real_menu_item_set_label (GtkMenuItem *menu_item,
const gchar *label)
{
+ GtkWidget *child;
+
gtk_menu_item_ensure_label (menu_item);
- if (GTK_IS_LABEL (GTK_BIN (menu_item)->child))
+ child = gtk_bin_get_child (GTK_BIN (menu_item));
+ if (GTK_IS_LABEL (child))
{
- gtk_label_set_label (GTK_LABEL (GTK_BIN (menu_item)->child), label ? label : "");
+ gtk_label_set_label (GTK_LABEL (child), label ? label : "");
g_object_notify (G_OBJECT (menu_item), "label");
}
@@ -1461,10 +1469,13 @@ gtk_real_menu_item_set_label (GtkMenuItem *menu_item,
static G_CONST_RETURN gchar *
gtk_real_menu_item_get_label (GtkMenuItem *menu_item)
{
+ GtkWidget *child;
+
gtk_menu_item_ensure_label (menu_item);
- if (GTK_IS_LABEL (GTK_BIN (menu_item)->child))
- return gtk_label_get_label (GTK_LABEL (GTK_BIN (menu_item)->child));
+ child = gtk_bin_get_child (GTK_BIN (menu_item));
+ if (GTK_IS_LABEL (child))
+ return gtk_label_get_label (GTK_LABEL (child));
return NULL;
}
@@ -2076,21 +2087,20 @@ gtk_menu_item_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data)
{
- GtkBin *bin;
+ GtkWidget *child;
g_return_if_fail (GTK_IS_MENU_ITEM (container));
g_return_if_fail (callback != NULL);
- bin = GTK_BIN (container);
-
- if (bin->child)
- callback (bin->child, callback_data);
+ child = gtk_bin_get_child (GTK_BIN (container));
+ if (child)
+ callback (child, callback_data);
}
gboolean
_gtk_menu_item_is_selectable (GtkWidget *menu_item)
{
- if ((!GTK_BIN (menu_item)->child &&
+ if ((!gtk_bin_get_child (GTK_BIN (menu_item)) &&
G_OBJECT_TYPE (menu_item) == GTK_TYPE_MENU_ITEM) ||
GTK_IS_SEPARATOR_MENU_ITEM (menu_item) ||
!gtk_widget_is_sensitive (menu_item) ||
@@ -2105,7 +2115,7 @@ gtk_menu_item_ensure_label (GtkMenuItem *menu_item)
{
GtkWidget *accel_label;
- if (!GTK_BIN (menu_item)->child)
+ if (!gtk_bin_get_child (GTK_BIN (menu_item)))
{
accel_label = g_object_new (GTK_TYPE_ACCEL_LABEL, NULL);
gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
@@ -2168,13 +2178,16 @@ void
gtk_menu_item_set_use_underline (GtkMenuItem *menu_item,
gboolean setting)
{
+ GtkWidget *child;
+
g_return_if_fail (GTK_IS_MENU_ITEM (menu_item));
gtk_menu_item_ensure_label (menu_item);
- if (GTK_IS_LABEL (GTK_BIN (menu_item)->child))
+ child = gtk_bin_get_child (GTK_BIN (menu_item));
+ if (GTK_IS_LABEL (child))
{
- gtk_label_set_use_underline (GTK_LABEL (GTK_BIN (menu_item)->child), setting);
+ gtk_label_set_use_underline (GTK_LABEL (child), setting);
g_object_notify (G_OBJECT (menu_item), "use-underline");
}
@@ -2195,12 +2208,15 @@ gtk_menu_item_set_use_underline (GtkMenuItem *menu_item,
gboolean
gtk_menu_item_get_use_underline (GtkMenuItem *menu_item)
{
+ GtkWidget *child;
+
g_return_val_if_fail (GTK_IS_MENU_ITEM (menu_item), FALSE);
gtk_menu_item_ensure_label (menu_item);
-
- if (GTK_IS_LABEL (GTK_BIN (menu_item)->child))
- return gtk_label_get_use_underline (GTK_LABEL (GTK_BIN (menu_item)->child));
+
+ child = gtk_bin_get_child (GTK_BIN (menu_item));
+ if (GTK_IS_LABEL (child))
+ return gtk_label_get_use_underline (GTK_LABEL (child));
return FALSE;
}
diff --git a/gtk/gtkmenutoolbutton.c b/gtk/gtkmenutoolbutton.c
index 0865016..5f25864 100644
--- a/gtk/gtkmenutoolbutton.c
+++ b/gtk/gtkmenutoolbutton.c
@@ -382,7 +382,7 @@ gtk_menu_tool_button_init (GtkMenuToolButton *button)
box = gtk_hbox_new (FALSE, 0);
- real_button = GTK_BIN (button)->child;
+ real_button = gtk_bin_get_child (GTK_BIN (button));
g_object_ref (real_button);
gtk_container_remove (GTK_CONTAINER (button), real_button);
gtk_container_add (GTK_CONTAINER (box), real_button);
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index c6bb222..3e3c81c 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -3299,12 +3299,13 @@ on_drag_icon_expose (GtkWidget *widget,
GdkEventExpose *event,
gpointer data)
{
- GtkWidget *notebook, *child = GTK_WIDGET (data);
+ GtkWidget *notebook, *child;
GtkRequisition requisition;
gint gap_pos;
notebook = GTK_WIDGET (data);
- child = GTK_BIN (widget)->child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
gtk_widget_size_request (widget, &requisition);
gap_pos = get_tab_gap_pos (GTK_NOTEBOOK (notebook));
@@ -6276,7 +6277,7 @@ static void
gtk_notebook_menu_label_unparent (GtkWidget *widget,
gpointer data)
{
- gtk_widget_unparent (GTK_BIN (widget)->child);
+ gtk_widget_unparent (gtk_bin_get_child (GTK_BIN (widget)));
GTK_BIN (widget)->child = NULL;
}
diff --git a/gtk/gtkoffscreenwindow.c b/gtk/gtkoffscreenwindow.c
index 417003b..30cc7a2 100644
--- a/gtk/gtkoffscreenwindow.c
+++ b/gtk/gtkoffscreenwindow.c
@@ -54,6 +54,7 @@ gtk_offscreen_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child;
gint border_width;
gint default_width, default_height;
@@ -62,11 +63,12 @@ gtk_offscreen_window_size_request (GtkWidget *widget,
requisition->width = border_width * 2;
requisition->height = border_width * 2;
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (gtk_widget_get_visible (child))
{
GtkRequisition child_req;
- gtk_widget_size_request (bin->child, &child_req);
+ gtk_widget_size_request (child, &child_req);
requisition->width += child_req.width;
requisition->height += child_req.height;
@@ -86,6 +88,7 @@ gtk_offscreen_window_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkBin *bin = GTK_BIN (widget);
+ GtkWidget *child;
gint border_width;
widget->allocation = *allocation;
@@ -99,7 +102,8 @@ gtk_offscreen_window_size_allocate (GtkWidget *widget,
allocation->width,
allocation->height);
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (gtk_widget_get_visible (child))
{
GtkAllocation child_alloc;
@@ -108,7 +112,7 @@ gtk_offscreen_window_size_allocate (GtkWidget *widget,
child_alloc.width = allocation->width - 2 * border_width;
child_alloc.height = allocation->height - 2 * border_width;
- gtk_widget_size_allocate (bin->child, &child_alloc);
+ gtk_widget_size_allocate (child, &child_alloc);
}
gtk_widget_queue_draw (widget);
@@ -118,6 +122,7 @@ static void
gtk_offscreen_window_realize (GtkWidget *widget)
{
GtkBin *bin;
+ GtkWidget *child;
GdkWindowAttr attributes;
gint attributes_mask;
gint border_width;
@@ -144,8 +149,9 @@ gtk_offscreen_window_realize (GtkWidget *widget)
&attributes, attributes_mask);
gdk_window_set_user_data (widget->window, widget);
- if (bin->child)
- gtk_widget_set_parent_window (bin->child, widget->window);
+ child = gtk_bin_get_child (bin);
+ if (child)
+ gtk_widget_set_parent_window (child, widget->window);
widget->style = gtk_style_attach (widget->style, widget->window);
diff --git a/gtk/gtkplug.c b/gtk/gtkplug.c
index 722fe87..5bb003a 100644
--- a/gtk/gtkplug.c
+++ b/gtk/gtkplug.c
@@ -705,13 +705,14 @@ gtk_plug_map (GtkWidget *widget)
{
GtkBin *bin = GTK_BIN (widget);
GtkPlug *plug = GTK_PLUG (widget);
+ GtkWidget *child;
gtk_widget_set_mapped (widget, TRUE);
- if (bin->child &&
- gtk_widget_get_visible (bin->child) &&
- !gtk_widget_get_mapped (bin->child))
- gtk_widget_map (bin->child);
+ child = gtk_bin_get_child (bin);
+ if (gtk_widget_get_visible (child) &&
+ !gtk_widget_get_mapped (child))
+ gtk_widget_map (child);
_gtk_plug_windowing_map_toplevel (plug);
@@ -748,6 +749,8 @@ static void
gtk_plug_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkWidget *child;
+
if (gtk_widget_is_toplevel (widget))
GTK_WIDGET_CLASS (gtk_plug_parent_class)->size_allocate (widget, allocation);
else
@@ -761,7 +764,8 @@ gtk_plug_size_allocate (GtkWidget *widget,
allocation->x, allocation->y,
allocation->width, allocation->height);
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (gtk_widget_get_visible (child))
{
GtkAllocation child_allocation;
@@ -771,7 +775,7 @@ gtk_plug_size_allocate (GtkWidget *widget,
child_allocation.height =
MAX (1, (gint)allocation->height - child_allocation.y * 2);
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
}
@@ -947,6 +951,7 @@ gtk_plug_focus (GtkWidget *widget,
GtkPlug *plug = GTK_PLUG (widget);
GtkWindow *window = GTK_WINDOW (widget);
GtkContainer *container = GTK_CONTAINER (widget);
+ GtkWidget *child;
GtkWidget *old_focus_child;
GtkWidget *parent;
@@ -974,7 +979,8 @@ gtk_plug_focus (GtkWidget *widget,
else
{
/* Try to focus the first widget in the window */
- if (bin->child && gtk_widget_child_focus (bin->child, direction))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_child_focus (child, direction))
return TRUE;
}
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index b43ed84..757b423 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -3719,7 +3719,7 @@ create_optional_page (GtkPrintUnixDialog *dialog,
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
table);
- gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN(scrolled)->child),
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (scrolled))),
GTK_SHADOW_NONE);
label = gtk_label_new (text);
@@ -3750,7 +3750,7 @@ create_advanced_page (GtkPrintUnixDialog *dialog)
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled),
main_vbox);
- gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN(scrolled)->child),
+ gtk_viewport_set_shadow_type (GTK_VIEWPORT (gtk_bin_get_child (GTK_BIN (scrolled))),
GTK_SHADOW_NONE);
priv->advanced_vbox = main_vbox;
diff --git a/gtk/gtkradiobutton.c b/gtk/gtkradiobutton.c
index 4824456..b86772f 100644
--- a/gtk/gtkradiobutton.c
+++ b/gtk/gtkradiobutton.c
@@ -830,7 +830,7 @@ gtk_radio_button_draw_indicator (GtkCheckButton *check_button,
x = widget->allocation.x + indicator_spacing + border_width;
y = widget->allocation.y + (widget->allocation.height - indicator_size) / 2;
- child = GTK_BIN (check_button)->child;
+ child = gtk_bin_get_child (GTK_BIN (check_button));
if (!interior_focus || !(child && gtk_widget_get_visible (child)))
x += focus_width + focus_pad;
diff --git a/gtk/gtkrecentchoosermenu.c b/gtk/gtkrecentchoosermenu.c
index d922f92..b328e12 100644
--- a/gtk/gtkrecentchoosermenu.c
+++ b/gtk/gtkrecentchoosermenu.c
@@ -865,7 +865,7 @@ gtk_recent_chooser_menu_create_item (GtkRecentChooserMenu *menu,
/* ellipsize the menu item label, in case the recent document
* display name is huge.
*/
- label = GTK_BIN (item)->child;
+ label = gtk_bin_get_child (GTK_BIN (item));
if (GTK_IS_LABEL (label))
{
gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 9accb0d..b22f005 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -437,6 +437,7 @@ gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window,
GtkAdjustment *hadjustment)
{
GtkBin *bin;
+ GtkWidget *child;
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (hadjustment)
@@ -477,9 +478,10 @@ gtk_scrolled_window_set_hadjustment (GtkScrolledWindow *scrolled_window,
G_CALLBACK (gtk_scrolled_window_adjustment_changed),
scrolled_window);
gtk_scrolled_window_adjustment_changed (hadjustment, scrolled_window);
-
- if (bin->child)
- gtk_widget_set_scroll_adjustments (bin->child,
+
+ child = gtk_bin_get_child (bin);
+ if (child)
+ gtk_widget_set_scroll_adjustments (child,
gtk_range_get_adjustment (GTK_RANGE (scrolled_window->hscrollbar)),
gtk_range_get_adjustment (GTK_RANGE (scrolled_window->vscrollbar)));
@@ -498,6 +500,7 @@ gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window,
GtkAdjustment *vadjustment)
{
GtkBin *bin;
+ GtkWidget *child;
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
if (vadjustment)
@@ -539,8 +542,9 @@ gtk_scrolled_window_set_vadjustment (GtkScrolledWindow *scrolled_window,
scrolled_window);
gtk_scrolled_window_adjustment_changed (vadjustment, scrolled_window);
- if (bin->child)
- gtk_widget_set_scroll_adjustments (bin->child,
+ child = gtk_bin_get_child (bin);
+ if (child)
+ gtk_widget_set_scroll_adjustments (child,
gtk_range_get_adjustment (GTK_RANGE (scrolled_window->hscrollbar)),
gtk_range_get_adjustment (GTK_RANGE (scrolled_window->vscrollbar)));
@@ -1317,6 +1321,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
GtkBin *bin;
GtkAllocation relative_allocation;
GtkAllocation child_allocation;
+ GtkWidget *child;
gboolean scrollbars_within_bevel;
gint scrollbar_spacing;
guint border_width;
@@ -1344,7 +1349,8 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
else if (scrolled_window->vscrollbar_policy == GTK_POLICY_NEVER)
scrolled_window->vscrollbar_visible = FALSE;
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
gboolean previous_hvis;
gboolean previous_vvis;
@@ -1362,7 +1368,7 @@ gtk_scrolled_window_size_allocate (GtkWidget *widget,
previous_hvis = scrolled_window->hscrollbar_visible;
previous_vvis = scrolled_window->vscrollbar_visible;
- gtk_widget_size_allocate (bin->child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
/* If, after the first iteration, the hscrollbar and the
* vscrollbar flip visiblity, then we need both.
@@ -1527,10 +1533,11 @@ gtk_scrolled_window_focus (GtkWidget *widget,
GtkDirectionType direction)
{
GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
+ GtkWidget *child;
gboolean had_focus_child;
had_focus_child = gtk_container_get_focus_child (GTK_CONTAINER (widget)) != NULL;
-
+
if (scrolled_window->focus_out)
{
scrolled_window->focus_out = FALSE; /* Clear this to catch the wrap-around case */
@@ -1543,9 +1550,10 @@ gtk_scrolled_window_focus (GtkWidget *widget,
/* We only put the scrolled window itself in the focus chain if it
* isn't possible to focus any children.
*/
- if (GTK_BIN (widget)->child)
+ child = gtk_bin_get_child (GTK_BIN (widget));
+ if (child)
{
- if (gtk_widget_child_focus (GTK_BIN (widget)->child, direction))
+ if (gtk_widget_child_focus (child, direction))
return TRUE;
}
@@ -1605,9 +1613,11 @@ gtk_scrolled_window_add (GtkContainer *container,
{
GtkScrolledWindow *scrolled_window;
GtkBin *bin;
+ GtkWidget *child_widget;
bin = GTK_BIN (container);
- g_return_if_fail (bin->child == NULL);
+ child_widget = gtk_bin_get_child (bin);
+ g_return_if_fail (child_widget == NULL);
scrolled_window = GTK_SCROLLED_WINDOW (container);
@@ -1628,7 +1638,7 @@ gtk_scrolled_window_remove (GtkContainer *container,
{
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (container));
g_return_if_fail (child != NULL);
- g_return_if_fail (GTK_BIN (container)->child == child);
+ g_return_if_fail (gtk_bin_get_child (GTK_BIN (container)) == child);
gtk_widget_set_scroll_adjustments (child, NULL, NULL);
@@ -1665,19 +1675,21 @@ gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window,
{
GtkBin *bin;
GtkWidget *viewport;
+ GtkWidget *child_widget;
g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window));
g_return_if_fail (GTK_IS_WIDGET (child));
g_return_if_fail (child->parent == NULL);
bin = GTK_BIN (scrolled_window);
+ child_widget = gtk_bin_get_child (bin);
- if (bin->child != NULL)
+ if (child_widget)
{
- g_return_if_fail (GTK_IS_VIEWPORT (bin->child));
- g_return_if_fail (GTK_BIN (bin->child)->child == NULL);
+ g_return_if_fail (GTK_IS_VIEWPORT (child_widget));
+ g_return_if_fail (gtk_bin_get_child (GTK_BIN (child_widget)) == NULL);
- viewport = bin->child;
+ viewport = child_widget;
}
else
{
@@ -1747,6 +1759,7 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
GtkRequisition hscrollbar_requisition;
GtkRequisition vscrollbar_requisition;
GtkRequisition minimum_req, natural_req;
+ GtkWidget *child;
gint min_child_size, nat_child_size;
guint border_width;
@@ -1766,15 +1779,16 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
&hscrollbar_requisition);
gtk_widget_size_request (scrolled_window->vscrollbar,
&vscrollbar_requisition);
-
- if (bin->child && gtk_widget_get_visible (bin->child))
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
- gtk_size_request_get_width (GTK_SIZE_REQUEST (bin->child),
+ gtk_size_request_get_width (GTK_SIZE_REQUEST (child),
&min_child_size,
&nat_child_size);
-
+
if (scrolled_window->hscrollbar_policy == GTK_POLICY_NEVER)
{
minimum_req.width += min_child_size;
@@ -1782,7 +1796,7 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
}
else
{
- GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (bin->child, FALSE);
+ GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (child, FALSE);
if (aux_info && aux_info->width > 0)
{
@@ -1799,10 +1813,10 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
}
else /* GTK_ORIENTATION_VERTICAL */
{
- gtk_size_request_get_height (GTK_SIZE_REQUEST (bin->child),
+ gtk_size_request_get_height (GTK_SIZE_REQUEST (child),
&min_child_size,
&nat_child_size);
-
+
if (scrolled_window->vscrollbar_policy == GTK_POLICY_NEVER)
{
minimum_req.height += min_child_size;
@@ -1810,7 +1824,7 @@ gtk_scrolled_window_get_size (GtkSizeRequest *widget,
}
else
{
- GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (bin->child, FALSE);
+ GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (child, FALSE);
if (aux_info && aux_info->height > 0)
{
diff --git a/gtk/gtksocket.c b/gtk/gtksocket.c
index bb7d514..08f0cd1 100644
--- a/gtk/gtksocket.c
+++ b/gtk/gtksocket.c
@@ -988,6 +988,7 @@ _gtk_socket_advance_toplevel_focus (GtkSocket *socket,
GtkBin *bin;
GtkWindow *window;
GtkContainer *container;
+ GtkWidget *child;
GtkWidget *toplevel;
GtkWidget *old_focus_child;
GtkWidget *parent;
@@ -1039,9 +1040,10 @@ _gtk_socket_advance_toplevel_focus (GtkSocket *socket,
}
/* Now try to focus the first widget in the window */
- if (bin->child)
+ child = gtk_bin_get_child (bin);
+ if (child)
{
- if (gtk_widget_child_focus (bin->child, direction))
+ if (gtk_widget_child_focus (child, direction))
return;
}
}
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 237a5dc..e18edae 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -421,7 +421,7 @@ gtk_toggle_button_expose (GtkWidget *widget,
{
if (gtk_widget_is_drawable (widget))
{
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
GtkButton *button = GTK_BUTTON (widget);
GtkStateType state_type;
GtkShadowType shadow_type;
diff --git a/gtk/gtktoolbutton.c b/gtk/gtktoolbutton.c
index a138c47..6cbd954 100644
--- a/gtk/gtktoolbutton.c
+++ b/gtk/gtktoolbutton.c
@@ -311,6 +311,7 @@ static void
gtk_tool_button_construct_contents (GtkToolItem *tool_item)
{
GtkToolButton *button = GTK_TOOL_BUTTON (tool_item);
+ GtkWidget *child;
GtkWidget *label = NULL;
GtkWidget *icon = NULL;
GtkToolbarStyle style;
@@ -340,12 +341,13 @@ gtk_tool_button_construct_contents (GtkToolItem *tool_item)
button->priv->label_widget);
}
- if (GTK_BIN (button->priv->button)->child)
+ child = gtk_bin_get_child (GTK_BIN (button->priv->button));
+ if (child)
{
/* Note: we are not destroying the label_widget or icon_widget
* here because they were removed from their containers above
*/
- gtk_widget_destroy (GTK_BIN (button->priv->button)->child);
+ gtk_widget_destroy (child);
}
style = gtk_tool_item_get_toolbar_style (GTK_TOOL_ITEM (button));
@@ -781,7 +783,7 @@ gtk_tool_button_update_icon_spacing (GtkToolButton *button)
GtkWidget *box;
guint spacing;
- box = GTK_BIN (button->priv->button)->child;
+ box = gtk_bin_get_child (GTK_BIN (button->priv->button));
if (GTK_IS_BOX (box))
{
gtk_widget_style_get (GTK_WIDGET (button),
diff --git a/gtk/gtktoolitem.c b/gtk/gtktoolitem.c
index a7008df..eae96ce 100644
--- a/gtk/gtktoolitem.c
+++ b/gtk/gtktoolitem.c
@@ -488,9 +488,10 @@ static void
gtk_tool_item_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child;
guint border_width;
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (child && gtk_widget_get_visible (child))
{
gtk_widget_size_request (child, requisition);
@@ -513,8 +514,9 @@ gtk_tool_item_size_allocate (GtkWidget *widget,
GtkToolItem *toolitem = GTK_TOOL_ITEM (widget);
GtkAllocation child_allocation;
gint border_width;
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
widget->allocation = *allocation;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -1063,8 +1065,7 @@ gtk_tool_item_set_tooltip_text (GtkToolItem *tool_item,
g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
- child = GTK_BIN (tool_item)->child;
-
+ child = gtk_bin_get_child (GTK_BIN (tool_item));
if (child)
gtk_widget_set_tooltip_text (child, text);
}
@@ -1087,8 +1088,7 @@ gtk_tool_item_set_tooltip_markup (GtkToolItem *tool_item,
g_return_if_fail (GTK_IS_TOOL_ITEM (tool_item));
- child = GTK_BIN (tool_item)->child;
-
+ child = gtk_bin_get_child (GTK_BIN (tool_item));
if (child)
gtk_widget_set_tooltip_markup (child, markup);
}
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index c22ae4e..7f75f2c 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -909,10 +909,10 @@ gtk_tree_view_column_update_button (GtkTreeViewColumn *tree_column)
if (! tree_column->button)
return;
- hbox = GTK_BIN (tree_column->button)->child;
+ hbox = gtk_bin_get_child (GTK_BIN (tree_column->button));
alignment = tree_column->alignment;
arrow = tree_column->arrow;
- current_child = GTK_BIN (alignment)->child;
+ current_child = gtk_bin_get_child (GTK_BIN (alignment));
/* Set up the actual button */
gtk_alignment_set (GTK_ALIGNMENT (alignment), tree_column->xalign,
diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c
index 2ff45a9..34586c5 100644
--- a/gtk/gtkviewport.c
+++ b/gtk/gtkviewport.c
@@ -393,6 +393,7 @@ viewport_set_hadjustment_values (GtkViewport *viewport,
GtkBin *bin = GTK_BIN (viewport);
GtkAllocation view_allocation;
GtkAdjustment *hadjustment = gtk_viewport_get_hadjustment (viewport);
+ GtkWidget *child;
gdouble old_page_size;
gdouble old_upper;
gdouble old_value;
@@ -408,11 +409,12 @@ viewport_set_hadjustment_values (GtkViewport *viewport,
hadjustment->lower = 0;
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
GtkRequisition child_requisition;
- gtk_widget_get_child_requisition (bin->child, &child_requisition);
+ gtk_widget_get_child_requisition (child, &child_requisition);
hadjustment->upper = MAX (child_requisition.width, view_allocation.width);
}
else
@@ -436,6 +438,7 @@ viewport_set_vadjustment_values (GtkViewport *viewport,
GtkBin *bin = GTK_BIN (viewport);
GtkAllocation view_allocation;
GtkAdjustment *vadjustment = gtk_viewport_get_vadjustment (viewport);
+ GtkWidget *child;
viewport_get_view_allocation (viewport, &view_allocation);
@@ -445,14 +448,15 @@ viewport_set_vadjustment_values (GtkViewport *viewport,
vadjustment->lower = 0;
- if (bin->child && gtk_widget_get_visible (bin->child))
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
{
gint natural_height;
-
- gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (bin->child),
- view_allocation.width,
- NULL,
- &natural_height);
+
+ gtk_size_request_get_height_for_width (GTK_SIZE_REQUEST (child),
+ view_allocation.width,
+ NULL,
+ &natural_height);
vadjustment->upper = MAX (natural_height, view_allocation.height);
}
else
@@ -632,12 +636,12 @@ gtk_viewport_realize (GtkWidget *widget)
GtkBin *bin = GTK_BIN (widget);
GtkAdjustment *hadjustment = gtk_viewport_get_hadjustment (viewport);
GtkAdjustment *vadjustment = gtk_viewport_get_vadjustment (viewport);
- guint border_width;
-
GtkAllocation view_allocation;
+ GtkWidget *child;
GdkWindowAttr attributes;
gint attributes_mask;
gint event_mask;
+ guint border_width;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -686,8 +690,9 @@ gtk_viewport_realize (GtkWidget *widget)
viewport->bin_window = gdk_window_new (viewport->view_window, &attributes, attributes_mask);
gdk_window_set_user_data (viewport->bin_window, viewport);
- if (bin->child)
- gtk_widget_set_parent_window (bin->child, viewport->bin_window);
+ child = gtk_bin_get_child (bin);
+ if (child)
+ gtk_widget_set_parent_window (child, viewport->bin_window);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
@@ -767,7 +772,7 @@ gtk_viewport_add (GtkContainer *container,
{
GtkBin *bin = GTK_BIN (container);
- g_return_if_fail (bin->child == NULL);
+ g_return_if_fail (gtk_bin_get_child (bin) == NULL);
gtk_widget_set_parent_window (child, GTK_VIEWPORT (bin)->bin_window);
@@ -785,6 +790,7 @@ gtk_viewport_size_allocate (GtkWidget *widget,
GtkAdjustment *hadjustment = gtk_viewport_get_hadjustment (viewport);
GtkAdjustment *vadjustment = gtk_viewport_get_vadjustment (viewport);
GtkAllocation child_allocation;
+ GtkWidget *child;
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
@@ -827,8 +833,10 @@ gtk_viewport_size_allocate (GtkWidget *widget,
child_allocation.width,
child_allocation.height);
}
- if (bin->child && gtk_widget_get_visible (bin->child))
- gtk_widget_size_allocate (bin->child, &child_allocation);
+
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child))
+ gtk_widget_size_allocate (child, &child_allocation);
gtk_adjustment_changed (hadjustment);
gtk_adjustment_changed (vadjustment);
@@ -844,8 +852,10 @@ gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment,
{
GtkViewport *viewport = GTK_VIEWPORT (data);
GtkBin *bin = GTK_BIN (data);
+ GtkWidget *child;
- if (bin->child && gtk_widget_get_visible (bin->child) &&
+ child = gtk_bin_get_child (bin);
+ if (child && gtk_widget_get_visible (child) &&
gtk_widget_get_realized (GTK_WIDGET (viewport)))
{
GtkAdjustment *hadjustment = gtk_viewport_get_hadjustment (viewport);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index e5ee01c..a9fa718 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -4553,6 +4553,7 @@ gtk_window_hide (GtkWidget *widget)
static void
gtk_window_map (GtkWidget *widget)
{
+ GtkWidget *child;
GtkWindow *window = GTK_WINDOW (widget);
GtkWindowPrivate *priv = GTK_WINDOW_GET_PRIVATE (window);
GdkWindow *toplevel;
@@ -4560,10 +4561,11 @@ gtk_window_map (GtkWidget *widget)
gtk_widget_set_mapped (widget, TRUE);
- if (window->bin.child &&
- gtk_widget_get_visible (window->bin.child) &&
- !gtk_widget_get_mapped (window->bin.child))
- gtk_widget_map (window->bin.child);
+ child = gtk_bin_get_child (&(window->bin));
+ if (child &&
+ gtk_widget_get_visible (child) &&
+ !gtk_widget_get_mapped (child))
+ gtk_widget_map (child);
if (window->frame)
toplevel = window->frame;
@@ -4929,12 +4931,14 @@ gtk_window_size_allocate (GtkWidget *widget,
{
GtkWindow *window;
GtkAllocation child_allocation;
+ GtkWidget *child;
guint border_width;
window = GTK_WINDOW (widget);
widget->allocation = *allocation;
- if (window->bin.child && gtk_widget_get_visible (window->bin.child))
+ child = gtk_bin_get_child (&(window->bin));
+ if (child && gtk_widget_get_visible (child))
{
border_width = gtk_container_get_border_width (GTK_CONTAINER (window));
child_allocation.x = border_width;
@@ -4944,7 +4948,7 @@ gtk_window_size_allocate (GtkWidget *widget,
child_allocation.height =
MAX (1, (gint)allocation->height - child_allocation.y * 2);
- gtk_widget_size_allocate (window->bin.child, &child_allocation);
+ gtk_widget_size_allocate (child, &child_allocation);
}
if (gtk_widget_get_realized (widget) && window->frame)
@@ -5396,6 +5400,7 @@ gtk_window_focus (GtkWidget *widget,
GtkBin *bin;
GtkWindow *window;
GtkContainer *container;
+ GtkWidget *child;
GtkWidget *old_focus_child;
GtkWidget *parent;
@@ -5437,9 +5442,10 @@ gtk_window_focus (GtkWidget *widget,
}
/* Now try to focus the first widget in the window */
- if (bin->child)
+ child = gtk_bin_get_child (bin);
+ if (child)
{
- if (gtk_widget_child_focus (bin->child, direction))
+ if (gtk_widget_child_focus (child, direction))
return TRUE;
}
diff --git a/gtk/tests/builder.c b/gtk/tests/builder.c
index e725b7d..d053ed9 100644
--- a/gtk/tests/builder.c
+++ b/gtk/tests/builder.c
@@ -355,7 +355,7 @@ test_uimanager_simple (void)
g_assert (strcmp (GTK_WIDGET (menu)->name, "file") == 0);
g_list_free (children);
- label = G_OBJECT (GTK_BIN (menu)->child);
+ label = G_OBJECT (gtk_bin_get_child (GTK_BIN (menu)));
g_assert (GTK_IS_LABEL (label));
g_assert (strcmp (gtk_label_get_text (GTK_LABEL (label)), "File") == 0);
@@ -2292,7 +2292,7 @@ test_add_objects (void)
g_assert (strcmp (GTK_WIDGET (menu)->name, "file") == 0);
g_list_free (children);
- label = G_OBJECT (GTK_BIN (menu)->child);
+ label = G_OBJECT (gtk_bin_get_child (GTK_BIN (menu)));
g_assert (label != NULL);
g_assert (GTK_IS_LABEL (label));
g_assert (strcmp (gtk_label_get_text (GTK_LABEL (label)), "File") == 0);
@@ -2319,7 +2319,7 @@ test_add_objects (void)
g_assert (strcmp (GTK_WIDGET (menu)->name, "file") == 0);
g_list_free (children);
- label = G_OBJECT (GTK_BIN (menu)->child);
+ label = G_OBJECT (gtk_bin_get_child (GTK_BIN (menu)));
g_assert (label != NULL);
g_assert (GTK_IS_LABEL (label));
g_assert (strcmp (gtk_label_get_text (GTK_LABEL (label)), "File") == 0);
@@ -2423,6 +2423,7 @@ test_menus (void)
"<object class=\"GtkAccelGroup\" id=\"accelgroup1\"/>"
"</interface>";
GtkBuilder *builder;
+ GtkWidget *child;
GtkWidget *window, *item;
GtkAccelGroup *accel_group;
GtkWidget *item_accel_label, *sample_accel_label, *sample_menu_item, *custom;
@@ -2438,14 +2439,16 @@ test_menus (void)
sample_menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, accel_group);
- g_assert (GTK_BIN (sample_menu_item)->child);
- g_assert (GTK_IS_ACCEL_LABEL (GTK_BIN (sample_menu_item)->child));
- sample_accel_label = GTK_WIDGET (GTK_BIN (sample_menu_item)->child);
+ child = gtk_bin_get_child (GTK_BIN (sample_menu_item));
+ g_assert (child);
+ g_assert (GTK_IS_ACCEL_LABEL (child));
+ sample_accel_label = child;
gtk_widget_show (sample_accel_label);
- g_assert (GTK_BIN (item)->child);
- g_assert (GTK_IS_ACCEL_LABEL (GTK_BIN (item)->child));
- item_accel_label = GTK_WIDGET (GTK_BIN (item)->child);
+ child = gtk_bin_get_child (GTK_BIN (item));
+ g_assert (child);
+ g_assert (GTK_IS_ACCEL_LABEL (child));
+ item_accel_label = child;
gtk_accel_label_refetch (GTK_ACCEL_LABEL (sample_accel_label));
gtk_accel_label_refetch (GTK_ACCEL_LABEL (item_accel_label));
diff --git a/gtk/tests/expander.c b/gtk/tests/expander.c
index 853b20a..e490d4c 100644
--- a/gtk/tests/expander.c
+++ b/gtk/tests/expander.c
@@ -34,7 +34,7 @@ test_click_expander (void)
gboolean expanded;
gboolean simsuccess;
gtk_container_add (GTK_CONTAINER (expander), label);
- gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), expander);
+ gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
gtk_widget_show (expander);
gtk_widget_show (label);
gtk_widget_show_now (window);
@@ -66,7 +66,7 @@ test_click_content_widget (void)
gboolean expanded;
gboolean simsuccess;
gtk_container_add (GTK_CONTAINER (expander), entry);
- gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), expander);
+ gtk_container_add (GTK_CONTAINER (gtk_bin_get_child (GTK_BIN (window))), expander);
gtk_expander_set_expanded (GTK_EXPANDER (expander), TRUE);
gtk_widget_show (expander);
gtk_widget_show (entry);
diff --git a/gtk/tests/testing.c b/gtk/tests/testing.c
index 6208ac6..c0e7559 100644
--- a/gtk/tests/testing.c
+++ b/gtk/tests/testing.c
@@ -74,9 +74,12 @@ test_button_keys (void)
static void
test_slider_ranges (void)
{
+ GtkWidget *child;
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: gtk_test_warp_slider");
GtkWidget *hscale = gtk_hscale_new_with_range (-50, +50, 5);
- gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), hscale);
+
+ child = gtk_bin_get_child (GTK_BIN (window));
+ gtk_container_add (GTK_CONTAINER (child), hscale);
gtk_widget_show (hscale);
gtk_widget_show_now (window);
while (gtk_events_pending ())
@@ -128,10 +131,13 @@ test_xserver_sync (void)
{
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_xserver_sync");
GtkWidget *darea = gtk_drawing_area_new ();
+ GtkWidget *child;
GTimer *gtimer = g_timer_new();
gint sync_is_slower = 0, repeat = 5;
+
+ child = gtk_bin_get_child (GTK_BIN (window));
gtk_widget_set_size_request (darea, 320, 200);
- gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), darea);
+ gtk_container_add (GTK_CONTAINER (child), darea);
gtk_widget_show (darea);
gtk_widget_show_now (window);
while (repeat--)
@@ -171,11 +177,14 @@ test_xserver_sync (void)
static void
test_spin_button_arrows (void)
{
+ GtkWidget *child;
GtkWidget *window = gtk_test_create_simple_window ("Test Window", "Test: test_spin_button_arrows");
GtkWidget *spinner = gtk_spin_button_new_with_range (0, 100, 5);
gboolean simsuccess;
double oldval, newval;
- gtk_container_add (GTK_CONTAINER (GTK_BIN (window)->child), spinner);
+
+ child = gtk_bin_get_child (GTK_BIN (window));
+ gtk_container_add (GTK_CONTAINER (child), spinner);
gtk_widget_show (spinner);
gtk_widget_show_now (window);
gtk_test_slider_set_perc (spinner, 0);
diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c
index baf1a97..dfa17bc 100644
--- a/modules/input/gtkimcontextxim.c
+++ b/modules/input/gtkimcontextxim.c
@@ -1849,7 +1849,7 @@ status_window_set_text (StatusWindow *status_window,
if (!status_window->window)
status_window_make_window (status_window);
- label = GTK_BIN (status_window->window)->child;
+ label = gtk_bin_get_child (GTK_BIN (status_window->window));
gtk_label_set_text (GTK_LABEL (label), text);
gtk_widget_show (status_window->window);
diff --git a/modules/other/gail/gailbutton.c b/modules/other/gail/gailbutton.c
index 8b0a05e..ec22818 100644
--- a/modules/other/gail/gailbutton.c
+++ b/modules/other/gail/gailbutton.c
@@ -240,7 +240,7 @@ gail_button_is_default_press (GtkWidget *widget)
gboolean ret = FALSE;
const gchar *parent_type_name;
- child = GTK_BIN (widget)->child;
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (GTK_IS_ARROW (child))
{
g_object_get (child,
diff --git a/modules/other/gail/gaillabel.c b/modules/other/gail/gaillabel.c
index 217db59..a527a8a 100644
--- a/modules/other/gail/gaillabel.c
+++ b/modules/other/gail/gaillabel.c
@@ -500,7 +500,7 @@ gail_label_ref_relation_set (AtkObject *obj)
{
GtkWidget *temp_widget;
- temp_widget = GTK_BIN (list->data)->child;
+ temp_widget = gtk_bin_get_child (GTK_BIN (list->data));
if (GTK_IS_BUTTON (temp_widget))
mnemonic_widget = temp_widget;
}
diff --git a/modules/other/gail/gailmenuitem.c b/modules/other/gail/gailmenuitem.c
index 6e42968..a0c5fb1 100644
--- a/modules/other/gail/gailmenuitem.c
+++ b/modules/other/gail/gailmenuitem.c
@@ -520,7 +520,7 @@ gail_menu_item_get_keybinding (AtkAction *action,
* we get here.
*/
key = NULL;
- child = GTK_BIN (item)->child;
+ child = gtk_bin_get_child (GTK_BIN (item));
if (GTK_IS_ACCEL_LABEL (child))
{
GtkAccelLabel *accel_label;
diff --git a/modules/other/gail/gailtoplevel.c b/modules/other/gail/gailtoplevel.c
index afbd5b3..8d01105 100644
--- a/modules/other/gail/gailtoplevel.c
+++ b/modules/other/gail/gailtoplevel.c
@@ -323,9 +323,10 @@ _gail_toplevel_remove_child (GailToplevel *toplevel,
static gboolean
is_attached_menu_window (GtkWidget *widget)
{
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child;
gboolean ret = FALSE;
+ child = gtk_bin_get_child (GTK_BIN (widget));
if (GTK_IS_MENU (child))
{
GtkWidget *attach;
@@ -342,19 +343,21 @@ is_attached_menu_window (GtkWidget *widget)
static gboolean
is_combo_window (GtkWidget *widget)
{
- GtkWidget *child = GTK_BIN (widget)->child;
+ GtkWidget *child;
AtkObject *obj;
GtkAccessible *accessible;
+ child = gtk_bin_get_child (GTK_BIN (widget));
+
if (!GTK_IS_EVENT_BOX (child))
return FALSE;
- child = GTK_BIN (child)->child;
+ child = gtk_bin_get_child (GTK_BIN (child));
if (!GTK_IS_FRAME (child))
return FALSE;
- child = GTK_BIN (child)->child;
+ child = gtk_bin_get_child (GTK_BIN (child));
if (!GTK_IS_SCROLLED_WINDOW (child))
return FALSE;
diff --git a/tests/prop-editor.c b/tests/prop-editor.c
index b6b3978..9117d60 100644
--- a/tests/prop-editor.c
+++ b/tests/prop-editor.c
@@ -375,6 +375,7 @@ static void
bool_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
GtkToggleButton *tb = GTK_TOGGLE_BUTTON (data);
+ GtkWidget *child;
GValue val = { 0, };
g_value_init (&val, G_TYPE_BOOLEAN);
@@ -387,8 +388,9 @@ bool_changed (GObject *object, GParamSpec *pspec, gpointer data)
unblock_controller (G_OBJECT (tb));
}
- gtk_label_set_text (GTK_LABEL (GTK_BIN (tb)->child), g_value_get_boolean (&val) ?
- "TRUE" : "FALSE");
+ child = gtk_bin_get_child (GTK_BIN (tb));
+ gtk_label_set_text (GTK_LABEL (child),
+ g_value_get_boolean (&val) ? "TRUE" : "FALSE");
g_value_unset (&val);
}
diff --git a/tests/testassistant.c b/tests/testassistant.c
index 33e06e3..b618796 100644
--- a/tests/testassistant.c
+++ b/tests/testassistant.c
@@ -116,7 +116,7 @@ progress_timeout (GtkWidget *assistant)
current_page = gtk_assistant_get_current_page (GTK_ASSISTANT (assistant));
page = gtk_assistant_get_nth_page (GTK_ASSISTANT (assistant), current_page);
- progress = GTK_BIN (page)->child;
+ progress = gtk_bin_get_child (GTK_BIN (page));
value = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (progress));
value += 0.1;
@@ -140,7 +140,7 @@ prepare_callback (GtkWidget *widget, GtkWidget *page)
{
GtkWidget *progress;
- progress = GTK_BIN (page)->child;
+ progress = gtk_bin_get_child (GTK_BIN (page));
gtk_assistant_set_page_complete (GTK_ASSISTANT (widget), page, FALSE);
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), 0.0);
gdk_threads_add_timeout (300, (GSourceFunc) progress_timeout, widget);
diff --git a/tests/testgtk.c b/tests/testgtk.c
index b661be8..94ac27d 100644
--- a/tests/testgtk.c
+++ b/tests/testgtk.c
@@ -2840,7 +2840,7 @@ create_rotated_text (GtkWidget *widget)
g_signal_connect (drawing_area, "unrealize",
G_CALLBACK (on_rotated_text_unrealize), NULL);
- gtk_widget_show_all (GTK_BIN (window)->child);
+ gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (window)));
gtk_widget_set_size_request (drawing_area, DEFAULT_TEXT_RADIUS * 2, DEFAULT_TEXT_RADIUS * 2);
gtk_widget_size_request (window, &requisition);
@@ -4835,7 +4835,7 @@ static void
size_group_hsize_changed (GtkSpinButton *spin_button,
GtkWidget *button)
{
- gtk_widget_set_size_request (GTK_BIN (button)->child,
+ gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (button)),
gtk_spin_button_get_value_as_int (spin_button),
-1);
}
@@ -4844,7 +4844,7 @@ static void
size_group_vsize_changed (GtkSpinButton *spin_button,
GtkWidget *button)
{
- gtk_widget_set_size_request (GTK_BIN (button)->child,
+ gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (button)),
-1,
gtk_spin_button_get_value_as_int (spin_button));
}
@@ -4900,7 +4900,7 @@ create_size_group_window (GdkScreen *screen,
gtk_size_group_add_widget (master_size_group, main_button);
gtk_size_group_add_widget (hgroup1, main_button);
gtk_size_group_add_widget (vgroup1, main_button);
- gtk_widget_set_size_request (GTK_BIN (main_button)->child,
+ gtk_widget_set_size_request (gtk_bin_get_child (GTK_BIN (main_button)),
SIZE_GROUP_INITIAL_SIZE,
SIZE_GROUP_INITIAL_SIZE);
@@ -10464,7 +10464,8 @@ create_styles (GtkWidget *widget)
font_desc = pango_font_description_from_string ("Helvetica,Sans Oblique 18");
button = gtk_button_new_with_label ("Some Text");
- gtk_widget_modify_font (GTK_BIN (button)->child, font_desc);
+ gtk_widget_modify_font (gtk_bin_get_child (GTK_BIN (button)),
+ font_desc);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
label = gtk_label_new ("Foreground:");
@@ -10472,7 +10473,8 @@ create_styles (GtkWidget *widget)
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Some Text");
- gtk_widget_modify_fg (GTK_BIN (button)->child, GTK_STATE_NORMAL, &red);
+ gtk_widget_modify_fg (gtk_bin_get_child (GTK_BIN (button)),
+ GTK_STATE_NORMAL, &red);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
label = gtk_label_new ("Background:");
@@ -10532,7 +10534,7 @@ create_styles (GtkWidget *widget)
rc_style->ythickness = 5;
gtk_widget_modify_style (button, rc_style);
- gtk_widget_modify_style (GTK_BIN (button)->child, rc_style);
+ gtk_widget_modify_style (gtk_bin_get_child (GTK_BIN (button)), rc_style);
g_object_unref (rc_style);
diff --git a/tests/testmenubars.c b/tests/testmenubars.c
index 853d822..42b1d2d 100644
--- a/tests/testmenubars.c
+++ b/tests/testmenubars.c
@@ -57,6 +57,7 @@ create_menubar (GtkPackDirection pack_dir,
GtkPackDirection child_pack_dir,
gdouble angle)
{
+ GtkWidget *child;
GtkWidget *menubar;
GtkWidget *menuitem;
GtkWidget *menu;
@@ -69,19 +70,22 @@ create_menubar (GtkPackDirection pack_dir,
menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_HOME, NULL);
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
- gtk_label_set_angle (GTK_LABEL (GTK_BIN (menuitem)->child), angle);
+ child = gtk_bin_get_child (GTK_BIN (menuitem));
+ gtk_label_set_angle (GTK_LABEL (child), angle);
menu = create_menu (2);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_label ("foo");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
- gtk_label_set_angle (GTK_LABEL (GTK_BIN (menuitem)->child), angle);
+ child = gtk_bin_get_child (GTK_BIN (menuitem));
+ gtk_label_set_angle (GTK_LABEL (child), angle);
menu = create_menu (2);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
menuitem = gtk_menu_item_new_with_label ("bar");
gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
- gtk_label_set_angle (GTK_LABEL (GTK_BIN (menuitem)->child), angle);
+ child = gtk_bin_get_child (GTK_BIN (menuitem));
+ gtk_label_set_angle (GTK_LABEL (child), angle);
menu = create_menu (2);
gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
diff --git a/tests/testmultidisplay.c b/tests/testmultidisplay.c
index 7d024ed..ad96216 100644
--- a/tests/testmultidisplay.c
+++ b/tests/testmultidisplay.c
@@ -130,7 +130,7 @@ main (int argc, char *argv[])
G_CALLBACK (get_screen_response), display_entry);
gtk_widget_grab_focus (display_entry);
- gtk_widget_show_all (GTK_BIN (dialog)->child);
+ gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (dialog)));
while (!correct_second_display)
{
diff --git a/tests/testtreeflow.c b/tests/testtreeflow.c
index 3b9653d..dec350a 100644
--- a/tests/testtreeflow.c
+++ b/tests/testtreeflow.c
@@ -163,7 +163,7 @@ main (int argc, char *argv[])
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
button = gtk_button_new_with_mnemonic ("<b>_Futz!!</b>");
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- gtk_label_set_use_markup (GTK_LABEL (GTK_BIN (button)->child), TRUE);
+ gtk_label_set_use_markup (GTK_LABEL (gtk_bin_get_child (GTK_BIN (button))), TRUE);
g_signal_connect (button, "clicked", G_CALLBACK (futz), NULL);
g_signal_connect (button, "realize", G_CALLBACK (gtk_widget_grab_focus), NULL);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 400);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]