Missed commit in order to fix compilation using '--enable-fatal' and '--disable-depre...
[hildon] / examples / hildon-banner-example.c
1 /*
2  * This file is a part of hildon examples
3  *
4  * Copyright (C) 2005, 2006, 2009 Nokia Corporation, all rights reserved.
5  *
6  * Author: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation; version 2.1 of
11  * the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21  * 02110-1301 USA
22  *
23  */
24
25 #include                                        <hildon/hildon.h>
26
27 #ifndef HILDON_DISABLE_DEPRECATED
28
29 static gboolean
30 on_animation_idle                               (GtkWidget *banner)
31 {
32     gtk_widget_destroy (banner);
33     g_object_unref (banner);
34     return FALSE;
35 }
36
37 static gboolean
38 on_progress_idle                                (GtkWidget *banner)
39 {
40     gtk_widget_destroy (banner);
41     g_object_unref (banner);
42     return FALSE;
43 }
44
45 #endif
46
47 static gboolean
48 on_information_clicked                          (GtkWidget *widget)
49 {
50     GtkWidget* banner = hildon_banner_show_information (widget, NULL, "Information banner");
51     hildon_banner_set_timeout (HILDON_BANNER (banner), 9000);
52     return TRUE;
53 }
54
55 #ifndef HILDON_DISABLE_DEPRECATED
56
57 static gboolean
58 on_animation_clicked                            (GtkWidget *widget)
59 {
60     GtkWidget *banner = hildon_banner_show_animation (widget, NULL, "Animation banner");
61     g_object_ref (banner);
62     gdk_threads_add_timeout (5000, (GSourceFunc) on_animation_idle, banner);
63     return TRUE;
64 }
65
66 static gboolean
67 on_progress_clicked                             (GtkWidget *widget)
68 {
69     GtkWidget *banner = hildon_banner_show_progress (widget, NULL, "Progress banner");
70     g_object_ref (banner);
71     gdk_threads_add_timeout (5000, (GSourceFunc) on_progress_idle, banner);
72     return TRUE;
73 }
74
75 #endif
76
77 int
78 main                                            (int argc,
79                                                  char **argv)
80 {
81     HildonProgram *program;
82     GtkWidget *window, *vbox, *button1;
83 #ifndef HILDON_DISABLE_DEPRECATED
84     GtkWidget *button2, *button3;
85 #endif
86
87     hildon_gtk_init (&argc, &argv);
88
89     window = hildon_window_new ();
90     program = hildon_program_get_instance ();
91     hildon_program_add_window (program, HILDON_WINDOW (window));
92
93     button1 = gtk_button_new_with_label ("Information");
94     g_signal_connect (button1, "clicked", G_CALLBACK (on_information_clicked), NULL);
95
96 #ifndef HILDON_DISABLE_DEPRECATED
97     button2 = gtk_button_new_with_label ("Animation");
98     g_signal_connect (button2, "clicked", G_CALLBACK (on_animation_clicked), NULL);
99
100     button3 = gtk_button_new_with_label ("Progress");
101     g_signal_connect (button3, "clicked", G_CALLBACK (on_progress_clicked), NULL);
102 #endif
103
104     vbox = gtk_vbox_new (6, FALSE);
105     gtk_box_pack_start (GTK_BOX (vbox), button1, TRUE, TRUE, 0);
106 #ifndef HILDON_DISABLE_DEPRECATED
107     gtk_box_pack_start (GTK_BOX (vbox), button2, TRUE, TRUE, 0);
108     gtk_box_pack_start (GTK_BOX (vbox), button3, TRUE, TRUE, 0);
109 #endif
110
111     gtk_container_set_border_width (GTK_CONTAINER (window), 6);
112     gtk_container_add (GTK_CONTAINER (window), vbox);
113
114     gtk_widget_show_all (window);
115
116     g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
117
118     gtk_main ();
119     return 0;
120 }