]> git.draconx.ca Git - aspectbin.git/blob - examples/simplebuttons.c
Update .gitignore.
[aspectbin.git] / examples / simplebuttons.c
1 /* AspectBin - A GTK+ container for packing with consrained aspect ratio.
2  * Copyright (C) 2009 Nick Bowler
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <stdlib.h>
21 #include <gtk/gtk.h>
22 #include <aspectbin.h>
23
24 int main(int argc, char **argv)
25 {
26         GtkWidget *window;
27         GtkWidget *aspectbin;
28         GtkWidget *button1, *button2;
29
30         gtk_init(&argc, &argv);
31
32         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
33         gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
34
35         aspectbin = aspect_bin_new();
36         button1 = gtk_button_new_with_label("Square");
37         button2 = gtk_button_new_with_label("Rectangle");
38
39         aspect_bin_set_body(ASPECT_BIN(aspectbin), button1, 1.0);
40         aspect_bin_set_side(ASPECT_BIN(aspectbin), button2);
41
42         g_object_set(G_OBJECT(aspectbin),
43                 "constrain", TRUE,
44                 NULL);
45         gtk_container_child_set(GTK_CONTAINER(aspectbin), button1,
46                 "align", 0.5,
47                 NULL);
48
49         gtk_container_add(GTK_CONTAINER(window), aspectbin);
50
51         g_signal_connect (G_OBJECT(window), "destroy",
52                 G_CALLBACK(gtk_main_quit), NULL);
53
54         gtk_widget_show_all(window);
55         gtk_main();
56
57         return 0;
58 }