Make sure that all timeouts in HildonBanner are removed
[hildon] / examples / hildon-banner-dnd-example.c
1 /*
2  * This file is a part of hildon examples
3  *
4  * Copyright (C) 2005, 2009 Nokia Corporation, all rights reserved.
5  *
6  * Author: Alejandro Pinheiro <apinheiro@igalia.com>
7  *
8  * Based on hildon-banner-example.c
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * as published by the Free Software Foundation; version 2.1 of
13  * the License, or (at your option) any later version.
14  *
15  * This library is distributed in the hope that it will be useful, but
16  * WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with this library; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23  * 02110-1301 USA
24  *
25  */
26
27 #include                                        <stdio.h>
28 #include                                        <stdlib.h>
29 #include                                        <glib.h>
30 #include                                        <gtk/gtk.h>
31 #include                                        <hildon/hildon.h>
32
33
34 static gboolean
35 on_information_clicked                          (GtkWidget *widget)
36 {
37   GtkWidget* banner = NULL;
38
39   banner = hildon_banner_show_information_override_dnd (widget,
40                                                         "Real important information!!");
41
42   hildon_banner_set_timeout (HILDON_BANNER (banner), 5000);
43   return TRUE;
44 }
45
46
47 int
48 main                                            (int argc,
49                                                  char **argv)
50 {
51   hildon_gtk_init (&argc, &argv);
52
53   HildonProgram *program = hildon_program_get_instance ();
54
55   GtkWidget *window = hildon_window_new ();
56
57   hildon_gtk_window_set_do_not_disturb (GTK_WINDOW (window), TRUE);
58   hildon_program_add_window (program, HILDON_WINDOW (window));
59
60   gtk_container_set_border_width (GTK_CONTAINER (window), 6);
61
62   GtkVBox *vbox = GTK_VBOX (gtk_vbox_new (6, FALSE));
63   GtkButton *button1 = 
64     GTK_BUTTON (gtk_button_new_with_label ("We are on DND mode\nPress here to show real important information"));
65
66   g_signal_connect (G_OBJECT (button1), "clicked", G_CALLBACK (on_information_clicked), NULL);
67
68   g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
69
70   gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (button1), TRUE, TRUE, 0);
71
72   gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));
73
74   gtk_widget_show_all (GTK_WIDGET (window));
75
76   gtk_main ();
77   return 0;
78 }
79
80