Scrollpane show/size issue
- From: Joel Becker <jlbec evilplan org>
- To: gtk-devel-list gnome org
- Subject: Scrollpane show/size issue
- Date: Fri, 31 Aug 2001 06:10:49 +0100
Folks,
Here's a bug that started showing up recently. I have a vbox
inside a GtkScrolledWindow. I set the whole thing insensitive, then
populate the vbox, then call show_all, then set it sensitive again.
What I am seeing is the first time I do this, sometimes the widgets
don't appear, and when they do, often the scrolled window doesn't put up
the scrollbar. If I drag resize the window, it discovers its error and
corrects it. After it has worked once in the application, it continues
to work.
I have attached a testcase. If the testcase doesn't trigger for
you, figure out how many vbox widgets allow for only one to be
offscreen, and it should then trigger. I also note that while I call
gtk_progress_bar_set_fraction(bar, 0.0), the progress bar's thumb does
not go away when the scrolled window fails to update correctly.
Joel
--
"Depend on the rabbit's foot if you will, but remember, it didn't
help the rabbit."
- R. E. Shay
http://www.jlbec.org/
jlbec evilplan org
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <glib.h>
#include <gtk/gtk.h>
static void do_quit(GtkWidget *widget, gpointer user_data)
{
gtk_main_quit();
}
static gboolean do_timeout(gpointer user_data)
{
gint i;
gchar *tmp;
GtkWidget *button, *box, *fr, *bar;
gint id;
box = GTK_WIDGET(user_data);
for (i = 0; i < 11; i++)
{
tmp = g_strdup_printf("Button %d", i);
button = gtk_label_new(tmp);
g_free(tmp);
gtk_box_pack_start(GTK_BOX(box), button, FALSE, FALSE, 2);
}
gtk_widget_show_all(box);
id = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(box),
"progress"));
fr = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(box), "frame"));
bar = GTK_WIDGET(gtk_object_get_data(GTK_OBJECT(box), "bar"));
g_source_remove(id);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(bar), 0.0);
gtk_frame_set_label(GTK_FRAME(fr), "Hello");
gtk_widget_set_sensitive(fr, TRUE);
return(FALSE);
}
gint main(gint argc, gchar *argv[])
{
GtkWidget *top, *nb, *sc, *box, *tbox, *bar, *fr;
gint id;
gtk_set_locale();
gtk_init(&argc, &argv);
top = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size(GTK_WINDOW(top), 300, 300);
gtk_container_set_border_width(GTK_CONTAINER(top), 5);
gtk_signal_connect(GTK_OBJECT(top), "destroy",
GTK_SIGNAL_FUNC(do_quit), NULL);
gtk_signal_connect(GTK_OBJECT(top), "delete-event",
GTK_SIGNAL_FUNC(do_quit), NULL);
nb = gtk_notebook_new();
gtk_notebook_set_show_tabs(GTK_NOTEBOOK(nb), FALSE);
gtk_notebook_set_show_border(GTK_NOTEBOOK(nb), FALSE);
sc = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sc),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_set_border_width(GTK_CONTAINER(sc), 3);
box = gtk_vbox_new(FALSE, 2);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sc), box);
gtk_notebook_append_page(GTK_NOTEBOOK(nb), sc, NULL);
fr = gtk_frame_new(NULL);
gtk_container_add(GTK_CONTAINER(fr), nb);
tbox = gtk_vbox_new(FALSE, 2);
gtk_box_pack_start(GTK_BOX(tbox), fr, TRUE, TRUE, 2);
bar = gtk_progress_bar_new();
gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(bar),
GTK_PROGRESS_LEFT_TO_RIGHT);
gtk_progress_bar_set_bar_style(GTK_PROGRESS_BAR(bar),
GTK_PROGRESS_CONTINUOUS);
gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(bar), 0.05);
gtk_box_pack_end(GTK_BOX(tbox), bar, FALSE, FALSE, 2);
gtk_object_set_data(GTK_OBJECT(box), "frame", fr);
gtk_object_set_data(GTK_OBJECT(box), "bar", bar);
gtk_container_add(GTK_CONTAINER(top), tbox);
id = g_timeout_add(100, (GtkFunction)gtk_progress_bar_pulse, bar);
gtk_object_set_data(GTK_OBJECT(box), "progress",
GINT_TO_POINTER(id));
g_timeout_add(1000, do_timeout, box);
gtk_widget_set_sensitive(fr, FALSE);
gtk_widget_show_all(top);
gtk_main();
return(0);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]