diff options
author | Benjamin Otte <otte@redhat.com> | 2011-12-07 23:51:19 +0100 |
---|---|---|
committer | Benjamin Otte <otte@redhat.com> | 2011-12-08 00:24:28 +0100 |
commit | 003d80dbea8ce71d900a6f93b6bb29e5c5ada457 (patch) | |
tree | a6367e32b61ce03363d2e0a30617a8b5c28665ca /gtk/gtkoverlay.c | |
parent | f34d0d6f7b3987c5ecb73495c0aa1a9298f9eb53 (diff) | |
download | gtk+-003d80dbea8ce71d900a6f93b6bb29e5c5ada457.tar.gz |
overlay: Move code
Move code for child allocation into the child allocation function. Don't
keep it in the overlay allocation code.
See the next commit for why this is useful.
Diffstat (limited to 'gtk/gtkoverlay.c')
-rw-r--r-- | gtk/gtkoverlay.c | 67 |
1 files changed, 32 insertions, 35 deletions
diff --git a/gtk/gtkoverlay.c b/gtk/gtkoverlay.c index db9d1728e6..b964fff53a 100644 --- a/gtk/gtkoverlay.c +++ b/gtk/gtkoverlay.c @@ -116,11 +116,31 @@ gtk_overlay_create_child_window (GtkOverlay *overlay, } static void -gtk_overlay_child_allocate (GtkOverlayChild *child, - GtkAllocation *allocation) +gtk_overlay_child_allocate (GtkOverlay *overlay, + GtkOverlayChild *child) { gint left, right, top, bottom; - GtkAllocation child_allocation; + GtkAllocation allocation, child_allocation, overlay_allocation; + gboolean result; + + if (gtk_widget_get_mapped (GTK_WIDGET (overlay))) + { + if (gtk_widget_get_visible (child->widget)) + gdk_window_show (child->window); + else if (gdk_window_is_visible (child->window)) + gdk_window_hide (child->window); + } + + if (!gtk_widget_get_visible (child->widget)) + return; + + g_signal_emit (overlay, signals[GET_CHILD_POSITION], + 0, child->widget, &allocation, &result); + + gtk_widget_get_allocation (GTK_WIDGET (overlay), &overlay_allocation); + + allocation.x += overlay_allocation.x; + allocation.y += overlay_allocation.y; /* put the margins outside the window; also arrange things * so that the adjusted child allocation still ends up at 0, 0 @@ -132,18 +152,18 @@ gtk_overlay_child_allocate (GtkOverlayChild *child, child_allocation.x = - left; child_allocation.y = - top; - child_allocation.width = allocation->width; - child_allocation.height = allocation->height; + child_allocation.width = allocation.width; + child_allocation.height = allocation.height; - allocation->x += left; - allocation->y += top; - allocation->width -= left + right; - allocation->height -= top + bottom; + allocation.x += left; + allocation.y += top; + allocation.width -= left + right; + allocation.height -= top + bottom; if (child->window) gdk_window_move_resize (child->window, - allocation->x, allocation->y, - allocation->width, allocation->height); + allocation.x, allocation.y, + allocation.width, allocation.height); gtk_widget_size_allocate (child->widget, &child_allocation); } @@ -205,30 +225,7 @@ gtk_overlay_size_allocate (GtkWidget *widget, for (children = priv->children; children; children = children->next) { - GtkOverlayChild *child; - GtkAllocation alloc; - gboolean result; - - child = children->data; - - if (gtk_widget_get_mapped (GTK_WIDGET (overlay))) - { - if (gtk_widget_get_visible (child->widget)) - gdk_window_show (child->window); - else if (gdk_window_is_visible (child->window)) - gdk_window_hide (child->window); - } - - if (!gtk_widget_get_visible (child->widget)) - continue; - - g_signal_emit (overlay, signals[GET_CHILD_POSITION], - 0, child->widget, &alloc, &result); - - alloc.x += allocation->x; - alloc.y += allocation->y; - - gtk_overlay_child_allocate (child, &alloc); + gtk_overlay_child_allocate (overlay, children->data); } } |