Debian Codegraph @

src/main.c

raw symbols SCIP
1 /*
2 *
3 * Connection Manager UI
4 *
5 * Copyright (C) 2012 Intel Corporation. All rights reserved.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * 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
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 *
20 */
21
22 #include <connman-ui-gtk.h>
23 #include <connman-interface.h>
24
25 #include <config.h>
26
27 GtkBuilder *cui_builder;
28
29 static void connman_manager_changed(const char *unused,
30 const char *property, void *user_data)
31 {
32 if (g_strcmp0(property, "State") == 0)
33 cui_trayicon_update_icon();
34 }
35
36 static void connman_up(void *user_data)
37 {
38 connman_manager_init(connman_manager_changed, NULL);
39 connman_service_init();
40 connman_technology_init();
41 connman_agent_init();
42 cui_agent_init_callbacks();
43
44 cui_trayicon_update_icon();
45
46 cui_tray_enable();
47 cui_right_menu_enable_all();
48 }
49
50 static void connman_down(void *user_data)
51 {
52 connman_agent_finalize();
53 connman_service_finalize();
54 connman_technology_finalize();
55 connman_manager_finalize();
56
57 cui_trayicon_update_icon();
58
59 cui_tray_left_menu_disable();
60 cui_right_menu_enable_only_quit();
61 }
62
63 int main(int argc, char *argv[])
64 {
65 int ret;
66
67 setlocale(LC_ALL, "");
68
69 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
70 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
71
72 textdomain(GETTEXT_PACKAGE);
73
74 printf("%s\n", GETTEXT_PACKAGE);
75
76 gtk_init(&argc, &argv);
77
78 cui_builder = gtk_builder_new();
79 if (cui_builder == NULL)
80 return -ENOMEM;
81
82 cui_load_theme();
83
84 if (cui_load_trayicon(cui_builder) != 0)
85 return -EINVAL;
86
87 if (cui_load_agent_dialogs() != 0)
88 return -EINVAL;
89
90 cui_tray_enable();
91
92 ret = connman_interface_init(connman_up, connman_down, NULL);
93 if (ret < 0)
94 return ret;
95
96 gtk_main();
97
98 connman_agent_finalize();
99 connman_service_finalize();
100 connman_technology_finalize();
101 connman_manager_finalize();
102 connman_interface_finalize();
103
104 return 0;
105 }
106