]> git.draconx.ca Git - aspectbin.git/blob - examples/simplebuttons.c
Add copyright and license information.
[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 void quit()
25 {
26         exit(0);
27 }
28
29 int main(int argc, char **argv)
30 {
31         GtkWidget *window;
32         GtkWidget *aspectbin;
33         GtkWidget *button1, *button2;
34
35         gtk_init(&argc, &argv);
36
37         window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
38         gtk_window_set_title(GTK_WINDOW(window), "Blargh");
39         gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
40
41         aspectbin = aspect_bin_new();
42         button1 = gtk_button_new_with_label("Square");
43         button2 = gtk_button_new_with_label("Rectangle");
44
45         gtk_container_add(GTK_CONTAINER(aspectbin), button1);
46         gtk_container_add(GTK_CONTAINER(aspectbin), button2);
47
48         g_object_set(G_OBJECT(aspectbin),
49                 "constrain", TRUE,
50                 NULL);
51         gtk_container_child_set(GTK_CONTAINER(aspectbin), button1,
52                 "align", 0.5,
53                 NULL);
54
55         gtk_container_add(GTK_CONTAINER(window), aspectbin);
56
57         g_signal_connect (G_OBJECT(window), "destroy", G_CALLBACK(quit), NULL);
58
59         gtk_widget_show_all(window);
60         gtk_main();
61
62         return 0;
63 }