[prev in list] [next in list] [prev in thread] [next in thread]
List: gtk-app-devel
Subject: Fwd: Resizing window
From: "=?ISO-8859-1?Q?Fernando_Apestegu=EDa?=" <fernando.apesteguia () gmail ! com>
Date: 2006-08-23 7:08:45
Message-ID: 1bd550a00608230008q27642443h5b84059db5e352ce () mail ! gmail ! com
[Download RAW message or body]
---------- Forwarded message ----------
From: Iago Rubio <iago@iagorubio.com>
Date: Aug 22, 2006 12:40 PM
Subject: Re: Resizing window
To: gtk-app-devel-list@gnome.org
On Tue, 2006-08-22 at 11:54 +0200, Iago Rubio wrote:
> On Tue, 2006-08-22 at 09:22 +0200, Fernando Apesteguía wrote:
> > I'm still looking for a solution. My app has internationalization
support.
> > So make the window fixed is not possible in order to allow all the
different
> > messages to fit in the window. I'll read more documentation.
> >
> > More ideas?
>
> Have you tried to pick the child's requisition and resize the window to
> it ?
>
> Try out the example attached.
Sorry, the attachment didn't make it.
// gcc test.c -o test `pkg-config --cflags --libs gtk+-2.0`
#include <gtk/gtk.h>
void
on_notebook_switch_page (GtkNotebook *notebook,
GtkNotebookPage *page,
guint page_num,
gpointer user_data)
{
GtkWidget *child;
GtkRequisition requisition;
child = gtk_notebook_get_nth_page (notebook,
page_num);
// pick the child's requisition
gtk_widget_size_request (child, &requisition);
// The "+10" stuff below is used because we're not taking
// into account the frame's width.
gtk_window_resize (GTK_WINDOW(user_data),
requisition.width + 10,
requisition.height + 10);
}
int main(int argc, char **argv)
{
GtkWidget *window, *window_vbox;
GtkWidget *notebook, *small_label, *big_label;
gtk_init (&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
window_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER(window), window_vbox);
gtk_widget_show (window_vbox);
notebook = gtk_notebook_new ();
gtk_widget_show (notebook);
gtk_box_pack_start (GTK_BOX (window_vbox), notebook, TRUE, TRUE, 0);
small_label = gtk_label_new ("Small label");
gtk_widget_show (small_label);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
small_label,
NULL);
big_label = gtk_label_new (
"T H I S I S A B I G G E R L A B E L"
);
gtk_widget_show (big_label);
gtk_notebook_append_page (GTK_NOTEBOOK(notebook),
big_label,
NULL);
g_signal_connect ( notebook,
"switch-page",
G_CALLBACK(on_notebook_switch_page),
window );
g_signal_connect_swapped ( window,
"delete_event",
gtk_main_quit,
NULL );
// force it to be smaller than it ought to be
gtk_widget_set_size_request (GTK_WIDGET(window), 100, 50);
gtk_widget_show (window);
gtk_main ();
return 0;
}
--
Iago Rubio
Many thanks Iago. I'll try it when I can get a bit of time.
Best regards
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic