From 257ca7ef7dd837d40678f0bbb0708390b967a903 Mon Sep 17 00:00:00 2001 From: Mikael Hallendal Date: Sat, 28 Jun 2008 16:16:26 +0000 Subject: [PATCH] Factor out gtk_box_pack from gtk_box_pack_start and gtk_box_pack_end to reduce code duplication. 2008-06-27 Mikael Hallendal * gtk/gtkbox.c (gtk_box_pack, gtk_box_pack_start, gtk_box_pack_end): Factored out gtk_box_pack from gtk_box_pack_start and use it from both pack_start and pack_end in order to reduce the code duplication. svn path=/trunk/; revision=20700 --- ChangeLog | 6 ++++ gtk/gtkbox.c | 91 ++++++++++++++++++++++------------------------------ 2 files changed, 45 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b45d7bc89..5dfc3d2a1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-27 Mikael Hallendal + + * gtk/gtkbox.c (gtk_box_pack, gtk_box_pack_start, gtk_box_pack_end): + Factored out gtk_box_pack from gtk_box_pack_start and use it from both + pack_start and pack_end in order to reduce the code duplication. + 2008-06-27 Michael Natterer Bug 442042 – GtkScaleButton is too limited diff --git a/gtk/gtkbox.c b/gtk/gtkbox.c index 457bd0a356..bc81a7698a 100644 --- a/gtk/gtkbox.c +++ b/gtk/gtkbox.c @@ -329,6 +329,43 @@ gtk_box_get_child_property (GtkContainer *container, } } +static void +gtk_box_pack (GtkBox *box, + GtkWidget *child, + gboolean expand, + gboolean fill, + guint padding, + GtkPackType pack_type) +{ + GtkBoxChild *child_info; + + g_return_if_fail (GTK_IS_BOX (box)); + g_return_if_fail (GTK_IS_WIDGET (child)); + g_return_if_fail (child->parent == NULL); + + child_info = g_new (GtkBoxChild, 1); + child_info->widget = child; + child_info->padding = padding; + child_info->expand = expand ? TRUE : FALSE; + child_info->fill = fill ? TRUE : FALSE; + child_info->pack = pack_type; + child_info->is_secondary = FALSE; + + box->children = g_list_append (box->children, child_info); + + gtk_widget_freeze_child_notify (child); + + gtk_widget_set_parent (child, GTK_WIDGET (box)); + + gtk_widget_child_notify (child, "expand"); + gtk_widget_child_notify (child, "fill"); + gtk_widget_child_notify (child, "padding"); + gtk_widget_child_notify (child, "pack-type"); + gtk_widget_child_notify (child, "position"); + gtk_widget_thaw_child_notify (child); + +} + /** * gtk_box_pack_start: * @box: a #GtkBox @@ -358,32 +395,7 @@ gtk_box_pack_start (GtkBox *box, gboolean fill, guint padding) { - GtkBoxChild *child_info; - - g_return_if_fail (GTK_IS_BOX (box)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); - - child_info = g_new (GtkBoxChild, 1); - child_info->widget = child; - child_info->padding = padding; - child_info->expand = expand ? TRUE : FALSE; - child_info->fill = fill ? TRUE : FALSE; - child_info->pack = GTK_PACK_START; - child_info->is_secondary = FALSE; - - box->children = g_list_append (box->children, child_info); - - gtk_widget_freeze_child_notify (child); - - gtk_widget_set_parent (child, GTK_WIDGET (box)); - - gtk_widget_child_notify (child, "expand"); - gtk_widget_child_notify (child, "fill"); - gtk_widget_child_notify (child, "padding"); - gtk_widget_child_notify (child, "pack-type"); - gtk_widget_child_notify (child, "position"); - gtk_widget_thaw_child_notify (child); + gtk_box_pack (box, child, expand, fill, padding, GTK_PACK_START); } /** @@ -415,32 +427,7 @@ gtk_box_pack_end (GtkBox *box, gboolean fill, guint padding) { - GtkBoxChild *child_info; - - g_return_if_fail (GTK_IS_BOX (box)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); - - child_info = g_new (GtkBoxChild, 1); - child_info->widget = child; - child_info->padding = padding; - child_info->expand = expand ? TRUE : FALSE; - child_info->fill = fill ? TRUE : FALSE; - child_info->pack = GTK_PACK_END; - child_info->is_secondary = FALSE; - - box->children = g_list_append (box->children, child_info); - - gtk_widget_freeze_child_notify (child); - - gtk_widget_set_parent (child, GTK_WIDGET (box)); - - gtk_widget_child_notify (child, "expand"); - gtk_widget_child_notify (child, "fill"); - gtk_widget_child_notify (child, "padding"); - gtk_widget_child_notify (child, "pack-type"); - gtk_widget_child_notify (child, "position"); - gtk_widget_thaw_child_notify (child); + gtk_box_pack (box, child, expand, fill, padding, GTK_PACK_END); } /**