From 9a0687a673cbf60ff76cc6058b7980d25d2143a4 Mon Sep 17 00:00:00 2001 From: Tim Janik Date: Sun, 22 Feb 1998 12:16:01 +0000 Subject: [PATCH] don't perform gdk operations on size allocation if the notebook isn't realized. yosh: this fixes the iwarp problem. -timj --- gtk/gtknotebook.c | 113 ++++++++++++++++++++++------------------------ gtk/gtkobject.h | 1 + gtk/gtkwidget.c | 2 + 3 files changed, 56 insertions(+), 60 deletions(-) diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 90c7e367d7..1ccdc4306a 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -2233,27 +2233,29 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, gint n = 1; gint old_fill = 0; gint new_fill = 0; - + if (!notebook->show_tabs || !notebook->children) return; - + widget = GTK_WIDGET (notebook); container = GTK_CONTAINER (notebook); - + child_allocation.x = container->border_width; child_allocation.y = container->border_width; - + switch (notebook->tab_pos) { case GTK_POS_BOTTOM: - child_allocation.y = allocation->height - - notebook->cur_page->requisition.height - container->border_width; + child_allocation.y = (allocation->height - + notebook->cur_page->requisition.height - + container->border_width); case GTK_POS_TOP: child_allocation.height = notebook->cur_page->requisition.height; break; case GTK_POS_RIGHT: - child_allocation.x = allocation->width - - notebook->cur_page->requisition.width - container->border_width; + child_allocation.x = (allocation->width - + notebook->cur_page->requisition.width - + container->border_width); case GTK_POS_LEFT: child_allocation.width = notebook->cur_page->requisition.width; break; @@ -2272,23 +2274,21 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, children = children->next; tab_space += page->requisition.width; } - if (tab_space > allocation->width - 2 * container->border_width - - TAB_OVERLAP) + if (tab_space > allocation->width - 2 * container->border_width - TAB_OVERLAP) { showarrow = TRUE; page = notebook->focus_tab->data; - tab_space = allocation->width - TAB_OVERLAP - - page->requisition.width - - 2 * (container->border_width + ARROW_SPACING + ARROW_SIZE); - x = allocation->width - 2 * ARROW_SIZE - ARROW_SPACING - - container->border_width; + + tab_space = (allocation->width - TAB_OVERLAP - page->requisition.width - + 2 * (container->border_width + ARROW_SPACING + ARROW_SIZE)); + x = allocation->width - 2 * ARROW_SIZE - ARROW_SPACING - container->border_width; + page = notebook->children->data; if (notebook->tab_pos == GTK_POS_TOP) - y = container->border_width + - (page->requisition.height - ARROW_SIZE) / 2; + y = container->border_width + (page->requisition.height - ARROW_SIZE) / 2; else - y = allocation->height - container->border_width - - ARROW_SIZE - (page->requisition.height - ARROW_SIZE) / 2; + y = (allocation->height - container->border_width - + ARROW_SIZE - (page->requisition.height - ARROW_SIZE) / 2); } break; case GTK_POS_LEFT: @@ -2299,26 +2299,23 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, children = children->next; tab_space += page->requisition.height; } - if (tab_space > allocation->height - 2 * container->border_width - - TAB_OVERLAP) + if (tab_space > (allocation->height - 2 * container->border_width - TAB_OVERLAP)) { showarrow = TRUE; page = notebook->focus_tab->data; - tab_space = allocation->height - - ARROW_SIZE - ARROW_SPACING - TAB_OVERLAP - - 2 * container->border_width - page->requisition.height; - y = allocation->height - container->border_width - - ARROW_SIZE; + tab_space = (allocation->height - + ARROW_SIZE - ARROW_SPACING - TAB_OVERLAP - + 2 * container->border_width - page->requisition.height); + y = allocation->height - container->border_width - ARROW_SIZE; + page = notebook->children->data; if (notebook->tab_pos == GTK_POS_LEFT) - x = container->border_width - + (page->requisition.width - - (2 * ARROW_SIZE - ARROW_SPACING)) / 2; + x = (container->border_width + + (page->requisition.width - (2 * ARROW_SIZE - ARROW_SPACING)) / 2); else - x = allocation->width - container->border_width - - (2 * ARROW_SIZE - ARROW_SPACING) - - (page->requisition.width - - (2 * ARROW_SIZE - ARROW_SPACING)) / 2; + x = (allocation->width - container->border_width - + (2 * ARROW_SIZE - ARROW_SPACING) - + (page->requisition.width - (2 * ARROW_SIZE - ARROW_SPACING)) / 2); } break; } @@ -2365,8 +2362,12 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, notebook->first_tab = children->next; } } - gdk_window_move (notebook->panel, x, y); - gdk_window_show (notebook->panel); + + if (GTK_WIDGET_REALIZED (notebook)) + { + gdk_window_move (notebook->panel, x, y); + gdk_window_show (notebook->panel); + } if (tab_space < 0) { @@ -2381,7 +2382,7 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, } else tab_space = 0; - + children = notebook->children; while (children != notebook->first_tab) { @@ -2390,23 +2391,24 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, if (GTK_WIDGET_MAPPED (page->tab_label)) gtk_widget_unmap (page->tab_label); - + } children = last_child; while (children) { page = children->data; children = children->next; - + if (GTK_WIDGET_MAPPED (page->tab_label)) gtk_widget_unmap (page->tab_label); } } else /* !showarrow */ { - gdk_window_hide (notebook->panel); notebook->first_tab = notebook->children; tab_space = 0; + if (GTK_WIDGET_REALIZED (notebook)) + gdk_window_hide (notebook->panel); } children = notebook->first_tab; } @@ -2426,13 +2428,11 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, { case GTK_POS_TOP: case GTK_POS_BOTTOM: - child_allocation.width = page->requisition.width - + TAB_OVERLAP + new_fill - old_fill; + child_allocation.width = page->requisition.width + TAB_OVERLAP + new_fill - old_fill; break; case GTK_POS_LEFT: case GTK_POS_RIGHT: - child_allocation.height = page->requisition.height - + TAB_OVERLAP + new_fill - old_fill; + child_allocation.height = page->requisition.height + TAB_OVERLAP + new_fill - old_fill; break; } old_fill = new_fill; @@ -2450,7 +2450,8 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook, break; } - if (!GTK_WIDGET_MAPPED (page->tab_label)) + if (GTK_WIDGET_REALIZED (notebook) && + !GTK_WIDGET_MAPPED (page->tab_label)) gtk_widget_map (page->tab_label); } } @@ -2494,37 +2495,29 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, { case GTK_POS_TOP: child_allocation.x = xthickness + notebook->tab_border; - child_allocation.y = ythickness + notebook->tab_border - + page->allocation.y; + child_allocation.y = ythickness + notebook->tab_border + page->allocation.y; child_allocation.width = page->allocation.width - child_allocation.x * 2; - child_allocation.height = page->allocation.height - ythickness - - 2 * notebook->tab_border; + child_allocation.height = page->allocation.height - ythickness - 2 * notebook->tab_border; child_allocation.x += page->allocation.x; break; case GTK_POS_BOTTOM: child_allocation.x = xthickness + notebook->tab_border; child_allocation.width = page->allocation.width - child_allocation.x * 2; - child_allocation.height = page->allocation.height - ythickness - - 2 * notebook->tab_border; + child_allocation.height = page->allocation.height - ythickness - 2 * notebook->tab_border; child_allocation.x += page->allocation.x; child_allocation.y = page->allocation.y + notebook->tab_border; break; case GTK_POS_LEFT: - child_allocation.x = xthickness + notebook->tab_border - + page->allocation.x; + child_allocation.x = xthickness + notebook->tab_border + page->allocation.x; child_allocation.y = ythickness + notebook->tab_border; - child_allocation.width = page->allocation.width - xthickness - - 2 * notebook->tab_border; - child_allocation.height = page->allocation.height - - child_allocation.y * 2; + child_allocation.width = page->allocation.width - xthickness - 2 * notebook->tab_border; + child_allocation.height = page->allocation.height - child_allocation.y * 2; child_allocation.y += page->allocation.y; break; case GTK_POS_RIGHT: child_allocation.y = ythickness + notebook->tab_border; - child_allocation.width = page->allocation.width - xthickness - - 2 * notebook->tab_border; - child_allocation.height = page->allocation.height - - child_allocation.y * 2; + child_allocation.width = page->allocation.width - xthickness - 2 * notebook->tab_border; + child_allocation.height = page->allocation.height - child_allocation.y * 2; child_allocation.x = page->allocation.x + notebook->tab_border; child_allocation.y += page->allocation.y; break; diff --git a/gtk/gtkobject.h b/gtk/gtkobject.h index 8c2020a20c..e6f83329f3 100644 --- a/gtk/gtkobject.h +++ b/gtk/gtkobject.h @@ -84,6 +84,7 @@ enum { GTK_ARG_READABLE = 1 << 0, GTK_ARG_WRITABLE = 1 << 1, + GTK_ARG_CONSTRUCT = 1 << 2 }; #define GTK_ARG_READWRITE (GTK_ARG_READABLE | GTK_ARG_WRITABLE) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 3188419cf6..b021ce155a 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -2367,6 +2367,8 @@ gtk_widget_get_parent_window (GtkWidget *widget) GdkWindow *parent_window; g_return_val_if_fail (widget != NULL, NULL); + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + g_return_val_if_fail (widget->parent != NULL, NULL); parent_window = gtk_object_get_data (GTK_OBJECT (widget), parent_window_key);