Update simplebuttons example.
[aspectbin.git] / examples / simplebuttons.c
blob7026829f87c4697793b04fc187b43c0cf80abe72
1 /* AspectBin - A GTK+ container for packing with consrained aspect ratio.
2 * Copyright (C) 2009 Nick Bowler
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.
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.
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.
20 #include <stdlib.h>
21 #include <gtk/gtk.h>
22 #include <aspectbin.h>
24 int main(int argc, char **argv)
26 GtkWidget *window;
27 GtkWidget *aspectbin;
28 GtkWidget *button1, *button2;
30 gtk_init(&argc, &argv);
32 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
33 gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
35 aspectbin = aspect_bin_new();
36 button1 = gtk_button_new_with_label("Square");
37 button2 = gtk_button_new_with_label("Rectangle");
39 aspect_bin_set_body(ASPECT_BIN(aspectbin), button1, 1.0);
40 aspect_bin_set_side(ASPECT_BIN(aspectbin), button2);
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);
49 gtk_container_add(GTK_CONTAINER(window), aspectbin);
51 g_signal_connect (G_OBJECT(window), "destroy",
52 G_CALLBACK(gtk_main_quit), NULL);
54 gtk_widget_show_all(window);
55 gtk_main();
57 return 0;