Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / libedataserverui / test-name-selector.c
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
3 /* test-name-selector.c - Test for name selector components.
4  *
5  * Copyright (C) 2004 Novell, Inc.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2 of the GNU Lesser General Public
9  * License as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this program; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * Author: Hans Petter Jansson <hpj@novell.com>
22  */
23
24 #ifdef HAVE_CONFIG_H
25 # include <config.h>
26 #endif
27
28 #include "e-name-selector-model.h"
29 #include "e-name-selector-dialog.h"
30 #include "e-name-selector-entry.h"
31 #include <gtk/gtk.h>
32 #include <camel/camel.h>
33
34 ENameSelectorDialog *name_selector_dialog;
35 GtkWidget           *name_selector_entry_window;
36
37 static void
38 close_dialog (GtkWidget *widget, int response, gpointer data)
39 {
40         gtk_widget_destroy (GTK_WIDGET (name_selector_dialog));
41         gtk_widget_destroy (name_selector_entry_window);
42
43         g_timeout_add (4000, (GSourceFunc) gtk_main_quit, NULL);
44 }
45
46 static gboolean
47 start_test (void)
48 {
49         ENameSelectorModel  *name_selector_model;
50         ENameSelectorEntry  *name_selector_entry;
51         EDestinationStore   *destination_store;
52         GtkWidget           *container;
53
54         destination_store = e_destination_store_new ();
55         name_selector_model = e_name_selector_model_new ();
56
57         e_name_selector_model_add_section (name_selector_model, "to", "To", destination_store);
58         e_name_selector_model_add_section (name_selector_model, "cc", "Cc", NULL);
59         e_name_selector_model_add_section (name_selector_model, "bcc", "Bcc", NULL);
60
61         name_selector_dialog = e_name_selector_dialog_new ();
62         e_name_selector_dialog_set_model (name_selector_dialog, name_selector_model);
63         gtk_window_set_modal(GTK_WINDOW (name_selector_dialog), FALSE);
64
65         name_selector_entry = e_name_selector_entry_new ();
66         e_name_selector_entry_set_destination_store (name_selector_entry, destination_store);
67
68         g_signal_connect (name_selector_dialog, "response", G_CALLBACK (close_dialog), name_selector_dialog);
69         gtk_widget_show (GTK_WIDGET (name_selector_dialog));
70
71         container = gtk_window_new (GTK_WINDOW_TOPLEVEL);
72         gtk_container_add (GTK_CONTAINER (container), GTK_WIDGET (name_selector_entry));
73         gtk_widget_show_all (container);
74
75         name_selector_entry_window = container;
76
77         g_object_unref (name_selector_model);
78         g_object_unref (destination_store);
79         return FALSE;
80 }
81
82 int
83 main (int argc, char **argv)
84 {
85         gtk_init (&argc, &argv);
86         g_thread_init (NULL);
87
88         camel_init (NULL, 0);
89
90         g_idle_add ((GSourceFunc) start_test, NULL);
91
92         gtk_main ();
93
94         return 0;
95 }