Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / libedataserverui / test-source-option-menu.c
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* test-source-option-menu.c - Test for ESourceOptionMenu.
3  *
4  * Copyright (C) 2003 Novell, Inc.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * Author: Ettore Perazzoli <ettore@ximian.com>
21  */
22
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26
27
28 #include "e-source-option-menu.h"
29
30 #include <gtk/gtkwindow.h>
31 #include <gtk/gtkmain.h>
32
33 static void
34 source_selected_callback (ESourceOptionMenu *menu,
35                           ESource *source,
36                           void *unused_data)
37 {
38         g_print ("source selected: \"%s\"\n", e_source_peek_name (source));
39 }
40
41
42 static int
43 on_idle_create_widget (const char *gconf_path)
44 {
45         GtkWidget *window;
46         GtkWidget *option_menu;
47         ESourceList *source_list;
48         GConfClient *gconf_client;
49
50         gconf_client = gconf_client_get_default ();
51         source_list = e_source_list_new_for_gconf (gconf_client, gconf_path);
52
53         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
54         option_menu = e_source_option_menu_new (source_list);
55         g_signal_connect (option_menu, "source_selected", G_CALLBACK (source_selected_callback), NULL);
56
57         gtk_container_add (GTK_CONTAINER (window), option_menu);
58         gtk_widget_show_all (window);
59
60         g_object_unref (gconf_client);
61         g_object_unref (source_list);
62
63         return FALSE;
64 }
65
66
67 int
68 main (int argc, char **argv)
69 {
70         const char *gconf_path;
71
72         gtk_init (&argc, &argv);
73         
74         if (argc < 2)
75                 gconf_path = "/apps/evolution/calendar/sources";
76         else
77                 gconf_path = argv [1];
78
79         g_idle_add ((GSourceFunc) on_idle_create_widget, (void *) gconf_path);
80
81         gtk_main ();
82
83         return 0;
84 }