Debian Codegraph @

src/theme.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
24 static GtkIconTheme *icon_theme = NULL;
25
26 void cui_theme_get_tethering_icone_and_info(GdkPixbuf **image,
27 const char **info)
28 {
29 if (image != NULL)
30 *image = gtk_icon_theme_load_icon(icon_theme,
31 "nm-adhoc", 24, 0, NULL);
32 if (info != NULL)
33 *info = _("Tethering");
34 }
35
36 void cui_theme_get_type_icone_and_info(const char *type,
37 GdkPixbuf **image, const char **info)
38 {
39 const char *nfo = NULL;
40 GdkPixbuf *img = NULL;
41
42 if (g_strcmp0(type, "ethernet") == 0) {
43 img = gtk_icon_theme_load_icon(icon_theme,
44 "network-wired-symbolic", 22, 0, NULL);
45 nfo = _("Ethernet");
46 } else if (g_strcmp0(type, "cellular") == 0) {
47 img = gtk_icon_theme_load_icon(icon_theme,
48 "gsm-3g-full", 22, 0, NULL);
49 nfo = _("Cellular");
50 }
51
52 if (image != NULL)
53 *image = img;
54
55 if (info != NULL)
56 *info = nfo;
57 }
58
59 void cui_theme_get_signal_icone_and_info(uint8_t signal_strength,
60 GdkPixbuf **image, const char **info)
61 {
62 const char *nfo;
63 GdkPixbuf *img;
64
65 if (signal_strength >= 80) {
66 img = gtk_icon_theme_load_icon(icon_theme,
67 "network-wireless-signal-excellent-symbolic", 22, 0, NULL);
68 nfo = _("Very good signal");
69 } else if (signal_strength >= 60 && signal_strength < 80) {
70 img = gtk_icon_theme_load_icon(icon_theme,
71 "network-wireless-signal-good-symbolic", 22, 0, NULL);
72 nfo = _("Good signal");
73 } else if (signal_strength >= 40 && signal_strength < 60) {
74 img = gtk_icon_theme_load_icon(icon_theme,
75 "network-wireless-signal-ok-symbolic", 22, 0, NULL);
76 nfo = _("Low signal");
77 } else {
78 img = gtk_icon_theme_load_icon(icon_theme,
79 "network-wireless-signal-weak-symbolic", 22, 0, NULL);
80 nfo = _("Very low signal");
81 }
82
83 if (image != NULL)
84 *image = img;
85
86 if (info != NULL)
87 *info = nfo;
88
89 }
90
91 void cui_theme_get_state_icone_and_info(enum connman_state state,
92 GdkPixbuf **image, const char **info)
93 {
94 const char *nfo = NULL;
95 GdkPixbuf *img = NULL;
96
97
98 switch (state) {
99 case CONNMAN_STATE_UNKNOWN:
100 img = gtk_icon_theme_load_icon(icon_theme,
101 "network-offline-symbolic", 24, 0, NULL);
102 nfo = _("Connman is not running");
103 break;
104 case CONNMAN_STATE_READY:
105 img = gtk_icon_theme_load_icon(icon_theme,
106 "network-idle-symbolic", 24, 0, NULL);
107 nfo = _("Connected");
108 break;
109 case CONNMAN_STATE_ONLINE:
110 img = gtk_icon_theme_load_icon(icon_theme,
111 "network-transmit-receive-symbolic", 24, 0, NULL);
112 nfo = _("Online");
113 break;
114 default:
115 img = gtk_icon_theme_load_icon(icon_theme,
116 "network-offline-symbolic", 24, 0, NULL);
117 nfo = _("Disconnected");
118
119 break;
120 }
121
122 if (image != NULL)
123 *image = img;
124
125 if (info != NULL)
126 *info = nfo;
127 }
128
129 void cui_load_theme(void)
130 {
131 icon_theme = gtk_icon_theme_get_default ();
132 gtk_icon_theme_append_search_path(icon_theme, CUI_ICON_PATH);
133 }