[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: GtkScrolledWindow trouble
- From: Alexander Mosley <alex mosley mailandnews com>
- To: gtk-app-devel-list redhat com
- Subject: Re: GtkScrolledWindow trouble
- Date: Thu, 07 Oct 1999 18:49:13 +0100
Alexander J Mosley wrote:
>
> I am new to gtk programming. I am having trouble
> using a scrolled window as a container for a
> clist. When I clear the clist and repopulate it,
> the scrolled window does not reflect the new
> length of the clist. If the clist has grown in
> length, it is not possible to view all elements of
> the clist. How do I get the scrolled window to
> adjust itself to accommodate the revised clist?
My clist is on one page of a notebook and is being
updated by actions on another page of the
notebook. When I return to the page containing the
clist, the clist has been updated, but the
scrolled window has not adjusted to the revised
clist. Resizing the window forces the scrolled
window to adjust, but I would like to force it.
Any hints?
I have included a small demo below illustrating my
problem. The button on the second page of the
notebook adds a lot of stuff to the clist on the
first page. Returning to the first page, the
scrolled window does not adjust unless the window
is resized.
I'm sure there is a simple solution to this
problem. If you know please tell me.
#include <gtk/gtk.h>
void delete(GtkWidget *widget, GtkWidget *event,
gpointer data) {
gtk_main_quit();
}
void button_cb(GtkWidget *widget, void *data) {
int index;
gchar *entry[1] = {"Another Item"};
for (index=0;index<100;index++) {
gtk_clist_append(GTK_CLIST(data), entry);
}
}
void main(int argc, char *argv[]) {
GtkWidget *window;
GtkWidget *button;
GtkWidget *notebook;
GtkWidget *label;
GtkWidget *scrolled_window, *clist;
gchar *titles[1] = {"List"};
gchar *entry[1] = {"An Item"};
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize(window, 150, 250);
gtk_signal_connect(GTK_OBJECT(window),
"delete_event",
GTK_SIGNAL_FUNC(delete), NULL);
gtk_container_set_border_width(GTK_CONTAINER
(window), 10);
notebook = gtk_notebook_new();
gtk_container_add(GTK_CONTAINER(window),
notebook);
scrolled_window = gtk_scrolled_window_new(NULL,
NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
(scrolled_window),
GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
clist = gtk_clist_new_with_titles( 1, titles);
gtk_clist_append(GTK_CLIST(clist), entry);
gtk_container_add(GTK_CONTAINER(scrolled_window),
clist);
label = gtk_label_new("CList");
gtk_notebook_append_page(GTK_NOTEBOOK
(notebook), scrolled_window, label);
button = gtk_button_new_with_label("Add stuff to
list");
gtk_signal_connect(GTK_OBJECT(button),
"clicked",
GTK_SIGNAL_FUNC(button_cb), clist);
label = gtk_label_new("Add Stuff");
gtk_notebook_append_page(GTK_NOTEBOOK
(notebook), button, label);
gtk_widget_show_all(window);
gtk_main();
}
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]