1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /* test-source-combo-box.c - Test for ESourceComboBox.
4 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
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.
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.
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.
20 * Author: Ettore Perazzoli <ettore@ximian.com>
26 #include <libedataserverui/libedataserverui.h>
28 static const gchar *extension_name;
31 source_changed_cb (ESourceComboBox *combo_box)
35 source = e_source_combo_box_ref_active (combo_box);
37 const gchar *display_name;
38 display_name = e_source_get_display_name (source);
39 g_print ("source selected: \"%s\"\n", display_name);
40 g_object_unref (source);
42 g_print ("source selected: (none)\n");
47 on_idle_create_widget (ESourceRegistry *registry)
54 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
56 box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
57 gtk_container_add (GTK_CONTAINER (window), box);
59 combo_box = e_source_combo_box_new (registry, extension_name);
62 G_CALLBACK (source_changed_cb), NULL);
63 gtk_box_pack_start (GTK_BOX (box), combo_box, FALSE, FALSE, 0);
65 button = gtk_toggle_button_new_with_label ("Show Colors");
66 gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 0);
68 g_object_bind_property (
69 combo_box, "show-colors",
71 G_BINDING_SYNC_CREATE |
72 G_BINDING_BIDIRECTIONAL);
74 gtk_widget_show_all (window);
83 ESourceRegistry *registry;
86 gtk_init (&argc, &argv);
89 extension_name = E_SOURCE_EXTENSION_ADDRESS_BOOK;
91 extension_name = argv[1];
93 registry = e_source_registry_new_sync (NULL, &error);
97 "Failed to load ESource registry: %s",
99 g_assert_not_reached ();
102 g_idle_add ((GSourceFunc) on_idle_create_widget, registry);