Make sure that all timeouts in HildonBanner are removed
[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 void
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 }
53
54 #ifndef HILDON_DISABLE_DEPRECATED
55
56 static void
57 on_animation_clicked                            (GtkWidget *widget)
58 {
59     GtkWidget *banner = hildon_banner_show_animation (widget, NULL, "Animation banner");
60     g_object_ref (banner);
61     gdk_threads_add_timeout (5000, (GSourceFunc) on_animation_idle, banner);
62 }
63
64 static void
65 on_progress_clicked                             (GtkWidget *widget)
66 {
67     GtkWidget *banner = hildon_banner_show_progress (widget, NULL, "Progress banner");
68     g_object_ref (banner);
69     gdk_threads_add_timeout (5000, (GSourceFunc) on_progress_idle, banner);
70 }
71
72 #endif
73
74 int
75 main                                            (int argc,
76                                                  char **argv)
77 {
78     HildonProgram *program;
79     GtkWidget *window, *vbox, *button1;
80 #ifndef HILDON_DISABLE_DEPRECATED
81     GtkWidget *button2, *button3;
82 #endif
83
84     hildon_gtk_init (&argc, &argv);
85
86     window = hildon_window_new ();
87     program = hildon_program_get_instance ();
88     hildon_program_add_window (program, HILDON_WINDOW (window));
89
90     button1 = gtk_button_new_with_label ("Information");
91     g_signal_connect (button1, "clicked", G_CALLBACK (on_information_clicked), NULL);
92
93 #ifndef HILDON_DISABLE_DEPRECATED
94     button2 = gtk_button_new_with_label ("Animation");
95     g_signal_connect (button2, "clicked", G_CALLBACK (on_animation_clicked), NULL);
96
97     button3 = gtk_button_new_with_label ("Progress");
98     g_signal_connect (button3, "clicked", G_CALLBACK (on_progress_clicked), NULL);
99 #endif
100
101     vbox = gtk_vbox_new (6, FALSE);
102     gtk_box_pack_start (GTK_BOX (vbox), button1, TRUE, TRUE, 0);
103 #ifndef HILDON_DISABLE_DEPRECATED
104     gtk_box_pack_start (GTK_BOX (vbox), button2, TRUE, TRUE, 0);
105     gtk_box_pack_start (GTK_BOX (vbox), button3, TRUE, TRUE, 0);
106 #endif
107
108     gtk_container_set_border_width (GTK_CONTAINER (window), 6);
109     gtk_container_add (GTK_CONTAINER (window), vbox);
110
111     gtk_widget_show_all (window);
112
113     g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
114
115     gtk_main ();
116     return 0;
117 }