]> Pileus Git - ~andy/gtk/blob - examples/arrow/arrow.c
finish conversion to g_signal_* functions by using G_OBJECT and G_CALLBACK
[~andy/gtk] / examples / arrow / arrow.c
1
2 #include <gtk/gtk.h>
3
4 /* Create an Arrow widget with the specified parameters
5  * and pack it into a button */
6 GtkWidget *create_arrow_button( GtkArrowType  arrow_type,
7                                 GtkShadowType shadow_type )
8 {
9   GtkWidget *button;
10   GtkWidget *arrow;
11
12   button = gtk_button_new ();
13   arrow = gtk_arrow_new (arrow_type, shadow_type);
14
15   gtk_container_add (GTK_CONTAINER (button), arrow);
16   
17   gtk_widget_show (button);
18   gtk_widget_show (arrow);
19
20   return button;
21 }
22
23 int main( int   argc,
24           char *argv[] )
25 {
26   /* GtkWidget is the storage type for widgets */
27   GtkWidget *window;
28   GtkWidget *button;
29   GtkWidget *box;
30
31   /* Initialize the toolkit */
32   gtk_init (&argc, &argv);
33
34   /* Create a new window */
35   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
36
37   gtk_window_set_title (GTK_WINDOW (window), "Arrow Buttons");
38
39   /* It's a good idea to do this for all windows. */
40   g_signal_connect (G_OBJECT (window), "destroy",
41                     G_CALLBACK (gtk_main_quit), NULL);
42
43   /* Sets the border width of the window. */
44   gtk_container_set_border_width (GTK_CONTAINER (window), 10);
45
46   /* Create a box to hold the arrows/buttons */
47   box = gtk_hbox_new (FALSE, 0);
48   gtk_container_set_border_width (GTK_CONTAINER (box), 2);
49   gtk_container_add (GTK_CONTAINER (window), box);
50
51   /* Pack and show all our widgets */
52   gtk_widget_show (box);
53
54   button = create_arrow_button (GTK_ARROW_UP, GTK_SHADOW_IN);
55   gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);
56
57   button = create_arrow_button (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
58   gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);
59   
60   button = create_arrow_button (GTK_ARROW_LEFT, GTK_SHADOW_ETCHED_IN);
61   gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);
62   
63   button = create_arrow_button (GTK_ARROW_RIGHT, GTK_SHADOW_ETCHED_OUT);
64   gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);
65   
66   gtk_widget_show (window);
67   
68   /* Rest in gtk_main and wait for the fun to begin! */
69   gtk_main ();
70   
71   return 0;
72 }