1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1 |
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2 |
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
|
3 |
*
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
|
7 |
* (at your option) any later version.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
14 |
* You should have received a copy of the GNU General Public License along
|
15 |
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
16 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
17 |
*
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
18 |
* Copyright (C) 2004 - 2011 Red Hat, Inc.
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
19 |
* Copyright (C) 2005 - 2008 Novell, Inc.
|
20 |
*
|
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
21 |
* This applet used the GNOME Wireless Applet as a skeleton to build from.
|
22 |
*
|
|
23 |
* GNOME Wireless Applet Authors:
|
|
24 |
* Eskil Heyn Olsen <eskil@eskil.dk>
|
|
25 |
* Bastien Nocera <hadess@hadess.net> (Gnome2 port)
|
|
26 |
*
|
|
27 |
* (C) Copyright 2001, 2002 Free Software Foundation
|
|
28 |
*/
|
|
29 |
||
30 |
#ifdef HAVE_CONFIG_H
|
|
31 |
#include <config.h> |
|
32 |
#endif
|
|
33 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
34 |
#include <time.h> |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
35 |
#include <string.h> |
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
36 |
#include <strings.h> |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
37 |
#include <gtk/gtk.h> |
38 |
#include <glib/gi18n.h> |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
39 |
#include <unistd.h> |
40 |
#include <sys/socket.h> |
|
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
41 |
#include <stdlib.h> |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
42 |
|
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
43 |
#include <gio/gio.h> |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
44 |
#include <dbus/dbus-glib.h> |
45 |
#include <dbus/dbus-glib-lowlevel.h> |
|
46 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
47 |
#include <NetworkManagerVPN.h> |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
48 |
#include <nm-device.h> |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
49 |
#include <nm-device-ethernet.h> |
50 |
#include <nm-device-wifi.h> |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
51 |
#include <nm-device-modem.h> |
1.2.4
by Tony Espy
Import upstream version 0.8~a~git.20090805t131328.d1edfce |
52 |
#include <nm-device-bt.h> |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
53 |
#include <nm-device-wimax.h> |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
54 |
#include <nm-utils.h> |
55 |
#include <nm-connection.h> |
|
56 |
#include <nm-vpn-connection.h> |
|
57 |
#include <nm-setting-connection.h> |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
58 |
#include <nm-setting-wired.h> |
59 |
#include <nm-setting-wireless.h> |
|
60 |
#include <nm-setting-pppoe.h> |
|
61 |
#include <nm-setting-gsm.h> |
|
62 |
#include <nm-setting-cdma.h> |
|
63 |
#include <nm-setting-bluetooth.h> |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
64 |
#include <nm-setting-vpn.h> |
65 |
#include <nm-active-connection.h> |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
66 |
#include <nm-secret-agent.h> |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
67 |
|
68 |
#include <gconf/gconf-client.h> |
|
69 |
#include <libnotify/notify.h> |
|
70 |
||
71 |
#include "applet.h" |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
72 |
#include "applet-device-wired.h" |
73 |
#include "applet-device-wifi.h" |
|
74 |
#include "applet-device-gsm.h" |
|
75 |
#include "applet-device-cdma.h" |
|
1.2.4
by Tony Espy
Import upstream version 0.8~a~git.20090805t131328.d1edfce |
76 |
#include "applet-device-bt.h" |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
77 |
#include "applet-device-wimax.h" |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
78 |
#include "applet-dialogs.h" |
1.2.25
by Mathieu Trudel-Lapierre
Import upstream version 0.9.1.90 |
79 |
#include "nm-wireless-dialog.h" |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
80 |
#include "applet-vpn-request.h" |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
81 |
#include "utils.h" |
82 |
#include "gconf-helpers.h" |
|
83 |
||
1.1.14
by Alexander Sack
Import upstream version 0.7.1~rc4 |
84 |
#define NOTIFY_CAPS_ACTIONS_KEY "actions"
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
85 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
86 |
extern gboolean shell_debug; |
87 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
88 |
G_DEFINE_TYPE(NMApplet, nma, G_TYPE_OBJECT) |
89 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
90 |
/********************************************************************/
|
91 |
/* Temporary dbus interface stuff */
|
|
92 |
||
93 |
static gboolean |
|
94 |
impl_dbus_connect_to_hidden_network (NMApplet *applet, GError **error) |
|
95 |
{
|
|
96 |
if (!applet_wifi_connect_to_hidden_network (applet)) { |
|
97 |
g_set_error_literal (error, |
|
98 |
NM_SECRET_AGENT_ERROR, |
|
99 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
100 |
"Failed to create wireless dialog"); |
|
101 |
return FALSE; |
|
102 |
}
|
|
103 |
||
104 |
return TRUE; |
|
105 |
}
|
|
106 |
||
107 |
static gboolean |
|
108 |
impl_dbus_create_wifi_network (NMApplet *applet, GError **error) |
|
109 |
{
|
|
110 |
if (!applet_wifi_can_create_wifi_network (applet)) { |
|
111 |
g_set_error_literal (error, |
|
112 |
NM_SECRET_AGENT_ERROR, |
|
113 |
NM_SECRET_AGENT_ERROR_NOT_AUTHORIZED, |
|
114 |
"Creation of wifi networks has been disabled by system policy."); |
|
115 |
return FALSE; |
|
116 |
}
|
|
117 |
||
118 |
if (!applet_wifi_create_wifi_network (applet)) { |
|
119 |
g_set_error_literal (error, |
|
120 |
NM_SECRET_AGENT_ERROR, |
|
121 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
122 |
"Failed to create wireless dialog"); |
|
123 |
return FALSE; |
|
124 |
}
|
|
125 |
||
126 |
return TRUE; |
|
127 |
}
|
|
128 |
||
129 |
static gboolean |
|
130 |
impl_dbus_connect_to_8021x_network (NMApplet *applet, |
|
131 |
const char *device_path, |
|
132 |
const char *ap_path, |
|
133 |
GError **error) |
|
134 |
{
|
|
135 |
NMDevice *device; |
|
136 |
NMAccessPoint *ap; |
|
137 |
||
138 |
device = nm_client_get_device_by_path (applet->nm_client, device_path); |
|
139 |
if (!device || NM_IS_DEVICE_WIFI (device) == FALSE) { |
|
140 |
g_set_error_literal (error, |
|
141 |
NM_SECRET_AGENT_ERROR, |
|
142 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
143 |
"The device could not be found."); |
|
144 |
return FALSE; |
|
145 |
}
|
|
146 |
||
147 |
ap = nm_device_wifi_get_access_point_by_path (NM_DEVICE_WIFI (device), ap_path); |
|
148 |
if (!ap) { |
|
149 |
g_set_error_literal (error, |
|
150 |
NM_SECRET_AGENT_ERROR, |
|
151 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
152 |
"The access point could not be found."); |
|
153 |
return FALSE; |
|
154 |
}
|
|
155 |
||
156 |
/* FIXME: this doesn't account for Dynamic WEP */
|
|
157 |
if ( !(nm_access_point_get_wpa_flags (ap) & NM_802_11_AP_SEC_KEY_MGMT_802_1X) |
|
158 |
&& !(nm_access_point_get_rsn_flags (ap) & NM_802_11_AP_SEC_KEY_MGMT_802_1X)) { |
|
159 |
g_set_error_literal (error, |
|
160 |
NM_SECRET_AGENT_ERROR, |
|
161 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
162 |
"The access point had no 802.1x capabilities"); |
|
163 |
return FALSE; |
|
164 |
}
|
|
165 |
||
166 |
if (!applet_wifi_connect_to_8021x_network (applet, device, ap)) { |
|
167 |
g_set_error_literal (error, |
|
168 |
NM_SECRET_AGENT_ERROR, |
|
169 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
170 |
"Failed to create wireless dialog"); |
|
171 |
return FALSE; |
|
172 |
}
|
|
173 |
||
174 |
return TRUE; |
|
175 |
}
|
|
176 |
||
177 |
static gboolean |
|
178 |
impl_dbus_connect_to_3g_network (NMApplet *applet, |
|
179 |
const char *device_path, |
|
180 |
GError **error) |
|
181 |
{
|
|
182 |
NMDevice *device; |
|
183 |
NMDeviceModemCapabilities caps; |
|
184 |
||
185 |
device = nm_client_get_device_by_path (applet->nm_client, device_path); |
|
186 |
if (!device || NM_IS_DEVICE_MODEM (device) == FALSE) { |
|
187 |
g_set_error_literal (error, |
|
188 |
NM_SECRET_AGENT_ERROR, |
|
189 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
190 |
"The device could not be found."); |
|
191 |
return FALSE; |
|
192 |
}
|
|
193 |
||
194 |
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); |
|
195 |
if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) { |
|
196 |
applet_gsm_connect_network (applet, device); |
|
197 |
} else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) { |
|
198 |
applet_cdma_connect_network (applet, device); |
|
199 |
} else { |
|
200 |
g_set_error_literal (error, |
|
201 |
NM_SECRET_AGENT_ERROR, |
|
202 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
203 |
"The device had no GSM or CDMA capabilities."); |
|
204 |
return FALSE; |
|
205 |
}
|
|
206 |
||
207 |
return TRUE; |
|
208 |
}
|
|
209 |
||
210 |
#include "applet-dbus-bindings.h" |
|
211 |
||
212 |
/********************************************************************/
|
|
213 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
214 |
struct _OfflineNotificationContextInfo { |
215 |
NMState state; |
|
216 |
NMDeviceState device_state; |
|
217 |
NMDeviceStateReason device_state_reason; |
|
218 |
NMDeviceType device_type; |
|
219 |
gchar* title; |
|
220 |
const gchar* text; |
|
221 |
const gchar* icon; |
|
222 |
NotifyUrgency urgency; |
|
223 |
};
|
|
224 |
||
225 |
typedef struct _OfflineNotificationContextInfo OfflineNotificationContextInfo; |
|
226 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
227 |
static NMActiveConnection * |
228 |
applet_get_best_activating_connection (NMApplet *applet, NMDevice **device) |
|
229 |
{
|
|
230 |
NMActiveConnection *best = NULL; |
|
231 |
NMDevice *best_dev = NULL; |
|
232 |
const GPtrArray *connections; |
|
233 |
int i; |
|
234 |
||
235 |
g_return_val_if_fail (NM_IS_APPLET (applet), NULL); |
|
236 |
g_return_val_if_fail (device != NULL, NULL); |
|
237 |
g_return_val_if_fail (*device == NULL, NULL); |
|
238 |
||
239 |
connections = nm_client_get_active_connections (applet->nm_client); |
|
240 |
for (i = 0; connections && (i < connections->len); i++) { |
|
241 |
NMActiveConnection *candidate = g_ptr_array_index (connections, i); |
|
242 |
const GPtrArray *devices; |
|
243 |
NMDevice *candidate_dev; |
|
244 |
||
245 |
if (nm_active_connection_get_state (candidate) != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) |
|
246 |
continue; |
|
247 |
||
248 |
devices = nm_active_connection_get_devices (candidate); |
|
249 |
if (!devices || !devices->len) |
|
250 |
continue; |
|
251 |
||
252 |
candidate_dev = g_ptr_array_index (devices, 0); |
|
253 |
if (!best_dev) { |
|
254 |
best_dev = candidate_dev; |
|
255 |
best = candidate; |
|
256 |
continue; |
|
257 |
}
|
|
258 |
||
259 |
if (NM_IS_DEVICE_WIFI (best_dev)) { |
|
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
260 |
if (NM_IS_DEVICE_ETHERNET (candidate_dev)) { |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
261 |
best_dev = candidate_dev; |
262 |
best = candidate; |
|
263 |
}
|
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
264 |
} else if (NM_IS_DEVICE_MODEM (best_dev)) { |
265 |
NMDeviceModemCapabilities best_caps; |
|
266 |
NMDeviceModemCapabilities candidate_caps = NM_DEVICE_MODEM_CAPABILITY_NONE; |
|
267 |
||
268 |
best_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (best_dev)); |
|
269 |
if (NM_IS_DEVICE_MODEM (candidate_dev)) |
|
270 |
candidate_caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (candidate_dev)); |
|
271 |
||
272 |
if (best_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) { |
|
273 |
if ( NM_IS_DEVICE_ETHERNET (candidate_dev) |
|
274 |
|| NM_IS_DEVICE_WIFI (candidate_dev)) { |
|
275 |
best_dev = candidate_dev; |
|
276 |
best = candidate; |
|
277 |
}
|
|
278 |
} else if (best_caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) { |
|
279 |
if ( NM_IS_DEVICE_ETHERNET (candidate_dev) |
|
280 |
|| NM_IS_DEVICE_WIFI (candidate_dev) |
|
281 |
|| (candidate_caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) { |
|
282 |
best_dev = candidate_dev; |
|
283 |
best = candidate; |
|
284 |
}
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
285 |
}
|
286 |
}
|
|
287 |
}
|
|
288 |
||
289 |
*device = best_dev; |
|
290 |
return best; |
|
291 |
}
|
|
292 |
||
293 |
static NMActiveConnection * |
|
294 |
applet_get_default_active_connection (NMApplet *applet, NMDevice **device) |
|
295 |
{
|
|
296 |
NMActiveConnection *default_ac = NULL; |
|
297 |
NMDevice *non_default_device = NULL; |
|
298 |
NMActiveConnection *non_default_ac = NULL; |
|
299 |
const GPtrArray *connections; |
|
300 |
int i; |
|
301 |
||
302 |
g_return_val_if_fail (NM_IS_APPLET (applet), NULL); |
|
303 |
g_return_val_if_fail (device != NULL, NULL); |
|
304 |
g_return_val_if_fail (*device == NULL, NULL); |
|
305 |
||
306 |
connections = nm_client_get_active_connections (applet->nm_client); |
|
307 |
for (i = 0; connections && (i < connections->len); i++) { |
|
308 |
NMActiveConnection *candidate = g_ptr_array_index (connections, i); |
|
309 |
const GPtrArray *devices; |
|
310 |
||
311 |
devices = nm_active_connection_get_devices (candidate); |
|
1.1.3
by Alexander Sack
Import upstream version 0.7~~svn20080817t183748 |
312 |
if (!devices || !devices->len) |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
313 |
continue; |
314 |
||
315 |
if (nm_active_connection_get_default (candidate)) { |
|
316 |
if (!default_ac) { |
|
317 |
*device = g_ptr_array_index (devices, 0); |
|
318 |
default_ac = candidate; |
|
319 |
}
|
|
320 |
} else { |
|
321 |
if (!non_default_ac) { |
|
322 |
non_default_device = g_ptr_array_index (devices, 0); |
|
323 |
non_default_ac = candidate; |
|
324 |
}
|
|
325 |
}
|
|
326 |
}
|
|
327 |
||
328 |
/* Prefer the default connection if one exists, otherwise return the first
|
|
329 |
* non-default connection.
|
|
330 |
*/
|
|
331 |
if (!default_ac && non_default_ac) { |
|
332 |
default_ac = non_default_ac; |
|
333 |
*device = non_default_device; |
|
334 |
}
|
|
335 |
return default_ac; |
|
336 |
}
|
|
337 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
338 |
NMRemoteSettings * |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
339 |
applet_get_settings (NMApplet *applet) |
340 |
{
|
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
341 |
return applet->settings; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
342 |
}
|
343 |
||
344 |
GSList * |
|
345 |
applet_get_all_connections (NMApplet *applet) |
|
346 |
{
|
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
347 |
return nm_remote_settings_list_connections (applet->settings); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
348 |
}
|
349 |
||
350 |
static NMConnection * |
|
351 |
applet_get_connection_for_active (NMApplet *applet, NMActiveConnection *active) |
|
352 |
{
|
|
353 |
GSList *list, *iter; |
|
354 |
NMConnection *connection = NULL; |
|
355 |
const char *path; |
|
356 |
||
357 |
path = nm_active_connection_get_connection (active); |
|
358 |
g_return_val_if_fail (path != NULL, NULL); |
|
359 |
||
360 |
list = applet_get_all_connections (applet); |
|
361 |
for (iter = list; iter; iter = g_slist_next (iter)) { |
|
362 |
NMConnection *candidate = NM_CONNECTION (iter->data); |
|
363 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
364 |
if (!strcmp (nm_connection_get_path (candidate), path)) { |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
365 |
connection = candidate; |
366 |
break; |
|
367 |
}
|
|
368 |
}
|
|
369 |
g_slist_free (list); |
|
370 |
||
371 |
return connection; |
|
372 |
}
|
|
373 |
||
374 |
static NMActiveConnection * |
|
375 |
applet_get_active_for_connection (NMApplet *applet, NMConnection *connection) |
|
376 |
{
|
|
377 |
const GPtrArray *active_list; |
|
378 |
int i; |
|
379 |
const char *cpath; |
|
380 |
||
381 |
cpath = nm_connection_get_path (connection); |
|
382 |
g_return_val_if_fail (cpath != NULL, NULL); |
|
383 |
||
384 |
active_list = nm_client_get_active_connections (applet->nm_client); |
|
385 |
for (i = 0; active_list && (i < active_list->len); i++) { |
|
386 |
NMActiveConnection *active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_list, i)); |
|
1.2.9
by Alexander Sack
Import upstream version 0.8~a~git.20091014t134532.4033e62 |
387 |
const char *active_cpath = nm_active_connection_get_connection (active); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
388 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
389 |
if (active_cpath && !strcmp (active_cpath, cpath)) |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
390 |
return active; |
391 |
}
|
|
392 |
return NULL; |
|
393 |
}
|
|
394 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
395 |
NMDevice * |
396 |
applet_get_device_for_connection (NMApplet *applet, NMConnection *connection) |
|
397 |
{
|
|
398 |
const GPtrArray *active_list; |
|
399 |
const char *cpath; |
|
400 |
int i; |
|
401 |
||
402 |
cpath = nm_connection_get_path (connection); |
|
403 |
g_return_val_if_fail (cpath != NULL, NULL); |
|
404 |
||
405 |
active_list = nm_client_get_active_connections (applet->nm_client); |
|
406 |
for (i = 0; active_list && (i < active_list->len); i++) { |
|
407 |
NMActiveConnection *active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_list, i)); |
|
408 |
||
409 |
if (!g_strcmp0 (nm_active_connection_get_connection (active), cpath)) |
|
410 |
return g_ptr_array_index (nm_active_connection_get_devices (active), 0); |
|
411 |
}
|
|
412 |
return NULL; |
|
413 |
}
|
|
414 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
415 |
static inline NMADeviceClass * |
416 |
get_device_class (NMDevice *device, NMApplet *applet) |
|
417 |
{
|
|
418 |
g_return_val_if_fail (device != NULL, NULL); |
|
419 |
g_return_val_if_fail (applet != NULL, NULL); |
|
420 |
||
421 |
if (NM_IS_DEVICE_ETHERNET (device)) |
|
422 |
return applet->wired_class; |
|
423 |
else if (NM_IS_DEVICE_WIFI (device)) |
|
424 |
return applet->wifi_class; |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
425 |
else if (NM_IS_DEVICE_MODEM (device)) { |
426 |
NMDeviceModemCapabilities caps; |
|
427 |
||
428 |
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device)); |
|
429 |
if (caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) |
|
430 |
return applet->gsm_class; |
|
431 |
else if (caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO) |
|
432 |
return applet->cdma_class; |
|
433 |
else
|
|
434 |
g_message ("%s: unhandled modem capabilities 0x%X", __func__, caps); |
|
435 |
} else if (NM_IS_DEVICE_BT (device)) |
|
436 |
return applet->bt_class; |
|
437 |
else if (NM_IS_DEVICE_WIMAX (device)) |
|
438 |
return applet->wimax_class; |
|
439 |
else
|
|
440 |
g_message ("%s: Unknown device type '%s'", __func__, G_OBJECT_TYPE_NAME (device)); |
|
441 |
return NULL; |
|
442 |
}
|
|
443 |
||
444 |
static inline NMADeviceClass * |
|
445 |
get_device_class_from_connection (NMConnection *connection, NMApplet *applet) |
|
446 |
{
|
|
447 |
NMSettingConnection *s_con; |
|
448 |
const char *ctype; |
|
449 |
||
450 |
g_return_val_if_fail (connection != NULL, NULL); |
|
451 |
g_return_val_if_fail (applet != NULL, NULL); |
|
452 |
||
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
453 |
s_con = nm_connection_get_setting_connection (connection); |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
454 |
g_return_val_if_fail (s_con != NULL, NULL); |
455 |
||
456 |
ctype = nm_setting_connection_get_connection_type (s_con); |
|
457 |
g_return_val_if_fail (ctype != NULL, NULL); |
|
458 |
||
459 |
if (!strcmp (ctype, NM_SETTING_WIRED_SETTING_NAME) || !strcmp (ctype, NM_SETTING_PPPOE_SETTING_NAME)) |
|
460 |
return applet->wired_class; |
|
461 |
else if (!strcmp (ctype, NM_SETTING_WIRELESS_SETTING_NAME)) |
|
462 |
return applet->wifi_class; |
|
463 |
else if (!strcmp (ctype, NM_SETTING_GSM_SETTING_NAME)) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
464 |
return applet->gsm_class; |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
465 |
else if (!strcmp (ctype, NM_SETTING_CDMA_SETTING_NAME)) |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
466 |
return applet->cdma_class; |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
467 |
else if (!strcmp (ctype, NM_SETTING_BLUETOOTH_SETTING_NAME)) |
1.2.4
by Tony Espy
Import upstream version 0.8~a~git.20090805t131328.d1edfce |
468 |
return applet->bt_class; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
469 |
else
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
470 |
g_warning ("%s: unhandled connection type '%s'", __func__, ctype); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
471 |
return NULL; |
472 |
}
|
|
473 |
||
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
474 |
typedef struct { |
475 |
NMApplet *applet; |
|
476 |
NMDevice *device; |
|
477 |
char *specific_object; |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
478 |
NMConnection *connection; |
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
479 |
} AppletItemActivateInfo; |
480 |
||
481 |
static void |
|
482 |
applet_item_activate_info_destroy (AppletItemActivateInfo *info) |
|
483 |
{
|
|
484 |
g_return_if_fail (info != NULL); |
|
485 |
||
486 |
if (info->device) |
|
487 |
g_object_unref (info->device); |
|
488 |
g_free (info->specific_object); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
489 |
if (info->connection) |
490 |
g_object_unref (info->connection); |
|
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
491 |
memset (info, 0, sizeof (AppletItemActivateInfo)); |
492 |
g_free (info); |
|
493 |
}
|
|
494 |
||
495 |
static void |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
496 |
add_and_activate_cb (NMClient *client, |
497 |
NMActiveConnection *active, |
|
498 |
const char *connection_path, |
|
499 |
GError *error, |
|
500 |
gpointer user_data) |
|
501 |
{
|
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
502 |
NMApplet *applet = NM_APPLET (user_data); |
88
by Mathieu Trudel-Lapierre
* New upstream release 0.9.4.1. |
503 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
504 |
if (error) |
505 |
g_warning ("Failed to add/activate connection: (%d) %s", error->code, error->message); |
|
506 |
||
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
507 |
applet_schedule_update_icon (applet); |
508 |
applet_schedule_update_menu (applet); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
509 |
}
|
510 |
||
511 |
static void |
|
512 |
applet_menu_item_activate_helper_new_connection (NMConnection *connection, |
|
513 |
gboolean auto_created, |
|
514 |
gboolean canceled, |
|
515 |
gpointer user_data) |
|
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
516 |
{
|
517 |
AppletItemActivateInfo *info = user_data; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
518 |
|
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
519 |
if (canceled) { |
520 |
applet_item_activate_info_destroy (info); |
|
521 |
return; |
|
522 |
}
|
|
523 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
524 |
g_return_if_fail (connection != NULL); |
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
525 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
526 |
/* Ask NM to add the new connection and activate it; NM will fill in the
|
527 |
* missing details based on the specific object and the device.
|
|
528 |
*/
|
|
529 |
nm_client_add_and_activate_connection (info->applet->nm_client, |
|
530 |
connection, |
|
531 |
info->device, |
|
532 |
info->specific_object, |
|
533 |
add_and_activate_cb, |
|
534 |
info->applet); |
|
535 |
||
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
536 |
applet_item_activate_info_destroy (info); |
537 |
}
|
|
538 |
||
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
539 |
static void |
540 |
disconnect_cb (NMDevice *device, GError *error, gpointer user_data) |
|
541 |
{
|
|
88
by Mathieu Trudel-Lapierre
* New upstream release 0.9.4.1. |
542 |
NMApplet *applet = NM_APPLET (user_data); |
543 |
||
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
544 |
if (error) { |
545 |
g_warning ("%s: device disconnect failed: (%d) %s", |
|
546 |
__func__, |
|
547 |
error ? error->code : -1, |
|
548 |
error && error->message ? error->message : "(unknown)"); |
|
549 |
}
|
|
88
by Mathieu Trudel-Lapierre
* New upstream release 0.9.4.1. |
550 |
|
551 |
applet_schedule_update_icon (applet); |
|
552 |
applet_schedule_update_menu (applet); |
|
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
553 |
}
|
554 |
||
555 |
void
|
|
556 |
applet_menu_item_disconnect_helper (NMDevice *device, |
|
557 |
NMApplet *applet) |
|
558 |
{
|
|
559 |
g_return_if_fail (NM_IS_DEVICE (device)); |
|
560 |
||
88
by Mathieu Trudel-Lapierre
* New upstream release 0.9.4.1. |
561 |
nm_device_disconnect (device, disconnect_cb, applet); |
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
562 |
}
|
563 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
564 |
static void |
565 |
activate_connection_cb (NMClient *client, |
|
566 |
NMActiveConnection *active, |
|
567 |
GError *error, |
|
568 |
gpointer user_data) |
|
569 |
{
|
|
570 |
if (error) |
|
571 |
g_warning ("Connection activation failed: %s", error->message); |
|
572 |
||
573 |
applet_schedule_update_icon (NM_APPLET (user_data)); |
|
574 |
}
|
|
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
575 |
|
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
576 |
void
|
577 |
applet_menu_item_activate_helper (NMDevice *device, |
|
578 |
NMConnection *connection, |
|
579 |
const char *specific_object, |
|
580 |
NMApplet *applet, |
|
581 |
gpointer dclass_data) |
|
582 |
{
|
|
583 |
AppletItemActivateInfo *info; |
|
584 |
NMADeviceClass *dclass; |
|
585 |
||
586 |
g_return_if_fail (NM_IS_DEVICE (device)); |
|
587 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
588 |
if (connection) { |
589 |
/* If the menu item had an associated connection already, just tell
|
|
590 |
* NM to activate that connection.
|
|
591 |
*/
|
|
592 |
nm_client_activate_connection (applet->nm_client, |
|
593 |
connection, |
|
594 |
device, |
|
595 |
specific_object, |
|
596 |
activate_connection_cb, |
|
597 |
applet); |
|
598 |
return; |
|
599 |
}
|
|
600 |
||
601 |
/* If no connection was given, ask the device class to create a new
|
|
602 |
* default connection for this device type. This could be a wizard,
|
|
603 |
* and thus take a while.
|
|
604 |
*/
|
|
605 |
||
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
606 |
info = g_malloc0 (sizeof (AppletItemActivateInfo)); |
607 |
info->applet = applet; |
|
608 |
info->specific_object = g_strdup (specific_object); |
|
609 |
info->device = g_object_ref (device); |
|
610 |
||
611 |
dclass = get_device_class (device, applet); |
|
612 |
g_assert (dclass); |
|
613 |
if (!dclass->new_auto_connection (device, dclass_data, |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
614 |
applet_menu_item_activate_helper_new_connection, |
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
615 |
info)) { |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
616 |
g_warning ("Couldn't create default connection."); |
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
617 |
applet_item_activate_info_destroy (info); |
618 |
}
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
619 |
}
|
620 |
||
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
621 |
void
|
622 |
applet_menu_item_add_complex_separator_helper (GtkWidget *menu, |
|
623 |
NMApplet *applet, |
|
624 |
const gchar* label, |
|
625 |
int pos) |
|
626 |
{
|
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
627 |
GtkWidget *menu_item = NULL; |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
628 |
#ifndef ENABLE_INDICATOR
|
1.2.22
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110707t152406.340f695 |
629 |
#if GTK_CHECK_VERSION(3,1,6)
|
630 |
GtkWidget *box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); |
|
631 |
#else
|
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
632 |
GtkWidget *box = gtk_hbox_new (FALSE, 0); |
1.2.22
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110707t152406.340f695 |
633 |
#endif
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
634 |
GtkWidget *xlabel = NULL; |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
635 |
menu_item = gtk_image_menu_item_new (); |
636 |
||
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
637 |
if (label) { |
638 |
xlabel = gtk_label_new (NULL); |
|
639 |
gtk_label_set_markup (GTK_LABEL (xlabel), label); |
|
640 |
||
1.2.22
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110707t152406.340f695 |
641 |
#if GTK_CHECK_VERSION(3,1,6)
|
642 |
gtk_box_pack_start (GTK_BOX (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 0); |
|
643 |
#else
|
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
644 |
gtk_box_pack_start (GTK_BOX (box), gtk_hseparator_new (), TRUE, TRUE, 0); |
1.2.22
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110707t152406.340f695 |
645 |
#endif
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
646 |
gtk_box_pack_start (GTK_BOX (box), xlabel, FALSE, FALSE, 2); |
647 |
}
|
|
648 |
||
1.2.22
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110707t152406.340f695 |
649 |
#if GTK_CHECK_VERSION(3,1,6)
|
650 |
gtk_box_pack_start (GTK_BOX (box), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 0); |
|
651 |
#else
|
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
652 |
gtk_box_pack_start (GTK_BOX (box), gtk_hseparator_new (), TRUE, TRUE, 0); |
1.2.22
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110707t152406.340f695 |
653 |
#endif
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
654 |
|
655 |
g_object_set (G_OBJECT (menu_item), |
|
656 |
"child", box, |
|
657 |
"sensitive", FALSE, |
|
658 |
NULL); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
659 |
#else
|
660 |
menu_item = gtk_separator_menu_item_new (); |
|
661 |
#endif
|
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
662 |
if (pos < 0) |
663 |
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); |
|
664 |
else
|
|
665 |
gtk_menu_shell_insert (GTK_MENU_SHELL (menu), menu_item, pos); |
|
666 |
return; |
|
667 |
}
|
|
668 |
||
669 |
GtkWidget * |
|
670 |
applet_new_menu_item_helper (NMConnection *connection, |
|
671 |
NMConnection *active, |
|
672 |
gboolean add_active) |
|
673 |
{
|
|
674 |
GtkWidget *item; |
|
675 |
NMSettingConnection *s_con; |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
676 |
#ifndef ENABLE_INDICATOR
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
677 |
char *markup; |
678 |
GtkWidget *label; |
|
86
by Mathieu Trudel-Lapierre
* upstream snapshot 2012-03-13 14:12:31 (GMT) |
679 |
#endif /* ENABLE_INDICATOR */ |
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
680 |
|
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
681 |
s_con = nm_connection_get_setting_connection (connection); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
682 |
#ifndef ENABLE_INDICATOR
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
683 |
item = gtk_image_menu_item_new_with_label (""); |
684 |
if (add_active && (active == connection)) { |
|
685 |
/* Pure evil */
|
|
686 |
label = gtk_bin_get_child (GTK_BIN (item)); |
|
687 |
gtk_label_set_use_markup (GTK_LABEL (label), TRUE); |
|
688 |
markup = g_markup_printf_escaped ("<b>%s</b>", nm_setting_connection_get_id (s_con)); |
|
689 |
gtk_label_set_markup (GTK_LABEL (label), markup); |
|
690 |
g_free (markup); |
|
691 |
} else |
|
692 |
gtk_menu_item_set_label (GTK_MENU_ITEM (item), nm_setting_connection_get_id (s_con)); |
|
693 |
||
694 |
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (item), TRUE); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
695 |
#else
|
696 |
item = gtk_menu_item_new_with_label (nm_setting_connection_get_id (s_con)); |
|
86
by Mathieu Trudel-Lapierre
* upstream snapshot 2012-03-13 14:12:31 (GMT) |
697 |
#endif /* ENABLE_INDICATOR */ |
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
698 |
return item; |
699 |
}
|
|
700 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
701 |
#ifndef ENABLE_INDICATOR
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
702 |
#define TITLE_TEXT_R ((double) 0x5e / 255.0 )
|
703 |
#define TITLE_TEXT_G ((double) 0x5e / 255.0 )
|
|
704 |
#define TITLE_TEXT_B ((double) 0x5e / 255.0 )
|
|
705 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
706 |
static void |
707 |
menu_item_draw_generic (GtkWidget *widget, cairo_t *cr) |
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
708 |
{
|
709 |
GtkWidget *label; |
|
710 |
PangoFontDescription *desc; |
|
711 |
PangoLayout *layout; |
|
712 |
int width = 0, height = 0, owidth, oheight; |
|
713 |
gdouble extraheight = 0, extrawidth = 0; |
|
714 |
const char *text; |
|
715 |
gdouble xpadding = 10.0; |
|
716 |
gdouble ypadding = 5.0; |
|
717 |
gdouble postpadding = 0.0; |
|
718 |
||
719 |
label = gtk_bin_get_child (GTK_BIN (widget)); |
|
720 |
text = gtk_label_get_text (GTK_LABEL (label)); |
|
721 |
||
722 |
layout = pango_cairo_create_layout (cr); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
723 |
#if GTK_CHECK_VERSION(2,20,0) && !GTK_CHECK_VERSION(2,91,6)
|
724 |
{
|
|
725 |
GtkStyle *style; |
|
726 |
style = gtk_widget_get_style (widget); |
|
727 |
desc = pango_font_description_copy (style->font_desc); |
|
728 |
}
|
|
729 |
#else
|
|
730 |
{
|
|
731 |
GtkStyleContext *style; |
|
732 |
style = gtk_widget_get_style_context (widget); |
|
733 |
gtk_style_context_get (style, gtk_style_context_get_state (style), |
|
734 |
"font", &desc, |
|
735 |
NULL); |
|
736 |
}
|
|
737 |
#endif
|
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
738 |
pango_font_description_set_variant (desc, PANGO_VARIANT_SMALL_CAPS); |
739 |
pango_font_description_set_weight (desc, PANGO_WEIGHT_SEMIBOLD); |
|
740 |
pango_layout_set_font_description (layout, desc); |
|
741 |
pango_layout_set_text (layout, text, -1); |
|
742 |
pango_cairo_update_layout (cr, layout); |
|
743 |
pango_layout_get_size (layout, &owidth, &oheight); |
|
744 |
width = owidth / PANGO_SCALE; |
|
745 |
height += oheight / PANGO_SCALE; |
|
746 |
||
747 |
cairo_save (cr); |
|
748 |
||
749 |
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); |
|
750 |
cairo_rectangle (cr, 0, 0, |
|
751 |
(double) (width + 2 * xpadding), |
|
752 |
(double) (height + ypadding + postpadding)); |
|
753 |
cairo_fill (cr); |
|
754 |
||
755 |
/* now the in-padding content */
|
|
756 |
cairo_translate (cr, xpadding , ypadding); |
|
757 |
cairo_set_source_rgb (cr, TITLE_TEXT_R, TITLE_TEXT_G, TITLE_TEXT_B); |
|
758 |
cairo_move_to (cr, extrawidth, extraheight); |
|
759 |
pango_cairo_show_layout (cr, layout); |
|
760 |
||
761 |
cairo_restore(cr); |
|
762 |
||
763 |
pango_font_description_free (desc); |
|
764 |
g_object_unref (layout); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
765 |
|
766 |
gtk_widget_set_size_request (widget, width + 2 * xpadding, height + ypadding + postpadding); |
|
767 |
}
|
|
768 |
||
769 |
#if GTK_CHECK_VERSION(2,90,7)
|
|
770 |
static gboolean |
|
771 |
menu_title_item_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data) |
|
772 |
{
|
|
773 |
menu_item_draw_generic (widget, cr); |
|
774 |
return TRUE; |
|
775 |
}
|
|
776 |
#else
|
|
777 |
static gboolean |
|
778 |
menu_title_item_expose (GtkWidget *widget, GdkEventExpose *event) |
|
779 |
{
|
|
780 |
GtkAllocation allocation; |
|
781 |
cairo_t *cr; |
|
782 |
||
783 |
cr = gdk_cairo_create (gtk_widget_get_window (widget)); |
|
784 |
||
785 |
/* The drawing area we get is the whole menu; clip the drawing to the
|
|
786 |
* event area, which should just be our menu item.
|
|
787 |
*/
|
|
788 |
cairo_rectangle (cr, |
|
789 |
event->area.x, event->area.y, |
|
790 |
event->area.width, event->area.height); |
|
791 |
cairo_clip (cr); |
|
792 |
||
793 |
/* We also need to reposition the cairo context so that (0, 0) is the
|
|
794 |
* top-left of where we're supposed to start drawing.
|
|
795 |
*/
|
|
796 |
gtk_widget_get_allocation (widget, &allocation); |
|
797 |
cairo_translate (cr, allocation.x, allocation.y); |
|
798 |
||
799 |
menu_item_draw_generic (widget, cr); |
|
800 |
||
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
801 |
cairo_destroy (cr); |
802 |
return TRUE; |
|
803 |
}
|
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
804 |
#endif
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
805 |
|
806 |
#endif /* ENABLE_INDICATOR */ |
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
807 |
|
808 |
GtkWidget * |
|
809 |
applet_menu_item_create_device_item_helper (NMDevice *device, |
|
810 |
NMApplet *applet, |
|
811 |
const gchar *text) |
|
812 |
{
|
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
813 |
GtkWidget *item; |
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
814 |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
815 |
item = gtk_menu_item_new_with_mnemonic (text); |
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
816 |
gtk_widget_set_sensitive (item, FALSE); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
817 |
#ifndef ENABLE_INDICATOR
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
818 |
#if GTK_CHECK_VERSION(2,90,7)
|
819 |
g_signal_connect (item, "draw", G_CALLBACK (menu_title_item_draw), NULL); |
|
820 |
#else
|
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
821 |
g_signal_connect (item, "expose-event", G_CALLBACK (menu_title_item_expose), NULL); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
822 |
#endif
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
823 |
#endif /* ENABLE_INDICATOR */ |
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
824 |
return item; |
825 |
}
|
|
826 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
827 |
static gboolean |
1.2.13
by Mathieu Trudel-Lapierre
Import upstream version 0.8.2+git.20101123t161608.f143e76 |
828 |
applet_notify_server_has_actions (void) |
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
829 |
{
|
81
by Martin Pitt
* Add no_Werror.patch: Disable building with -Werror to avoid build failure |
830 |
static gboolean has_actions = FALSE; |
831 |
static gboolean initialized = FALSE; |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
832 |
GList *server_caps, *iter; |
833 |
||
81
by Martin Pitt
* Add no_Werror.patch: Disable building with -Werror to avoid build failure |
834 |
if (initialized) |
835 |
return has_actions; |
|
836 |
initialized = TRUE; |
|
837 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
838 |
server_caps = notify_get_server_caps(); |
839 |
for (iter = server_caps; iter; iter = g_list_next (iter)) { |
|
840 |
if (!strcmp ((const char *) iter->data, NOTIFY_CAPS_ACTIONS_KEY)) { |
|
841 |
has_actions = TRUE; |
|
842 |
break; |
|
843 |
}
|
|
844 |
}
|
|
845 |
g_list_foreach (server_caps, (GFunc) g_free, NULL); |
|
846 |
g_list_free (server_caps); |
|
847 |
||
848 |
return has_actions; |
|
849 |
}
|
|
850 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
851 |
void
|
852 |
applet_do_notify (NMApplet *applet, |
|
853 |
NotifyUrgency urgency, |
|
854 |
const char *summary, |
|
855 |
const char *message, |
|
856 |
const char *icon, |
|
857 |
const char *action1, |
|
858 |
const char *action1_label, |
|
859 |
NotifyActionCallback action1_cb, |
|
860 |
gpointer action1_user_data) |
|
861 |
{
|
|
862 |
NotifyNotification *notify; |
|
863 |
GError *error = NULL; |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
864 |
char *escaped; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
865 |
|
866 |
g_return_if_fail (applet != NULL); |
|
867 |
g_return_if_fail (summary != NULL); |
|
868 |
g_return_if_fail (message != NULL); |
|
869 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
870 |
#ifndef ENABLE_INDICATOR
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
871 |
if (!gtk_status_icon_is_embedded (applet->status_icon)) |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
872 |
#else
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
873 |
if (!gtk_status_icon_is_embedded (applet->status_icon) && |
874 |
app_indicator_get_status (applet->app_indicator) == APP_INDICATOR_STATUS_PASSIVE) |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
875 |
#endif /* ENABLE_INDICATOR */ |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
876 |
return; |
877 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
878 |
escaped = utils_escape_notify_message (message); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
879 |
|
880 |
if (applet->notification == NULL) { |
|
881 |
notify = notify_notification_new (summary, |
|
882 |
escaped, |
|
883 |
icon ? icon : GTK_STOCK_NETWORK |
|
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
884 |
#if HAVE_LIBNOTIFY_07
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
885 |
);
|
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
886 |
#else
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
887 |
, NULL); |
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
888 |
#endif
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
889 |
|
890 |
applet->notification = notify; |
|
891 |
} else { |
|
892 |
notify = applet->notification; |
|
893 |
notify_notification_update (notify, |
|
894 |
summary, |
|
895 |
escaped, |
|
896 |
icon ? icon : GTK_STOCK_NETWORK); |
|
897 |
}
|
|
898 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
899 |
g_free (escaped); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
900 |
|
1.2.21
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110616t193616.b2e6a33 |
901 |
#if HAVE_LIBNOTIFY_07
|
902 |
notify_notification_set_hint (notify, "transient", g_variant_new_boolean (TRUE)); |
|
903 |
#else
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
904 |
notify_notification_attach_to_status_icon (notify, applet->status_icon); |
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
905 |
#endif
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
906 |
notify_notification_set_urgency (notify, urgency); |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
907 |
notify_notification_set_timeout (notify, NOTIFY_EXPIRES_DEFAULT); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
908 |
|
81
by Martin Pitt
* Add no_Werror.patch: Disable building with -Werror to avoid build failure |
909 |
if (applet_notify_server_has_actions () && action1) { |
74
by Mathieu Trudel-Lapierre
* debian/patches/clear-notification-actions.patch: clear actions tied to |
910 |
notify_notification_clear_actions (notify); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
911 |
notify_notification_add_action (notify, action1, action1_label, |
912 |
action1_cb, action1_user_data, NULL); |
|
913 |
}
|
|
914 |
||
915 |
if (!notify_notification_show (notify, &error)) { |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
916 |
g_warning ("Failed to show notification: %s", |
917 |
error && error->message ? error->message : "(unknown)"); |
|
918 |
g_clear_error (&error); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
919 |
}
|
920 |
}
|
|
921 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
922 |
static void |
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
923 |
notify_dont_show_cb (NotifyNotification *notify, |
924 |
gchar *id, |
|
925 |
gpointer user_data) |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
926 |
{
|
927 |
NMApplet *applet = NM_APPLET (user_data); |
|
928 |
||
929 |
if (!id) |
|
930 |
return; |
|
931 |
||
932 |
if ( strcmp (id, PREF_DISABLE_CONNECTED_NOTIFICATIONS) |
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
933 |
&& strcmp (id, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS) |
934 |
&& strcmp (id, PREF_DISABLE_VPN_NOTIFICATIONS)) |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
935 |
return; |
936 |
||
937 |
gconf_client_set_bool (applet->gconf_client, id, TRUE, NULL); |
|
938 |
}
|
|
939 |
||
940 |
void applet_do_notify_with_pref (NMApplet *applet, |
|
941 |
const char *summary, |
|
942 |
const char *message, |
|
943 |
const char *icon, |
|
944 |
const char *pref) |
|
945 |
{
|
|
946 |
if (gconf_client_get_bool (applet->gconf_client, pref, NULL)) |
|
947 |
return; |
|
948 |
||
949 |
applet_do_notify (applet, NOTIFY_URGENCY_LOW, summary, message, icon, pref, |
|
950 |
_("Don't show this message again"), |
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
951 |
notify_dont_show_cb, |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
952 |
applet); |
953 |
}
|
|
954 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
955 |
static gboolean |
956 |
animation_timeout (gpointer data) |
|
957 |
{
|
|
958 |
applet_schedule_update_icon (NM_APPLET (data)); |
|
959 |
return TRUE; |
|
960 |
}
|
|
961 |
||
962 |
static void |
|
963 |
start_animation_timeout (NMApplet *applet) |
|
964 |
{
|
|
965 |
if (applet->animation_id == 0) { |
|
966 |
applet->animation_step = 0; |
|
967 |
applet->animation_id = g_timeout_add (100, animation_timeout, applet); |
|
968 |
}
|
|
969 |
}
|
|
970 |
||
971 |
static void |
|
972 |
clear_animation_timeout (NMApplet *applet) |
|
973 |
{
|
|
974 |
if (applet->animation_id) { |
|
975 |
g_source_remove (applet->animation_id); |
|
976 |
applet->animation_id = 0; |
|
977 |
applet->animation_step = 0; |
|
978 |
}
|
|
979 |
}
|
|
980 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
981 |
static gboolean |
982 |
applet_is_any_device_activating (NMApplet *applet) |
|
983 |
{
|
|
984 |
const GPtrArray *devices; |
|
985 |
int i; |
|
986 |
||
987 |
/* Check for activating devices */
|
|
988 |
devices = nm_client_get_devices (applet->nm_client); |
|
989 |
for (i = 0; devices && (i < devices->len); i++) { |
|
990 |
NMDevice *candidate = NM_DEVICE (g_ptr_array_index (devices, i)); |
|
991 |
NMDeviceState state; |
|
992 |
||
993 |
state = nm_device_get_state (candidate); |
|
994 |
if (state > NM_DEVICE_STATE_DISCONNECTED && state < NM_DEVICE_STATE_ACTIVATED) |
|
995 |
return TRUE; |
|
996 |
}
|
|
997 |
return FALSE; |
|
998 |
}
|
|
999 |
||
1000 |
static gboolean |
|
1001 |
applet_is_any_vpn_activating (NMApplet *applet) |
|
1002 |
{
|
|
1003 |
const GPtrArray *connections; |
|
1004 |
int i; |
|
1005 |
||
1006 |
connections = nm_client_get_active_connections (applet->nm_client); |
|
1007 |
for (i = 0; connections && (i < connections->len); i++) { |
|
1008 |
NMActiveConnection *candidate = NM_ACTIVE_CONNECTION (g_ptr_array_index (connections, i)); |
|
1009 |
NMVPNConnectionState vpn_state; |
|
1010 |
||
1011 |
if (NM_IS_VPN_CONNECTION (candidate)) { |
|
1012 |
vpn_state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (candidate)); |
|
1013 |
if ( vpn_state == NM_VPN_CONNECTION_STATE_PREPARE |
|
1014 |
|| vpn_state == NM_VPN_CONNECTION_STATE_NEED_AUTH |
|
1015 |
|| vpn_state == NM_VPN_CONNECTION_STATE_CONNECT |
|
1016 |
|| vpn_state == NM_VPN_CONNECTION_STATE_IP_CONFIG_GET) { |
|
1017 |
return TRUE; |
|
1018 |
}
|
|
1019 |
}
|
|
1020 |
}
|
|
1021 |
return FALSE; |
|
1022 |
}
|
|
1.2.6
by Alexander Sack
Import upstream version 0.8~a~git.20090913t161448.cc2f6be |
1023 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1024 |
static char * |
1025 |
make_vpn_failure_message (NMVPNConnection *vpn, |
|
1026 |
NMVPNConnectionStateReason reason, |
|
1027 |
NMApplet *applet) |
|
1028 |
{
|
|
1029 |
NMConnection *connection; |
|
1030 |
NMSettingConnection *s_con; |
|
1031 |
||
1032 |
g_return_val_if_fail (vpn != NULL, NULL); |
|
1033 |
||
1034 |
connection = applet_get_connection_for_active (applet, NM_ACTIVE_CONNECTION (vpn)); |
|
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
1035 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1036 |
|
1037 |
switch (reason) { |
|
1038 |
case NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED: |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1039 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because the network connection was interrupted."), |
1040 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1041 |
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1042 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service stopped unexpectedly."), |
1043 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1044 |
case NM_VPN_CONNECTION_STATE_REASON_IP_CONFIG_INVALID: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1045 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service returned invalid configuration."), |
1046 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1047 |
case NM_VPN_CONNECTION_STATE_REASON_CONNECT_TIMEOUT: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1048 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because the connection attempt timed out."), |
1049 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1050 |
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_TIMEOUT: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1051 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service did not start in time."), |
1052 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1053 |
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_START_FAILED: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1054 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service failed to start."), |
1055 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1056 |
case NM_VPN_CONNECTION_STATE_REASON_NO_SECRETS: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1057 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because there were no valid VPN secrets."), |
1058 |
nm_setting_connection_get_id (s_con)); |
|
1.1.5
by Alexander Sack
Import upstream version 0.7~~svn20080927t101113 |
1059 |
case NM_VPN_CONNECTION_STATE_REASON_LOGIN_FAILED: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1060 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed because of invalid VPN secrets."), |
1061 |
nm_setting_connection_get_id (s_con)); |
|
1.1.5
by Alexander Sack
Import upstream version 0.7~~svn20080927t101113 |
1062 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1063 |
default: |
1064 |
break; |
|
1065 |
}
|
|
1066 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1067 |
return g_strdup_printf (_("\nThe VPN connection '%s' failed."), nm_setting_connection_get_id (s_con)); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1068 |
}
|
1069 |
||
1070 |
static char * |
|
1071 |
make_vpn_disconnection_message (NMVPNConnection *vpn, |
|
1072 |
NMVPNConnectionStateReason reason, |
|
1073 |
NMApplet *applet) |
|
1074 |
{
|
|
1075 |
NMConnection *connection; |
|
1076 |
NMSettingConnection *s_con; |
|
1077 |
||
1078 |
g_return_val_if_fail (vpn != NULL, NULL); |
|
1079 |
||
1080 |
connection = applet_get_connection_for_active (applet, NM_ACTIVE_CONNECTION (vpn)); |
|
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
1081 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1082 |
|
1083 |
switch (reason) { |
|
1084 |
case NM_VPN_CONNECTION_STATE_REASON_DEVICE_DISCONNECTED: |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1085 |
return g_strdup_printf (_("\nThe VPN connection '%s' disconnected because the network connection was interrupted."), |
1086 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1087 |
case NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED: |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1088 |
return g_strdup_printf (_("\nThe VPN connection '%s' disconnected because the VPN service stopped."), |
1089 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1090 |
default: |
1091 |
break; |
|
1092 |
}
|
|
1093 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1094 |
return g_strdup_printf (_("\nThe VPN connection '%s' disconnected."), nm_setting_connection_get_id (s_con)); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1095 |
}
|
1096 |
||
1097 |
static void |
|
1098 |
vpn_connection_state_changed (NMVPNConnection *vpn, |
|
1099 |
NMVPNConnectionState state, |
|
1100 |
NMVPNConnectionStateReason reason, |
|
1101 |
gpointer user_data) |
|
1102 |
{
|
|
1103 |
NMApplet *applet = NM_APPLET (user_data); |
|
1104 |
const char *banner; |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1105 |
char *title = NULL, *msg; |
1106 |
gboolean device_activating, vpn_activating; |
|
1107 |
||
1108 |
device_activating = applet_is_any_device_activating (applet); |
|
1109 |
vpn_activating = applet_is_any_vpn_activating (applet); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1110 |
|
1111 |
switch (state) { |
|
1112 |
case NM_VPN_CONNECTION_STATE_PREPARE: |
|
1113 |
case NM_VPN_CONNECTION_STATE_NEED_AUTH: |
|
1114 |
case NM_VPN_CONNECTION_STATE_CONNECT: |
|
1115 |
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET: |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1116 |
/* Be sure to turn animation timeout on here since the dbus signals
|
1117 |
* for new active connections might not have come through yet.
|
|
1118 |
*/
|
|
1119 |
vpn_activating = TRUE; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1120 |
break; |
1121 |
case NM_VPN_CONNECTION_STATE_ACTIVATED: |
|
1122 |
banner = nm_vpn_connection_get_banner (vpn); |
|
1.2.13
by Mathieu Trudel-Lapierre
Import upstream version 0.8.2+git.20101123t161608.f143e76 |
1123 |
if (banner && strlen (banner)) |
1124 |
msg = g_strdup_printf ("VPN connection has been successfully established.\n\n%s\n", banner); |
|
1125 |
else
|
|
1126 |
msg = g_strdup ("VPN connection has been successfully established.\n"); |
|
1127 |
||
1128 |
title = _("VPN Login Message"); |
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
1129 |
applet_do_notify_with_pref (applet, title, msg, "gnome-lockscreen", |
1130 |
PREF_DISABLE_VPN_NOTIFICATIONS); |
|
1.2.13
by Mathieu Trudel-Lapierre
Import upstream version 0.8.2+git.20101123t161608.f143e76 |
1131 |
g_free (msg); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1132 |
break; |
1133 |
case NM_VPN_CONNECTION_STATE_FAILED: |
|
1134 |
title = _("VPN Connection Failed"); |
|
1135 |
msg = make_vpn_failure_message (vpn, reason, applet); |
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
1136 |
applet_do_notify_with_pref (applet, title, msg, "gnome-lockscreen", |
1137 |
PREF_DISABLE_VPN_NOTIFICATIONS); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1138 |
g_free (msg); |
1139 |
break; |
|
1140 |
case NM_VPN_CONNECTION_STATE_DISCONNECTED: |
|
1141 |
if (reason != NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED) { |
|
1142 |
title = _("VPN Connection Failed"); |
|
1143 |
msg = make_vpn_disconnection_message (vpn, reason, applet); |
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
1144 |
applet_do_notify_with_pref (applet, title, msg, "gnome-lockscreen", |
1145 |
PREF_DISABLE_VPN_NOTIFICATIONS); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1146 |
g_free (msg); |
1147 |
}
|
|
1148 |
break; |
|
1149 |
default: |
|
1150 |
break; |
|
1151 |
}
|
|
1152 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1153 |
if (device_activating || vpn_activating) |
1154 |
start_animation_timeout (applet); |
|
1155 |
else
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1156 |
clear_animation_timeout (applet); |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1157 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1158 |
applet_schedule_update_icon (applet); |
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
1159 |
applet_schedule_update_menu (applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1160 |
}
|
1161 |
||
1162 |
static const char * |
|
1163 |
get_connection_id (NMConnection *connection) |
|
1164 |
{
|
|
1165 |
NMSettingConnection *s_con; |
|
1166 |
||
1167 |
g_return_val_if_fail (connection != NULL, NULL); |
|
1168 |
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL); |
|
1169 |
||
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
1170 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1171 |
g_return_val_if_fail (s_con != NULL, NULL); |
1172 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1173 |
return nm_setting_connection_get_id (s_con); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1174 |
}
|
1175 |
||
1176 |
typedef struct { |
|
1177 |
NMApplet *applet; |
|
1178 |
char *vpn_name; |
|
1179 |
} VPNActivateInfo; |
|
1180 |
||
1181 |
static void |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1182 |
activate_vpn_cb (NMClient *client, |
1183 |
NMActiveConnection *active, |
|
1184 |
GError *error, |
|
1185 |
gpointer user_data) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1186 |
{
|
1187 |
VPNActivateInfo *info = (VPNActivateInfo *) user_data; |
|
1188 |
char *title, *msg, *name; |
|
1189 |
||
1190 |
if (error) { |
|
1.1.5
by Alexander Sack
Import upstream version 0.7~~svn20080927t101113 |
1191 |
clear_animation_timeout (info->applet); |
1192 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1193 |
title = _("VPN Connection Failed"); |
1194 |
||
1195 |
/* dbus-glib GError messages _always_ have two NULLs, the D-Bus error
|
|
1196 |
* name comes after the first NULL. Find it.
|
|
1197 |
*/
|
|
1198 |
name = error->message + strlen (error->message) + 1; |
|
1199 |
if (strstr (name, "ServiceStartFailed")) { |
|
1200 |
msg = g_strdup_printf (_("\nThe VPN connection '%s' failed because the VPN service failed to start.\n\n%s"), |
|
1201 |
info->vpn_name, error->message); |
|
1202 |
} else { |
|
1203 |
msg = g_strdup_printf (_("\nThe VPN connection '%s' failed to start.\n\n%s"), |
|
1204 |
info->vpn_name, error->message); |
|
1205 |
}
|
|
1206 |
||
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
1207 |
applet_do_notify_with_pref (info->applet, title, msg, "gnome-lockscreen", |
1208 |
PREF_DISABLE_VPN_NOTIFICATIONS); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1209 |
g_free (msg); |
1210 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1211 |
g_warning ("VPN Connection activation failed: (%s) %s", name, error->message); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1212 |
}
|
1213 |
||
1214 |
applet_schedule_update_icon (info->applet); |
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
1215 |
applet_schedule_update_menu (info->applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1216 |
g_free (info->vpn_name); |
1217 |
g_free (info); |
|
1218 |
}
|
|
1219 |
||
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
1220 |
static void nma_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer user_data); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1221 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1222 |
static void |
1223 |
nma_menu_vpn_item_clicked (GtkMenuItem *item, gpointer user_data) |
|
1224 |
{
|
|
1225 |
NMApplet *applet = NM_APPLET (user_data); |
|
1226 |
VPNActivateInfo *info; |
|
1227 |
NMConnection *connection; |
|
1228 |
NMSettingConnection *s_con; |
|
1229 |
NMActiveConnection *active; |
|
1230 |
NMDevice *device = NULL; |
|
1231 |
||
1232 |
active = applet_get_default_active_connection (applet, &device); |
|
1233 |
if (!active || !device) { |
|
1234 |
g_warning ("%s: no active connection or device.", __func__); |
|
1235 |
return; |
|
1236 |
}
|
|
1237 |
||
1238 |
connection = NM_CONNECTION (g_object_get_data (G_OBJECT (item), "connection")); |
|
1239 |
if (!connection) { |
|
1240 |
g_warning ("%s: no connection associated with menu item!", __func__); |
|
1241 |
return; |
|
1242 |
}
|
|
1243 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1244 |
if (applet_get_active_for_connection (applet, connection)) { |
1245 |
#ifndef ENABLE_INDICATOR
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1246 |
/* Connection already active; do nothing */
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1247 |
#else
|
1248 |
nma_menu_disconnect_vpn_item_activate (item, applet); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
1249 |
#endif /* ENABLE_INDICATOR */ |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1250 |
return; |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1251 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1252 |
|
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
1253 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1254 |
info = g_malloc0 (sizeof (VPNActivateInfo)); |
1255 |
info->applet = applet; |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1256 |
info->vpn_name = g_strdup (nm_setting_connection_get_id (s_con)); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1257 |
|
1258 |
/* Connection inactive, activate */
|
|
1259 |
nm_client_activate_connection (applet->nm_client, |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1260 |
connection, |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1261 |
device, |
1262 |
nm_object_get_path (NM_OBJECT (active)), |
|
1263 |
activate_vpn_cb, |
|
1264 |
info); |
|
1.1.5
by Alexander Sack
Import upstream version 0.7~~svn20080927t101113 |
1265 |
start_animation_timeout (applet); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1266 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1267 |
// nmi_dbus_signal_user_interface_activated (applet->connection);
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1268 |
}
|
1269 |
||
1270 |
||
1271 |
/*
|
|
1272 |
* nma_menu_configure_vpn_item_activate
|
|
1273 |
*
|
|
1274 |
* Signal function called when user clicks "Configure VPN..."
|
|
1275 |
*
|
|
1276 |
*/
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1277 |
static void |
1278 |
nma_menu_configure_vpn_item_activate (GtkMenuItem *item, gpointer user_data) |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1279 |
{
|
1.2.21
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110616t193616.b2e6a33 |
1280 |
const char *argv[] = { BINDIR "/nm-connection-editor", "--show", "--type", NM_SETTING_VPN_SETTING_NAME, NULL}; |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1281 |
|
1282 |
g_spawn_async (NULL, (gchar **) argv, NULL, 0, NULL, NULL, NULL, NULL); |
|
1283 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1284 |
// nmi_dbus_signal_user_interface_activated (applet->connection);
|
1285 |
}
|
|
1286 |
||
1287 |
static NMActiveConnection * |
|
1288 |
applet_get_first_active_vpn_connection (NMApplet *applet, |
|
1289 |
NMVPNConnectionState *out_state) |
|
1290 |
{
|
|
1291 |
const GPtrArray *active_list; |
|
1292 |
int i; |
|
1293 |
||
1294 |
active_list = nm_client_get_active_connections (applet->nm_client); |
|
1295 |
for (i = 0; active_list && (i < active_list->len); i++) { |
|
1296 |
NMActiveConnection *candidate; |
|
1297 |
NMConnection *connection; |
|
1298 |
NMSettingConnection *s_con; |
|
1299 |
||
1300 |
candidate = g_ptr_array_index (active_list, i); |
|
1301 |
||
1302 |
connection = applet_get_connection_for_active (applet, candidate); |
|
1303 |
if (!connection) |
|
1304 |
continue; |
|
1305 |
||
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
1306 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1307 |
g_assert (s_con); |
1308 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1309 |
if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) { |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1310 |
if (out_state) |
1311 |
*out_state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (candidate)); |
|
1312 |
return candidate; |
|
1313 |
}
|
|
1314 |
}
|
|
1315 |
||
1316 |
return NULL; |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1317 |
}
|
1318 |
||
1319 |
/*
|
|
1320 |
* nma_menu_disconnect_vpn_item_activate
|
|
1321 |
*
|
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1322 |
* Signal function called when user clicks "Disconnect VPN"
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1323 |
*
|
1324 |
*/
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1325 |
static void |
1326 |
nma_menu_disconnect_vpn_item_activate (GtkMenuItem *item, gpointer user_data) |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1327 |
{
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1328 |
NMApplet *applet = NM_APPLET (user_data); |
1329 |
NMActiveConnection *active_vpn = NULL; |
|
1330 |
NMVPNConnectionState state = NM_VPN_CONNECTION_STATE_UNKNOWN; |
|
1331 |
||
1332 |
active_vpn = applet_get_first_active_vpn_connection (applet, &state); |
|
1333 |
if (active_vpn) |
|
1334 |
nm_client_deactivate_connection (applet->nm_client, active_vpn); |
|
1335 |
else
|
|
1336 |
g_warning ("%s: deactivate clicked but no active VPN connection could be found.", __func__); |
|
1337 |
// nmi_dbus_signal_user_interface_activated (applet->connection);
|
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1338 |
}
|
1339 |
||
1340 |
/*
|
|
1341 |
* nma_menu_add_separator_item
|
|
1342 |
*
|
|
1343 |
*/
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1344 |
static void |
1345 |
nma_menu_add_separator_item (GtkWidget *menu) |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1346 |
{
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1347 |
GtkWidget *menu_item; |
1348 |
||
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1349 |
menu_item = gtk_separator_menu_item_new (); |
1350 |
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); |
|
1351 |
gtk_widget_show (menu_item); |
|
1352 |
}
|
|
1353 |
||
1354 |
||
1355 |
/*
|
|
1356 |
* nma_menu_add_text_item
|
|
1357 |
*
|
|
1358 |
* Add a non-clickable text item to a menu
|
|
1359 |
*
|
|
1360 |
*/
|
|
1361 |
static void nma_menu_add_text_item (GtkWidget *menu, char *text) |
|
1362 |
{
|
|
1363 |
GtkWidget *menu_item; |
|
1364 |
||
1365 |
g_return_if_fail (text != NULL); |
|
1366 |
g_return_if_fail (menu != NULL); |
|
1367 |
||
1368 |
menu_item = gtk_menu_item_new_with_label (text); |
|
1369 |
gtk_widget_set_sensitive (menu_item, FALSE); |
|
1370 |
||
1371 |
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); |
|
1372 |
gtk_widget_show (menu_item); |
|
1373 |
}
|
|
1374 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1375 |
static gint |
1376 |
sort_devices (gconstpointer a, gconstpointer b) |
|
1377 |
{
|
|
1378 |
NMDevice *aa = NM_DEVICE (a); |
|
1379 |
NMDevice *bb = NM_DEVICE (b); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1380 |
GType aa_type = G_OBJECT_TYPE (G_OBJECT (aa)); |
1381 |
GType bb_type = G_OBJECT_TYPE (G_OBJECT (bb)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1382 |
|
1383 |
if (aa_type == bb_type) { |
|
1384 |
char *aa_desc = NULL; |
|
1385 |
char *bb_desc = NULL; |
|
1386 |
||
1387 |
aa_desc = (char *) utils_get_device_description (aa); |
|
1388 |
if (!aa_desc) |
|
1389 |
aa_desc = (char *) nm_device_get_iface (aa); |
|
1390 |
||
1391 |
bb_desc = (char *) utils_get_device_description (bb); |
|
1392 |
if (!bb_desc) |
|
1393 |
bb_desc = (char *) nm_device_get_iface (bb); |
|
1394 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1395 |
return g_strcmp0 (aa_desc, bb_desc); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1396 |
}
|
1397 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1398 |
/* Ethernet always first */
|
1399 |
if (aa_type == NM_TYPE_DEVICE_ETHERNET) |
|
1400 |
return -1; |
|
1401 |
if (bb_type == NM_TYPE_DEVICE_ETHERNET) |
|
1402 |
return 1; |
|
1403 |
||
1404 |
/* Modems next */
|
|
1405 |
if (aa_type == NM_TYPE_DEVICE_MODEM) |
|
1406 |
return -1; |
|
1407 |
if (bb_type == NM_TYPE_DEVICE_MODEM) |
|
1408 |
return 1; |
|
1409 |
||
1410 |
/* Bluetooth next */
|
|
1411 |
if (aa_type == NM_TYPE_DEVICE_BT) |
|
1412 |
return -1; |
|
1413 |
if (bb_type == NM_TYPE_DEVICE_BT) |
|
1414 |
return 1; |
|
1415 |
||
1416 |
/* WiMAX next */
|
|
1417 |
if (aa_type == NM_TYPE_DEVICE_WIMAX) |
|
1418 |
return -1; |
|
1419 |
if (bb_type == NM_TYPE_DEVICE_WIMAX) |
|
1420 |
return 1; |
|
1421 |
||
1422 |
/* WiFi last because it has many menu items */
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1423 |
return 1; |
1424 |
}
|
|
1425 |
||
1426 |
static gboolean |
|
1427 |
nm_g_ptr_array_contains (const GPtrArray *haystack, gpointer needle) |
|
1428 |
{
|
|
1429 |
int i; |
|
1430 |
||
1431 |
for (i = 0; haystack && (i < haystack->len); i++) { |
|
1432 |
if (g_ptr_array_index (haystack, i) == needle) |
|
1433 |
return TRUE; |
|
1434 |
}
|
|
1435 |
return FALSE; |
|
1436 |
}
|
|
1437 |
||
1438 |
NMConnection * |
|
1439 |
applet_find_active_connection_for_device (NMDevice *device, |
|
1440 |
NMApplet *applet, |
|
1441 |
NMActiveConnection **out_active) |
|
1442 |
{
|
|
1443 |
const GPtrArray *active_connections; |
|
1444 |
NMConnection *connection = NULL; |
|
1445 |
int i; |
|
1446 |
||
1447 |
g_return_val_if_fail (NM_IS_DEVICE (device), NULL); |
|
1448 |
g_return_val_if_fail (NM_IS_APPLET (applet), NULL); |
|
1449 |
if (out_active) |
|
1450 |
g_return_val_if_fail (*out_active == NULL, NULL); |
|
1451 |
||
1452 |
active_connections = nm_client_get_active_connections (applet->nm_client); |
|
1453 |
for (i = 0; active_connections && (i < active_connections->len); i++) { |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1454 |
NMRemoteConnection *tmp; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1455 |
NMActiveConnection *active; |
1456 |
const char *connection_path; |
|
1457 |
const GPtrArray *devices; |
|
1458 |
||
1459 |
active = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_connections, i)); |
|
1460 |
devices = nm_active_connection_get_devices (active); |
|
1461 |
connection_path = nm_active_connection_get_connection (active); |
|
1462 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1463 |
if (!devices || !connection_path) |
1.2.3
by Tony Espy
Import upstream version 0.7.1.git.3.0461fff8 |
1464 |
continue; |
1465 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1466 |
if (!nm_g_ptr_array_contains (devices, device)) |
1467 |
continue; |
|
1468 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1469 |
tmp = nm_remote_settings_get_connection_by_path (applet->settings, connection_path); |
1.2.6
by Alexander Sack
Import upstream version 0.8~a~git.20090913t161448.cc2f6be |
1470 |
if (tmp) { |
1471 |
connection = NM_CONNECTION (tmp); |
|
1472 |
if (out_active) |
|
1473 |
*out_active = active; |
|
1474 |
break; |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1475 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1476 |
}
|
1477 |
||
1478 |
return connection; |
|
1479 |
}
|
|
1480 |
||
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
1481 |
gboolean
|
1482 |
nma_menu_device_check_unusable (NMDevice *device) |
|
1483 |
{
|
|
1484 |
switch (nm_device_get_state (device)) { |
|
1485 |
case NM_DEVICE_STATE_UNKNOWN: |
|
1486 |
case NM_DEVICE_STATE_UNAVAILABLE: |
|
1487 |
case NM_DEVICE_STATE_UNMANAGED: |
|
1488 |
return TRUE; |
|
1489 |
default: |
|
1490 |
break; |
|
1491 |
}
|
|
1492 |
return FALSE; |
|
1493 |
}
|
|
1494 |
||
1495 |
||
1496 |
struct AppletDeviceMenuInfo { |
|
1497 |
NMDevice *device; |
|
1498 |
NMApplet *applet; |
|
1499 |
};
|
|
1500 |
||
1501 |
static void |
|
1502 |
applet_device_info_destroy (struct AppletDeviceMenuInfo *info) |
|
1503 |
{
|
|
1504 |
g_return_if_fail (info != NULL); |
|
1505 |
||
1506 |
if (info->device) |
|
1507 |
g_object_unref (info->device); |
|
1508 |
memset (info, 0, sizeof (struct AppletDeviceMenuInfo)); |
|
1509 |
g_free (info); |
|
1510 |
}
|
|
1511 |
||
1512 |
static void |
|
1513 |
applet_device_disconnect_db (GtkMenuItem *item, gpointer user_data) |
|
1514 |
{
|
|
1515 |
struct AppletDeviceMenuInfo *info = user_data; |
|
1516 |
||
1517 |
applet_menu_item_disconnect_helper (info->device, |
|
1518 |
info->applet); |
|
1519 |
}
|
|
1520 |
||
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
1521 |
GtkWidget * |
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
1522 |
nma_menu_device_get_menu_item (NMDevice *device, |
1523 |
NMApplet *applet, |
|
1524 |
const char *unavailable_msg) |
|
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
1525 |
{
|
1526 |
GtkWidget *item = NULL; |
|
1527 |
gboolean managed = TRUE; |
|
1528 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1529 |
if (!unavailable_msg) { |
1530 |
if (nm_device_get_firmware_missing (device)) |
|
1531 |
unavailable_msg = _("device not ready (firmware missing)"); |
|
1532 |
else
|
|
1533 |
unavailable_msg = _("device not ready"); |
|
1534 |
}
|
|
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
1535 |
|
1536 |
switch (nm_device_get_state (device)) { |
|
1537 |
case NM_DEVICE_STATE_UNKNOWN: |
|
1538 |
case NM_DEVICE_STATE_UNAVAILABLE: |
|
1539 |
item = gtk_menu_item_new_with_label (unavailable_msg); |
|
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
1540 |
gtk_widget_set_sensitive (item, FALSE); |
1541 |
break; |
|
1542 |
case NM_DEVICE_STATE_DISCONNECTED: |
|
1543 |
unavailable_msg = _("disconnected"); |
|
1544 |
item = gtk_menu_item_new_with_label (unavailable_msg); |
|
1545 |
gtk_widget_set_sensitive (item, FALSE); |
|
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
1546 |
break; |
1547 |
case NM_DEVICE_STATE_UNMANAGED: |
|
1548 |
managed = FALSE; |
|
1549 |
break; |
|
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
1550 |
case NM_DEVICE_STATE_PREPARE: |
1551 |
case NM_DEVICE_STATE_CONFIG: |
|
1552 |
case NM_DEVICE_STATE_NEED_AUTH: |
|
1553 |
case NM_DEVICE_STATE_IP_CONFIG: |
|
1554 |
case NM_DEVICE_STATE_ACTIVATED: |
|
1555 |
{
|
|
1556 |
struct AppletDeviceMenuInfo *info = g_new0 (struct AppletDeviceMenuInfo, 1); |
|
1557 |
info->device = g_object_ref (device); |
|
1558 |
info->applet = applet; |
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
1559 |
item = gtk_menu_item_new_with_label (_("Disconnect")); |
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
1560 |
g_signal_connect_data (item, "activate", |
1561 |
G_CALLBACK (applet_device_disconnect_db), |
|
1562 |
info, |
|
1563 |
(GClosureNotify) applet_device_info_destroy, 0); |
|
1564 |
gtk_widget_set_sensitive (item, TRUE); |
|
1565 |
break; |
|
1566 |
}
|
|
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
1567 |
default: |
1568 |
managed = nm_device_get_managed (device); |
|
1569 |
break; |
|
1570 |
}
|
|
1571 |
||
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
1572 |
if (!managed) { |
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
1573 |
item = gtk_menu_item_new_with_label (_("device not managed")); |
1574 |
gtk_widget_set_sensitive (item, FALSE); |
|
1.2.7
by Alexander Sack
Import upstream version 0.8~a~git.20090923t220421.1ac8ffd |
1575 |
}
|
1.1.11
by Alexander Sack
Import upstream version 0.7.1~20090213+bzr960 |
1576 |
|
1577 |
return item; |
|
1578 |
}
|
|
1579 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1580 |
static guint32 |
1581 |
nma_menu_add_devices (GtkWidget *menu, NMApplet *applet) |
|
1582 |
{
|
|
1583 |
const GPtrArray *temp = NULL; |
|
1584 |
GSList *devices = NULL, *iter = NULL; |
|
1.1.3
by Alexander Sack
Import upstream version 0.7~~svn20080817t183748 |
1585 |
gint n_wifi_devices = 0; |
1586 |
gint n_usable_wifi_devices = 0; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1587 |
gint n_wired_devices = 0; |
1.1.7
by Alexander Sack
Import upstream version 0.7~~svn20081012t133407 |
1588 |
gint n_mb_devices = 0; |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1589 |
gint n_bt_devices = 0; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1590 |
int i; |
1591 |
||
1592 |
temp = nm_client_get_devices (applet->nm_client); |
|
1593 |
for (i = 0; temp && (i < temp->len); i++) |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1594 |
devices = g_slist_insert_sorted (devices, g_ptr_array_index (temp, i), sort_devices); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1595 |
|
1596 |
for (iter = devices; iter; iter = iter->next) { |
|
1597 |
NMDevice *device = NM_DEVICE (iter->data); |
|
1598 |
||
1599 |
/* Ignore unsupported devices */
|
|
1600 |
if (!(nm_device_get_capabilities (device) & NM_DEVICE_CAP_NM_SUPPORTED)) |
|
1601 |
continue; |
|
1602 |
||
1603 |
if (NM_IS_DEVICE_WIFI (device)) { |
|
1.1.3
by Alexander Sack
Import upstream version 0.7~~svn20080817t183748 |
1604 |
n_wifi_devices++; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1605 |
if ( nm_client_wireless_get_enabled (applet->nm_client) |
1.1.3
by Alexander Sack
Import upstream version 0.7~~svn20080817t183748 |
1606 |
&& (nm_device_get_state (device) >= NM_DEVICE_STATE_DISCONNECTED)) |
1607 |
n_usable_wifi_devices++; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1608 |
} else if (NM_IS_DEVICE_ETHERNET (device)) |
1609 |
n_wired_devices++; |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1610 |
else if (NM_IS_DEVICE_MODEM (device)) |
1.1.7
by Alexander Sack
Import upstream version 0.7~~svn20081012t133407 |
1611 |
n_mb_devices++; |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1612 |
else if (NM_IS_DEVICE_BT (device)) |
1613 |
n_bt_devices++; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1614 |
}
|
1615 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1616 |
if (!n_wired_devices && !n_wifi_devices && !n_mb_devices && !n_bt_devices) { |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1617 |
nma_menu_add_text_item (menu, _("No network devices available")); |
1618 |
goto out; |
|
1619 |
}
|
|
1620 |
||
1621 |
/* Add all devices in our device list to the menu */
|
|
1622 |
for (iter = devices; iter; iter = iter->next) { |
|
1623 |
NMDevice *device = NM_DEVICE (iter->data); |
|
1624 |
gint n_devices = 0; |
|
1625 |
NMADeviceClass *dclass; |
|
1626 |
NMConnection *active; |
|
1627 |
||
1628 |
/* Ignore unsupported devices */
|
|
1629 |
if (!(nm_device_get_capabilities (device) & NM_DEVICE_CAP_NM_SUPPORTED)) |
|
1630 |
continue; |
|
1631 |
||
1632 |
if (NM_IS_DEVICE_WIFI (device)) |
|
1.1.3
by Alexander Sack
Import upstream version 0.7~~svn20080817t183748 |
1633 |
n_devices = n_wifi_devices; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1634 |
else if (NM_IS_DEVICE_ETHERNET (device)) |
1635 |
n_devices = n_wired_devices; |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1636 |
else if (NM_IS_DEVICE_MODEM (device)) |
1.1.7
by Alexander Sack
Import upstream version 0.7~~svn20081012t133407 |
1637 |
n_devices = n_mb_devices; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1638 |
|
1639 |
active = applet_find_active_connection_for_device (device, applet, NULL); |
|
1640 |
||
1641 |
dclass = get_device_class (device, applet); |
|
1642 |
if (dclass) |
|
1643 |
dclass->add_menu_item (device, n_devices, active, menu, applet); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1644 |
|
1645 |
nma_menu_add_separator_item (menu); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1646 |
}
|
1647 |
||
1648 |
out: |
|
1649 |
g_slist_free (devices); |
|
1.1.3
by Alexander Sack
Import upstream version 0.7~~svn20080817t183748 |
1650 |
|
1651 |
/* Return # of usable wifi devices here for correct enable/disable state
|
|
1652 |
* of things like Enable Wireless, "Connect to other..." and such.
|
|
1653 |
*/
|
|
1654 |
return n_usable_wifi_devices; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1655 |
}
|
1656 |
||
1657 |
static int |
|
1658 |
sort_vpn_connections (gconstpointer a, gconstpointer b) |
|
1659 |
{
|
|
1660 |
return strcmp (get_connection_id (NM_CONNECTION (a)), get_connection_id (NM_CONNECTION (b))); |
|
1661 |
}
|
|
1662 |
||
1663 |
static GSList * |
|
1664 |
get_vpn_connections (NMApplet *applet) |
|
1665 |
{
|
|
1666 |
GSList *all_connections; |
|
1.1.1
by Alexander Sack
Import upstream version 0.6.6 |
1667 |
GSList *iter; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1668 |
GSList *list = NULL; |
1669 |
||
1670 |
all_connections = applet_get_all_connections (applet); |
|
1671 |
||
1672 |
for (iter = all_connections; iter; iter = iter->next) { |
|
1673 |
NMConnection *connection = NM_CONNECTION (iter->data); |
|
1674 |
NMSettingConnection *s_con; |
|
1675 |
||
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
1676 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1677 |
if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1678 |
/* Not a VPN connection */
|
1679 |
continue; |
|
1680 |
||
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
1681 |
if (!nm_connection_get_setting_vpn (connection)) { |
1.2.19
by Mathieu Trudel-Lapierre
Import upstream version 0.8.4 |
1682 |
g_warning ("%s: VPN connection '%s' didn't have required vpn setting.", __func__, |
1683 |
nm_setting_connection_get_id (s_con)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1684 |
continue; |
1685 |
}
|
|
1686 |
||
1687 |
list = g_slist_prepend (list, connection); |
|
1.1.1
by Alexander Sack
Import upstream version 0.6.6 |
1688 |
}
|
1689 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1690 |
g_slist_free (all_connections); |
1691 |
||
1692 |
return g_slist_sort (list, sort_vpn_connections); |
|
1693 |
}
|
|
1694 |
||
1695 |
static void |
|
1696 |
nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet) |
|
1697 |
{
|
|
1698 |
GtkMenu *vpn_menu; |
|
1699 |
GtkMenuItem *item; |
|
1700 |
GSList *list, *iter; |
|
1701 |
int num_vpn_active = 0; |
|
1702 |
||
1703 |
vpn_menu = GTK_MENU (gtk_menu_new ()); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1704 |
|
1705 |
item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_VPN Connections"))); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1706 |
gtk_menu_item_set_submenu (item, GTK_WIDGET (vpn_menu)); |
1707 |
gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item)); |
|
1708 |
||
1709 |
list = get_vpn_connections (applet); |
|
1710 |
for (iter = list; iter; iter = g_slist_next (iter)) { |
|
1711 |
NMConnection *connection = NM_CONNECTION (iter->data); |
|
1712 |
||
1713 |
if (applet_get_active_for_connection (applet, connection)) |
|
1714 |
num_vpn_active++; |
|
1715 |
}
|
|
1716 |
||
1717 |
for (iter = list; iter; iter = g_slist_next (iter)) { |
|
1718 |
NMConnection *connection = NM_CONNECTION (iter->data); |
|
1719 |
NMActiveConnection *active; |
|
1720 |
const char *name; |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1721 |
#ifndef ENABLE_INDICATOR
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
1722 |
GtkWidget *image; |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
1723 |
#endif /* ENABLE_INDICATOR */ |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1724 |
NMState state; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1725 |
|
1726 |
name = get_connection_id (connection); |
|
1727 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1728 |
#ifndef ENABLE_INDICATOR
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
1729 |
item = GTK_MENU_ITEM (gtk_image_menu_item_new_with_label (name)); |
1730 |
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1731 |
#else
|
1732 |
item = GTK_MENU_ITEM (gtk_check_menu_item_new_with_label (name)); |
|
1733 |
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), FALSE); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
1734 |
#endif /* ENABLE_INDICATOR */ |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1735 |
|
1736 |
/* If no VPN connections are active, draw all menu items enabled. If
|
|
1737 |
* >= 1 VPN connections are active, only the active VPN menu item is
|
|
1738 |
* drawn enabled.
|
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1739 |
*/
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1740 |
active = applet_get_active_for_connection (applet, connection); |
1741 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1742 |
state = nm_client_get_state (applet->nm_client); |
1743 |
if ( state != NM_STATE_CONNECTED_LOCAL |
|
1744 |
&& state != NM_STATE_CONNECTED_SITE |
|
1745 |
&& state != NM_STATE_CONNECTED_GLOBAL) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1746 |
gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); |
1747 |
else if ((num_vpn_active == 0) || active) |
|
1748 |
gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE); |
|
1749 |
else
|
|
1750 |
gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); |
|
1751 |
||
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
1752 |
if (active) { |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1753 |
#ifndef ENABLE_INDICATOR
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
1754 |
image = gtk_image_new_from_stock (GTK_STOCK_CONNECT, GTK_ICON_SIZE_MENU); |
1755 |
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1756 |
#else
|
1757 |
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM(item), TRUE); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
1758 |
#endif /* ENABLE_INDICATOR */ |
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
1759 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1760 |
|
1761 |
g_object_set_data_full (G_OBJECT (item), "connection", |
|
1762 |
g_object_ref (connection), |
|
1763 |
(GDestroyNotify) g_object_unref); |
|
1764 |
||
1765 |
g_signal_connect (item, "activate", G_CALLBACK (nma_menu_vpn_item_clicked), applet); |
|
1766 |
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item)); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1767 |
}
|
1768 |
||
1769 |
/* Draw a seperator, but only if we have VPN connections above it */
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1770 |
if (list) |
1771 |
nma_menu_add_separator_item (GTK_WIDGET (vpn_menu)); |
|
1772 |
||
1773 |
item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Configure VPN..."))); |
|
1774 |
g_signal_connect (item, "activate", G_CALLBACK (nma_menu_configure_vpn_item_activate), applet); |
|
1775 |
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item)); |
|
1776 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1777 |
item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Disconnect VPN"))); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1778 |
g_signal_connect (item, "activate", G_CALLBACK (nma_menu_disconnect_vpn_item_activate), applet); |
1779 |
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item)); |
|
1780 |
if (num_vpn_active == 0) |
|
1781 |
gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE); |
|
1782 |
||
1783 |
g_slist_free (list); |
|
1784 |
}
|
|
1785 |
||
1786 |
||
1787 |
static void |
|
1788 |
nma_set_wireless_enabled_cb (GtkWidget *widget, NMApplet *applet) |
|
1789 |
{
|
|
1790 |
gboolean state; |
|
1791 |
||
1792 |
g_return_if_fail (applet != NULL); |
|
1793 |
||
1794 |
state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)); |
|
1795 |
nm_client_wireless_set_enabled (applet->nm_client, state); |
|
1796 |
}
|
|
1797 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1798 |
static void |
1799 |
nma_set_wwan_enabled_cb (GtkWidget *widget, NMApplet *applet) |
|
1800 |
{
|
|
1801 |
gboolean state; |
|
1802 |
||
1803 |
g_return_if_fail (applet != NULL); |
|
1804 |
||
1805 |
state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)); |
|
1806 |
nm_client_wwan_set_enabled (applet->nm_client, state); |
|
1807 |
}
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1808 |
|
1809 |
static void |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1810 |
nma_set_wimax_enabled_cb (GtkWidget *widget, NMApplet *applet) |
1811 |
{
|
|
1812 |
gboolean state; |
|
1813 |
||
1814 |
g_return_if_fail (applet != NULL); |
|
1815 |
||
1816 |
state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)); |
|
1817 |
nm_client_wimax_set_enabled (applet->nm_client, state); |
|
1818 |
}
|
|
1819 |
||
1820 |
static void |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1821 |
nma_set_networking_enabled_cb (GtkWidget *widget, NMApplet *applet) |
1822 |
{
|
|
1823 |
gboolean state; |
|
1824 |
||
1825 |
g_return_if_fail (applet != NULL); |
|
1826 |
||
1827 |
state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1828 |
nm_client_networking_set_enabled (applet->nm_client, state); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1829 |
}
|
1830 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1831 |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1832 |
#ifndef ENABLE_INDICATOR
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1833 |
static void |
1834 |
nma_set_notifications_enabled_cb (GtkWidget *widget, NMApplet *applet) |
|
1835 |
{
|
|
1836 |
gboolean state; |
|
1837 |
||
1838 |
g_return_if_fail (applet != NULL); |
|
1839 |
||
1840 |
state = gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (widget)); |
|
1841 |
||
1842 |
gconf_client_set_bool (applet->gconf_client, |
|
1843 |
PREF_DISABLE_CONNECTED_NOTIFICATIONS, |
|
1844 |
!state, |
|
1845 |
NULL); |
|
1846 |
gconf_client_set_bool (applet->gconf_client, |
|
1847 |
PREF_DISABLE_DISCONNECTED_NOTIFICATIONS, |
|
1848 |
!state, |
|
1849 |
NULL); |
|
1850 |
gconf_client_set_bool (applet->gconf_client, |
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
1851 |
PREF_DISABLE_VPN_NOTIFICATIONS, |
1852 |
!state, |
|
1853 |
NULL); |
|
1854 |
gconf_client_set_bool (applet->gconf_client, |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1855 |
PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE, |
1856 |
!state, |
|
1857 |
NULL); |
|
1858 |
}
|
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
1859 |
#endif /* ENABLE_INDICATOR */ |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1860 |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1861 |
/*
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1862 |
* nma_menu_show_cb
|
1863 |
*
|
|
1864 |
* Pop up the wireless networks menu
|
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1865 |
*
|
1866 |
*/
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1867 |
static void nma_menu_show_cb (GtkWidget *menu, NMApplet *applet) |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1868 |
{
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1869 |
guint32 n_wireless; |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1870 |
|
1871 |
g_return_if_fail (menu != NULL); |
|
1872 |
g_return_if_fail (applet != NULL); |
|
1873 |
||
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
1874 |
gtk_status_icon_set_tooltip_text (applet->status_icon, NULL); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1875 |
|
1876 |
if (!nm_client_get_manager_running (applet->nm_client)) { |
|
1877 |
nma_menu_add_text_item (menu, _("NetworkManager is not running...")); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1878 |
return; |
1879 |
}
|
|
1880 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1881 |
if (nm_client_get_state (applet->nm_client) == NM_STATE_ASLEEP) { |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1882 |
nma_menu_add_text_item (menu, _("Networking disabled")); |
1883 |
return; |
|
1884 |
}
|
|
1885 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1886 |
n_wireless = nma_menu_add_devices (menu, applet); |
1887 |
||
1888 |
if (n_wireless > 0 && nm_client_wireless_get_enabled (applet->nm_client)) { |
|
1.1.6
by Alexander Sack
Import upstream version 0.7~~svn20081005t082522 |
1889 |
/* Add the "Hidden wireless network..." entry */
|
1890 |
nma_menu_add_hidden_network_item (menu, applet); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1891 |
nma_menu_add_create_network_item (menu, applet); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1892 |
nma_menu_add_separator_item (menu); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1893 |
}
|
1.1.1
by Alexander Sack
Import upstream version 0.6.6 |
1894 |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1895 |
nma_menu_add_vpn_submenu (menu, applet); |
1896 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1897 |
gtk_widget_show_all (menu); |
1898 |
||
1899 |
// nmi_dbus_signal_user_interface_activated (applet->connection);
|
|
1900 |
}
|
|
1901 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1902 |
static gboolean |
1903 |
destroy_old_menu (gpointer user_data) |
|
1904 |
{
|
|
1905 |
g_object_unref (user_data); |
|
1906 |
return FALSE; |
|
1907 |
}
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1908 |
|
1909 |
static void |
|
1910 |
nma_menu_deactivate_cb (GtkWidget *widget, NMApplet *applet) |
|
1911 |
{
|
|
1912 |
/* Must punt the destroy to a low-priority idle to ensure that
|
|
1913 |
* the menu items don't get destroyed before any 'activate' signal
|
|
1914 |
* fires for an item.
|
|
1915 |
*/
|
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1916 |
g_signal_handlers_disconnect_by_func (applet->menu, G_CALLBACK (nma_menu_deactivate_cb), applet); |
1917 |
g_idle_add_full (G_PRIORITY_LOW, destroy_old_menu, applet->menu, NULL); |
|
1918 |
applet->menu = NULL; |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1919 |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
1920 |
/* Re-set the tooltip */
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
1921 |
gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1922 |
}
|
1923 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1924 |
static gboolean |
1925 |
is_permission_yes (NMApplet *applet, NMClientPermission perm) |
|
1926 |
{
|
|
1927 |
if ( applet->permissions[perm] == NM_CLIENT_PERMISSION_RESULT_YES |
|
1928 |
|| applet->permissions[perm] == NM_CLIENT_PERMISSION_RESULT_AUTH) |
|
1929 |
return TRUE; |
|
1930 |
return FALSE; |
|
1931 |
}
|
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1932 |
|
1933 |
/*
|
|
1934 |
* nma_context_menu_update
|
|
1935 |
*
|
|
1936 |
*/
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1937 |
static void |
1938 |
nma_context_menu_update (NMApplet *applet) |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1939 |
{
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1940 |
NMState state; |
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1941 |
gboolean net_enabled = TRUE; |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
1942 |
gboolean have_wireless = FALSE; |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1943 |
gboolean have_wwan = FALSE; |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1944 |
gboolean have_wimax = FALSE; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1945 |
gboolean wireless_hw_enabled; |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1946 |
gboolean wwan_hw_enabled; |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1947 |
gboolean wimax_hw_enabled; |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
1948 |
#ifndef ENABLE_INDICATOR
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1949 |
gboolean notifications_enabled = TRUE; |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
1950 |
#endif /* ENABLE_INDICATOR */ |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1951 |
gboolean sensitive = FALSE; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1952 |
|
1953 |
state = nm_client_get_state (applet->nm_client); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1954 |
sensitive = ( state == NM_STATE_CONNECTED_LOCAL |
1955 |
|| state == NM_STATE_CONNECTED_SITE |
|
1956 |
|| state == NM_STATE_CONNECTED_GLOBAL); |
|
1957 |
gtk_widget_set_sensitive (applet->info_menu_item, sensitive); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1958 |
|
1959 |
/* Update checkboxes, and block 'toggled' signal when updating so that the
|
|
1960 |
* callback doesn't get triggered.
|
|
1961 |
*/
|
|
1962 |
||
1963 |
/* Enabled Networking */
|
|
1964 |
g_signal_handler_block (G_OBJECT (applet->networking_enabled_item), |
|
1965 |
applet->networking_enabled_toggled_id); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1966 |
net_enabled = nm_client_networking_get_enabled (applet->nm_client); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1967 |
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->networking_enabled_item), |
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1968 |
net_enabled && (state != NM_STATE_ASLEEP)); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1969 |
g_signal_handler_unblock (G_OBJECT (applet->networking_enabled_item), |
1970 |
applet->networking_enabled_toggled_id); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1971 |
gtk_widget_set_sensitive (applet->networking_enabled_item, |
1972 |
is_permission_yes (applet, NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1973 |
|
1974 |
/* Enabled Wireless */
|
|
1975 |
g_signal_handler_block (G_OBJECT (applet->wifi_enabled_item), |
|
1976 |
applet->wifi_enabled_toggled_id); |
|
1977 |
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->wifi_enabled_item), |
|
1978 |
nm_client_wireless_get_enabled (applet->nm_client)); |
|
1979 |
g_signal_handler_unblock (G_OBJECT (applet->wifi_enabled_item), |
|
1980 |
applet->wifi_enabled_toggled_id); |
|
1981 |
||
1982 |
wireless_hw_enabled = nm_client_wireless_hardware_get_enabled (applet->nm_client); |
|
1983 |
gtk_widget_set_sensitive (GTK_WIDGET (applet->wifi_enabled_item), |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1984 |
wireless_hw_enabled && is_permission_yes (applet, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI)); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
1985 |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1986 |
/* Enabled Mobile Broadband */
|
1987 |
g_signal_handler_block (G_OBJECT (applet->wwan_enabled_item), |
|
1988 |
applet->wwan_enabled_toggled_id); |
|
1989 |
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->wwan_enabled_item), |
|
1990 |
nm_client_wwan_get_enabled (applet->nm_client)); |
|
1991 |
g_signal_handler_unblock (G_OBJECT (applet->wwan_enabled_item), |
|
1992 |
applet->wwan_enabled_toggled_id); |
|
1993 |
||
1994 |
wwan_hw_enabled = nm_client_wwan_hardware_get_enabled (applet->nm_client); |
|
1995 |
gtk_widget_set_sensitive (GTK_WIDGET (applet->wwan_enabled_item), |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
1996 |
wwan_hw_enabled && is_permission_yes (applet, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN)); |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
1997 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
1998 |
/* Enable WiMAX */
|
1999 |
g_signal_handler_block (G_OBJECT (applet->wimax_enabled_item), |
|
2000 |
applet->wimax_enabled_toggled_id); |
|
2001 |
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->wimax_enabled_item), |
|
2002 |
nm_client_wimax_get_enabled (applet->nm_client)); |
|
2003 |
g_signal_handler_unblock (G_OBJECT (applet->wimax_enabled_item), |
|
2004 |
applet->wimax_enabled_toggled_id); |
|
2005 |
||
2006 |
wimax_hw_enabled = nm_client_wimax_hardware_get_enabled (applet->nm_client); |
|
2007 |
gtk_widget_set_sensitive (GTK_WIDGET (applet->wimax_enabled_item), |
|
2008 |
wimax_hw_enabled && is_permission_yes (applet, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX)); |
|
2009 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2010 |
#ifndef ENABLE_INDICATOR
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2011 |
/* Enabled notifications */
|
2012 |
g_signal_handler_block (G_OBJECT (applet->notifications_enabled_item), |
|
2013 |
applet->notifications_enabled_toggled_id); |
|
2014 |
if ( gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_CONNECTED_NOTIFICATIONS, NULL) |
|
2015 |
&& gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS, NULL) |
|
1.2.16
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110203t003354.9bf0b98 |
2016 |
&& gconf_client_get_bool (applet->gconf_client, PREF_DISABLE_VPN_NOTIFICATIONS, NULL) |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2017 |
&& gconf_client_get_bool (applet->gconf_client, PREF_SUPPRESS_WIRELESS_NETWORKS_AVAILABLE, NULL)) |
2018 |
notifications_enabled = FALSE; |
|
2019 |
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (applet->notifications_enabled_item), notifications_enabled); |
|
2020 |
g_signal_handler_unblock (G_OBJECT (applet->notifications_enabled_item), |
|
2021 |
applet->notifications_enabled_toggled_id); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2022 |
#endif /* ENABLE_INDICATOR */ |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2023 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2024 |
/* Don't show wifi-specific stuff if wireless is off */
|
2025 |
if (state != NM_STATE_ASLEEP) { |
|
2026 |
const GPtrArray *devices; |
|
2027 |
int i; |
|
2028 |
||
2029 |
devices = nm_client_get_devices (applet->nm_client); |
|
2030 |
for (i = 0; devices && (i < devices->len); i++) { |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2031 |
NMDevice *candidate = g_ptr_array_index (devices, i); |
2032 |
||
2033 |
if (NM_IS_DEVICE_WIFI (candidate)) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2034 |
have_wireless = TRUE; |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2035 |
else if (NM_IS_DEVICE_MODEM (candidate)) |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2036 |
have_wwan = TRUE; |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2037 |
else if (NM_IS_DEVICE_WIMAX (candidate)) |
2038 |
have_wimax = TRUE; |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2039 |
}
|
2040 |
}
|
|
2041 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2042 |
if (have_wireless) |
2043 |
gtk_widget_show_all (applet->wifi_enabled_item); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2044 |
else
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2045 |
gtk_widget_hide (applet->wifi_enabled_item); |
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2046 |
|
2047 |
if (have_wwan) |
|
2048 |
gtk_widget_show_all (applet->wwan_enabled_item); |
|
2049 |
else
|
|
2050 |
gtk_widget_hide (applet->wwan_enabled_item); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2051 |
|
2052 |
if (have_wimax) |
|
2053 |
gtk_widget_show_all (applet->wimax_enabled_item); |
|
2054 |
else
|
|
2055 |
gtk_widget_hide (applet->wimax_enabled_item); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2056 |
}
|
2057 |
||
2058 |
static void |
|
2059 |
ce_child_setup (gpointer user_data G_GNUC_UNUSED) |
|
2060 |
{
|
|
2061 |
/* We are in the child process at this point */
|
|
2062 |
pid_t pid = getpid (); |
|
2063 |
setpgid (pid, pid); |
|
2064 |
}
|
|
2065 |
||
2066 |
static void |
|
2067 |
nma_edit_connections_cb (GtkMenuItem *mi, NMApplet *applet) |
|
2068 |
{
|
|
2069 |
char *argv[2]; |
|
2070 |
GError *error = NULL; |
|
2071 |
gboolean success; |
|
2072 |
||
2073 |
argv[0] = BINDIR "/nm-connection-editor"; |
|
2074 |
argv[1] = NULL; |
|
2075 |
||
2076 |
success = g_spawn_async ("/", argv, NULL, 0, &ce_child_setup, NULL, NULL, &error); |
|
2077 |
if (!success) { |
|
2078 |
g_warning ("Error launching connection editor: %s", error->message); |
|
2079 |
g_error_free (error); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2080 |
}
|
2081 |
}
|
|
2082 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2083 |
static void |
2084 |
applet_connection_info_cb (NMApplet *applet) |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2085 |
{
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2086 |
applet_info_dialog_show (applet); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2087 |
}
|
2088 |
||
2089 |
/*
|
|
2090 |
* nma_context_menu_create
|
|
2091 |
*
|
|
2092 |
* Generate the contextual popup menu.
|
|
2093 |
*
|
|
2094 |
*/
|
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2095 |
static GtkWidget *nma_context_menu_create (NMApplet *applet, GtkMenuShell *menu) |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2096 |
{
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2097 |
#ifndef ENABLE_INDICATOR
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2098 |
GtkMenuShell *menu; |
2099 |
GtkWidget *menu_item; |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2100 |
#endif
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2101 |
GtkWidget *image; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2102 |
guint id; |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2103 |
|
2104 |
g_return_val_if_fail (applet != NULL, NULL); |
|
2105 |
||
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2106 |
#ifndef ENABLE_INDICATOR
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2107 |
menu = GTK_MENU_SHELL (gtk_menu_new ()); |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2108 |
#endif
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2109 |
|
2110 |
/* 'Enable Networking' item */
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2111 |
applet->networking_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable _Networking")); |
2112 |
id = g_signal_connect (applet->networking_enabled_item, |
|
2113 |
"toggled", |
|
2114 |
G_CALLBACK (nma_set_networking_enabled_cb), |
|
2115 |
applet); |
|
2116 |
applet->networking_enabled_toggled_id = id; |
|
2117 |
gtk_menu_shell_append (menu, applet->networking_enabled_item); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2118 |
|
2119 |
/* 'Enable Wireless' item */
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2120 |
applet->wifi_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable _Wireless")); |
2121 |
id = g_signal_connect (applet->wifi_enabled_item, |
|
2122 |
"toggled", |
|
2123 |
G_CALLBACK (nma_set_wireless_enabled_cb), |
|
2124 |
applet); |
|
2125 |
applet->wifi_enabled_toggled_id = id; |
|
2126 |
gtk_menu_shell_append (menu, applet->wifi_enabled_item); |
|
1.1.1
by Alexander Sack
Import upstream version 0.6.6 |
2127 |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2128 |
/* 'Enable Mobile Broadband' item */
|
2129 |
applet->wwan_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable _Mobile Broadband")); |
|
2130 |
id = g_signal_connect (applet->wwan_enabled_item, |
|
2131 |
"toggled", |
|
2132 |
G_CALLBACK (nma_set_wwan_enabled_cb), |
|
2133 |
applet); |
|
2134 |
applet->wwan_enabled_toggled_id = id; |
|
2135 |
gtk_menu_shell_append (menu, applet->wwan_enabled_item); |
|
2136 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2137 |
/* 'Enable WiMAX Mobile Broadband' item */
|
2138 |
applet->wimax_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable WiMA_X Mobile Broadband")); |
|
2139 |
id = g_signal_connect (applet->wimax_enabled_item, |
|
2140 |
"toggled", |
|
2141 |
G_CALLBACK (nma_set_wimax_enabled_cb), |
|
2142 |
applet); |
|
2143 |
applet->wimax_enabled_toggled_id = id; |
|
2144 |
gtk_menu_shell_append (menu, applet->wimax_enabled_item); |
|
2145 |
||
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2146 |
nma_menu_add_separator_item (GTK_WIDGET (menu)); |
2147 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2148 |
#ifndef ENABLE_INDICATOR
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2149 |
/* Toggle notifications item */
|
2150 |
applet->notifications_enabled_item = gtk_check_menu_item_new_with_mnemonic (_("Enable N_otifications")); |
|
2151 |
id = g_signal_connect (applet->notifications_enabled_item, |
|
2152 |
"toggled", |
|
2153 |
G_CALLBACK (nma_set_notifications_enabled_cb), |
|
2154 |
applet); |
|
2155 |
applet->notifications_enabled_toggled_id = id; |
|
2156 |
gtk_menu_shell_append (menu, applet->notifications_enabled_item); |
|
2157 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2158 |
nma_menu_add_separator_item (GTK_WIDGET (menu)); |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2159 |
#endif /* ENABLE_INDICATOR */ |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2160 |
|
2161 |
/* 'Connection Information' item */
|
|
2162 |
applet->info_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Connection _Information")); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2163 |
g_signal_connect_swapped (applet->info_menu_item, |
2164 |
"activate", |
|
2165 |
G_CALLBACK (applet_connection_info_cb), |
|
2166 |
applet); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2167 |
image = gtk_image_new_from_stock (GTK_STOCK_INFO, GTK_ICON_SIZE_MENU); |
2168 |
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->info_menu_item), image); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2169 |
gtk_menu_shell_append (menu, applet->info_menu_item); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2170 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2171 |
/* 'Edit Connections...' item */
|
2172 |
applet->connections_menu_item = gtk_image_menu_item_new_with_mnemonic (_("Edit Connections...")); |
|
2173 |
g_signal_connect (applet->connections_menu_item, |
|
2174 |
"activate", |
|
2175 |
G_CALLBACK (nma_edit_connections_cb), |
|
2176 |
applet); |
|
1.1.1
by Alexander Sack
Import upstream version 0.6.6 |
2177 |
image = gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2178 |
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (applet->connections_menu_item), image); |
2179 |
gtk_menu_shell_append (menu, applet->connections_menu_item); |
|
1.1.1
by Alexander Sack
Import upstream version 0.6.6 |
2180 |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2181 |
#ifndef ENABLE_INDICATOR
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2182 |
/* Separator */
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2183 |
nma_menu_add_separator_item (GTK_WIDGET (menu)); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2184 |
|
2185 |
#if 0 /* FIXME: Implement the help callback, nma_help_cb()! */ |
|
2186 |
/* Help item */
|
|
2187 |
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Help"));
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2188 |
g_signal_connect (menu_item, "activate", G_CALLBACK (nma_help_cb), applet);
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2189 |
image = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_MENU);
|
2190 |
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image);
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2191 |
gtk_menu_shell_append (menu, menu_item);
|
2192 |
gtk_widget_set_sensitive (menu_item, FALSE);
|
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2193 |
#endif
|
2194 |
||
2195 |
/* About item */
|
|
2196 |
menu_item = gtk_image_menu_item_new_with_mnemonic (_("_About")); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2197 |
g_signal_connect_swapped (menu_item, "activate", G_CALLBACK (applet_about_dialog_show), applet); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2198 |
image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_MENU); |
2199 |
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2200 |
gtk_menu_shell_append (menu, menu_item); |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2201 |
#endif /* ENABLE_INDICATOR */ |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2202 |
|
2203 |
gtk_widget_show_all (GTK_WIDGET (menu)); |
|
2204 |
||
2205 |
return GTK_WIDGET (menu); |
|
2206 |
}
|
|
2207 |
||
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
2208 |
#ifdef ENABLE_INDICATOR
|
2209 |
static void |
|
2210 |
indicator_update_menu (NMApplet *applet) |
|
2211 |
{
|
|
83
by Mathieu Trudel-Lapierre
* debian/patches/nm-applet-use-indicator.patch: |
2212 |
if (!applet->in_fallback) { |
2213 |
if (applet->menu) |
|
2214 |
g_object_unref (applet->menu); |
|
2215 |
||
2216 |
applet->menu = gtk_menu_new (); |
|
2217 |
g_object_ref_sink (G_OBJECT (applet->menu)); |
|
2218 |
nma_menu_show_cb (applet->menu, applet); |
|
2219 |
nma_menu_add_separator_item (applet->menu); |
|
2220 |
applet->menu = nma_context_menu_create (applet, GTK_MENU_SHELL(applet->menu)); |
|
2221 |
||
2222 |
app_indicator_set_menu (applet->app_indicator, GTK_MENU (applet->menu)); |
|
2223 |
||
2224 |
nma_context_menu_update (applet); |
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
2225 |
}
|
2226 |
||
2227 |
applet->update_menu_id = 0; |
|
2228 |
}
|
|
2229 |
||
2230 |
static gboolean |
|
2231 |
applet_update_indicator_menu (gpointer user_data) |
|
2232 |
{
|
|
2233 |
NMApplet *applet = NM_APPLET (user_data); |
|
2234 |
||
2235 |
indicator_update_menu (applet); |
|
2236 |
||
2237 |
return FALSE; |
|
2238 |
}
|
|
2239 |
||
2240 |
void
|
|
2241 |
applet_schedule_update_menu (NMApplet *applet) |
|
2242 |
{
|
|
2243 |
if (!applet->update_menu_id) |
|
2244 |
applet->update_menu_id = g_idle_add (applet_update_indicator_menu, applet); |
|
2245 |
}
|
|
2246 |
||
2247 |
static void |
|
2248 |
new_connection_cb (NMRemoteSettings *settings, NMRemoteConnection *connection, gpointer user_data) |
|
2249 |
{
|
|
2250 |
NMApplet *applet = NM_APPLET (user_data); |
|
2251 |
||
2252 |
//if (nm_connection_is_type (NM_CONNECTION (connection), NM_SETTING_VPN_SETTING_NAME))
|
|
2253 |
applet_schedule_update_menu (applet); |
|
2254 |
}
|
|
2255 |
#endif /* ENABLE_INDICATOR */ |
|
2256 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2257 |
|
2258 |
/*****************************************************************************/
|
|
2259 |
||
2260 |
static void |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2261 |
foo_set_icon (NMApplet *applet, guint32 layer, GdkPixbuf *pixbuf, char *icon_name, char *new_tip) |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2262 |
{
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2263 |
GString *tip = NULL; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2264 |
int i; |
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
2265 |
|
2266 |
#ifdef ENABLE_INDICATOR
|
|
2267 |
if (icon_name == NULL && layer == ICON_LAYER_LINK) { |
|
2268 |
icon_name = g_strdup ("nm-no-connection"); |
|
2269 |
}
|
|
2270 |
||
2271 |
if (icon_name != NULL && |
|
2272 |
g_strcmp0 (app_indicator_get_icon (applet->app_indicator), icon_name) != 0) { |
|
2273 |
app_indicator_set_icon_full (applet->app_indicator, icon_name, applet->tip); |
|
2274 |
}
|
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2275 |
#endif /* ENABLE_INDICATOR */ |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2276 |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2277 |
switch (layer) { |
2278 |
case ICON_LAYER_LINK: |
|
2279 |
if (new_tip == NULL) |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2280 |
new_tip = g_strdup (_("No network connection")); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2281 |
tip = g_string_new (new_tip); |
2282 |
break; |
|
2283 |
case ICON_LAYER_VPN: |
|
2284 |
tip = g_string_new (applet->tip); |
|
2285 |
||
2286 |
if (new_tip) |
|
2287 |
g_string_append_printf (tip, "%s%s", tip->len ? "\n" : "", new_tip); |
|
2288 |
break; |
|
2289 |
default: |
|
2290 |
tip = g_string_new (""); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2291 |
if (layer > ICON_LAYER_MAX) { |
2292 |
g_string_free (tip, TRUE); |
|
2293 |
g_warning ("Tried to icon to invalid layer %d", layer); |
|
2294 |
return; |
|
2295 |
}
|
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2296 |
break; |
2297 |
}
|
|
2298 |
||
2299 |
if (tip->len) { |
|
2300 |
g_free (applet->tip); |
|
2301 |
applet->tip = tip->str; |
|
2302 |
}
|
|
2303 |
||
2304 |
g_free (new_tip); |
|
2305 |
g_string_free (tip, FALSE); |
|
2306 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2307 |
/* Ignore setting of the same icon as is already displayed */
|
2308 |
if (applet->icon_layers[layer] == pixbuf) |
|
2309 |
return; |
|
2310 |
||
2311 |
if (applet->icon_layers[layer]) { |
|
2312 |
g_object_unref (applet->icon_layers[layer]); |
|
2313 |
applet->icon_layers[layer] = NULL; |
|
2314 |
}
|
|
2315 |
||
2316 |
if (pixbuf) |
|
2317 |
applet->icon_layers[layer] = g_object_ref (pixbuf); |
|
2318 |
||
2319 |
if (!applet->icon_layers[0]) { |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2320 |
nma_icon_check_and_load ("nm-no-connection", &applet->no_connection_icon, applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2321 |
pixbuf = g_object_ref (applet->no_connection_icon); |
2322 |
} else { |
|
2323 |
pixbuf = gdk_pixbuf_copy (applet->icon_layers[0]); |
|
2324 |
||
2325 |
for (i = ICON_LAYER_LINK + 1; i <= ICON_LAYER_MAX; i++) { |
|
2326 |
GdkPixbuf *top = applet->icon_layers[i]; |
|
2327 |
||
2328 |
if (!top) |
|
2329 |
continue; |
|
2330 |
||
2331 |
gdk_pixbuf_composite (top, pixbuf, 0, 0, gdk_pixbuf_get_width (top), |
|
2332 |
gdk_pixbuf_get_height (top), |
|
2333 |
0, 0, 1.0, 1.0, |
|
2334 |
GDK_INTERP_NEAREST, 255); |
|
2335 |
}
|
|
2336 |
}
|
|
2337 |
||
2338 |
gtk_status_icon_set_from_pixbuf (applet->status_icon, pixbuf); |
|
2339 |
g_object_unref (pixbuf); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2340 |
#if GTK_CHECK_VERSION(2, 15, 0)
|
2341 |
gtk_status_icon_set_tooltip_text (applet->status_icon, applet->tip); |
|
2342 |
#else
|
|
2343 |
gtk_status_icon_set_tooltip (applet->status_icon, applet->tip); |
|
2344 |
#endif
|
|
2345 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2346 |
}
|
2347 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2348 |
NMRemoteConnection * |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2349 |
applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet) |
2350 |
{
|
|
2351 |
const GPtrArray *active_connections; |
|
2352 |
int i; |
|
2353 |
||
2354 |
active_connections = nm_client_get_active_connections (applet->nm_client); |
|
2355 |
for (i = 0; active_connections && (i < active_connections->len); i++) { |
|
2356 |
NMActiveConnection *active; |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2357 |
NMRemoteConnection *connection; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2358 |
const char *connection_path; |
2359 |
const GPtrArray *devices; |
|
2360 |
||
2361 |
active = g_ptr_array_index (active_connections, i); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2362 |
if (!active) |
2363 |
continue; |
|
2364 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2365 |
devices = nm_active_connection_get_devices (active); |
2366 |
connection_path = nm_active_connection_get_connection (active); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2367 |
if (!devices || !connection_path) |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2368 |
continue; |
2369 |
||
2370 |
if (!nm_g_ptr_array_contains (devices, device)) |
|
2371 |
continue; |
|
2372 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2373 |
connection = nm_remote_settings_get_connection_by_path (applet->settings, connection_path); |
1.2.6
by Alexander Sack
Import upstream version 0.8~a~git.20090913t161448.cc2f6be |
2374 |
if (connection) |
2375 |
return connection; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2376 |
}
|
2377 |
return NULL; |
|
2378 |
}
|
|
2379 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2380 |
static gboolean |
2381 |
select_merged_notification_text (OfflineNotificationContextInfo *info) |
|
2382 |
{
|
|
2383 |
info->urgency = NOTIFY_URGENCY_LOW; |
|
2384 |
/* only do something if this is about full offline state */
|
|
2385 |
if(info->state != NM_STATE_UNKNOWN || info->device_state != NM_DEVICE_STATE_UNKNOWN) { |
|
2386 |
info->urgency = NOTIFY_URGENCY_NORMAL; |
|
2387 |
if (!info->title) |
|
2388 |
info->title = g_strdup (_("Network")); |
|
2389 |
if (info->state == NM_STATE_DISCONNECTED || info->state == NM_STATE_ASLEEP) { |
|
2390 |
info->text = _("Disconnected - you are now offline"); |
|
2391 |
} else |
|
2392 |
info->text = _("Disconnected"); |
|
2393 |
||
2394 |
switch (info->device_type) { |
|
2395 |
case NM_DEVICE_TYPE_ETHERNET: |
|
2396 |
info->icon = "notification-network-ethernet-disconnected"; |
|
2397 |
break; |
|
2398 |
case NM_DEVICE_TYPE_WIFI: |
|
2399 |
info->icon = "notification-network-wireless-disconnected"; |
|
2400 |
break; |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2401 |
case NM_DEVICE_TYPE_MODEM: |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2402 |
info->icon = "notification-gsm-disconnected"; |
2403 |
break; |
|
2404 |
default: |
|
2405 |
info->icon = "notification-network-disconnected"; |
|
2406 |
break; |
|
2407 |
}
|
|
2408 |
g_debug("going for offline with icon: %s", info->icon); |
|
2409 |
return TRUE; |
|
2410 |
}
|
|
2411 |
return FALSE; |
|
2412 |
}
|
|
2413 |
||
2414 |
static gboolean |
|
2415 |
foo_online_offline_deferred_notify (gpointer user_data) |
|
2416 |
{
|
|
2417 |
NMApplet *applet = NM_APPLET (user_data); |
|
2418 |
OfflineNotificationContextInfo *info = applet->notification_queue_data; |
|
2419 |
if(select_merged_notification_text (info)) |
|
2420 |
applet_do_notify (applet, info->urgency, info->title, info->text, info->icon, NULL, NULL, NULL, applet); |
|
2421 |
else
|
|
2422 |
g_debug("no notification because merged found that we have nothing to say (e.g. not offline)"); |
|
2423 |
if (info->title) |
|
2424 |
g_free (info->title); |
|
2425 |
info->title = NULL; |
|
2426 |
g_free (applet->notification_queue_data); |
|
2427 |
applet->notification_queue_data = NULL; |
|
2428 |
applet->deferred_id = 0; |
|
2429 |
return FALSE; |
|
2430 |
}
|
|
2431 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2432 |
static void |
2433 |
applet_common_device_state_changed (NMDevice *device, |
|
1.1.6
by Alexander Sack
Import upstream version 0.7~~svn20081005t082522 |
2434 |
NMDeviceState new_state, |
2435 |
NMDeviceState old_state, |
|
2436 |
NMDeviceStateReason reason, |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2437 |
NMApplet *applet) |
2438 |
{
|
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2439 |
gboolean device_activating = FALSE, vpn_activating = FALSE; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2440 |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2441 |
device_activating = applet_is_any_device_activating (applet); |
2442 |
vpn_activating = applet_is_any_vpn_activating (applet); |
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
2443 |
|
1.1.6
by Alexander Sack
Import upstream version 0.7~~svn20081005t082522 |
2444 |
switch (new_state) { |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2445 |
case NM_DEVICE_STATE_FAILED: |
2446 |
case NM_DEVICE_STATE_DISCONNECTED: |
|
2447 |
case NM_DEVICE_STATE_UNMANAGED: |
|
2448 |
case NM_DEVICE_STATE_UNAVAILABLE: |
|
2449 |
{
|
|
2450 |
if (old_state != NM_DEVICE_STATE_FAILED && |
|
2451 |
old_state != NM_DEVICE_STATE_UNKNOWN && |
|
2452 |
old_state != NM_DEVICE_STATE_DISCONNECTED && |
|
2453 |
old_state != NM_DEVICE_STATE_UNMANAGED && |
|
2454 |
old_state != NM_DEVICE_STATE_UNAVAILABLE) { |
|
2455 |
OfflineNotificationContextInfo *info = applet->notification_queue_data; |
|
2456 |
if (!info) { |
|
2457 |
info = g_new0(OfflineNotificationContextInfo, 1); |
|
2458 |
applet->notification_queue_data = info; |
|
2459 |
}
|
|
2460 |
||
2461 |
info->device_state = new_state; |
|
2462 |
info->device_state_reason = reason; |
|
2463 |
if (info->title) { |
|
2464 |
g_free(info->title); |
|
2465 |
info->title = NULL; |
|
2466 |
}
|
|
2467 |
if (NM_IS_DEVICE_WIFI (device)) { |
|
2468 |
info->device_type = NM_DEVICE_TYPE_WIFI; |
|
2469 |
info->title = g_strdup(g_object_get_data (G_OBJECT(device), "canonical-last-essid")); |
|
2470 |
if (!info->title) |
|
2471 |
info->title = g_strdup (_("Wireless network")); |
|
2472 |
} else if (NM_IS_DEVICE_ETHERNET (device)) { |
|
2473 |
info->device_type = NM_DEVICE_TYPE_ETHERNET; |
|
2474 |
info->title = g_strdup(_("Wired network")); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2475 |
} else if (NM_IS_DEVICE_MODEM (device)) { |
2476 |
info->device_type = NM_DEVICE_TYPE_MODEM; |
|
2477 |
info->title = g_strdup (_("Modem network")); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2478 |
} else { |
2479 |
info->device_type = NM_DEVICE_TYPE_UNKNOWN; |
|
2480 |
info->title = g_strdup (_("Network")); |
|
2481 |
}
|
|
2482 |
||
2483 |
if (applet->deferred_id) |
|
2484 |
g_source_remove (applet->deferred_id); |
|
2485 |
applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet); |
|
2486 |
||
2487 |
clear_animation_timeout (applet); |
|
2488 |
} else { |
|
2489 |
g_debug ("old state indicates that this was not a disconnect %d", old_state); |
|
2490 |
}
|
|
2491 |
break; |
|
2492 |
}
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2493 |
case NM_DEVICE_STATE_PREPARE: |
2494 |
case NM_DEVICE_STATE_CONFIG: |
|
2495 |
case NM_DEVICE_STATE_NEED_AUTH: |
|
2496 |
case NM_DEVICE_STATE_IP_CONFIG: |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2497 |
/* Be sure to turn animation timeout on here since the dbus signals
|
2498 |
* for new active connections or devices might not have come through yet.
|
|
2499 |
*/
|
|
2500 |
device_activating = TRUE; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2501 |
break; |
2502 |
case NM_DEVICE_STATE_ACTIVATED: |
|
2503 |
default: |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
2504 |
break; |
2505 |
}
|
|
2506 |
||
2507 |
/* If there's an activating device but we're not animating, start animation.
|
|
2508 |
* If we're animating, but there's no activating device or VPN, stop animating.
|
|
2509 |
*/
|
|
2510 |
if (device_activating || vpn_activating) |
|
2511 |
start_animation_timeout (applet); |
|
2512 |
else
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2513 |
clear_animation_timeout (applet); |
2514 |
}
|
|
2515 |
||
2516 |
static void |
|
1.1.6
by Alexander Sack
Import upstream version 0.7~~svn20081005t082522 |
2517 |
foo_device_state_changed_cb (NMDevice *device, |
2518 |
NMDeviceState new_state, |
|
2519 |
NMDeviceState old_state, |
|
2520 |
NMDeviceStateReason reason, |
|
2521 |
gpointer user_data) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2522 |
{
|
2523 |
NMApplet *applet = NM_APPLET (user_data); |
|
2524 |
NMADeviceClass *dclass; |
|
2525 |
||
2526 |
dclass = get_device_class (device, applet); |
|
2527 |
g_assert (dclass); |
|
2528 |
||
1.1.6
by Alexander Sack
Import upstream version 0.7~~svn20081005t082522 |
2529 |
dclass->device_state_changed (device, new_state, old_state, reason, applet); |
2530 |
applet_common_device_state_changed (device, new_state, old_state, reason, applet); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2531 |
|
2532 |
applet_schedule_update_icon (applet); |
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
2533 |
applet_schedule_update_menu (applet); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2534 |
}
|
2535 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2536 |
static void |
2537 |
foo_device_added_cb (NMClient *client, NMDevice *device, gpointer user_data) |
|
2538 |
{
|
|
2539 |
NMApplet *applet = NM_APPLET (user_data); |
|
2540 |
NMADeviceClass *dclass; |
|
2541 |
||
2542 |
dclass = get_device_class (device, applet); |
|
2543 |
g_return_if_fail (dclass != NULL); |
|
2544 |
||
2545 |
if (dclass->device_added) |
|
2546 |
dclass->device_added (device, applet); |
|
2547 |
||
1.1.6
by Alexander Sack
Import upstream version 0.7~~svn20081005t082522 |
2548 |
g_signal_connect (device, "state-changed", |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2549 |
G_CALLBACK (foo_device_state_changed_cb), |
2550 |
user_data); |
|
2551 |
||
1.1.6
by Alexander Sack
Import upstream version 0.7~~svn20081005t082522 |
2552 |
foo_device_state_changed_cb (device, |
2553 |
nm_device_get_state (device), |
|
2554 |
NM_DEVICE_STATE_UNKNOWN, |
|
2555 |
NM_DEVICE_STATE_REASON_NONE, |
|
2556 |
applet); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2557 |
}
|
2558 |
||
2559 |
static void |
|
2560 |
foo_client_state_changed_cb (NMClient *client, GParamSpec *pspec, gpointer user_data) |
|
2561 |
{
|
|
2562 |
NMApplet *applet = NM_APPLET (user_data); |
|
2563 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2564 |
g_debug("foo_client_state_changed_cb"); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2565 |
switch (nm_client_get_state (client)) { |
2566 |
case NM_STATE_DISCONNECTED: |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2567 |
case NM_STATE_ASLEEP: |
2568 |
{
|
|
2569 |
OfflineNotificationContextInfo *info = applet->notification_queue_data; |
|
2570 |
if (!info) { |
|
2571 |
info = g_new0(OfflineNotificationContextInfo, 1); |
|
2572 |
applet->notification_queue_data = info; |
|
2573 |
}
|
|
2574 |
||
2575 |
info->state = nm_client_get_state (client); |
|
2576 |
select_merged_notification_text (info); |
|
2577 |
||
2578 |
if (applet->deferred_id) |
|
2579 |
g_source_remove (applet->deferred_id); |
|
2580 |
applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet); |
|
2581 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2582 |
/* Fall through */
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2583 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2584 |
default: |
2585 |
break; |
|
2586 |
}
|
|
2587 |
||
2588 |
applet_schedule_update_icon (applet); |
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
2589 |
applet_schedule_update_menu (applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2590 |
}
|
2591 |
||
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2592 |
#ifdef ENABLE_INDICATOR
|
2593 |
static void |
|
2594 |
foo_device_removed_cb (NMClient *client, NMDevice *device, gpointer user_data) |
|
2595 |
{
|
|
2596 |
NMApplet *applet = NM_APPLET (user_data); |
|
2597 |
||
2598 |
applet_schedule_update_icon (applet); |
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
2599 |
applet_schedule_update_menu (applet); |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2600 |
}
|
2601 |
#endif
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2602 |
|
2603 |
static void |
|
2604 |
foo_manager_running_cb (NMClient *client, |
|
2605 |
GParamSpec *pspec, |
|
2606 |
gpointer user_data) |
|
2607 |
{
|
|
2608 |
NMApplet *applet = NM_APPLET (user_data); |
|
2609 |
||
2610 |
if (nm_client_get_manager_running (client)) { |
|
2611 |
g_message ("NM appeared"); |
|
2612 |
} else { |
|
2613 |
g_message ("NM disappeared"); |
|
2614 |
clear_animation_timeout (applet); |
|
2615 |
}
|
|
2616 |
||
2617 |
applet_schedule_update_icon (applet); |
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
2618 |
applet_schedule_update_menu (applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2619 |
}
|
2620 |
||
2621 |
#define VPN_STATE_ID_TAG "vpn-state-id"
|
|
2622 |
||
2623 |
static void |
|
2624 |
foo_active_connections_changed_cb (NMClient *client, |
|
2625 |
GParamSpec *pspec, |
|
2626 |
gpointer user_data) |
|
2627 |
{
|
|
2628 |
NMApplet *applet = NM_APPLET (user_data); |
|
2629 |
const GPtrArray *active_list; |
|
2630 |
int i; |
|
2631 |
||
2632 |
/* Track the state of new VPN connections */
|
|
2633 |
active_list = nm_client_get_active_connections (client); |
|
2634 |
for (i = 0; active_list && (i < active_list->len); i++) { |
|
2635 |
NMActiveConnection *candidate = NM_ACTIVE_CONNECTION (g_ptr_array_index (active_list, i)); |
|
2636 |
guint id; |
|
2637 |
||
2638 |
if ( !NM_IS_VPN_CONNECTION (candidate) |
|
2639 |
|| g_object_get_data (G_OBJECT (candidate), VPN_STATE_ID_TAG)) |
|
2640 |
continue; |
|
2641 |
||
2642 |
id = g_signal_connect (G_OBJECT (candidate), "vpn-state-changed", |
|
2643 |
G_CALLBACK (vpn_connection_state_changed), applet); |
|
2644 |
g_object_set_data (G_OBJECT (candidate), VPN_STATE_ID_TAG, GUINT_TO_POINTER (id)); |
|
2645 |
}
|
|
2646 |
||
2647 |
applet_schedule_update_icon (applet); |
|
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
2648 |
applet_schedule_update_menu (applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2649 |
}
|
2650 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2651 |
static void |
2652 |
foo_manager_permission_changed (NMClient *client, |
|
2653 |
NMClientPermission permission, |
|
2654 |
NMClientPermissionResult result, |
|
2655 |
gpointer user_data) |
|
2656 |
{
|
|
2657 |
NMApplet *applet = NM_APPLET (user_data); |
|
2658 |
||
2659 |
if (permission <= NM_CLIENT_PERMISSION_LAST) |
|
2660 |
applet->permissions[permission] = result; |
|
2661 |
}
|
|
2662 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2663 |
static gboolean |
2664 |
foo_set_initial_state (gpointer data) |
|
2665 |
{
|
|
2666 |
NMApplet *applet = NM_APPLET (data); |
|
2667 |
const GPtrArray *devices; |
|
2668 |
int i; |
|
2669 |
||
2670 |
devices = nm_client_get_devices (applet->nm_client); |
|
2671 |
for (i = 0; devices && (i < devices->len); i++) |
|
2672 |
foo_device_added_cb (applet->nm_client, NM_DEVICE (g_ptr_array_index (devices, i)), applet); |
|
2673 |
||
2674 |
foo_active_connections_changed_cb (applet->nm_client, NULL, applet); |
|
2675 |
||
2676 |
applet_schedule_update_icon (applet); |
|
2677 |
||
2678 |
return FALSE; |
|
2679 |
}
|
|
2680 |
||
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2681 |
static gboolean setup_widgets (NMApplet *applet); |
2682 |
static void nma_icons_init (NMApplet *applet); |
|
2683 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2684 |
static void |
2685 |
foo_client_setup (NMApplet *applet) |
|
2686 |
{
|
|
2687 |
applet->nm_client = nm_client_new (); |
|
2688 |
if (!applet->nm_client) |
|
2689 |
return; |
|
2690 |
||
2691 |
g_signal_connect (applet->nm_client, "notify::state", |
|
2692 |
G_CALLBACK (foo_client_state_changed_cb), |
|
2693 |
applet); |
|
2694 |
g_signal_connect (applet->nm_client, "notify::active-connections", |
|
2695 |
G_CALLBACK (foo_active_connections_changed_cb), |
|
2696 |
applet); |
|
2697 |
g_signal_connect (applet->nm_client, "device-added", |
|
2698 |
G_CALLBACK (foo_device_added_cb), |
|
2699 |
applet); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2700 |
#ifdef ENABLE_INDICATOR
|
2701 |
g_signal_connect (applet->nm_client, "device-removed", |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2702 |
G_CALLBACK (foo_device_removed_cb), |
2703 |
applet); |
|
2704 |
#endif /* ENABLE_INDICATOR */ |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2705 |
g_signal_connect (applet->nm_client, "notify::manager-running", |
2706 |
G_CALLBACK (foo_manager_running_cb), |
|
2707 |
applet); |
|
2708 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2709 |
g_signal_connect (applet->nm_client, "permission-changed", |
2710 |
G_CALLBACK (foo_manager_permission_changed), |
|
2711 |
applet); |
|
1.2.13
by Mathieu Trudel-Lapierre
Import upstream version 0.8.2+git.20101123t161608.f143e76 |
2712 |
/* Initialize permissions - the initial 'permission-changed' signal is emitted from NMClient constructor, and thus not caught */
|
2713 |
applet->permissions[NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_ENABLE_DISABLE_NETWORK); |
|
2714 |
applet->permissions[NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIFI); |
|
2715 |
applet->permissions[NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WWAN); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2716 |
applet->permissions[NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX] = nm_client_get_permission_result (applet->nm_client, NM_CLIENT_PERMISSION_ENABLE_DISABLE_WIMAX); |
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2717 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2718 |
if (nm_client_get_manager_running (applet->nm_client)) |
2719 |
g_idle_add (foo_set_initial_state, applet); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2720 |
|
2721 |
applet_schedule_update_icon (applet); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2722 |
}
|
2723 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2724 |
static void |
2725 |
applet_common_get_device_icon (NMDeviceState state, |
|
2726 |
GdkPixbuf **out_pixbuf, |
|
2727 |
char **out_indicator_icon, |
|
2728 |
NMApplet *applet) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2729 |
{
|
2730 |
int stage = -1; |
|
2731 |
||
2732 |
switch (state) { |
|
2733 |
case NM_DEVICE_STATE_PREPARE: |
|
2734 |
stage = 0; |
|
2735 |
break; |
|
2736 |
case NM_DEVICE_STATE_CONFIG: |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2737 |
case NM_DEVICE_STATE_NEED_AUTH: |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2738 |
stage = 1; |
2739 |
break; |
|
2740 |
case NM_DEVICE_STATE_IP_CONFIG: |
|
2741 |
stage = 2; |
|
2742 |
break; |
|
2743 |
default: |
|
2744 |
break; |
|
2745 |
}
|
|
2746 |
||
2747 |
if (stage >= 0) { |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2748 |
/* Don't overwrite pixbufs or names given by specific device classes */
|
2749 |
if (out_pixbuf && !*out_pixbuf) { |
|
2750 |
int i, j; |
|
2751 |
for (i = 0; i < NUM_CONNECTING_STAGES; i++) { |
|
2752 |
for (j = 0; j < NUM_CONNECTING_FRAMES; j++) { |
|
2753 |
char *name; |
|
2754 |
||
2755 |
name = g_strdup_printf ("nm-stage%02d-connecting%02d", i+1, j+1); |
|
2756 |
nma_icon_check_and_load (name, &applet->network_connecting_icons[i][j], applet); |
|
2757 |
g_free (name); |
|
2758 |
}
|
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2759 |
}
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2760 |
*out_pixbuf = applet->network_connecting_icons[stage][applet->animation_step]; |
87
by Mathieu Trudel-Lapierre
debian/patches/lp939802_fix_mobile_icon_leak.patch: avoid leaking memory |
2761 |
if (out_pixbuf && *out_pixbuf) |
2762 |
g_object_ref (*out_pixbuf); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2763 |
}
|
2764 |
if (out_indicator_icon && !*out_indicator_icon) { |
|
2765 |
*out_indicator_icon = g_strdup_printf ("nm-stage%02d-connecting%02d", |
|
2766 |
stage + 1, |
|
2767 |
applet->animation_step + 1); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2768 |
}
|
2769 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2770 |
applet->animation_step++; |
2771 |
if (applet->animation_step >= NUM_CONNECTING_FRAMES) |
|
2772 |
applet->animation_step = 0; |
|
2773 |
}
|
|
2774 |
}
|
|
2775 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2776 |
static char * |
2777 |
get_tip_for_device_state (NMDevice *device, |
|
2778 |
NMDeviceState state, |
|
2779 |
NMConnection *connection) |
|
2780 |
{
|
|
2781 |
NMSettingConnection *s_con; |
|
2782 |
char *tip = NULL; |
|
2783 |
const char *id = NULL; |
|
2784 |
||
2785 |
id = nm_device_get_iface (device); |
|
2786 |
if (connection) { |
|
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
2787 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2788 |
id = nm_setting_connection_get_id (s_con); |
2789 |
}
|
|
2790 |
||
2791 |
switch (state) { |
|
2792 |
case NM_DEVICE_STATE_PREPARE: |
|
2793 |
case NM_DEVICE_STATE_CONFIG: |
|
2794 |
tip = g_strdup_printf (_("Preparing network connection '%s'..."), id); |
|
2795 |
break; |
|
2796 |
case NM_DEVICE_STATE_NEED_AUTH: |
|
2797 |
tip = g_strdup_printf (_("User authentication required for network connection '%s'..."), id); |
|
2798 |
break; |
|
2799 |
case NM_DEVICE_STATE_IP_CONFIG: |
|
2800 |
tip = g_strdup_printf (_("Requesting a network address for '%s'..."), id); |
|
2801 |
break; |
|
2802 |
case NM_DEVICE_STATE_ACTIVATED: |
|
2803 |
tip = g_strdup_printf (_("Network connection '%s' active"), id); |
|
2804 |
break; |
|
2805 |
default: |
|
2806 |
break; |
|
2807 |
}
|
|
2808 |
||
2809 |
return tip; |
|
2810 |
}
|
|
2811 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2812 |
static void |
2813 |
applet_get_device_icon_for_state (NMApplet *applet, |
|
2814 |
GdkPixbuf **out_pixbuf, |
|
2815 |
char **out_indicator_icon, |
|
2816 |
char **out_tip) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2817 |
{
|
2818 |
NMActiveConnection *active; |
|
2819 |
NMDevice *device = NULL; |
|
2820 |
NMDeviceState state = NM_DEVICE_STATE_UNKNOWN; |
|
2821 |
NMADeviceClass *dclass; |
|
2822 |
||
2823 |
// FIXME: handle multiple device states here
|
|
2824 |
||
2825 |
/* First show the best activating device's state */
|
|
2826 |
active = applet_get_best_activating_connection (applet, &device); |
|
2827 |
if (!active || !device) { |
|
2828 |
/* If there aren't any activating devices, then show the state of
|
|
2829 |
* the default active connection instead.
|
|
2830 |
*/
|
|
2831 |
active = applet_get_default_active_connection (applet, &device); |
|
2832 |
if (!active || !device) |
|
2833 |
goto out; |
|
2834 |
}
|
|
2835 |
||
2836 |
state = nm_device_get_state (device); |
|
2837 |
||
2838 |
dclass = get_device_class (device, applet); |
|
1.1.7
by Alexander Sack
Import upstream version 0.7~~svn20081012t133407 |
2839 |
if (dclass) { |
2840 |
NMConnection *connection; |
|
2841 |
||
2842 |
connection = applet_find_active_connection_for_device (device, applet, NULL); |
|
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
2843 |
/* device class returns a referenced pixbuf */
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2844 |
dclass->get_icon (device, state, connection, out_pixbuf, out_indicator_icon, out_tip, applet); |
2845 |
if (out_tip && !*out_tip) |
|
2846 |
*out_tip = get_tip_for_device_state (device, state, connection); |
|
1.1.7
by Alexander Sack
Import upstream version 0.7~~svn20081012t133407 |
2847 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2848 |
|
2849 |
out: |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2850 |
applet_common_get_device_icon (state, out_pixbuf, out_indicator_icon, applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2851 |
}
|
2852 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2853 |
static char * |
2854 |
get_tip_for_vpn (NMActiveConnection *active, NMVPNConnectionState state, NMApplet *applet) |
|
2855 |
{
|
|
2856 |
char *tip = NULL; |
|
2857 |
const char *path, *id = NULL; |
|
2858 |
GSList *iter, *list; |
|
2859 |
||
2860 |
path = nm_active_connection_get_connection (active); |
|
2861 |
g_return_val_if_fail (path != NULL, NULL); |
|
2862 |
||
2863 |
list = applet_get_all_connections (applet); |
|
2864 |
for (iter = list; iter; iter = g_slist_next (iter)) { |
|
2865 |
NMConnection *candidate = NM_CONNECTION (iter->data); |
|
2866 |
NMSettingConnection *s_con; |
|
2867 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
2868 |
if (!strcmp (nm_connection_get_path (candidate), path)) { |
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
2869 |
s_con = nm_connection_get_setting_connection (candidate); |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2870 |
id = nm_setting_connection_get_id (s_con); |
2871 |
break; |
|
2872 |
}
|
|
2873 |
}
|
|
2874 |
g_slist_free (list); |
|
2875 |
||
2876 |
if (!id) |
|
2877 |
return NULL; |
|
2878 |
||
2879 |
switch (state) { |
|
2880 |
case NM_VPN_CONNECTION_STATE_CONNECT: |
|
2881 |
case NM_VPN_CONNECTION_STATE_PREPARE: |
|
2882 |
tip = g_strdup_printf (_("Starting VPN connection '%s'..."), id); |
|
2883 |
break; |
|
2884 |
case NM_VPN_CONNECTION_STATE_NEED_AUTH: |
|
2885 |
tip = g_strdup_printf (_("User authentication required for VPN connection '%s'..."), id); |
|
2886 |
break; |
|
2887 |
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET: |
|
2888 |
tip = g_strdup_printf (_("Requesting a VPN address for '%s'..."), id); |
|
2889 |
break; |
|
2890 |
case NM_VPN_CONNECTION_STATE_ACTIVATED: |
|
2891 |
tip = g_strdup_printf (_("VPN connection '%s' active"), id); |
|
2892 |
break; |
|
2893 |
default: |
|
2894 |
break; |
|
2895 |
}
|
|
2896 |
||
2897 |
return tip; |
|
2898 |
}
|
|
2899 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2900 |
static gboolean |
2901 |
applet_update_icon (gpointer user_data) |
|
2902 |
{
|
|
2903 |
NMApplet *applet = NM_APPLET (user_data); |
|
2904 |
GdkPixbuf *pixbuf = NULL; |
|
2905 |
NMState state; |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2906 |
char *dev_tip = NULL, *vpn_tip = NULL, *icon_name = NULL; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2907 |
NMVPNConnectionState vpn_state = NM_VPN_SERVICE_STATE_UNKNOWN; |
2908 |
gboolean nm_running; |
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2909 |
NMActiveConnection *active_vpn = NULL; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2910 |
|
2911 |
applet->update_icon_id = 0; |
|
2912 |
||
2913 |
nm_running = nm_client_get_manager_running (applet->nm_client); |
|
2914 |
||
2915 |
/* Handle device state first */
|
|
2916 |
||
2917 |
state = nm_client_get_state (applet->nm_client); |
|
2918 |
if (!nm_running) |
|
2919 |
state = NM_STATE_UNKNOWN; |
|
2920 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2921 |
#ifdef ENABLE_INDICATOR
|
85
by Mathieu Trudel-Lapierre
debian/patches/lp829673_gconf_hide_applet.patch: only set the applet |
2922 |
if (applet->in_fallback) |
2923 |
gtk_status_icon_set_visible (applet->status_icon, applet->visible); |
|
2924 |
else
|
|
2925 |
gtk_status_icon_set_visible (applet->status_icon, FALSE); |
|
2926 |
||
84
by Mathieu Trudel-Lapierre
* debian/patches/lp829673_gconf_hide_applet.patch: allow toggling the applet |
2927 |
if (nm_running && applet->visible) |
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
2928 |
app_indicator_set_status (applet->app_indicator, APP_INDICATOR_STATUS_ACTIVE); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2929 |
else
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
2930 |
app_indicator_set_status (applet->app_indicator, APP_INDICATOR_STATUS_PASSIVE); |
85
by Mathieu Trudel-Lapierre
debian/patches/lp829673_gconf_hide_applet.patch: only set the applet |
2931 |
#else
|
2932 |
gtk_status_icon_set_visible (applet->status_icon, applet->visible); |
|
2933 |
#endif /* ENABLE_INDICATOR */ |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2934 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2935 |
switch (state) { |
2936 |
case NM_STATE_UNKNOWN: |
|
2937 |
case NM_STATE_ASLEEP: |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2938 |
icon_name = g_strdup ("nm-no-connection"); |
2939 |
pixbuf = nma_icon_check_and_load (icon_name, &applet->no_connection_icon, applet); |
|
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
2940 |
g_object_ref (pixbuf); |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2941 |
dev_tip = g_strdup (_("Networking disabled")); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2942 |
break; |
2943 |
case NM_STATE_DISCONNECTED: |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2944 |
icon_name = g_strdup ("nm-no-connection"); |
2945 |
pixbuf = nma_icon_check_and_load (icon_name, &applet->no_connection_icon, applet); |
|
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
2946 |
g_object_ref (pixbuf); |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2947 |
dev_tip = g_strdup (_("No network connection")); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2948 |
break; |
2949 |
default: |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2950 |
applet_get_device_icon_for_state (applet, &pixbuf, &icon_name, &dev_tip); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2951 |
break; |
2952 |
}
|
|
2953 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2954 |
foo_set_icon (applet, ICON_LAYER_LINK, pixbuf, icon_name, dev_tip); |
87
by Mathieu Trudel-Lapierre
debian/patches/lp939802_fix_mobile_icon_leak.patch: avoid leaking memory |
2955 |
if (pixbuf) |
2956 |
g_object_unref (pixbuf); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
2957 |
if (icon_name) |
2958 |
g_free (icon_name); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2959 |
|
2960 |
/* VPN state next */
|
|
2961 |
pixbuf = NULL; |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2962 |
icon_name = NULL; |
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2963 |
active_vpn = applet_get_first_active_vpn_connection (applet, &vpn_state); |
2964 |
if (active_vpn) { |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2965 |
int i; |
2966 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2967 |
switch (vpn_state) { |
2968 |
case NM_VPN_CONNECTION_STATE_ACTIVATED: |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2969 |
#ifndef ENABLE_INDICATOR
|
2970 |
icon_name = g_strdup_printf ("nm-vpn-active-lock"); |
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
2971 |
#else
|
2972 |
icon_name = g_strdup_printf ("%s-secure", app_indicator_get_icon (applet->app_indicator)); |
|
88
by Mathieu Trudel-Lapierre
* New upstream release 0.9.4.1. |
2973 |
#endif /* ENABLE_INDICATOR */ |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2974 |
pixbuf = nma_icon_check_and_load (icon_name, &applet->vpn_lock_icon, applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2975 |
break; |
2976 |
case NM_VPN_CONNECTION_STATE_PREPARE: |
|
2977 |
case NM_VPN_CONNECTION_STATE_NEED_AUTH: |
|
2978 |
case NM_VPN_CONNECTION_STATE_CONNECT: |
|
2979 |
case NM_VPN_CONNECTION_STATE_IP_CONFIG_GET: |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
2980 |
for (i = 0; i < NUM_VPN_CONNECTING_FRAMES; i++) { |
2981 |
char *name; |
|
2982 |
||
2983 |
name = g_strdup_printf ("nm-vpn-connecting%02d", i+1); |
|
2984 |
nma_icon_check_and_load (name, &applet->vpn_connecting_icons[i], applet); |
|
2985 |
g_free (name); |
|
2986 |
}
|
|
2987 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2988 |
pixbuf = applet->vpn_connecting_icons[applet->animation_step]; |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2989 |
#ifdef ENABLE_INDICATOR
|
88
by Mathieu Trudel-Lapierre
* New upstream release 0.9.4.1. |
2990 |
icon_name = g_strdup_printf ("nm-vpn-connecting%02d", applet->animation_step+1); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
2991 |
#endif
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2992 |
applet->animation_step++; |
2993 |
if (applet->animation_step >= NUM_VPN_CONNECTING_FRAMES) |
|
2994 |
applet->animation_step = 0; |
|
2995 |
break; |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
2996 |
default: |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
2997 |
break; |
2998 |
}
|
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
2999 |
|
3000 |
vpn_tip = get_tip_for_vpn (active_vpn, vpn_state, applet); |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
3001 |
}
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3002 |
foo_set_icon (applet, ICON_LAYER_VPN, pixbuf, icon_name, vpn_tip); |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
3003 |
if (icon_name) |
3004 |
g_free (icon_name); |
|
3005 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3006 |
return FALSE; |
3007 |
}
|
|
3008 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3009 |
void
|
3010 |
applet_schedule_update_icon (NMApplet *applet) |
|
3011 |
{
|
|
3012 |
if (!applet->update_icon_id) |
|
3013 |
applet->update_icon_id = g_idle_add (applet_update_icon, applet); |
|
3014 |
}
|
|
3015 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3016 |
/*****************************************************************************/
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3017 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3018 |
static SecretsRequest * |
3019 |
applet_secrets_request_new (size_t totsize, |
|
3020 |
NMConnection *connection, |
|
3021 |
gpointer request_id, |
|
3022 |
const char *setting_name, |
|
3023 |
const char **hints, |
|
3024 |
guint32 flags, |
|
3025 |
AppletAgentSecretsCallback callback, |
|
3026 |
gpointer callback_data, |
|
3027 |
NMApplet *applet) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3028 |
{
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3029 |
SecretsRequest *req; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3030 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3031 |
g_return_val_if_fail (totsize >= sizeof (SecretsRequest), NULL); |
1.2.6
by Alexander Sack
Import upstream version 0.8~a~git.20090913t161448.cc2f6be |
3032 |
g_return_val_if_fail (connection != NULL, NULL); |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3033 |
|
3034 |
req = g_malloc0 (totsize); |
|
3035 |
req->totsize = totsize; |
|
3036 |
req->connection = g_object_ref (connection); |
|
3037 |
req->reqid = request_id; |
|
3038 |
req->setting_name = g_strdup (setting_name); |
|
3039 |
req->hints = g_strdupv ((char **) hints); |
|
3040 |
req->flags = flags; |
|
3041 |
req->callback = callback; |
|
3042 |
req->callback_data = callback_data; |
|
3043 |
req->applet = applet; |
|
3044 |
return req; |
|
3045 |
}
|
|
3046 |
||
3047 |
void
|
|
3048 |
applet_secrets_request_set_free_func (SecretsRequest *req, |
|
3049 |
SecretsRequestFreeFunc free_func) |
|
3050 |
{
|
|
3051 |
req->free_func = free_func; |
|
3052 |
}
|
|
3053 |
||
3054 |
void
|
|
3055 |
applet_secrets_request_complete (SecretsRequest *req, |
|
3056 |
GHashTable *settings, |
|
3057 |
GError *error) |
|
3058 |
{
|
|
3059 |
req->callback (req->applet->agent, error ? NULL : settings, error, req->callback_data); |
|
3060 |
}
|
|
3061 |
||
3062 |
void
|
|
3063 |
applet_secrets_request_complete_setting (SecretsRequest *req, |
|
3064 |
const char *setting_name, |
|
3065 |
GError *error) |
|
3066 |
{
|
|
3067 |
NMSetting *setting; |
|
3068 |
GHashTable *settings = NULL, *secrets; |
|
3069 |
||
3070 |
if (setting_name && !error) { |
|
3071 |
setting = nm_connection_get_setting_by_name (req->connection, setting_name); |
|
3072 |
if (setting) { |
|
3073 |
secrets = nm_setting_to_hash (NM_SETTING (setting), NM_SETTING_HASH_FLAG_ALL); |
|
3074 |
if (secrets) { |
|
3075 |
/* Returned secrets are a{sa{sv}}; this is the outer a{s...} hash that
|
|
3076 |
* will contain all the individual settings hashes.
|
|
3077 |
*/
|
|
3078 |
settings = g_hash_table_new_full (g_str_hash, |
|
3079 |
g_str_equal, |
|
3080 |
g_free, |
|
3081 |
(GDestroyNotify) g_hash_table_destroy); |
|
3082 |
g_hash_table_insert (settings, g_strdup (setting_name), secrets); |
|
3083 |
} else { |
|
3084 |
g_set_error (&error, |
|
3085 |
NM_SECRET_AGENT_ERROR, |
|
3086 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
3087 |
"%s.%d (%s): failed to hash setting '%s'.", |
|
3088 |
__FILE__, __LINE__, __func__, setting_name); |
|
3089 |
}
|
|
3090 |
} else { |
|
3091 |
g_set_error (&error, |
|
3092 |
NM_SECRET_AGENT_ERROR, |
|
3093 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
3094 |
"%s.%d (%s): unhandled setting '%s'", |
|
3095 |
__FILE__, __LINE__, __func__, setting_name); |
|
3096 |
}
|
|
3097 |
}
|
|
3098 |
||
3099 |
req->callback (req->applet->agent, settings, error, req->callback_data); |
|
3100 |
}
|
|
3101 |
||
3102 |
void
|
|
3103 |
applet_secrets_request_free (SecretsRequest *req) |
|
3104 |
{
|
|
3105 |
g_return_if_fail (req != NULL); |
|
3106 |
||
3107 |
if (req->free_func) |
|
3108 |
req->free_func (req); |
|
3109 |
||
3110 |
req->applet->secrets_reqs = g_slist_remove (req->applet->secrets_reqs, req); |
|
3111 |
||
3112 |
g_object_unref (req->connection); |
|
3113 |
g_free (req->setting_name); |
|
3114 |
g_strfreev (req->hints); |
|
3115 |
memset (req, 0, req->totsize); |
|
3116 |
g_free (req); |
|
3117 |
}
|
|
3118 |
||
3119 |
static void |
|
3120 |
get_existing_secrets_cb (NMSecretAgent *agent, |
|
3121 |
NMConnection *connection, |
|
3122 |
GHashTable *secrets, |
|
3123 |
GError *secrets_error, |
|
3124 |
gpointer user_data) |
|
3125 |
{
|
|
3126 |
SecretsRequest *req = user_data; |
|
3127 |
NMADeviceClass *dclass; |
|
3128 |
GError *error = NULL; |
|
3129 |
||
3130 |
/* Merge existing secrets into connection; ignore errors */
|
|
3131 |
nm_connection_update_secrets (connection, req->setting_name, secrets, NULL); |
|
3132 |
||
3133 |
dclass = get_device_class_from_connection (connection, req->applet); |
|
3134 |
g_assert (dclass); |
|
3135 |
||
3136 |
/* Let the device class handle secrets */
|
|
3137 |
if (!dclass->get_secrets (req, &error)) { |
|
3138 |
g_warning ("%s:%d - %s", __func__, __LINE__, error ? error->message : "(unknown)"); |
|
3139 |
applet_secrets_request_complete (req, NULL, error); |
|
3140 |
applet_secrets_request_free (req); |
|
3141 |
g_error_free (error); |
|
3142 |
}
|
|
3143 |
/* Otherwise success; wait for the secrets callback */
|
|
3144 |
}
|
|
3145 |
||
3146 |
static void |
|
3147 |
applet_agent_get_secrets_cb (AppletAgent *agent, |
|
3148 |
gpointer request_id, |
|
3149 |
NMConnection *connection, |
|
3150 |
const char *setting_name, |
|
3151 |
const char **hints, |
|
3152 |
guint32 flags, |
|
3153 |
AppletAgentSecretsCallback callback, |
|
3154 |
gpointer callback_data, |
|
3155 |
gpointer user_data) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3156 |
{
|
3157 |
NMApplet *applet = NM_APPLET (user_data); |
|
3158 |
NMSettingConnection *s_con; |
|
3159 |
NMADeviceClass *dclass; |
|
3160 |
GError *error = NULL; |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3161 |
SecretsRequest *req = NULL; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3162 |
|
1.2.27
by Mathieu Trudel-Lapierre
Import upstream version 0.9.3.995+git.20120313t141231.c89224f |
3163 |
s_con = nm_connection_get_setting_connection (connection); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3164 |
g_return_if_fail (s_con != NULL); |
3165 |
||
3166 |
/* VPN secrets get handled a bit differently */
|
|
1.1.10
by Alexander Sack
Import upstream version 0.7 |
3167 |
if (!strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_VPN_SETTING_NAME)) { |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3168 |
req = applet_secrets_request_new (applet_vpn_request_get_secrets_size (), |
3169 |
connection, |
|
3170 |
request_id, |
|
3171 |
setting_name, |
|
3172 |
hints, |
|
3173 |
flags, |
|
3174 |
callback, |
|
3175 |
callback_data, |
|
3176 |
applet); |
|
3177 |
if (!applet_vpn_request_get_secrets (req, &error)) |
|
3178 |
goto error; |
|
3179 |
||
3180 |
applet->secrets_reqs = g_slist_prepend (applet->secrets_reqs, req); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3181 |
return; |
3182 |
}
|
|
3183 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3184 |
dclass = get_device_class_from_connection (connection, applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3185 |
if (!dclass) { |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3186 |
error = g_error_new (NM_SECRET_AGENT_ERROR, |
3187 |
NM_SECRET_AGENT_ERROR_INTERNAL_ERROR, |
|
3188 |
"%s.%d (%s): device type unknown", |
|
3189 |
__FILE__, __LINE__, __func__); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3190 |
goto error; |
3191 |
}
|
|
3192 |
||
3193 |
if (!dclass->get_secrets) { |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3194 |
error = g_error_new (NM_SECRET_AGENT_ERROR, |
3195 |
NM_SECRET_AGENT_ERROR_NO_SECRETS, |
|
3196 |
"%s.%d (%s): no secrets found", |
|
3197 |
__FILE__, __LINE__, __func__); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3198 |
goto error; |
3199 |
}
|
|
3200 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3201 |
g_assert (dclass->secrets_request_size); |
3202 |
req = applet_secrets_request_new (dclass->secrets_request_size, |
|
3203 |
connection, |
|
3204 |
request_id, |
|
3205 |
setting_name, |
|
3206 |
hints, |
|
3207 |
flags, |
|
3208 |
callback, |
|
3209 |
callback_data, |
|
3210 |
applet); |
|
3211 |
applet->secrets_reqs = g_slist_prepend (applet->secrets_reqs, req); |
|
1.2.8
by Alexander Sack
Import upstream version 0.8~a~git.20091002t194214.8515a07 |
3212 |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3213 |
/* Get existing secrets, if any */
|
3214 |
nm_secret_agent_get_secrets (NM_SECRET_AGENT (applet->agent), |
|
3215 |
connection, |
|
3216 |
setting_name, |
|
3217 |
hints, |
|
3218 |
NM_SECRET_AGENT_GET_SECRETS_FLAG_NONE, |
|
3219 |
get_existing_secrets_cb, |
|
3220 |
req); |
|
3221 |
return; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3222 |
|
3223 |
error: |
|
3224 |
g_warning ("%s", error->message); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3225 |
callback (agent, NULL, error, callback_data); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3226 |
g_error_free (error); |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3227 |
|
3228 |
if (req) |
|
3229 |
applet_secrets_request_free (req); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3230 |
}
|
3231 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3232 |
static void |
3233 |
applet_agent_cancel_secrets_cb (AppletAgent *agent, |
|
3234 |
gpointer request_id, |
|
3235 |
gpointer user_data) |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3236 |
{
|
3237 |
NMApplet *applet = NM_APPLET (user_data); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3238 |
GSList *iter; |
3239 |
||
3240 |
for (iter = applet->secrets_reqs; iter; iter = g_slist_next (iter)) { |
|
3241 |
SecretsRequest *req = iter->data; |
|
3242 |
||
3243 |
if (req->reqid == request_id) { |
|
3244 |
/* cancel and free this password request */
|
|
3245 |
applet_secrets_request_free (req); |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3246 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3247 |
}
|
3248 |
}
|
|
3249 |
||
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
3250 |
static void |
3251 |
applet_agent_registered_cb (AppletAgent *agent, |
|
3252 |
GParamSpec *pspec, |
|
3253 |
gpointer user_data) |
|
3254 |
{
|
|
3255 |
NMApplet *applet = NM_APPLET (user_data); |
|
3256 |
||
3257 |
/* If the shell is running and the agent just got registered, unregister it */
|
|
3258 |
if ( (applet->shell_version >= 3.4) |
|
3259 |
&& nm_secret_agent_get_registered (NM_SECRET_AGENT (agent))) { |
|
3260 |
g_message ("Stopping registered applet secret agent because GNOME Shell is running"); |
|
3261 |
nm_secret_agent_unregister (NM_SECRET_AGENT (agent)); |
|
3262 |
}
|
|
3263 |
}
|
|
3264 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3265 |
/*****************************************************************************/
|
3266 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3267 |
static void |
3268 |
nma_clear_icon (GdkPixbuf **icon, NMApplet *applet) |
|
3269 |
{
|
|
3270 |
g_return_if_fail (icon != NULL); |
|
3271 |
g_return_if_fail (applet != NULL); |
|
3272 |
||
3273 |
if (*icon && (*icon != applet->fallback_icon)) { |
|
3274 |
g_object_unref (*icon); |
|
3275 |
*icon = NULL; |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3276 |
}
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3277 |
}
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3278 |
|
3279 |
static void nma_icons_free (NMApplet *applet) |
|
3280 |
{
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3281 |
int i, j; |
3282 |
||
3283 |
for (i = 0; i <= ICON_LAYER_MAX; i++) |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3284 |
nma_clear_icon (&applet->icon_layers[i], applet); |
3285 |
||
3286 |
nma_clear_icon (&applet->no_connection_icon, applet); |
|
3287 |
nma_clear_icon (&applet->wired_icon, applet); |
|
3288 |
nma_clear_icon (&applet->adhoc_icon, applet); |
|
3289 |
nma_clear_icon (&applet->wwan_icon, applet); |
|
3290 |
nma_clear_icon (&applet->wwan_tower_icon, applet); |
|
3291 |
nma_clear_icon (&applet->vpn_lock_icon, applet); |
|
3292 |
nma_clear_icon (&applet->wireless_00_icon, applet); |
|
3293 |
nma_clear_icon (&applet->wireless_25_icon, applet); |
|
3294 |
nma_clear_icon (&applet->wireless_50_icon, applet); |
|
3295 |
nma_clear_icon (&applet->wireless_75_icon, applet); |
|
3296 |
nma_clear_icon (&applet->wireless_100_icon, applet); |
|
3297 |
nma_clear_icon (&applet->secure_lock_icon, applet); |
|
3298 |
||
3299 |
nma_clear_icon (&applet->mb_tech_1x_icon, applet); |
|
3300 |
nma_clear_icon (&applet->mb_tech_evdo_icon, applet); |
|
3301 |
nma_clear_icon (&applet->mb_tech_gprs_icon, applet); |
|
3302 |
nma_clear_icon (&applet->mb_tech_edge_icon, applet); |
|
3303 |
nma_clear_icon (&applet->mb_tech_umts_icon, applet); |
|
3304 |
nma_clear_icon (&applet->mb_tech_hspa_icon, applet); |
|
3305 |
nma_clear_icon (&applet->mb_roaming_icon, applet); |
|
3306 |
nma_clear_icon (&applet->mb_tech_3g_icon, applet); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3307 |
|
3308 |
for (i = 0; i < NUM_CONNECTING_STAGES; i++) { |
|
3309 |
for (j = 0; j < NUM_CONNECTING_FRAMES; j++) |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3310 |
nma_clear_icon (&applet->network_connecting_icons[i][j], applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3311 |
}
|
3312 |
||
3313 |
for (i = 0; i < NUM_VPN_CONNECTING_FRAMES; i++) |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3314 |
nma_clear_icon (&applet->vpn_connecting_icons[i], applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3315 |
|
3316 |
for (i = 0; i <= ICON_LAYER_MAX; i++) |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3317 |
nma_clear_icon (&applet->icon_layers[i], applet); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3318 |
}
|
3319 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3320 |
GdkPixbuf * |
3321 |
nma_icon_check_and_load (const char *name, GdkPixbuf **icon, NMApplet *applet) |
|
3322 |
{
|
|
3323 |
GError *error = NULL; |
|
3324 |
||
3325 |
g_return_val_if_fail (name != NULL, NULL); |
|
3326 |
g_return_val_if_fail (icon != NULL, NULL); |
|
3327 |
g_return_val_if_fail (applet != NULL, NULL); |
|
3328 |
||
3329 |
/* icon already loaded successfully */
|
|
3330 |
if (*icon && (*icon != applet->fallback_icon)) |
|
3331 |
return *icon; |
|
3332 |
||
3333 |
/* Try to load the icon; if the load fails, log the problem, and set
|
|
3334 |
* the icon to the fallback icon if requested.
|
|
3335 |
*/
|
|
3336 |
*icon = gtk_icon_theme_load_icon (applet->icon_theme, name, applet->icon_size, 0, &error); |
|
3337 |
if (!*icon) { |
|
3338 |
g_warning ("Icon %s missing: (%d) %s", |
|
3339 |
name, |
|
3340 |
error ? error->code : -1, |
|
3341 |
(error && error->message) ? error->message : "(unknown)"); |
|
3342 |
g_clear_error (&error); |
|
3343 |
||
3344 |
*icon = applet->fallback_icon; |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3345 |
}
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3346 |
return *icon; |
3347 |
}
|
|
3348 |
||
1.2.15
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110114t131931.fd589a7 |
3349 |
#include "fallback-icon.h" |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3350 |
|
3351 |
static gboolean |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3352 |
nma_icons_reload (NMApplet *applet) |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3353 |
{
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3354 |
GError *error = NULL; |
1.2.15
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110114t131931.fd589a7 |
3355 |
GdkPixbufLoader *loader; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3356 |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
3357 |
g_return_val_if_fail (applet->icon_size > 0, FALSE); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3358 |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3359 |
nma_icons_free (applet); |
3360 |
||
1.2.15
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110114t131931.fd589a7 |
3361 |
loader = gdk_pixbuf_loader_new_with_type ("png", &error); |
3362 |
if (!loader) |
|
3363 |
goto error; |
|
3364 |
||
3365 |
if (!gdk_pixbuf_loader_write (loader, |
|
3366 |
fallback_icon_data, |
|
3367 |
sizeof (fallback_icon_data), |
|
3368 |
&error)) |
|
3369 |
goto error; |
|
3370 |
||
3371 |
if (!gdk_pixbuf_loader_close (loader, &error)) |
|
3372 |
goto error; |
|
3373 |
||
3374 |
applet->fallback_icon = gdk_pixbuf_loader_get_pixbuf (loader); |
|
3375 |
g_object_ref (applet->fallback_icon); |
|
3376 |
g_assert (applet->fallback_icon); |
|
3377 |
g_object_unref (loader); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3378 |
|
3379 |
return TRUE; |
|
1.2.15
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20110114t131931.fd589a7 |
3380 |
|
3381 |
error: |
|
3382 |
g_warning ("Could not load fallback icon: (%d) %s", |
|
3383 |
error ? error->code : -1, |
|
3384 |
(error && error->message) ? error->message : "(unknown)"); |
|
3385 |
g_clear_error (&error); |
|
3386 |
/* Die if we can't get a fallback icon */
|
|
3387 |
g_assert (FALSE); |
|
3388 |
return FALSE; |
|
1
by Anthony Mercatante
Import upstream version 0.6.5 |
3389 |
}
|
3390 |
||
3391 |
static void nma_icon_theme_changed (GtkIconTheme *icon_theme, NMApplet *applet) |
|
3392 |
{
|
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3393 |
nma_icons_reload (applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3394 |
}
|
3395 |
||
3396 |
static void nma_icons_init (NMApplet *applet) |
|
3397 |
{
|
|
3398 |
GdkScreen *screen; |
|
3399 |
gboolean path_appended; |
|
3400 |
||
3401 |
if (applet->icon_theme) { |
|
3402 |
g_signal_handlers_disconnect_by_func (applet->icon_theme, |
|
3403 |
G_CALLBACK (nma_icon_theme_changed), |
|
3404 |
applet); |
|
3405 |
g_object_unref (G_OBJECT (applet->icon_theme)); |
|
3406 |
}
|
|
3407 |
||
3408 |
screen = gtk_status_icon_get_screen (applet->status_icon); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3409 |
g_assert (screen); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3410 |
applet->icon_theme = gtk_icon_theme_get_for_screen (screen); |
3411 |
||
3412 |
/* If not done yet, append our search path */
|
|
3413 |
path_appended = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (applet->icon_theme), |
|
3414 |
"NMAIconPathAppended")); |
|
3415 |
if (path_appended == FALSE) { |
|
3416 |
gtk_icon_theme_append_search_path (applet->icon_theme, ICONDIR); |
|
3417 |
g_object_set_data (G_OBJECT (applet->icon_theme), |
|
3418 |
"NMAIconPathAppended", |
|
3419 |
GINT_TO_POINTER (TRUE)); |
|
3420 |
}
|
|
3421 |
||
3422 |
g_signal_connect (applet->icon_theme, "changed", G_CALLBACK (nma_icon_theme_changed), applet); |
|
3423 |
}
|
|
3424 |
||
3425 |
static void |
|
3426 |
status_icon_screen_changed_cb (GtkStatusIcon *icon, |
|
3427 |
GParamSpec *pspec, |
|
3428 |
NMApplet *applet) |
|
3429 |
{
|
|
3430 |
nma_icons_init (applet); |
|
3431 |
nma_icon_theme_changed (NULL, applet); |
|
3432 |
}
|
|
3433 |
||
3434 |
static gboolean |
|
3435 |
status_icon_size_changed_cb (GtkStatusIcon *icon, |
|
3436 |
gint size, |
|
3437 |
NMApplet *applet) |
|
3438 |
{
|
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
3439 |
/* icon_size may be 0 if for example the panel hasn't given us any space
|
3440 |
* yet. We'll get resized later, but for now just load the 16x16 icons.
|
|
3441 |
*/
|
|
3442 |
applet->icon_size = MAX (16, size); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3443 |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3444 |
nma_icons_reload (applet); |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3445 |
|
3446 |
applet_schedule_update_icon (applet); |
|
3447 |
||
3448 |
return TRUE; |
|
3449 |
}
|
|
3450 |
||
3451 |
static void |
|
3452 |
status_icon_activate_cb (GtkStatusIcon *icon, NMApplet *applet) |
|
3453 |
{
|
|
3454 |
/* Have clicking on the applet act also as acknowledgement
|
|
3455 |
* of the notification.
|
|
3456 |
*/
|
|
3457 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3458 |
/* Kill any old menu */
|
3459 |
if (applet->menu) |
|
3460 |
g_object_unref (applet->menu); |
|
3461 |
||
3462 |
/* And make a fresh new one */
|
|
3463 |
applet->menu = gtk_menu_new (); |
|
3464 |
/* Sink the ref so we can explicitly destroy the menu later */
|
|
3465 |
g_object_ref_sink (G_OBJECT (applet->menu)); |
|
3466 |
||
3467 |
gtk_container_set_border_width (GTK_CONTAINER (applet->menu), 0); |
|
3468 |
g_signal_connect (applet->menu, "show", G_CALLBACK (nma_menu_show_cb), applet); |
|
3469 |
g_signal_connect (applet->menu, "deactivate", G_CALLBACK (nma_menu_deactivate_cb), applet); |
|
3470 |
||
3471 |
/* Display the new menu */
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3472 |
gtk_menu_popup (GTK_MENU (applet->menu), NULL, NULL, |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3473 |
gtk_status_icon_position_menu, icon, |
3474 |
1, gtk_get_current_event_time ()); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3475 |
}
|
3476 |
||
3477 |
static void |
|
3478 |
status_icon_popup_menu_cb (GtkStatusIcon *icon, |
|
3479 |
guint button, |
|
3480 |
guint32 activate_time, |
|
3481 |
NMApplet *applet) |
|
3482 |
{
|
|
3483 |
/* Have clicking on the applet act also as acknowledgement
|
|
3484 |
* of the notification.
|
|
3485 |
*/
|
|
3486 |
||
83
by Mathieu Trudel-Lapierre
* debian/patches/nm-applet-use-indicator.patch: |
3487 |
/* Kill the old menu */
|
3488 |
if (applet->context_menu) |
|
3489 |
g_object_unref (applet->context_menu); |
|
3490 |
||
3491 |
/* And make a fresh new one */
|
|
3492 |
applet->context_menu = gtk_menu_new (); |
|
3493 |
g_object_ref_sink (G_OBJECT (applet->context_menu)); |
|
3494 |
applet->context_menu = nma_context_menu_create (applet, GTK_MENU_SHELL (applet->context_menu)); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3495 |
nma_context_menu_update (applet); |
3496 |
gtk_menu_popup (GTK_MENU (applet->context_menu), NULL, NULL, |
|
3497 |
gtk_status_icon_position_menu, icon, |
|
3498 |
button, activate_time); |
|
3499 |
}
|
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3500 |
|
3501 |
#ifdef ENABLE_INDICATOR
|
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3502 |
static GtkStatusIcon * |
3503 |
indicator_fallback (AppIndicator *indicator) |
|
3504 |
{
|
|
3505 |
NMApplet *applet; |
|
3506 |
||
3507 |
applet = NM_APPLET(g_object_get_data (G_OBJECT (indicator), "applet")); |
|
3508 |
g_return_val_if_fail (NM_IS_APPLET (applet), NULL); |
|
3509 |
g_return_val_if_fail (applet->status_icon, NULL); |
|
3510 |
||
3511 |
g_message ("using fallback from indicator to GtkStatusIcon"); |
|
84
by Mathieu Trudel-Lapierre
* debian/patches/lp829673_gconf_hide_applet.patch: allow toggling the applet |
3512 |
gtk_status_icon_set_visible (applet->status_icon, applet->visible); |
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3513 |
|
83
by Mathieu Trudel-Lapierre
* debian/patches/nm-applet-use-indicator.patch: |
3514 |
applet->in_fallback = TRUE; |
3515 |
||
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3516 |
return applet->status_icon; |
3517 |
}
|
|
3518 |
||
3519 |
static void |
|
3520 |
indicator_unfallback (AppIndicator *indicator, GtkStatusIcon *status_icon) |
|
3521 |
{
|
|
3522 |
NMApplet *applet; |
|
3523 |
||
3524 |
applet = NM_APPLET(g_object_get_data (G_OBJECT (indicator), "applet")); |
|
3525 |
g_return_if_fail (NM_IS_APPLET (applet)); |
|
3526 |
g_return_if_fail (applet->status_icon); |
|
3527 |
||
3528 |
g_message ("moving back from GtkStatusIcon to indicator"); |
|
3529 |
gtk_status_icon_set_visible (applet->status_icon, FALSE); |
|
83
by Mathieu Trudel-Lapierre
* debian/patches/nm-applet-use-indicator.patch: |
3530 |
|
3531 |
applet->in_fallback = FALSE; |
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3532 |
}
|
3533 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3534 |
static gboolean |
3535 |
setup_indicator_menu (NMApplet *applet) |
|
3536 |
{
|
|
3537 |
g_return_val_if_fail (NM_IS_APPLET (applet), FALSE); |
|
3538 |
||
83
by Mathieu Trudel-Lapierre
* debian/patches/nm-applet-use-indicator.patch: |
3539 |
applet->in_fallback = FALSE; |
3540 |
||
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3541 |
applet->app_indicator = app_indicator_new |
3542 |
("nm-applet", "nm-no-connection", |
|
3543 |
APP_INDICATOR_CATEGORY_SYSTEM_SERVICES); |
|
3544 |
||
83
by Mathieu Trudel-Lapierre
* debian/patches/nm-applet-use-indicator.patch: |
3545 |
app_indicator_set_title(applet->app_indicator, _("Network")); |
3546 |
||
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3547 |
g_object_set_data (G_OBJECT (applet->app_indicator), "applet", (gpointer) applet); |
3548 |
||
3549 |
APP_INDICATOR_GET_CLASS(applet->app_indicator)->fallback = indicator_fallback; |
|
3550 |
APP_INDICATOR_GET_CLASS(applet->app_indicator)->unfallback = indicator_unfallback; |
|
3551 |
||
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
3552 |
applet->menu = gtk_menu_new (); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3553 |
|
70
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-07-07 15:24:06 (GMT) |
3554 |
g_object_ref_sink (G_OBJECT (applet->menu)); |
3555 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3556 |
applet->menu = nma_context_menu_create (applet, GTK_MENU_SHELL(applet->menu)); |
3557 |
nma_context_menu_update(applet); |
|
3558 |
||
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3559 |
app_indicator_set_menu(applet->app_indicator, GTK_MENU(applet->menu)); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3560 |
|
3561 |
return TRUE; |
|
3562 |
}
|
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3563 |
#endif /* ENABLE_INDICATOR */ |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3564 |
|
3565 |
static gboolean |
|
3566 |
setup_statusicon_menu (NMApplet *applet) |
|
3567 |
{
|
|
3568 |
g_return_val_if_fail (NM_IS_APPLET (applet), FALSE); |
|
3569 |
||
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3570 |
applet->status_icon = gtk_status_icon_new (); |
3571 |
||
3572 |
#ifdef ENABLE_INDICATOR
|
|
84
by Mathieu Trudel-Lapierre
* debian/patches/lp829673_gconf_hide_applet.patch: allow toggling the applet |
3573 |
gtk_status_icon_set_visible (applet->status_icon, applet->visible); |
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3574 |
#endif
|
3575 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3576 |
if (!applet->status_icon) |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3577 |
return FALSE; |
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3578 |
if (shell_debug) |
3579 |
gtk_status_icon_set_name (applet->status_icon, "adsfasdfasdfadfasdf"); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3580 |
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3581 |
g_signal_connect (applet->status_icon, "notify::screen", |
3582 |
G_CALLBACK (status_icon_screen_changed_cb), applet); |
|
3583 |
g_signal_connect (applet->status_icon, "size-changed", |
|
3584 |
G_CALLBACK (status_icon_size_changed_cb), applet); |
|
3585 |
g_signal_connect (applet->status_icon, "activate", |
|
3586 |
G_CALLBACK (status_icon_activate_cb), applet); |
|
3587 |
g_signal_connect (applet->status_icon, "popup-menu", |
|
3588 |
G_CALLBACK (status_icon_popup_menu_cb), applet); |
|
3589 |
||
3590 |
applet->context_menu = gtk_menu_new (); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3591 |
applet->context_menu = nma_context_menu_create (applet, GTK_MENU_SHELL (applet->context_menu)); |
83
by Mathieu Trudel-Lapierre
* debian/patches/nm-applet-use-indicator.patch: |
3592 |
g_object_ref_sink (G_OBJECT (applet->context_menu)); |
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
3593 |
if (!applet->context_menu) |
3594 |
return FALSE; |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3595 |
|
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
3596 |
return TRUE; |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3597 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3598 |
|
3599 |
static gboolean |
|
3600 |
setup_widgets (NMApplet *applet) |
|
3601 |
{
|
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3602 |
gboolean success = FALSE; |
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3603 |
gboolean indicator_success = FALSE; |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3604 |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3605 |
g_return_val_if_fail (NM_IS_APPLET (applet), FALSE); |
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3606 |
|
3607 |
success = setup_statusicon_menu (applet); |
|
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3608 |
|
3609 |
#ifdef ENABLE_INDICATOR
|
|
3610 |
indicator_success = setup_indicator_menu (applet); |
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3611 |
#endif
|
3612 |
||
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3613 |
#ifndef ENABLE_INDICATOR
|
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3614 |
return success; |
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3615 |
#else
|
3616 |
return success || indicator_success; |
|
3617 |
#endif
|
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3618 |
}
|
3619 |
||
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3620 |
static void |
3621 |
applet_embedded_cb (GObject *object, GParamSpec *pspec, gpointer user_data) |
|
3622 |
{
|
|
3623 |
gboolean embedded = gtk_status_icon_is_embedded (GTK_STATUS_ICON (object)); |
|
3624 |
||
3625 |
g_message ("applet now %s the notification area", |
|
3626 |
embedded ? "embedded in" : "removed from"); |
|
3627 |
}
|
|
3628 |
||
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
3629 |
#if GLIB_CHECK_VERSION(2,26,0)
|
3630 |
static gboolean |
|
3631 |
delayed_start_agent (gpointer user_data) |
|
3632 |
{
|
|
3633 |
NMApplet *applet = user_data; |
|
3634 |
||
3635 |
applet->agent_start_id = 0; |
|
3636 |
||
3637 |
g_assert (applet->agent); |
|
3638 |
||
3639 |
/* If the agent is already running, there's nothing to do. */
|
|
3640 |
if (nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)) == TRUE) |
|
3641 |
return FALSE; |
|
3642 |
||
3643 |
if (nm_secret_agent_register (NM_SECRET_AGENT (applet->agent))) |
|
3644 |
g_message ("Starting applet secret agent because GNOME Shell disappeared"); |
|
3645 |
else
|
|
3646 |
g_warning ("Failed to start applet secret agent!"); |
|
3647 |
return FALSE; |
|
3648 |
}
|
|
3649 |
||
3650 |
static gboolean |
|
3651 |
get_shell_version (GDBusProxy *proxy, gdouble *out_version) |
|
3652 |
{
|
|
3653 |
GVariant *v; |
|
3654 |
char *version, *p; |
|
3655 |
gboolean success = FALSE; |
|
3656 |
gdouble converted; |
|
3657 |
||
3658 |
/* Ask for the shell's version */
|
|
3659 |
v = g_dbus_proxy_get_cached_property (proxy, "ShellVersion"); |
|
3660 |
if (v) { |
|
3661 |
g_warn_if_fail (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)); |
|
3662 |
version = g_variant_dup_string (v, NULL); |
|
3663 |
if (version) { |
|
3664 |
/* Terminate at the second dot if there is one */
|
|
3665 |
p = strchr (version, '.'); |
|
3666 |
if (p && (p = strchr (p + 1, '.'))) |
|
3667 |
*p = '\0'; |
|
3668 |
||
3669 |
converted = strtod (version, NULL); |
|
3670 |
g_warn_if_fail (converted > 0); |
|
3671 |
g_warn_if_fail (converted < 1000); |
|
3672 |
if (converted > 0 && converted < 1000) { |
|
3673 |
*out_version = converted; |
|
3674 |
success = TRUE; |
|
3675 |
}
|
|
3676 |
g_free (version); |
|
3677 |
}
|
|
3678 |
g_variant_unref (v); |
|
3679 |
}
|
|
3680 |
return success; |
|
3681 |
}
|
|
3682 |
||
3683 |
static void |
|
3684 |
name_owner_changed_cb (GDBusProxy *proxy, GParamSpec *pspec, gpointer user_data) |
|
3685 |
{
|
|
3686 |
NMApplet *applet = user_data; |
|
3687 |
char *owner; |
|
3688 |
||
3689 |
owner = g_dbus_proxy_get_name_owner (proxy); |
|
3690 |
if (owner) { |
|
3691 |
applet->shell_version = 0; |
|
3692 |
if (applet->agent_start_id) |
|
3693 |
g_source_remove (applet->agent_start_id); |
|
3694 |
||
3695 |
if ( get_shell_version (proxy, &applet->shell_version) |
|
3696 |
&& applet->shell_version >= 3.4 |
|
3697 |
&& applet->agent |
|
3698 |
&& nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent))) { |
|
3699 |
g_message ("Stopping applet secret agent because GNOME Shell appeared"); |
|
3700 |
nm_secret_agent_unregister (NM_SECRET_AGENT (applet->agent)); |
|
3701 |
}
|
|
3702 |
} else { |
|
3703 |
/* If the shell quit and our agent wasn't already registered, do it
|
|
3704 |
* now on a delay (just in case the shell is restarting.
|
|
3705 |
*/
|
|
3706 |
applet->shell_version = 0; |
|
3707 |
if (applet->agent_start_id) |
|
3708 |
g_source_remove (applet->agent_start_id); |
|
3709 |
||
3710 |
if (nm_secret_agent_get_registered (NM_SECRET_AGENT (applet->agent)) == FALSE) |
|
3711 |
applet->agent_start_id = g_timeout_add_seconds (4, delayed_start_agent, applet); |
|
3712 |
}
|
|
3713 |
g_free (owner); |
|
3714 |
}
|
|
3715 |
#endif
|
|
3716 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3717 |
static gboolean |
3718 |
dbus_setup (NMApplet *applet, GError **error) |
|
3719 |
{
|
|
3720 |
DBusConnection *connection; |
|
3721 |
DBusGProxy *proxy; |
|
3722 |
guint result; |
|
3723 |
gboolean success; |
|
3724 |
||
3725 |
applet->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, error); |
|
3726 |
if (!applet->bus) |
|
3727 |
return FALSE; |
|
3728 |
||
3729 |
connection = dbus_g_connection_get_connection (applet->bus); |
|
3730 |
dbus_connection_set_exit_on_disconnect (connection, FALSE); |
|
3731 |
||
3732 |
applet->session_bus = dbus_g_bus_get (DBUS_BUS_SESSION, error); |
|
3733 |
if (!applet->session_bus) |
|
3734 |
return FALSE; |
|
3735 |
||
3736 |
dbus_g_connection_register_g_object (applet->session_bus, |
|
3737 |
"/org/gnome/network_manager_applet", |
|
3738 |
G_OBJECT (applet)); |
|
3739 |
||
3740 |
proxy = dbus_g_proxy_new_for_name (applet->session_bus, |
|
3741 |
DBUS_SERVICE_DBUS, |
|
3742 |
DBUS_PATH_DBUS, |
|
3743 |
DBUS_INTERFACE_DBUS); |
|
3744 |
success = dbus_g_proxy_call (proxy, "RequestName", error, |
|
3745 |
G_TYPE_STRING, "org.gnome.network_manager_applet", |
|
3746 |
G_TYPE_UINT, DBUS_NAME_FLAG_DO_NOT_QUEUE, |
|
3747 |
G_TYPE_INVALID, |
|
3748 |
G_TYPE_UINT, &result, |
|
3749 |
G_TYPE_INVALID); |
|
3750 |
g_object_unref (proxy); |
|
3751 |
||
3752 |
return success; |
|
3753 |
}
|
|
3754 |
||
3755 |
static void |
|
3756 |
add_cb (NMRemoteSettings *settings, |
|
3757 |
NMRemoteConnection *connection, |
|
3758 |
GError *error, |
|
3759 |
gpointer user_data) |
|
3760 |
{
|
|
3761 |
NMConnection *c = user_data; |
|
3762 |
||
3763 |
if (error) { |
|
3764 |
g_warning ("Failed to move connection '%s' to NetworkManager system settings: %s", |
|
3765 |
nm_connection_get_id (c), |
|
3766 |
error->message); |
|
3767 |
}
|
|
3768 |
g_object_unref (c); |
|
3769 |
}
|
|
3770 |
||
3771 |
static void |
|
3772 |
import_cb (NMConnection *connection, gpointer user_data) |
|
3773 |
{
|
|
3774 |
NMApplet *applet = user_data; |
|
3775 |
||
3776 |
if (!nm_remote_settings_add_connection (applet->settings, connection, add_cb, g_object_ref (connection))) { |
|
3777 |
g_warning ("Failed to move connection '%s' to NetworkManager system settings.", |
|
3778 |
nm_connection_get_id (connection)); |
|
3779 |
}
|
|
3780 |
}
|
|
3781 |
||
84
by Mathieu Trudel-Lapierre
* debian/patches/lp829673_gconf_hide_applet.patch: allow toggling the applet |
3782 |
static void |
3783 |
applet_gconf_value_changed (GConfClient *client, |
|
3784 |
guint cnxn_id, |
|
3785 |
GConfEntry *entry, |
|
3786 |
gpointer user_data) |
|
3787 |
{
|
|
3788 |
NMApplet *applet = NM_APPLET (user_data); |
|
3789 |
GConfValue *value = NULL; |
|
3790 |
||
3791 |
g_return_if_fail (entry != NULL); |
|
3792 |
||
3793 |
if (g_strcmp0(gconf_entry_get_key (entry), PREF_SHOW_APPLET) == 0) { |
|
3794 |
value = gconf_entry_get_value (entry); |
|
3795 |
applet->visible = gconf_value_get_bool (value); |
|
3796 |
||
3797 |
gtk_status_icon_set_visible (applet->status_icon, applet->visible); |
|
3798 |
||
3799 |
#ifdef ENABLE_INDICATOR
|
|
3800 |
if (applet->visible) |
|
3801 |
app_indicator_set_status (applet->app_indicator, APP_INDICATOR_STATUS_ACTIVE); |
|
3802 |
else
|
|
3803 |
app_indicator_set_status (applet->app_indicator, APP_INDICATOR_STATUS_PASSIVE); |
|
3804 |
#endif /* ENABLE_INDICATOR */ |
|
3805 |
}
|
|
3806 |
}
|
|
3807 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3808 |
static GObject * |
3809 |
constructor (GType type, |
|
3810 |
guint n_props, |
|
3811 |
GObjectConstructParam *construct_props) |
|
3812 |
{
|
|
3813 |
NMApplet *applet; |
|
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
3814 |
GError* error = NULL; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3815 |
|
3816 |
applet = NM_APPLET (G_OBJECT_CLASS (nma_parent_class)->constructor (type, n_props, construct_props)); |
|
3817 |
||
3818 |
g_set_application_name (_("NetworkManager Applet")); |
|
3819 |
gtk_window_set_default_icon_name (GTK_STOCK_NETWORK); |
|
3820 |
||
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
3821 |
applet->info_dialog_ui = gtk_builder_new (); |
3822 |
||
1.2.19
by Mathieu Trudel-Lapierre
Import upstream version 0.8.4 |
3823 |
if (!gtk_builder_add_from_file (applet->info_dialog_ui, UIDIR "/info.ui", &error)) { |
3824 |
g_warning ("Couldn't load info dialog ui file: %s", error->message); |
|
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
3825 |
g_error_free (error); |
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
3826 |
goto error; |
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
3827 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3828 |
|
3829 |
applet->gconf_client = gconf_client_get_default (); |
|
3830 |
if (!applet->gconf_client) |
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
3831 |
goto error; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3832 |
|
1.2.13
by Mathieu Trudel-Lapierre
Import upstream version 0.8.2+git.20101123t161608.f143e76 |
3833 |
gconf_client_add_dir (applet->gconf_client, |
3834 |
APPLET_PREFS_PATH, |
|
3835 |
GCONF_CLIENT_PRELOAD_ONELEVEL, |
|
3836 |
NULL); |
|
3837 |
||
84
by Mathieu Trudel-Lapierre
* debian/patches/lp829673_gconf_hide_applet.patch: allow toggling the applet |
3838 |
applet->visible = gconf_client_get_bool (applet->gconf_client, |
3839 |
PREF_SHOW_APPLET, |
|
3840 |
NULL); |
|
3841 |
||
3842 |
gconf_client_notify_add (applet->gconf_client, |
|
3843 |
APPLET_PREFS_PATH, |
|
3844 |
(GConfClientNotifyFunc) applet_gconf_value_changed, |
|
3845 |
applet, NULL, NULL); |
|
3846 |
||
68
by Mathieu Trudel-Lapierre
* upstream snapshot 2011-05-29 17:00:33 (GMT) |
3847 |
foo_client_setup (applet); |
3848 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3849 |
/* Load pixmaps and create applet widgets */
|
3850 |
if (!setup_widgets (applet)) |
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
3851 |
goto error; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3852 |
nma_icons_init (applet); |
3853 |
||
3854 |
if (!notify_is_initted ()) |
|
3855 |
notify_init ("NetworkManager"); |
|
3856 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3857 |
if (!dbus_setup (applet, &error)) { |
3858 |
g_warning ("Failed to initialize D-Bus: %s", error->message); |
|
3859 |
g_error_free (error); |
|
3860 |
goto error; |
|
3861 |
}
|
|
3862 |
applet->settings = nm_remote_settings_new (applet->bus); |
|
3863 |
||
3864 |
/* Move user connections to the system */
|
|
3865 |
nm_gconf_move_connections_to_system (import_cb, applet); |
|
3866 |
||
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
3867 |
#ifdef ENABLE_INDICATOR
|
3868 |
/* Watch for new connections */
|
|
3869 |
g_signal_connect (applet->settings, "new-connection", |
|
3870 |
G_CALLBACK (new_connection_cb), |
|
3871 |
applet); |
|
3872 |
#endif /* ENABLE_INDICATOR */ |
|
3873 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3874 |
applet->agent = applet_agent_new (); |
3875 |
g_assert (applet->agent); |
|
3876 |
g_signal_connect (applet->agent, APPLET_AGENT_GET_SECRETS, |
|
3877 |
G_CALLBACK (applet_agent_get_secrets_cb), applet); |
|
3878 |
g_signal_connect (applet->agent, APPLET_AGENT_CANCEL_SECRETS, |
|
3879 |
G_CALLBACK (applet_agent_cancel_secrets_cb), applet); |
|
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
3880 |
g_signal_connect (applet->agent, "notify::" NM_SECRET_AGENT_REGISTERED, |
3881 |
G_CALLBACK (applet_agent_registered_cb), applet); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3882 |
|
3883 |
/* Initialize device classes */
|
|
3884 |
applet->wired_class = applet_device_wired_get_class (applet); |
|
3885 |
g_assert (applet->wired_class); |
|
3886 |
||
3887 |
applet->wifi_class = applet_device_wifi_get_class (applet); |
|
3888 |
g_assert (applet->wifi_class); |
|
3889 |
||
3890 |
applet->gsm_class = applet_device_gsm_get_class (applet); |
|
3891 |
g_assert (applet->gsm_class); |
|
3892 |
||
3893 |
applet->cdma_class = applet_device_cdma_get_class (applet); |
|
3894 |
g_assert (applet->cdma_class); |
|
3895 |
||
1.2.4
by Tony Espy
Import upstream version 0.8~a~git.20090805t131328.d1edfce |
3896 |
applet->bt_class = applet_device_bt_get_class (applet); |
3897 |
g_assert (applet->bt_class); |
|
3898 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3899 |
applet->wimax_class = applet_device_wimax_get_class (applet); |
3900 |
g_assert (applet->wimax_class); |
|
3901 |
||
67
by Mathieu Trudel-Lapierre
* New upstream release 0.8.4. |
3902 |
/* Track embedding to help debug issues where user has removed the
|
3903 |
* notification area applet from the panel, and thus nm-applet too.
|
|
3904 |
*/
|
|
3905 |
g_signal_connect (applet->status_icon, "notify::embedded", |
|
3906 |
G_CALLBACK (applet_embedded_cb), NULL); |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3907 |
applet_embedded_cb (G_OBJECT (applet->status_icon), NULL, NULL); |
3908 |
||
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
3909 |
#if GLIB_CHECK_VERSION(2,26,0)
|
3910 |
/* Watch GNOME Shell so we can unregister our applet agent if it appears */
|
|
3911 |
applet->shell_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, |
|
3912 |
G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, |
|
3913 |
NULL, |
|
3914 |
"org.gnome.Shell", |
|
3915 |
"/org/gnome/Shell", |
|
3916 |
"org.gnome.Shell", |
|
3917 |
NULL, |
|
3918 |
NULL); |
|
3919 |
g_signal_connect (applet->shell_proxy, |
|
3920 |
"notify::g-name-owner", |
|
3921 |
G_CALLBACK (name_owner_changed_cb), |
|
3922 |
applet); |
|
3923 |
name_owner_changed_cb (applet->shell_proxy, NULL, applet); |
|
3924 |
#endif
|
|
3925 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3926 |
return G_OBJECT (applet); |
3927 |
||
3928 |
error: |
|
3929 |
g_object_unref (applet); |
|
3930 |
return NULL; |
|
3931 |
}
|
|
3932 |
||
3933 |
static void finalize (GObject *object) |
|
3934 |
{
|
|
3935 |
NMApplet *applet = NM_APPLET (object); |
|
3936 |
||
3937 |
g_slice_free (NMADeviceClass, applet->wired_class); |
|
3938 |
g_slice_free (NMADeviceClass, applet->wifi_class); |
|
3939 |
g_slice_free (NMADeviceClass, applet->gsm_class); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3940 |
g_slice_free (NMADeviceClass, applet->cdma_class); |
3941 |
g_slice_free (NMADeviceClass, applet->bt_class); |
|
3942 |
g_slice_free (NMADeviceClass, applet->wimax_class); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3943 |
|
3944 |
if (applet->update_icon_id) |
|
3945 |
g_source_remove (applet->update_icon_id); |
|
3946 |
||
82
by Mathieu Trudel-Lapierre, Mathieu Trudel-Lapierre, Luke Yelavich
[ Mathieu Trudel-Lapierre ] |
3947 |
#ifdef ENABLE_INDICATOR
|
3948 |
if (applet->update_menu_id) |
|
3949 |
g_source_remove (applet->update_menu_id); |
|
3950 |
#endif /* ENABLE_INDICATOR */ |
|
3951 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3952 |
if (applet->menu) |
3953 |
g_object_unref (applet->menu); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3954 |
nma_icons_free (applet); |
3955 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
3956 |
g_free (applet->tip); |
3957 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3958 |
while (g_slist_length (applet->secrets_reqs)) |
3959 |
applet_secrets_request_free ((SecretsRequest *) applet->secrets_reqs->data); |
|
3960 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3961 |
if (applet->notification) { |
3962 |
notify_notification_close (applet->notification, NULL); |
|
3963 |
g_object_unref (applet->notification); |
|
3964 |
}
|
|
3965 |
||
1.2.14
by Mathieu Trudel-Lapierre
Import upstream version 0.8.3+git.20101209t081952.0330eca |
3966 |
if (applet->info_dialog_ui) |
3967 |
g_object_unref (applet->info_dialog_ui); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3968 |
|
1.2.13
by Mathieu Trudel-Lapierre
Import upstream version 0.8.2+git.20101123t161608.f143e76 |
3969 |
if (applet->gconf_client) { |
3970 |
gconf_client_remove_dir (applet->gconf_client, |
|
3971 |
APPLET_PREFS_PATH, |
|
3972 |
NULL); |
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
3973 |
g_object_unref (applet->gconf_client); |
1.2.13
by Mathieu Trudel-Lapierre
Import upstream version 0.8.2+git.20101123t161608.f143e76 |
3974 |
}
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3975 |
|
3976 |
if (applet->status_icon) |
|
3977 |
g_object_unref (applet->status_icon); |
|
3978 |
||
73
by Mathieu Trudel-Lapierre
* debian/patches/default-ipv6-auto.patch: don't expect a missing DHCPv6 method |
3979 |
#ifdef ENABLE_INDICATOR
|
3980 |
if (applet->app_indicator) |
|
3981 |
g_object_unref (applet->app_indicator); |
|
3982 |
#endif
|
|
3983 |
||
1.1.10
by Alexander Sack
Import upstream version 0.7 |
3984 |
if (applet->nm_client) |
3985 |
g_object_unref (applet->nm_client); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
3986 |
|
1.2.12
by Mathieu Trudel-Lapierre
Import upstream version 0.8.1+git.20100809t190028.290dc70 |
3987 |
if (applet->fallback_icon) |
3988 |
g_object_unref (applet->fallback_icon); |
|
3989 |
||
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
3990 |
if (applet->agent) |
3991 |
g_object_unref (applet->agent); |
|
3992 |
||
3993 |
if (applet->settings) |
|
3994 |
g_object_unref (applet->settings); |
|
3995 |
||
3996 |
if (applet->bus) |
|
3997 |
dbus_g_connection_unref (applet->bus); |
|
3998 |
||
3999 |
if (applet->session_bus) |
|
4000 |
dbus_g_connection_unref (applet->session_bus); |
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
4001 |
|
1.2.28
by Mathieu Trudel-Lapierre
Import upstream version 0.9.4.1 |
4002 |
#if GLIB_CHECK_VERSION(2,26,0)
|
4003 |
if (applet->shell_proxy) |
|
4004 |
g_object_unref (applet->shell_proxy); |
|
4005 |
#endif
|
|
4006 |
if (applet->agent_start_id) |
|
4007 |
g_source_remove (applet->agent_start_id); |
|
4008 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
4009 |
G_OBJECT_CLASS (nma_parent_class)->finalize (object); |
4010 |
}
|
|
4011 |
||
4012 |
static void nma_init (NMApplet *applet) |
|
4013 |
{
|
|
4014 |
applet->animation_id = 0; |
|
4015 |
applet->animation_step = 0; |
|
4016 |
applet->icon_theme = NULL; |
|
4017 |
applet->notification = NULL; |
|
1.2.10
by Tony Espy
Import upstream version 0.8~rc2 |
4018 |
applet->icon_size = 16; |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
4019 |
}
|
4020 |
||
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
4021 |
enum { |
4022 |
PROP_0, |
|
4023 |
PROP_LOOP, |
|
4024 |
LAST_PROP
|
|
4025 |
};
|
|
4026 |
||
4027 |
static void |
|
4028 |
set_property (GObject *object, guint prop_id, |
|
4029 |
const GValue *value, GParamSpec *pspec) |
|
4030 |
{
|
|
4031 |
NMApplet *applet = NM_APPLET (object); |
|
4032 |
||
4033 |
switch (prop_id) { |
|
4034 |
case PROP_LOOP: |
|
4035 |
applet->loop = g_value_get_pointer (value); |
|
4036 |
break; |
|
4037 |
default: |
|
4038 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
|
4039 |
break; |
|
4040 |
}
|
|
4041 |
}
|
|
4042 |
||
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
4043 |
static void nma_class_init (NMAppletClass *klass) |
4044 |
{
|
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
4045 |
GObjectClass *oclass = G_OBJECT_CLASS (klass); |
4046 |
GParamSpec *pspec; |
|
4047 |
||
4048 |
oclass->set_property = set_property; |
|
4049 |
oclass->constructor = constructor; |
|
4050 |
oclass->finalize = finalize; |
|
4051 |
||
4052 |
pspec = g_param_spec_pointer ("loop", "Loop", "Applet mainloop", G_PARAM_CONSTRUCT | G_PARAM_WRITABLE); |
|
4053 |
g_object_class_install_property (oclass, PROP_LOOP, pspec); |
|
1.2.20
by Mathieu Trudel-Lapierre
Import upstream version 0.8.9997+git.20110529t170033.9ec4c5d |
4054 |
|
4055 |
dbus_g_object_type_install_info (NM_TYPE_APPLET, &dbus_glib_nma_object_info); |
|
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
4056 |
}
|
4057 |
||
4058 |
NMApplet * |
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
4059 |
nm_applet_new (GMainLoop *loop) |
1.1.2
by Alexander Sack
Import upstream version 0.7~~svn20080721t051503 |
4060 |
{
|
1.1.12
by Alexander Sack
Import upstream version 0.7.1~rc1+20090219+bzr974 |
4061 |
return g_object_new (NM_TYPE_APPLET, "loop", loop, NULL); |
1
by Anthony Mercatante
Import upstream version 0.6.5 |
4062 |
}
|
4063 |