]> Pileus Git - ~andy/gtk/blob - examples/aspectframe/aspectframe.c
f32da1b9d2625053254aada7b1a89e396f898913
[~andy/gtk] / examples / aspectframe / aspectframe.c
1
2 #include <gtk/gtk.h>
3    
4 int main( int argc,
5           char *argv[] )
6 {
7     GtkWidget *window;
8     GtkWidget *aspect_frame;
9     GtkWidget *drawing_area;
10     gtk_init (&argc, &argv);
11    
12     window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
13     gtk_window_set_title (GTK_WINDOW (window), "Aspect Frame");
14     g_signal_connect (G_OBJECT (window), "destroy",
15                       G_CALLBACK (gtk_main_quit), NULL);
16     gtk_container_set_border_width (GTK_CONTAINER (window), 10);
17    
18     /* Create an aspect_frame and add it to our toplevel window */
19    
20     aspect_frame = gtk_aspect_frame_new ("2x1", /* label */
21                                          0.5, /* center x */
22                                          0.5, /* center y */
23                                          2, /* xsize/ysize = 2 */
24                                          FALSE /* ignore child's aspect */);
25    
26     gtk_container_add (GTK_CONTAINER (window), aspect_frame);
27     gtk_widget_show (aspect_frame);
28    
29     /* Now add a child widget to the aspect frame */
30    
31     drawing_area = gtk_drawing_area_new ();
32    
33     /* Ask for a 200x200 window, but the AspectFrame will give us a 200x100
34      * window since we are forcing a 2x1 aspect ratio */
35     gtk_widget_set_size_request (drawing_area, 200, 200);
36     gtk_container_add (GTK_CONTAINER (aspect_frame), drawing_area);
37     gtk_widget_show (drawing_area);
38    
39     gtk_widget_show (window);
40     gtk_main ();
41     return 0;
42 }