diff options
author | Manish Singh <yosh@src.gnome.org> | 1998-11-28 03:05:31 +0000 |
---|---|---|
committer | Manish Singh <yosh@src.gnome.org> | 1998-11-28 03:05:31 +0000 |
commit | 67d445eebc8d350f5a5131dc6e3d7b8d8ef9da13 (patch) | |
tree | 9d1e50b2d02a7ae8c8b79685f5f0a8ca3600670d /gtk/gtkscrolledwindow.c | |
parent | 33347533ecca414f9de3dbc95265f8d4470aebcd (diff) | |
download | gtk+-67d445eebc8d350f5a5131dc6e3d7b8d8ef9da13.tar.gz |
check for existing viewport first, and don't add one if there already is
* gtk/gtkscrolledwindow.c (gtk_scrolled_window_add_with_viewport):
check for existing viewport first, and don't add one if there
already is one
-Yosh
Diffstat (limited to 'gtk/gtkscrolledwindow.c')
-rw-r--r-- | gtk/gtkscrolledwindow.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 944026fc2b..ea7939f4dd 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -867,13 +867,23 @@ gtk_scrolled_window_add_with_viewport (GtkScrolledWindow *scrolled_window, g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); g_return_if_fail (child != NULL); g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (scrolled_window->child == NULL); g_return_if_fail (child->parent == NULL); - viewport = - gtk_viewport_new (gtk_scrolled_window_get_hadjustment (scrolled_window), - gtk_scrolled_window_get_vadjustment (scrolled_window)); + if (scrolled_window->child != NULL) + { + g_return_if_fail (GTK_IS_VIEWPORT (scrolled_window->child)); + g_return_if_fail (GTK_BIN (scrolled_window->child)->child == NULL); + + viewport = scrolled_window->child; + } + else + { + viewport = + gtk_viewport_new (gtk_scrolled_window_get_hadjustment (scrolled_window), + gtk_scrolled_window_get_vadjustment (scrolled_window)); + gtk_container_add (GTK_CONTAINER (scrolled_window), viewport); + } + gtk_widget_show (viewport); gtk_container_add (GTK_CONTAINER (viewport), child); - gtk_container_add (GTK_CONTAINER (scrolled_window), viewport); } |