File: test-proxy-preferences.c

package info (click to toggle)
evolution 3.12.9~git20141130.241663-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 135,148 kB
  • ctags: 42,742
  • sloc: ansic: 398,340; sh: 11,322; xml: 6,861; makefile: 4,982; perl: 164
file content (85 lines) | stat: -rw-r--r-- 2,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
 * test-proxy-preferences.c
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <e-util/e-util.h>

static EProxyPreferences *preferences;

static gboolean
quit_delay_cb (gpointer user_data)
{
	gtk_main_quit ();

	return FALSE;
}

static gint
delete_event_cb (GtkWidget *widget,
                 GdkEventAny *event,
                 gpointer data)
{
	e_proxy_preferences_submit (preferences);

	/* Cycle the main loop for a bit longer to
	 * give the commit operation time to finish. */
	g_timeout_add_seconds (1, quit_delay_cb, NULL);

	return FALSE;
}

gint
main (gint argc,
      gchar **argv)
{
	ESourceRegistry *registry;
	GtkWidget *window;
	GtkWidget *widget;
	GError *local_error = NULL;

	gtk_init (&argc, &argv);

	registry = e_source_registry_new_sync (NULL, &local_error);

	if (local_error != NULL) {
		g_error (
			"Failed to load ESource registry: %s",
			local_error->message);
		g_assert_not_reached ();
	}

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width (GTK_CONTAINER (window), 12);
	gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
	gtk_window_set_title (GTK_WINDOW (window), "Proxy Preferences");
	gtk_widget_show (window);

	g_signal_connect (
		window, "delete-event",
		G_CALLBACK (delete_event_cb), NULL);

	widget = e_proxy_preferences_new (registry);
	gtk_container_add (GTK_CONTAINER (window), widget);
	preferences = E_PROXY_PREFERENCES (widget);
	gtk_widget_show (widget);

	g_object_unref (registry);

	gtk_main ();

	return 0;
}