Re: Trouble with vbox allocation.
- From: Angelo Cano <acano systec com>
- To: gtk-app-devel-list gnome org
- Subject: Re: Trouble with vbox allocation.
- Date: Thu, 29 Mar 2001 11:53:56 -0500
On Wed, Mar 28, 2001 at 10:43:39AM +0200, Lecomte Jean François wrote:
Hi there,
i've one vbox which contains many other small widgets...
But at the end, size requested by all these widgets exceeded the 32767 max
size of the widget container.
And obviously the (x,y) position of some of these widgets at the end of
the list step over this limit.
I just want to make these widgets scrollable in a viewport, could you
tell me how to avoid this trouble.
Any suggestion ?
Any examples ?
GtkLayout doesn't have that size limitation:
/* GtkLayout acting as a big GtkVBox */
#include <gtk/gtk.h>
GtkWidget *layout;
gint x = 0;
gint y = 0;
void add_to_layout (GtkWidget *widget)
{
GtkRequisition req;
gtk_widget_size_request (widget, &req);
gtk_layout_put (GTK_LAYOUT (layout), widget, x, 0);
x += req.width;
y = MAX (y, req.height);
gtk_layout_set_size (GTK_LAYOUT (layout), x, y);
}
int main (int argc, char *argv[])
{
GtkWidget *window, *scrolled_window, *button;
gint i;
gchar *label;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize (window, 400, 200);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (window), scrolled_window);
layout = gtk_layout_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled_window), layout);
for (i = 0; i < 1000; i++) {
label = g_strdup_printf ("button %d", i);
button = gtk_button_new_with_label (label);
g_free (label);
add_to_layout (button);
}
g_print ("width: %d height: %d\n", x, y);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
Thanks
--
--
J-François LECOMTE IDEALX S.A.S.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]