Merge lp:~donadigo/switchboard-plug-networking/hotspot into lp:~elementary-pantheon/switchboard-plug-networking/trunk
- hotspot
- Merge into trunk
Status: | Rejected |
---|---|
Rejected by: | xapantu |
Proposed branch: | lp:~donadigo/switchboard-plug-networking/hotspot |
Merge into: | lp:~elementary-pantheon/switchboard-plug-networking/trunk |
Diff against target: |
1620 lines (+973/-174) 18 files modified
src/CMakeLists.txt (+2/-0) src/Plug.vala (+2/-3) src/Settings/ProxySettings.vala (+22/-0) src/Utils.vala (+259/-78) src/Widgets/Device/DeviceItem.vala (+31/-13) src/Widgets/Device/DevicePage.vala (+4/-4) src/Widgets/DeviceList.vala (+85/-37) src/Widgets/Footer.vala (+2/-2) src/Widgets/Hotspot/HotspotDialog.vala (+230/-0) src/Widgets/Hotspot/HotspotPage.vala (+174/-0) src/Widgets/InfoBox.vala (+2/-2) src/Widgets/InfoScreen.vala (+2/-2) src/Widgets/Page.vala (+1/-1) src/Widgets/Proxy/ProxyConfigurationPage.vala (+22/-1) src/Widgets/Proxy/ProxyExceptionsPage.vala (+22/-0) src/Widgets/Proxy/ProxyPage.vala (+40/-1) src/Widgets/WifiInterface.vala (+53/-25) src/common/Widgets/AbstractWifiInterface.vala (+20/-5) |
To merge this branch: | bzr merge lp:~donadigo/switchboard-plug-networking/hotspot |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
xapantu (community) | Needs Information | ||
Danielle Foré | ux | Approve | |
Review via email: mp+276926@code.launchpad.net |
Commit message
* Added new Hotspot Mode functionality.
* Code refactor.
* Code cleanup.
* Relay only on the children of the ListBox not on "items" variable.
* Sort items instead of hardcoding them.
* Set headers based on the ItemType.
* Update links and licenses.
Description of the change
This branch introduces new Hotspot Mode functionality. Hotspot item will show in the sidebar only if the Wifi device is not in unmanaged, unknown or unavaliable mode. I also kept the common folder without changes affecting indicator-network.
Every change is described in the commit message.
- 176. By Adam Bieńkowski
-
Fix not creating InfoBox from argument
- 177. By Adam Bieńkowski
-
Remove one line
- 178. By Adam Bieńkowski
-
Add licenses
- 179. By Adam Bieńkowski
-
Update links and licenses
Cody Garver (codygarver) wrote : | # |
Adam Bieńkowski (donadigo) wrote : | # |
Ahh, good catch, thanks ;)
Danielle Foré (danrabbit) wrote : | # |
Hm, I think while you are using Wireless to create a Hotspot that the Wireless connection should show as "disabled" instead of "connected". While it's true that we are using this device and the device itself is not disabled, we are using it for the purpose of creating a hotspot so the ability to use it to connect to another wireless network is, in effect, "disabled".
- 180. By Adam Bieńkowski
-
Rebuild UI of WifiInterface; added missing > in licenses; show disconnected when in hotspot mode
- 181. By Adam Bieńkowski
-
Don't use CssProvider
Danielle Foré (danrabbit) wrote : | # |
Hey right on. Like the alert messaging when it's in hotspot mode. Looks good :)
xapantu (xapantu) wrote : | # |
Why is Utils a class in src/Utils.vala ?
xapantu (xapantu) wrote : | # |
Superseded by the other hotspot branch.
Unmerged revisions
Preview Diff
1 | === modified file 'src/CMakeLists.txt' | |||
2 | --- src/CMakeLists.txt 2015-08-01 23:06:00 +0000 | |||
3 | +++ src/CMakeLists.txt 2015-11-07 23:35:34 +0000 | |||
4 | @@ -27,6 +27,8 @@ | |||
5 | 27 | Widgets/InfoBox.vala | 27 | Widgets/InfoBox.vala |
6 | 28 | Widgets/Footer.vala | 28 | Widgets/Footer.vala |
7 | 29 | Widgets/InfoScreen.vala | 29 | Widgets/InfoScreen.vala |
8 | 30 | Widgets/Hotspot/HotspotDialog.vala | ||
9 | 31 | Widgets/Hotspot/HotspotPage.vala | ||
10 | 30 | common/Utils.vala | 32 | common/Utils.vala |
11 | 31 | common/Widgets/WifiMenuItem.vala | 33 | common/Widgets/WifiMenuItem.vala |
12 | 32 | common/Widgets/AbstractWifiInterface.vala | 34 | common/Widgets/AbstractWifiInterface.vala |
13 | 33 | 35 | ||
14 | === modified file 'src/Plug.vala' | |||
15 | --- src/Plug.vala 2015-10-30 20:42:55 +0000 | |||
16 | +++ src/Plug.vala 2015-11-07 23:35:34 +0000 | |||
17 | @@ -1,6 +1,6 @@ | |||
18 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
19 | 2 | /*- | 2 | /*- |
21 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
22 | 4 | * | 4 | * |
23 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
24 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
25 | @@ -17,7 +17,7 @@ | |||
26 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
27 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
28 | 19 | * | 19 | * |
30 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
31 | 21 | */ | 21 | */ |
32 | 22 | 22 | ||
33 | 23 | /* Main client instance */ | 23 | /* Main client instance */ |
34 | @@ -64,7 +64,6 @@ | |||
35 | 64 | } | 64 | } |
36 | 65 | 65 | ||
37 | 66 | content.remove (widget_interface); | 66 | content.remove (widget_interface); |
38 | 67 | |||
39 | 68 | show_all (); | 67 | show_all (); |
40 | 69 | } | 68 | } |
41 | 70 | 69 | ||
42 | 71 | 70 | ||
43 | === modified file 'src/Settings/ProxySettings.vala' | |||
44 | --- src/Settings/ProxySettings.vala 2015-10-09 19:12:42 +0000 | |||
45 | +++ src/Settings/ProxySettings.vala 2015-11-07 23:35:34 +0000 | |||
46 | @@ -1,3 +1,25 @@ | |||
47 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
48 | 2 | /*- | ||
49 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) | ||
50 | 4 | * | ||
51 | 5 | * This library is free software; you can redistribute it and/or | ||
52 | 6 | * modify it under the terms of the GNU Library General Public | ||
53 | 7 | * License as published by the Free Software Foundation; either | ||
54 | 8 | * version 3 of the License, or (at your option) any later version. | ||
55 | 9 | * | ||
56 | 10 | * This library is distributed in the hope that it will be useful, | ||
57 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
58 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
59 | 13 | * Library General Public License for more details. | ||
60 | 14 | * | ||
61 | 15 | * You should have received a copy of the GNU Library General Public | ||
62 | 16 | * License along with this library; if not, write to the | ||
63 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
64 | 18 | * Boston, MA 02111-1307, USA. | ||
65 | 19 | * | ||
66 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> | ||
67 | 21 | */ | ||
68 | 22 | |||
69 | 1 | namespace Network { | 23 | namespace Network { |
70 | 2 | public class ProxySettings : Granite.Services.Settings { | 24 | public class ProxySettings : Granite.Services.Settings { |
71 | 3 | public string autoconfig_url { get; set; } | 25 | public string autoconfig_url { get; set; } |
72 | 4 | 26 | ||
73 | === modified file 'src/Utils.vala' | |||
74 | --- src/Utils.vala 2015-10-22 16:46:13 +0000 | |||
75 | +++ src/Utils.vala 2015-11-07 23:35:34 +0000 | |||
76 | @@ -1,81 +1,262 @@ | |||
155 | 1 | namespace Network.Utils { | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
156 | 2 | public enum ItemType { | 2 | /*- |
157 | 3 | DEVICE = 0, | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
158 | 4 | PROXY, | 4 | * |
159 | 5 | INVALID | 5 | * This library is free software; you can redistribute it and/or |
160 | 6 | } | 6 | * modify it under the terms of the GNU Library General Public |
161 | 7 | 7 | * License as published by the Free Software Foundation; either | |
162 | 8 | public Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) { | 8 | * version 3 of the License, or (at your option) any later version. |
163 | 9 | var details_btn = new Gtk.Button.with_label (title); | 9 | * |
164 | 10 | details_btn.clicked.connect (() => { | 10 | * This library is distributed in the hope that it will be useful, |
165 | 11 | new Granite.Services.SimpleCommand ("/usr/bin", | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
166 | 12 | "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run (); | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
167 | 13 | }); | 13 | * Library General Public License for more details. |
168 | 14 | 14 | * | |
169 | 15 | return details_btn; | 15 | * You should have received a copy of the GNU Library General Public |
170 | 16 | } | 16 | * License along with this library; if not, write to the |
171 | 17 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
172 | 18 | public string state_to_string (NM.DeviceState state) { | 18 | * Boston, MA 02111-1307, USA. |
173 | 19 | switch (state) { | 19 | * |
174 | 20 | case NM.DeviceState.ACTIVATED: | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
175 | 21 | return _("Connected"); | 21 | */ |
176 | 22 | case NM.DeviceState.DISCONNECTED: | 22 | |
177 | 23 | return _("Disconnected"); | 23 | namespace Network { |
178 | 24 | case NM.DeviceState.UNMANAGED: | 24 | public class Utils { |
179 | 25 | return _("Unmanaged"); | 25 | public class Hotspot { |
180 | 26 | case NM.DeviceState.PREPARE: | 26 | public delegate void UpdateSecretCallback (); |
181 | 27 | return _("In preparation"); | 27 | |
182 | 28 | case NM.DeviceState.CONFIG: | 28 | public static void activate_hotspot (NM.DeviceWifi wifi_device, |
183 | 29 | return _("Connecting..."); | 29 | ByteArray ssid, |
184 | 30 | case NM.DeviceState.NEED_AUTH: | 30 | string key, |
185 | 31 | return _("Requires more information"); | 31 | NM.Connection? selected) { |
186 | 32 | case NM.DeviceState.IP_CONFIG: | 32 | if (selected != null) { |
187 | 33 | return _("Requesting adresses..."); | 33 | client.activate_connection (selected, wifi_device, null, null); |
188 | 34 | case NM.DeviceState.IP_CHECK: | 34 | return; |
189 | 35 | return _("Checking connection..."); | 35 | } |
190 | 36 | case NM.DeviceState.SECONDARIES: | 36 | |
191 | 37 | return _("Waiting for connection..."); | 37 | var hotspot_c = new NM.Connection (); |
192 | 38 | case NM.DeviceState.DEACTIVATING: | 38 | |
193 | 39 | return _("Disconnecting..."); | 39 | var setting_connection = new NM.SettingConnection (); |
194 | 40 | case NM.DeviceState.FAILED: | 40 | setting_connection.@set (NM.SettingConnection.TYPE, "802-11-wireless"); |
195 | 41 | return _("Failed to connect"); | 41 | setting_connection.@set (NM.SettingConnection.ID, "Hotspot"); |
196 | 42 | case NM.DeviceState.UNKNOWN: | 42 | setting_connection.autoconnect = false; |
197 | 43 | default: | 43 | hotspot_c.add_setting (setting_connection); |
198 | 44 | return _("Unknown"); | 44 | |
199 | 45 | } | 45 | var setting_wireless = new NM.SettingWireless (); |
200 | 46 | } | 46 | |
201 | 47 | 47 | string? mode = null; | |
202 | 48 | public string type_to_string (NM.DeviceType type) { | 48 | var caps = wifi_device.get_capabilities (); |
203 | 49 | switch (type) { | 49 | if ((caps & NM.DeviceWifiCapabilities.AP) != 0) { |
204 | 50 | case NM.DeviceType.ETHERNET: | 50 | mode = NM.SettingWireless.MODE_AP; |
205 | 51 | return _("Ethernet"); | 51 | } else { |
206 | 52 | case NM.DeviceType.WIFI: | 52 | mode = NM.SettingWireless.MODE_ADHOC; |
207 | 53 | return _("Wi-Fi"); | 53 | } |
208 | 54 | case NM.DeviceType.UNUSED1: | 54 | |
209 | 55 | return _("Not used"); | 55 | setting_wireless.mode = mode; |
210 | 56 | case NM.DeviceType.UNUSED2: | 56 | setting_wireless.security = "802-11-wireless-security"; |
211 | 57 | return _("Not used"); | 57 | |
212 | 58 | case NM.DeviceType.BT: | 58 | hotspot_c.add_setting (setting_wireless); |
213 | 59 | return _("Bluetooth"); | 59 | |
214 | 60 | case NM.DeviceType.OLPC_MESH: | 60 | var ip4_setting = new NM.SettingIP4Config (); |
215 | 61 | return _("OLPC XO"); | 61 | ip4_setting.method = "shared"; |
216 | 62 | case NM.DeviceType.WIMAX: | 62 | hotspot_c.add_setting (ip4_setting); |
217 | 63 | return _("WiMAX Broadband"); | 63 | |
218 | 64 | case NM.DeviceType.MODEM: | 64 | setting_wireless.@set (NM.SettingWireless.SSID, ssid); |
219 | 65 | return _("Modem"); | 65 | |
220 | 66 | case NM.DeviceType.INFINIBAND: | 66 | var setting_wireless_security = new NM.SettingWirelessSecurity (); |
221 | 67 | return _("InfiniBand device"); | 67 | |
222 | 68 | case NM.DeviceType.BOND: | 68 | if (mode == NM.SettingWireless.MODE_AP) { |
223 | 69 | return _("Bond master"); | 69 | if ((caps & NM.DeviceWifiCapabilities.RSN) != 0) { |
224 | 70 | case NM.DeviceType.VLAN: | 70 | set_wpa_key (setting_wireless_security, key); |
225 | 71 | return _("VLAN Interface"); | 71 | setting_wireless_security.add_proto ("rsn"); |
226 | 72 | case NM.DeviceType.ADSL: | 72 | setting_wireless_security.add_pairwise ("ccmp"); |
227 | 73 | return _("ADSL Modem"); | 73 | setting_wireless_security.add_group ("ccmp"); |
228 | 74 | case NM.DeviceType.BRIDGE: | 74 | } else if ((caps & NM.DeviceWifiCapabilities.WPA) != 0) { |
229 | 75 | return _("Bridge master"); | 75 | set_wpa_key (setting_wireless_security, key); |
230 | 76 | case NM.DeviceType.UNKNOWN: | 76 | setting_wireless_security.add_proto ("wpa"); |
231 | 77 | default: | 77 | setting_wireless_security.add_pairwise ("tkip"); |
232 | 78 | return _("Unknown"); | 78 | setting_wireless_security.add_group ("tkip"); |
233 | 79 | } else { | ||
234 | 80 | set_wep_key (setting_wireless_security, key); | ||
235 | 81 | } | ||
236 | 82 | } else { | ||
237 | 83 | set_wep_key (setting_wireless_security, key); | ||
238 | 84 | } | ||
239 | 85 | |||
240 | 86 | hotspot_c.add_setting (setting_wireless_security); | ||
241 | 87 | client.add_and_activate_connection (hotspot_c, | ||
242 | 88 | wifi_device, | ||
243 | 89 | null, | ||
244 | 90 | finish_connection_cb); | ||
245 | 91 | } | ||
246 | 92 | |||
247 | 93 | public static void update_secrets (NM.RemoteConnection connection, UpdateSecretCallback callback) { | ||
248 | 94 | connection.get_secrets (connection.get_setting_wireless ().get_security (), ((_connection, secrets, error) => { | ||
249 | 95 | var setting_wireless = _connection.get_setting_wireless (); | ||
250 | 96 | try { | ||
251 | 97 | _connection.update_secrets (setting_wireless.get_security (), secrets); | ||
252 | 98 | } catch (Error e) { | ||
253 | 99 | warning ("%s\n", e.message); | ||
254 | 100 | return; | ||
255 | 101 | } | ||
256 | 102 | |||
257 | 103 | callback (); | ||
258 | 104 | })); | ||
259 | 105 | } | ||
260 | 106 | |||
261 | 107 | public static void deactivate_hotspot (NM.DeviceWifi wifi_device) { | ||
262 | 108 | client.get_active_connections ().@foreach ((active_connection) => { | ||
263 | 109 | var devices = active_connection.get_devices (); | ||
264 | 110 | if (devices != null && devices.@get (0) == wifi_device) { | ||
265 | 111 | client.deactivate_connection (active_connection); | ||
266 | 112 | } | ||
267 | 113 | }); | ||
268 | 114 | } | ||
269 | 115 | |||
270 | 116 | private static void set_wpa_key (NM.SettingWirelessSecurity setting, string key) { | ||
271 | 117 | setting.key_mgmt = "wpa-psk"; | ||
272 | 118 | setting.psk = key; | ||
273 | 119 | } | ||
274 | 120 | |||
275 | 121 | private static void set_wep_key (NM.SettingWirelessSecurity setting, string key) { | ||
276 | 122 | setting.key_mgmt = "none"; | ||
277 | 123 | setting.wep_key0 = key; | ||
278 | 124 | setting.wep_key_type = NM.WepKeyType.PASSPHRASE; | ||
279 | 125 | } | ||
280 | 126 | |||
281 | 127 | public static bool get_device_is_hotspot (NM.DeviceWifi wifi_device, NM.RemoteSettings nm_settings) { | ||
282 | 128 | if (wifi_device.get_active_connection () != null) { | ||
283 | 129 | var connection = nm_settings.get_connection_by_path (wifi_device.get_active_connection ().get_connection ()); | ||
284 | 130 | if (connection != null) { | ||
285 | 131 | var ip4_setting = connection.get_setting_ip4_config (); | ||
286 | 132 | return (ip4_setting != null && ip4_setting.get_method () == "shared"); | ||
287 | 133 | } | ||
288 | 134 | } | ||
289 | 135 | |||
290 | 136 | return false; | ||
291 | 137 | } | ||
292 | 138 | |||
293 | 139 | public static bool get_connection_is_hotspot (NM.Connection connection) { | ||
294 | 140 | var setting_connection = connection.get_setting_connection (); | ||
295 | 141 | if (setting_connection.get_connection_type () != "802-11-wireless") { | ||
296 | 142 | return false; | ||
297 | 143 | } | ||
298 | 144 | |||
299 | 145 | var setting_wireless = connection.get_setting_wireless (); | ||
300 | 146 | if (setting_wireless.get_mode () != "adhoc" | ||
301 | 147 | && setting_wireless.get_mode () != "ap") { | ||
302 | 148 | return false; | ||
303 | 149 | } | ||
304 | 150 | |||
305 | 151 | if (setting_wireless.get_security () != "802-11-wireless-security") { | ||
306 | 152 | return false; | ||
307 | 153 | } | ||
308 | 154 | |||
309 | 155 | var ip4_config = connection.get_setting_ip4_config (); | ||
310 | 156 | if (ip4_config.get_method () != "shared") { | ||
311 | 157 | return false; | ||
312 | 158 | } | ||
313 | 159 | |||
314 | 160 | return true; | ||
315 | 161 | } | ||
316 | 162 | |||
317 | 163 | private static void finish_connection_cb (NM.Client? cb_client, | ||
318 | 164 | NM.ActiveConnection? cb_connection, | ||
319 | 165 | string? new_connection_path, | ||
320 | 166 | Error? error) { | ||
321 | 167 | if (error != null && error.code != 0) { | ||
322 | 168 | warning ("%s\n", error.message); | ||
323 | 169 | } | ||
324 | 170 | } | ||
325 | 171 | } | ||
326 | 172 | |||
327 | 173 | public enum CustomMode { | ||
328 | 174 | PROXY_NONE = 0, | ||
329 | 175 | PROXY_MANUAL, | ||
330 | 176 | PROXY_AUTO, | ||
331 | 177 | HOTSPOT_ENABLED, | ||
332 | 178 | HOTSPOT_DISABLED, | ||
333 | 179 | INVALID | ||
334 | 180 | } | ||
335 | 181 | |||
336 | 182 | public enum ItemType { | ||
337 | 183 | DEVICE = 0, | ||
338 | 184 | VIRTUAL, | ||
339 | 185 | INVALID | ||
340 | 186 | } | ||
341 | 187 | |||
342 | 188 | public static Gtk.Button get_advanced_button_from_device (NM.Device? device, string title = _("Advanced Settings…")) { | ||
343 | 189 | var details_btn = new Gtk.Button.with_label (title); | ||
344 | 190 | details_btn.clicked.connect (() => { | ||
345 | 191 | new Granite.Services.SimpleCommand ("/usr/bin", | ||
346 | 192 | "nm-connection-editor --edit=" + device.get_active_connection ().get_uuid ()).run (); | ||
347 | 193 | }); | ||
348 | 194 | |||
349 | 195 | return details_btn; | ||
350 | 196 | } | ||
351 | 197 | |||
352 | 198 | public static string state_to_string (NM.DeviceState state) { | ||
353 | 199 | switch (state) { | ||
354 | 200 | case NM.DeviceState.ACTIVATED: | ||
355 | 201 | return _("Connected"); | ||
356 | 202 | case NM.DeviceState.DISCONNECTED: | ||
357 | 203 | return _("Disconnected"); | ||
358 | 204 | case NM.DeviceState.UNMANAGED: | ||
359 | 205 | return _("Unmanaged"); | ||
360 | 206 | case NM.DeviceState.PREPARE: | ||
361 | 207 | return _("In preparation"); | ||
362 | 208 | case NM.DeviceState.CONFIG: | ||
363 | 209 | return _("Connecting..."); | ||
364 | 210 | case NM.DeviceState.NEED_AUTH: | ||
365 | 211 | return _("Requires more information"); | ||
366 | 212 | case NM.DeviceState.IP_CONFIG: | ||
367 | 213 | return _("Requesting adresses..."); | ||
368 | 214 | case NM.DeviceState.IP_CHECK: | ||
369 | 215 | return _("Checking connection..."); | ||
370 | 216 | case NM.DeviceState.SECONDARIES: | ||
371 | 217 | return _("Waiting for connection..."); | ||
372 | 218 | case NM.DeviceState.DEACTIVATING: | ||
373 | 219 | return _("Disconnecting..."); | ||
374 | 220 | case NM.DeviceState.FAILED: | ||
375 | 221 | return _("Failed to connect"); | ||
376 | 222 | case NM.DeviceState.UNKNOWN: | ||
377 | 223 | default: | ||
378 | 224 | return _("Unknown"); | ||
379 | 225 | } | ||
380 | 226 | } | ||
381 | 227 | |||
382 | 228 | public static string type_to_string (NM.DeviceType type) { | ||
383 | 229 | switch (type) { | ||
384 | 230 | case NM.DeviceType.ETHERNET: | ||
385 | 231 | return _("Ethernet"); | ||
386 | 232 | case NM.DeviceType.WIFI: | ||
387 | 233 | return _("Wi-Fi"); | ||
388 | 234 | case NM.DeviceType.UNUSED1: | ||
389 | 235 | return _("Not used"); | ||
390 | 236 | case NM.DeviceType.UNUSED2: | ||
391 | 237 | return _("Not used"); | ||
392 | 238 | case NM.DeviceType.BT: | ||
393 | 239 | return _("Bluetooth"); | ||
394 | 240 | case NM.DeviceType.OLPC_MESH: | ||
395 | 241 | return _("OLPC XO"); | ||
396 | 242 | case NM.DeviceType.WIMAX: | ||
397 | 243 | return _("WiMAX Broadband"); | ||
398 | 244 | case NM.DeviceType.MODEM: | ||
399 | 245 | return _("Modem"); | ||
400 | 246 | case NM.DeviceType.INFINIBAND: | ||
401 | 247 | return _("InfiniBand device"); | ||
402 | 248 | case NM.DeviceType.BOND: | ||
403 | 249 | return _("Bond master"); | ||
404 | 250 | case NM.DeviceType.VLAN: | ||
405 | 251 | return _("VLAN Interface"); | ||
406 | 252 | case NM.DeviceType.ADSL: | ||
407 | 253 | return _("ADSL Modem"); | ||
408 | 254 | case NM.DeviceType.BRIDGE: | ||
409 | 255 | return _("Bridge master"); | ||
410 | 256 | case NM.DeviceType.UNKNOWN: | ||
411 | 257 | default: | ||
412 | 258 | return _("Unknown"); | ||
413 | 259 | } | ||
414 | 79 | } | 260 | } |
415 | 80 | } | 261 | } |
416 | 81 | } | 262 | } |
417 | 82 | 263 | ||
418 | === modified file 'src/Widgets/Device/DeviceItem.vala' | |||
419 | --- src/Widgets/Device/DeviceItem.vala 2015-10-20 20:34:36 +0000 | |||
420 | +++ src/Widgets/Device/DeviceItem.vala 2015-11-07 23:35:34 +0000 | |||
421 | @@ -1,6 +1,6 @@ | |||
422 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
423 | 2 | /*- | 2 | /*- |
425 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
426 | 4 | * | 4 | * |
427 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
428 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
429 | @@ -17,12 +17,13 @@ | |||
430 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
431 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
432 | 19 | * | 19 | * |
434 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
435 | 21 | */ | 21 | */ |
436 | 22 | 22 | ||
437 | 23 | namespace Network.Widgets { | 23 | namespace Network.Widgets { |
438 | 24 | public class DeviceItem : Gtk.ListBoxRow { | 24 | public class DeviceItem : Gtk.ListBoxRow { |
439 | 25 | public NM.Device? device = null; | 25 | public NM.Device? device = null; |
440 | 26 | private NM.RemoteSettings? nm_settings = null; | ||
441 | 26 | public Gtk.Box? page = null; | 27 | public Gtk.Box? page = null; |
442 | 27 | public Utils.ItemType type; | 28 | public Utils.ItemType type; |
443 | 28 | 29 | ||
444 | @@ -30,7 +31,7 @@ | |||
445 | 30 | private Gtk.Image row_image; | 31 | private Gtk.Image row_image; |
446 | 31 | private Gtk.Image status_image; | 32 | private Gtk.Image status_image; |
447 | 32 | 33 | ||
449 | 33 | private string title; | 34 | public string title; |
450 | 34 | private string subtitle; | 35 | private string subtitle; |
451 | 35 | private string icon_name; | 36 | private string icon_name; |
452 | 36 | 37 | ||
453 | @@ -63,10 +64,15 @@ | |||
454 | 63 | this.icon_name = _icon_name; | 64 | this.icon_name = _icon_name; |
455 | 64 | 65 | ||
456 | 65 | create_ui (icon_name); | 66 | create_ui (icon_name); |
461 | 66 | switch_status (device.get_state ()); | 67 | switch_status (Utils.CustomMode.INVALID, device.get_state ()); |
462 | 67 | 68 | ||
463 | 68 | device.state_changed.connect ( () => { | 69 | nm_settings = new NM.RemoteSettings (null); |
464 | 69 | switch_status (device.get_state ()); | 70 | nm_settings.connections_read.connect (() => { |
465 | 71 | switch_status (Utils.CustomMode.INVALID, device.get_state ()); | ||
466 | 72 | }); | ||
467 | 73 | |||
468 | 74 | device.state_changed.connect (() => { | ||
469 | 75 | switch_status (Utils.CustomMode.INVALID, device.get_state ()); | ||
470 | 70 | }); | 76 | }); |
471 | 71 | } | 77 | } |
472 | 72 | 78 | ||
473 | @@ -120,8 +126,15 @@ | |||
474 | 120 | return icon_name; | 126 | return icon_name; |
475 | 121 | } | 127 | } |
476 | 122 | 128 | ||
478 | 123 | public void switch_status (NM.DeviceState? state = null, string proxy_mode = "") { | 129 | public void switch_status (Utils.CustomMode custom_mode, NM.DeviceState? state = null) { |
479 | 124 | if (state != null) { | 130 | if (state != null) { |
480 | 131 | if (device != null | ||
481 | 132 | && nm_settings != null | ||
482 | 133 | && device is NM.DeviceWifi | ||
483 | 134 | && Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings)) { | ||
484 | 135 | state = NM.DeviceState.DISCONNECTED; | ||
485 | 136 | } | ||
486 | 137 | |||
487 | 125 | switch (state) { | 138 | switch (state) { |
488 | 126 | case NM.DeviceState.ACTIVATED: | 139 | case NM.DeviceState.ACTIVATED: |
489 | 127 | status_image.icon_name = "user-available"; | 140 | status_image.icon_name = "user-available"; |
490 | @@ -148,20 +161,25 @@ | |||
491 | 148 | row_description.label = Utils.state_to_string (state); | 161 | row_description.label = Utils.state_to_string (state); |
492 | 149 | } | 162 | } |
493 | 150 | 163 | ||
497 | 151 | if (proxy_mode != "") { | 164 | if (custom_mode != Utils.CustomMode.INVALID) { |
498 | 152 | switch (proxy_mode) { | 165 | switch (custom_mode) { |
499 | 153 | case "none": | 166 | case Utils.CustomMode.PROXY_NONE: |
500 | 167 | case Utils.CustomMode.HOTSPOT_DISABLED: | ||
501 | 154 | row_description.label = _("Disabled"); | 168 | row_description.label = _("Disabled"); |
502 | 155 | status_image.icon_name = "user-offline"; | 169 | status_image.icon_name = "user-offline"; |
503 | 156 | break; | 170 | break; |
505 | 157 | case "manual": | 171 | case Utils.CustomMode.PROXY_MANUAL: |
506 | 158 | row_description.label = _("Enabled (manual mode)"); | 172 | row_description.label = _("Enabled (manual mode)"); |
507 | 159 | status_image.icon_name = "user-available"; | 173 | status_image.icon_name = "user-available"; |
508 | 160 | break; | 174 | break; |
510 | 161 | case "auto": | 175 | case Utils.CustomMode.PROXY_AUTO: |
511 | 162 | row_description.label = _("Enabled (auto mode)"); | 176 | row_description.label = _("Enabled (auto mode)"); |
512 | 163 | status_image.icon_name = "user-available"; | 177 | status_image.icon_name = "user-available"; |
513 | 164 | break; | 178 | break; |
514 | 179 | case Utils.CustomMode.HOTSPOT_ENABLED: | ||
515 | 180 | row_description.label = _("Enabled"); | ||
516 | 181 | status_image.icon_name = "user-available"; | ||
517 | 182 | break; | ||
518 | 165 | } | 183 | } |
519 | 166 | } | 184 | } |
520 | 167 | 185 | ||
521 | 168 | 186 | ||
522 | === modified file 'src/Widgets/Device/DevicePage.vala' | |||
523 | --- src/Widgets/Device/DevicePage.vala 2015-10-08 19:04:34 +0000 | |||
524 | +++ src/Widgets/Device/DevicePage.vala 2015-11-07 23:35:34 +0000 | |||
525 | @@ -1,6 +1,6 @@ | |||
526 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
527 | 2 | /*- | 2 | /*- |
529 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
530 | 4 | * | 4 | * |
531 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
532 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
533 | @@ -17,14 +17,14 @@ | |||
534 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
535 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
536 | 19 | * | 19 | * |
538 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
539 | 21 | */ | 21 | */ |
540 | 22 | 22 | ||
541 | 23 | namespace Network.Widgets { | 23 | namespace Network.Widgets { |
542 | 24 | public class DevicePage : Network.WidgetNMInterface { | 24 | public class DevicePage : Network.WidgetNMInterface { |
543 | 25 | 25 | ||
544 | 26 | public DevicePage (NM.Client client, NM.RemoteSettings settings, NM.Device device) { | 26 | public DevicePage (NM.Client client, NM.RemoteSettings settings, NM.Device device) { |
546 | 27 | info_box = new info_box.from_device (device); | 27 | info_box = new InfoBox.from_device (device); |
547 | 28 | this.init (device, info_box); | 28 | this.init (device, info_box); |
548 | 29 | 29 | ||
549 | 30 | bottom_revealer.transition_type = Gtk.RevealerTransitionType.NONE; | 30 | bottom_revealer.transition_type = Gtk.RevealerTransitionType.NONE; |
550 | @@ -45,7 +45,7 @@ | |||
551 | 45 | } | 45 | } |
552 | 46 | 46 | ||
553 | 47 | public DevicePage.from_owner (DeviceItem? owner) { | 47 | public DevicePage.from_owner (DeviceItem? owner) { |
555 | 48 | info_box = new info_box.from_owner (owner); | 48 | info_box = new InfoBox.from_owner (owner); |
556 | 49 | this.init (owner.get_item_device (), info_box); | 49 | this.init (owner.get_item_device (), info_box); |
557 | 50 | 50 | ||
558 | 51 | this.icon_name = owner.get_item_icon_name (); | 51 | this.icon_name = owner.get_item_icon_name (); |
559 | 52 | 52 | ||
560 | === modified file 'src/Widgets/DeviceList.vala' | |||
561 | --- src/Widgets/DeviceList.vala 2015-10-22 17:08:56 +0000 | |||
562 | +++ src/Widgets/DeviceList.vala 2015-11-07 23:35:34 +0000 | |||
563 | @@ -1,6 +1,6 @@ | |||
564 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
565 | 2 | /*- | 2 | /*- |
567 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
568 | 4 | * | 4 | * |
569 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
570 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
571 | @@ -17,59 +17,54 @@ | |||
572 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
573 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
574 | 19 | * | 19 | * |
576 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
577 | 21 | */ | 21 | */ |
578 | 22 | 22 | ||
579 | 23 | namespace Network.Widgets { | 23 | namespace Network.Widgets { |
580 | 24 | public class DeviceList : Gtk.ListBox { | 24 | public class DeviceList : Gtk.ListBox { |
581 | 25 | public signal void show_no_devices (bool show); | 25 | public signal void show_no_devices (bool show); |
589 | 26 | 26 | ||
590 | 27 | public NM.Client client; | 27 | private Gtk.Label virtual_l; |
584 | 28 | |||
585 | 29 | private List<DeviceItem> items; | ||
586 | 30 | private DeviceItem item; | ||
587 | 31 | |||
588 | 32 | private Gtk.Label settings_l; | ||
591 | 33 | private Gtk.Label devices_l; | 28 | private Gtk.Label devices_l; |
592 | 34 | private DeviceItem proxy; | 29 | private DeviceItem proxy; |
593 | 35 | 30 | ||
594 | 36 | private int wireless_item = 0; | 31 | private int wireless_item = 0; |
595 | 37 | 32 | ||
596 | 38 | public DeviceList () { | 33 | public DeviceList () { |
597 | 34 | virtual_l = new Gtk.Label (_("Virtual")); | ||
598 | 35 | virtual_l.get_style_context ().add_class ("h4"); | ||
599 | 36 | virtual_l.halign = Gtk.Align.START; | ||
600 | 37 | |||
601 | 38 | devices_l = new Gtk.Label (_("Devices")); | ||
602 | 39 | devices_l.get_style_context ().add_class ("h4"); | ||
603 | 40 | devices_l.halign = Gtk.Align.START; | ||
604 | 41 | |||
605 | 39 | this.selection_mode = Gtk.SelectionMode.SINGLE; | 42 | this.selection_mode = Gtk.SelectionMode.SINGLE; |
606 | 40 | this.activate_on_single_click = true; | 43 | this.activate_on_single_click = true; |
607 | 41 | this.set_header_func (update_headers); | 44 | this.set_header_func (update_headers); |
620 | 42 | 45 | this.set_sort_func (sort_items); | |
621 | 43 | items = new List<DeviceItem> (); | 46 | |
622 | 44 | 47 | bool show = (get_children ().length () > 0); | |
611 | 45 | settings_l = new Gtk.Label (_("Virtual")); | ||
612 | 46 | settings_l.get_style_context ().add_class ("h4"); | ||
613 | 47 | settings_l.halign = Gtk.Align.START; | ||
614 | 48 | |||
615 | 49 | devices_l = new Gtk.Label (_("Devices")); | ||
616 | 50 | devices_l.get_style_context ().add_class ("h4"); | ||
617 | 51 | devices_l.halign = Gtk.Align.START; | ||
618 | 52 | |||
619 | 53 | bool show = (items.length () > 0); | ||
623 | 54 | this.show_no_devices (!show); | 48 | this.show_no_devices (!show); |
624 | 55 | this.add_proxy (); | 49 | this.add_proxy (); |
625 | 56 | } | 50 | } |
626 | 57 | 51 | ||
627 | 58 | public void add_device_to_list (WidgetNMInterface iface) { | 52 | public void add_device_to_list (WidgetNMInterface iface) { |
628 | 53 | DeviceItem item; | ||
629 | 54 | if (!iface.device.get_managed ()) { | ||
630 | 55 | warning ("Unmanaged device, probably something that has just been added."); | ||
631 | 56 | } | ||
632 | 57 | |||
633 | 59 | if (iface.device.get_device_type () == NM.DeviceType.WIFI) { | 58 | if (iface.device.get_device_type () == NM.DeviceType.WIFI) { |
634 | 60 | string title = _("Wireless"); | 59 | string title = _("Wireless"); |
635 | 61 | if (wireless_item > 0) { | 60 | if (wireless_item > 0) { |
637 | 62 | title += SUFFIX + wireless_item.to_string (); | 61 | title = _("Wireless %s".printf (wireless_item.to_string ())); |
638 | 63 | } | 62 | } |
639 | 64 | 63 | ||
640 | 65 | item = new DeviceItem.from_interface (iface, "network-wireless", title); | 64 | item = new DeviceItem.from_interface (iface, "network-wireless", title); |
641 | 65 | add_hotspot (iface, wireless_item); | ||
642 | 66 | wireless_item++; | 66 | wireless_item++; |
643 | 67 | } else { | 67 | } else { |
644 | 68 | |||
645 | 69 | if (!iface.device.get_managed ()) { | ||
646 | 70 | warning ("Unmanaged device, probably something that has just been added."); | ||
647 | 71 | } | ||
648 | 72 | |||
649 | 73 | if (iface.device.get_iface ().has_prefix ("usb")) { | 68 | if (iface.device.get_iface ().has_prefix ("usb")) { |
650 | 74 | item = new DeviceItem.from_interface (iface, "drive-removable-media"); | 69 | item = new DeviceItem.from_interface (iface, "drive-removable-media"); |
651 | 75 | } else { | 70 | } else { |
652 | @@ -77,16 +72,15 @@ | |||
653 | 77 | } | 72 | } |
654 | 78 | } | 73 | } |
655 | 79 | 74 | ||
658 | 80 | items.append (item); | 75 | add (item); |
657 | 81 | insert (item, (int) items.length () - 1); | ||
659 | 82 | show_all (); | 76 | show_all (); |
660 | 83 | } | 77 | } |
661 | 84 | 78 | ||
662 | 85 | public void remove_device_from_list (NM.Device device) { | 79 | public void remove_device_from_list (NM.Device device) { |
664 | 86 | foreach (var list_item in items) { | 80 | foreach (Gtk.Widget _list_item in get_children ()) { |
665 | 81 | var list_item = (DeviceItem)_list_item; | ||
666 | 87 | if (list_item.device == device) { | 82 | if (list_item.device == device) { |
667 | 88 | remove_row_from_list (list_item); | 83 | remove_row_from_list (list_item); |
668 | 89 | break; | ||
669 | 90 | } | 84 | } |
670 | 91 | } | 85 | } |
671 | 92 | } | 86 | } |
672 | @@ -96,14 +90,39 @@ | |||
673 | 96 | wireless_item--; | 90 | wireless_item--; |
674 | 97 | } | 91 | } |
675 | 98 | 92 | ||
676 | 99 | items.remove (item); | ||
677 | 100 | this.remove (item); | 93 | this.remove (item); |
678 | 94 | show_all (); | ||
679 | 95 | } | ||
680 | 96 | |||
681 | 97 | private void add_hotspot (WidgetNMInterface iface, int wireless_item) { | ||
682 | 98 | string title = _("Hotspot"); | ||
683 | 99 | if (wireless_item > 0) { | ||
684 | 100 | title = _("Hotspot %s".printf (wireless_item.to_string ())); | ||
685 | 101 | } | ||
686 | 102 | |||
687 | 103 | var hotspot = new DeviceItem (title, "", "network-wireless-hotspot"); | ||
688 | 104 | hotspot.no_show_all = true; | ||
689 | 105 | iface.device.state_changed.connect ((state) => { | ||
690 | 106 | hotspot.visible = (state != NM.DeviceState.UNAVAILABLE | ||
691 | 107 | && state != NM.DeviceState.UNMANAGED | ||
692 | 108 | && state != NM.DeviceState.UNKNOWN); | ||
693 | 109 | }); | ||
694 | 110 | |||
695 | 111 | hotspot.device = iface.device; | ||
696 | 112 | hotspot.type = Utils.ItemType.VIRTUAL; | ||
697 | 113 | |||
698 | 114 | var hotspot_page = new HotspotPage (hotspot, ((WifiInterface)iface)); | ||
699 | 115 | hotspot_page.title = title; | ||
700 | 116 | hotspot.page = hotspot_page; | ||
701 | 117 | |||
702 | 118 | this.add (hotspot); | ||
703 | 101 | } | 119 | } |
704 | 102 | 120 | ||
705 | 103 | private void add_proxy () { | 121 | private void add_proxy () { |
706 | 104 | proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network"); | 122 | proxy = new DeviceItem (_("Proxy"), "", "preferences-system-network"); |
709 | 105 | proxy.page = new Widgets.ProxyPage (proxy); | 123 | proxy.page = new ProxyPage (proxy); |
710 | 106 | proxy.type = Utils.ItemType.PROXY; | 124 | proxy.type = Utils.ItemType.VIRTUAL; |
711 | 125 | |||
712 | 107 | this.add (proxy); | 126 | this.add (proxy); |
713 | 108 | } | 127 | } |
714 | 109 | 128 | ||
715 | @@ -111,14 +130,43 @@ | |||
716 | 111 | this.get_row_at_index (0).activate (); | 130 | this.get_row_at_index (0).activate (); |
717 | 112 | } | 131 | } |
718 | 113 | 132 | ||
719 | 133 | private int sort_items (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) { | ||
720 | 134 | if (((DeviceItem) row1).type == Utils.ItemType.DEVICE) { | ||
721 | 135 | return -1; | ||
722 | 136 | } else if (((DeviceItem) row1).type == Utils.ItemType.VIRTUAL) { | ||
723 | 137 | return 1; | ||
724 | 138 | } else { | ||
725 | 139 | return 0; | ||
726 | 140 | } | ||
727 | 141 | } | ||
728 | 142 | |||
729 | 114 | private void update_headers (Gtk.ListBoxRow row, Gtk.ListBoxRow? before = null) { | 143 | private void update_headers (Gtk.ListBoxRow row, Gtk.ListBoxRow? before = null) { |
733 | 115 | if (((DeviceItem) row).type != Utils.ItemType.DEVICE) { | 144 | if (((DeviceItem) row).type == Utils.ItemType.VIRTUAL) { |
734 | 116 | row.set_header (settings_l); | 145 | if (before != null && ((DeviceItem) before).type == Utils.ItemType.VIRTUAL) { |
735 | 117 | } else if (row == items.nth_data (0)) { | 146 | return; |
736 | 147 | } | ||
737 | 148 | |||
738 | 149 | remove_headers_for_type (Utils.ItemType.VIRTUAL); | ||
739 | 150 | row.set_header (virtual_l); | ||
740 | 151 | } else if (((DeviceItem) row).type == Utils.ItemType.DEVICE) { | ||
741 | 152 | if (before != null && ((DeviceItem) before).type == Utils.ItemType.DEVICE) { | ||
742 | 153 | return; | ||
743 | 154 | } | ||
744 | 155 | |||
745 | 156 | remove_headers_for_type (Utils.ItemType.DEVICE); | ||
746 | 118 | row.set_header (devices_l); | 157 | row.set_header (devices_l); |
747 | 119 | } else { | 158 | } else { |
748 | 120 | row.set_header (null); | 159 | row.set_header (null); |
749 | 121 | } | 160 | } |
750 | 122 | } | 161 | } |
751 | 162 | |||
752 | 163 | private void remove_headers_for_type (Utils.ItemType type) { | ||
753 | 164 | foreach (Gtk.Widget _item in get_children ()) { | ||
754 | 165 | var item = (DeviceItem)_item; | ||
755 | 166 | if (item.type == type) { | ||
756 | 167 | item.set_header (null); | ||
757 | 168 | } | ||
758 | 169 | } | ||
759 | 170 | } | ||
760 | 123 | } | 171 | } |
761 | 124 | } | 172 | } |
762 | 125 | 173 | ||
763 | === modified file 'src/Widgets/Footer.vala' | |||
764 | --- src/Widgets/Footer.vala 2015-10-08 17:08:13 +0000 | |||
765 | +++ src/Widgets/Footer.vala 2015-11-07 23:35:34 +0000 | |||
766 | @@ -1,6 +1,6 @@ | |||
767 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
768 | 2 | /*- | 2 | /*- |
770 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
771 | 4 | * | 4 | * |
772 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
773 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
774 | @@ -17,7 +17,7 @@ | |||
775 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
776 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
777 | 19 | * | 19 | * |
779 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
780 | 21 | */ | 21 | */ |
781 | 22 | 22 | ||
782 | 23 | namespace Network { | 23 | namespace Network { |
783 | 24 | 24 | ||
784 | === added directory 'src/Widgets/Hotspot' | |||
785 | === added file 'src/Widgets/Hotspot/HotspotDialog.vala' | |||
786 | --- src/Widgets/Hotspot/HotspotDialog.vala 1970-01-01 00:00:00 +0000 | |||
787 | +++ src/Widgets/Hotspot/HotspotDialog.vala 2015-11-07 23:35:34 +0000 | |||
788 | @@ -0,0 +1,230 @@ | |||
789 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
790 | 2 | /*- | ||
791 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) | ||
792 | 4 | * | ||
793 | 5 | * This library is free software; you can redistribute it and/or | ||
794 | 6 | * modify it under the terms of the GNU Library General Public | ||
795 | 7 | * License as published by the Free Software Foundation; either | ||
796 | 8 | * version 3 of the License, or (at your option) any later version. | ||
797 | 9 | * | ||
798 | 10 | * This library is distributed in the hope that it will be useful, | ||
799 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
800 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
801 | 13 | * Library General Public License for more details. | ||
802 | 14 | * | ||
803 | 15 | * You should have received a copy of the GNU Library General Public | ||
804 | 16 | * License along with this library; if not, write to the | ||
805 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
806 | 18 | * Boston, MA 02111-1307, USA. | ||
807 | 19 | * | ||
808 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> | ||
809 | 21 | */ | ||
810 | 22 | |||
811 | 23 | namespace Network.Widgets { | ||
812 | 24 | public class HotspotDialog : Gtk.Dialog { | ||
813 | 25 | private const string NEW_ID = "0"; | ||
814 | 26 | private Gtk.Entry ssid_entry; | ||
815 | 27 | private Gtk.Entry key_entry; | ||
816 | 28 | |||
817 | 29 | private Gtk.Label ssid_label; | ||
818 | 30 | private Gtk.Label key_label; | ||
819 | 31 | |||
820 | 32 | private Gtk.ComboBoxText conn_combo; | ||
821 | 33 | |||
822 | 34 | private Gtk.CheckButton check_btn; | ||
823 | 35 | private Gtk.Label dumb; | ||
824 | 36 | |||
825 | 37 | private Gtk.Button create_btn; | ||
826 | 38 | |||
827 | 39 | private HashTable<string, NM.Connection> conn_hash; | ||
828 | 40 | private unowned List<NM.Connection> available; | ||
829 | 41 | |||
830 | 42 | public HotspotDialog (NM.AccessPoint? active, List<NM.Connection> _available) { | ||
831 | 43 | this.available = _available; | ||
832 | 44 | this.deletable = false; | ||
833 | 45 | this.resizable = false; | ||
834 | 46 | this.border_width = 6; | ||
835 | 47 | |||
836 | 48 | conn_hash = new HashTable<string, NM.Connection> (str_hash, str_equal); | ||
837 | 49 | |||
838 | 50 | var content_area = this.get_content_area (); | ||
839 | 51 | content_area.halign = content_area.valign = Gtk.Align.CENTER; | ||
840 | 52 | |||
841 | 53 | var main_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0); | ||
842 | 54 | var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); | ||
843 | 55 | |||
844 | 56 | vbox.margin_left = vbox.margin_right = 6; | ||
845 | 57 | |||
846 | 58 | string? ssid_str = null; | ||
847 | 59 | if (active != null) { | ||
848 | 60 | ssid_str = NM.Utils.ssid_to_utf8 (active.get_ssid ()); | ||
849 | 61 | } else { | ||
850 | 62 | ssid_str = _("current"); | ||
851 | 63 | } | ||
852 | 64 | |||
853 | 65 | var title = new Gtk.Label ("<span weight='bold' size='larger'>" + _("Wireless Hotspot") + "</span>"); | ||
854 | 66 | title.use_markup = true; | ||
855 | 67 | title.halign = Gtk.Align.START; | ||
856 | 68 | |||
857 | 69 | var image = new Gtk.Image.from_icon_name ("network-wireless-hotspot", Gtk.IconSize.DIALOG); | ||
858 | 70 | image.valign = Gtk.Align.START; | ||
859 | 71 | main_box.add (image); | ||
860 | 72 | |||
861 | 73 | var info_label = new Gtk.Label (_("Enabling Wireless Hotspot will disconnect from %s network.").printf (ssid_str) + "\n" + | ||
862 | 74 | _("You will not be able to connect to a wireless network while Hotspot is active.")); | ||
863 | 75 | info_label.halign = Gtk.Align.START; | ||
864 | 76 | info_label.margin_top = 6; | ||
865 | 77 | info_label.use_markup = true; | ||
866 | 78 | |||
867 | 79 | var grid = new Gtk.Grid (); | ||
868 | 80 | grid.hexpand = true; | ||
869 | 81 | grid.row_spacing = 6; | ||
870 | 82 | grid.column_spacing = 12; | ||
871 | 83 | grid.vexpand_set = true; | ||
872 | 84 | |||
873 | 85 | ssid_entry = new Gtk.Entry (); | ||
874 | 86 | ssid_entry.hexpand = true; | ||
875 | 87 | ssid_entry.text = get_ssid_for_hotspot (); | ||
876 | 88 | |||
877 | 89 | key_entry = new Gtk.Entry (); | ||
878 | 90 | key_entry.hexpand = true; | ||
879 | 91 | key_entry.visibility = false; | ||
880 | 92 | key_entry.secondary_icon_tooltip_text = _("Password needs to be at least 8 characters long."); | ||
881 | 93 | |||
882 | 94 | check_btn = new Gtk.CheckButton.with_label (_("Show Password")); | ||
883 | 95 | check_btn.toggled.connect (() => { | ||
884 | 96 | key_entry.visibility = check_btn.active; | ||
885 | 97 | }); | ||
886 | 98 | |||
887 | 99 | ssid_entry.changed.connect (update); | ||
888 | 100 | key_entry.changed.connect (update); | ||
889 | 101 | |||
890 | 102 | ssid_label = new Gtk.Label (_("Network Name:")); | ||
891 | 103 | ssid_label.halign = Gtk.Align.END; | ||
892 | 104 | |||
893 | 105 | key_label = new Gtk.Label (_("Password:")); | ||
894 | 106 | key_label.halign = Gtk.Align.END; | ||
895 | 107 | |||
896 | 108 | conn_combo = new Gtk.ComboBoxText (); | ||
897 | 109 | conn_combo.append (NEW_ID, _("New…")); | ||
898 | 110 | int i = 1; | ||
899 | 111 | foreach (var connection in available) { | ||
900 | 112 | var setting_wireless = connection.get_setting_wireless (); | ||
901 | 113 | conn_combo.append (i.to_string (), NM.Utils.ssid_to_utf8 (setting_wireless.get_ssid ())); | ||
902 | 114 | conn_hash.insert (i.to_string (), connection); | ||
903 | 115 | i++; | ||
904 | 116 | } | ||
905 | 117 | |||
906 | 118 | conn_combo.active_id = NEW_ID; | ||
907 | 119 | conn_combo.changed.connect (update); | ||
908 | 120 | |||
909 | 121 | var conn_label = new Gtk.Label (_("Connection:")); | ||
910 | 122 | conn_label.halign = Gtk.Align.END; | ||
911 | 123 | |||
912 | 124 | grid.attach (conn_label, 0, 0, 1, 1); | ||
913 | 125 | grid.attach_next_to (conn_combo, conn_label, Gtk.PositionType.RIGHT, 1, 1); | ||
914 | 126 | |||
915 | 127 | dumb = new Gtk.Label (""); | ||
916 | 128 | |||
917 | 129 | grid.attach_next_to (ssid_label, conn_label, Gtk.PositionType.BOTTOM, 1, 1); | ||
918 | 130 | grid.attach_next_to (ssid_entry, ssid_label, Gtk.PositionType.RIGHT, 1, 1); | ||
919 | 131 | grid.attach_next_to (key_label, ssid_label, Gtk.PositionType.BOTTOM, 1, 1); | ||
920 | 132 | grid.attach_next_to (key_entry, key_label, Gtk.PositionType.RIGHT, 1, 1); | ||
921 | 133 | grid.attach_next_to (dumb, key_label, Gtk.PositionType.BOTTOM, 1, 1); | ||
922 | 134 | grid.attach_next_to (check_btn, dumb, Gtk.PositionType.RIGHT, 1, 1); | ||
923 | 135 | |||
924 | 136 | var cancel_btn = new Gtk.Button.with_label (_("Cancel")); | ||
925 | 137 | create_btn = new Gtk.Button.with_label (_("Enable Hotspot")); | ||
926 | 138 | if (active != null) { | ||
927 | 139 | create_btn.label = _("Switch to Hotspot"); | ||
928 | 140 | } | ||
929 | 141 | |||
930 | 142 | create_btn.get_style_context ().add_class ("suggested-action"); | ||
931 | 143 | |||
932 | 144 | this.add_action_widget (cancel_btn, 0); | ||
933 | 145 | this.add_action_widget (create_btn, 1); | ||
934 | 146 | |||
935 | 147 | vbox.add (title); | ||
936 | 148 | vbox.add (info_label); | ||
937 | 149 | vbox.add (grid); | ||
938 | 150 | |||
939 | 151 | update (); | ||
940 | 152 | |||
941 | 153 | main_box.add (vbox); | ||
942 | 154 | content_area.add (main_box); | ||
943 | 155 | this.show_all (); | ||
944 | 156 | } | ||
945 | 157 | |||
946 | 158 | public ByteArray get_ssid () { | ||
947 | 159 | var byte_array = new ByteArray (); | ||
948 | 160 | byte_array.append (ssid_entry.get_text ().data); | ||
949 | 161 | return byte_array; | ||
950 | 162 | } | ||
951 | 163 | |||
952 | 164 | public string get_key () { | ||
953 | 165 | return key_entry.get_text (); | ||
954 | 166 | } | ||
955 | 167 | |||
956 | 168 | public NM.Connection? get_selected_connection () { | ||
957 | 169 | return conn_hash[conn_combo.get_active_id ()]; | ||
958 | 170 | } | ||
959 | 171 | |||
960 | 172 | private string get_ssid_for_hotspot () { | ||
961 | 173 | string hostname = ""; | ||
962 | 174 | try { | ||
963 | 175 | Process.spawn_command_line_sync ("hostname", out hostname, null, null); | ||
964 | 176 | } catch (SpawnError e) { | ||
965 | 177 | warning ("%s\n", e.message); | ||
966 | 178 | } | ||
967 | 179 | |||
968 | 180 | return hostname.strip ().replace ("\n", ""); | ||
969 | 181 | } | ||
970 | 182 | |||
971 | 183 | private void update () { | ||
972 | 184 | bool sensitive = (conn_combo.get_active_id () == NEW_ID); | ||
973 | 185 | ssid_label.sensitive = sensitive; | ||
974 | 186 | key_label.sensitive = sensitive; | ||
975 | 187 | |||
976 | 188 | ssid_entry.sensitive = sensitive; | ||
977 | 189 | key_entry.sensitive = sensitive; | ||
978 | 190 | |||
979 | 191 | check_btn.sensitive = sensitive; | ||
980 | 192 | dumb.sensitive = sensitive; | ||
981 | 193 | |||
982 | 194 | string? secret = null; | ||
983 | 195 | if (get_selected_connection () != null) { | ||
984 | 196 | var setting_wireless_security = get_selected_connection ().get_setting_wireless_security (); | ||
985 | 197 | |||
986 | 198 | string key_mgmt = setting_wireless_security.get_key_mgmt (); | ||
987 | 199 | if (key_mgmt == "none") { | ||
988 | 200 | secret = setting_wireless_security.get_wep_key (0); | ||
989 | 201 | } else if (key_mgmt == "wpa-psk" || | ||
990 | 202 | key_mgmt == "wpa-none") { | ||
991 | 203 | secret = setting_wireless_security.get_psk (); | ||
992 | 204 | } | ||
993 | 205 | |||
994 | 206 | if (secret == null) { | ||
995 | 207 | var connection = get_selected_connection (); | ||
996 | 208 | Utils.Hotspot.update_secrets (((NM.RemoteConnection) connection), update); | ||
997 | 209 | } | ||
998 | 210 | } | ||
999 | 211 | |||
1000 | 212 | if (conn_combo.get_active_id () != NEW_ID) { | ||
1001 | 213 | ssid_entry.text = NM.Utils.ssid_to_utf8 (get_selected_connection ().get_setting_wireless ().get_ssid ()); | ||
1002 | 214 | if (secret == null) { | ||
1003 | 215 | secret = ""; | ||
1004 | 216 | } | ||
1005 | 217 | |||
1006 | 218 | key_entry.text = secret; | ||
1007 | 219 | } | ||
1008 | 220 | |||
1009 | 221 | create_btn.sensitive = ((ssid_entry.get_text () != "" && key_entry.get_text ().to_utf8 ().length >= 8) || !sensitive); | ||
1010 | 222 | |||
1011 | 223 | if (key_entry.get_text ().to_utf8 ().length < 8 && key_entry.get_text () != "") { | ||
1012 | 224 | key_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, "process-error-symbolic"); | ||
1013 | 225 | } else { | ||
1014 | 226 | key_entry.set_icon_from_icon_name (Gtk.EntryIconPosition.SECONDARY, ""); | ||
1015 | 227 | } | ||
1016 | 228 | } | ||
1017 | 229 | } | ||
1018 | 230 | } | ||
1019 | 0 | \ No newline at end of file | 231 | \ No newline at end of file |
1020 | 1 | 232 | ||
1021 | === added file 'src/Widgets/Hotspot/HotspotPage.vala' | |||
1022 | --- src/Widgets/Hotspot/HotspotPage.vala 1970-01-01 00:00:00 +0000 | |||
1023 | +++ src/Widgets/Hotspot/HotspotPage.vala 2015-11-07 23:35:34 +0000 | |||
1024 | @@ -0,0 +1,174 @@ | |||
1025 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
1026 | 2 | /*- | ||
1027 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) | ||
1028 | 4 | * | ||
1029 | 5 | * This library is free software; you can redistribute it and/or | ||
1030 | 6 | * modify it under the terms of the GNU Library General Public | ||
1031 | 7 | * License as published by the Free Software Foundation; either | ||
1032 | 8 | * version 3 of the License, or (at your option) any later version. | ||
1033 | 9 | * | ||
1034 | 10 | * This library is distributed in the hope that it will be useful, | ||
1035 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1036 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1037 | 13 | * Library General Public License for more details. | ||
1038 | 14 | * | ||
1039 | 15 | * You should have received a copy of the GNU Library General Public | ||
1040 | 16 | * License along with this library; if not, write to the | ||
1041 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
1042 | 18 | * Boston, MA 02111-1307, USA. | ||
1043 | 19 | * | ||
1044 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> | ||
1045 | 21 | */ | ||
1046 | 22 | |||
1047 | 23 | namespace Network.Widgets { | ||
1048 | 24 | public class HotspotPage : Network.WidgetNMInterface { | ||
1049 | 25 | private DeviceItem owner; | ||
1050 | 26 | |||
1051 | 27 | private WifiInterface root_iface; | ||
1052 | 28 | private NM.RemoteSettings nm_settings; | ||
1053 | 29 | private Gtk.Revealer hotspot_revealer; | ||
1054 | 30 | private Gtk.Button hotspot_settings_btn; | ||
1055 | 31 | private Gtk.Label ssid_label; | ||
1056 | 32 | private Gtk.Label key_label; | ||
1057 | 33 | private bool switch_updating = false; | ||
1058 | 34 | |||
1059 | 35 | public HotspotPage (DeviceItem _owner, WifiInterface _root_iface) { | ||
1060 | 36 | owner = _owner; | ||
1061 | 37 | root_iface = _root_iface; | ||
1062 | 38 | nm_settings = root_iface.get_nm_settings (); | ||
1063 | 39 | info_box = new InfoBox.from_device (owner.get_item_device ()); | ||
1064 | 40 | this.init (owner.get_item_device (), info_box); | ||
1065 | 41 | |||
1066 | 42 | this.icon_name = owner.get_item_icon_name (); | ||
1067 | 43 | this.title = Utils.type_to_string (device.get_device_type ()); | ||
1068 | 44 | |||
1069 | 45 | hotspot_revealer = new Gtk.Revealer (); | ||
1070 | 46 | hotspot_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN; | ||
1071 | 47 | |||
1072 | 48 | hotspot_settings_btn = Utils.get_advanced_button_from_device (device, _("Hotspot Settings…")); | ||
1073 | 49 | |||
1074 | 50 | var hinfo_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); | ||
1075 | 51 | |||
1076 | 52 | ssid_label = new Gtk.Label (""); | ||
1077 | 53 | ssid_label.halign = Gtk.Align.START; | ||
1078 | 54 | |||
1079 | 55 | key_label = new Gtk.Label (""); | ||
1080 | 56 | key_label.halign = Gtk.Align.START; | ||
1081 | 57 | |||
1082 | 58 | hinfo_box.add (ssid_label); | ||
1083 | 59 | hinfo_box.add (key_label); | ||
1084 | 60 | hotspot_revealer.add (hinfo_box); | ||
1085 | 61 | |||
1086 | 62 | bottom_revealer = new Gtk.Revealer (); | ||
1087 | 63 | |||
1088 | 64 | var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); | ||
1089 | 65 | button_box.pack_end (hotspot_settings_btn, false, false, 0); | ||
1090 | 66 | bottom_revealer.add (button_box); | ||
1091 | 67 | |||
1092 | 68 | nm_settings.connections_read.connect (update); | ||
1093 | 69 | device.state_changed.connect (update); | ||
1094 | 70 | |||
1095 | 71 | update (); | ||
1096 | 72 | |||
1097 | 73 | this.add (hotspot_revealer); | ||
1098 | 74 | this.pack_end (bottom_revealer, false, false); | ||
1099 | 75 | this.show_all (); | ||
1100 | 76 | } | ||
1101 | 77 | |||
1102 | 78 | protected override void update () { | ||
1103 | 79 | if (hotspot_settings_btn != null) { | ||
1104 | 80 | hotspot_settings_btn.sensitive = (Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings)); | ||
1105 | 81 | } | ||
1106 | 82 | |||
1107 | 83 | update_hotspot_info (); | ||
1108 | 84 | base.update (); | ||
1109 | 85 | } | ||
1110 | 86 | |||
1111 | 87 | protected override void update_switch () { | ||
1112 | 88 | switch_updating = true; | ||
1113 | 89 | control_switch.active = (Utils.Hotspot.get_device_is_hotspot ((NM.DeviceWifi)device, nm_settings)); | ||
1114 | 90 | switch_updating = false; | ||
1115 | 91 | } | ||
1116 | 92 | |||
1117 | 93 | protected override void control_switch_activated () { | ||
1118 | 94 | if (switch_updating) { | ||
1119 | 95 | switch_updating = false; | ||
1120 | 96 | return; | ||
1121 | 97 | } | ||
1122 | 98 | |||
1123 | 99 | var wifi_device = (NM.DeviceWifi)device; | ||
1124 | 100 | if (!control_switch.active && Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) { | ||
1125 | 101 | Utils.Hotspot.deactivate_hotspot (wifi_device); | ||
1126 | 102 | } else { | ||
1127 | 103 | var hotspot_dialog = new HotspotDialog (wifi_device.get_active_access_point (), get_hotspot_connections ()); | ||
1128 | 104 | hotspot_dialog.response.connect ((response) => { | ||
1129 | 105 | if (response == 1) { | ||
1130 | 106 | Utils.Hotspot.activate_hotspot (wifi_device, | ||
1131 | 107 | hotspot_dialog.get_ssid (), | ||
1132 | 108 | hotspot_dialog.get_key (), | ||
1133 | 109 | hotspot_dialog.get_selected_connection ()); | ||
1134 | 110 | |||
1135 | 111 | } | ||
1136 | 112 | }); | ||
1137 | 113 | |||
1138 | 114 | hotspot_dialog.run (); | ||
1139 | 115 | hotspot_dialog.destroy (); | ||
1140 | 116 | } | ||
1141 | 117 | } | ||
1142 | 118 | |||
1143 | 119 | private void update_hotspot_info () { | ||
1144 | 120 | var wifi_device = (NM.DeviceWifi)device; | ||
1145 | 121 | bool hotspot_mode = Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings); | ||
1146 | 122 | |||
1147 | 123 | var mode = Utils.CustomMode.HOTSPOT_DISABLED; | ||
1148 | 124 | if (hotspot_mode) { | ||
1149 | 125 | mode = Utils.CustomMode.HOTSPOT_ENABLED; | ||
1150 | 126 | } | ||
1151 | 127 | |||
1152 | 128 | owner.switch_status (mode); | ||
1153 | 129 | |||
1154 | 130 | hotspot_revealer.set_reveal_child (hotspot_mode); | ||
1155 | 131 | |||
1156 | 132 | if (hotspot_mode) { | ||
1157 | 133 | var connection = nm_settings.get_connection_by_path (wifi_device.get_active_connection ().get_connection ()); | ||
1158 | 134 | |||
1159 | 135 | var setting_wireless = connection.get_setting_wireless (); | ||
1160 | 136 | ssid_label.label = _("Network Name (SSID): %s").printf (NM.Utils.ssid_to_utf8 (setting_wireless.get_ssid ())); | ||
1161 | 137 | |||
1162 | 138 | var setting_wireless_security = connection.get_setting_wireless_security (); | ||
1163 | 139 | |||
1164 | 140 | string key_mgmt = setting_wireless_security.get_key_mgmt (); | ||
1165 | 141 | string? secret = null; | ||
1166 | 142 | string security = ""; | ||
1167 | 143 | if (key_mgmt == "none") { | ||
1168 | 144 | secret = setting_wireless_security.get_wep_key (0); | ||
1169 | 145 | security = _("(WEP)"); | ||
1170 | 146 | } else if (key_mgmt == "wpa-psk" || | ||
1171 | 147 | key_mgmt == "wpa-none") { | ||
1172 | 148 | security = _("(WPA)"); | ||
1173 | 149 | secret = setting_wireless_security.get_psk (); | ||
1174 | 150 | } | ||
1175 | 151 | |||
1176 | 152 | if (secret == null) { | ||
1177 | 153 | Utils.Hotspot.update_secrets (connection, update); | ||
1178 | 154 | return; | ||
1179 | 155 | } | ||
1180 | 156 | |||
1181 | 157 | key_label.label = _("Password %s: %s").printf (security, secret); | ||
1182 | 158 | } | ||
1183 | 159 | } | ||
1184 | 160 | |||
1185 | 161 | private List<NM.Connection> get_hotspot_connections () { | ||
1186 | 162 | var list = new List<NM.Connection> (); | ||
1187 | 163 | var connections = nm_settings.list_connections (); | ||
1188 | 164 | |||
1189 | 165 | foreach (var connection in connections) { | ||
1190 | 166 | if (Utils.Hotspot.get_connection_is_hotspot (connection)) { | ||
1191 | 167 | list.append (connection); | ||
1192 | 168 | } | ||
1193 | 169 | } | ||
1194 | 170 | |||
1195 | 171 | return list; | ||
1196 | 172 | } | ||
1197 | 173 | } | ||
1198 | 174 | } | ||
1199 | 0 | 175 | ||
1200 | === modified file 'src/Widgets/InfoBox.vala' | |||
1201 | --- src/Widgets/InfoBox.vala 2015-10-20 20:34:36 +0000 | |||
1202 | +++ src/Widgets/InfoBox.vala 2015-11-07 23:35:34 +0000 | |||
1203 | @@ -1,6 +1,6 @@ | |||
1204 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1205 | 2 | /*- | 2 | /*- |
1207 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1208 | 4 | * | 4 | * |
1209 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
1210 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
1211 | @@ -17,7 +17,7 @@ | |||
1212 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1213 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
1214 | 19 | * | 19 | * |
1216 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1217 | 21 | */ | 21 | */ |
1218 | 22 | 22 | ||
1219 | 23 | namespace Network.Widgets { | 23 | namespace Network.Widgets { |
1220 | 24 | 24 | ||
1221 | === modified file 'src/Widgets/InfoScreen.vala' | |||
1222 | --- src/Widgets/InfoScreen.vala 2015-07-18 16:56:50 +0000 | |||
1223 | +++ src/Widgets/InfoScreen.vala 2015-11-07 23:35:34 +0000 | |||
1224 | @@ -1,6 +1,6 @@ | |||
1225 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1226 | 2 | /*- | 2 | /*- |
1228 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1229 | 4 | * | 4 | * |
1230 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
1231 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
1232 | @@ -17,7 +17,7 @@ | |||
1233 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1234 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
1235 | 19 | * | 19 | * |
1237 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1238 | 21 | */ | 21 | */ |
1239 | 22 | 22 | ||
1240 | 23 | namespace Network { | 23 | namespace Network { |
1241 | 24 | 24 | ||
1242 | === modified file 'src/Widgets/Page.vala' | |||
1243 | --- src/Widgets/Page.vala 2015-10-09 19:12:42 +0000 | |||
1244 | +++ src/Widgets/Page.vala 2015-11-07 23:35:34 +0000 | |||
1245 | @@ -1,6 +1,6 @@ | |||
1246 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1247 | 2 | /*- | 2 | /*- |
1249 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1250 | 4 | * | 4 | * |
1251 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
1252 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
1253 | 7 | 7 | ||
1254 | === modified file 'src/Widgets/Proxy/ProxyConfigurationPage.vala' | |||
1255 | --- src/Widgets/Proxy/ProxyConfigurationPage.vala 2015-10-09 19:12:42 +0000 | |||
1256 | +++ src/Widgets/Proxy/ProxyConfigurationPage.vala 2015-11-07 23:35:34 +0000 | |||
1257 | @@ -1,5 +1,26 @@ | |||
1258 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
1259 | 2 | /*- | ||
1260 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) | ||
1261 | 4 | * | ||
1262 | 5 | * This library is free software; you can redistribute it and/or | ||
1263 | 6 | * modify it under the terms of the GNU Library General Public | ||
1264 | 7 | * License as published by the Free Software Foundation; either | ||
1265 | 8 | * version 3 of the License, or (at your option) any later version. | ||
1266 | 9 | * | ||
1267 | 10 | * This library is distributed in the hope that it will be useful, | ||
1268 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1269 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1270 | 13 | * Library General Public License for more details. | ||
1271 | 14 | * | ||
1272 | 15 | * You should have received a copy of the GNU Library General Public | ||
1273 | 16 | * License along with this library; if not, write to the | ||
1274 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
1275 | 18 | * Boston, MA 02111-1307, USA. | ||
1276 | 19 | * | ||
1277 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | ||
1278 | 21 | */ | ||
1279 | 22 | |||
1280 | 1 | namespace Network.Widgets { | 23 | namespace Network.Widgets { |
1281 | 2 | |||
1282 | 3 | public class ConfigurationPage : Gtk.Box { | 24 | public class ConfigurationPage : Gtk.Box { |
1283 | 4 | private const string DEFAULT_PROXY = "host:port"; | 25 | private const string DEFAULT_PROXY = "host:port"; |
1284 | 5 | private bool syntax_error = false; | 26 | private bool syntax_error = false; |
1285 | 6 | 27 | ||
1286 | === modified file 'src/Widgets/Proxy/ProxyExceptionsPage.vala' | |||
1287 | --- src/Widgets/Proxy/ProxyExceptionsPage.vala 2015-08-03 00:16:24 +0000 | |||
1288 | +++ src/Widgets/Proxy/ProxyExceptionsPage.vala 2015-11-07 23:35:34 +0000 | |||
1289 | @@ -1,3 +1,25 @@ | |||
1290 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
1291 | 2 | /*- | ||
1292 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) | ||
1293 | 4 | * | ||
1294 | 5 | * This library is free software; you can redistribute it and/or | ||
1295 | 6 | * modify it under the terms of the GNU Library General Public | ||
1296 | 7 | * License as published by the Free Software Foundation; either | ||
1297 | 8 | * version 3 of the License, or (at your option) any later version. | ||
1298 | 9 | * | ||
1299 | 10 | * This library is distributed in the hope that it will be useful, | ||
1300 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1301 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1302 | 13 | * Library General Public License for more details. | ||
1303 | 14 | * | ||
1304 | 15 | * You should have received a copy of the GNU Library General Public | ||
1305 | 16 | * License along with this library; if not, write to the | ||
1306 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
1307 | 18 | * Boston, MA 02111-1307, USA. | ||
1308 | 19 | * | ||
1309 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> | ||
1310 | 21 | */ | ||
1311 | 22 | |||
1312 | 1 | namespace Network.Widgets { | 23 | namespace Network.Widgets { |
1313 | 2 | public class ExecepionsPage : Gtk.Box { | 24 | public class ExecepionsPage : Gtk.Box { |
1314 | 3 | private Gtk.ListBox ignored_list; | 25 | private Gtk.ListBox ignored_list; |
1315 | 4 | 26 | ||
1316 | === modified file 'src/Widgets/Proxy/ProxyPage.vala' | |||
1317 | --- src/Widgets/Proxy/ProxyPage.vala 2015-10-20 20:34:36 +0000 | |||
1318 | +++ src/Widgets/Proxy/ProxyPage.vala 2015-11-07 23:35:34 +0000 | |||
1319 | @@ -1,3 +1,26 @@ | |||
1320 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | ||
1321 | 2 | /*- | ||
1322 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) | ||
1323 | 4 | * | ||
1324 | 5 | * This library is free software; you can redistribute it and/or | ||
1325 | 6 | * modify it under the terms of the GNU Library General Public | ||
1326 | 7 | * License as published by the Free Software Foundation; either | ||
1327 | 8 | * version 3 of the License, or (at your option) any later version. | ||
1328 | 9 | * | ||
1329 | 10 | * This library is distributed in the hope that it will be useful, | ||
1330 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1331 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
1332 | 13 | * Library General Public License for more details. | ||
1333 | 14 | * | ||
1334 | 15 | * You should have received a copy of the GNU Library General Public | ||
1335 | 16 | * License along with this library; if not, write to the | ||
1336 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
1337 | 18 | * Boston, MA 02111-1307, USA. | ||
1338 | 19 | * | ||
1339 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> | ||
1340 | 21 | */ | ||
1341 | 22 | |||
1342 | 23 | |||
1343 | 1 | namespace Network.Widgets { | 24 | namespace Network.Widgets { |
1344 | 2 | public class ProxyPage : Gtk.Box { | 25 | public class ProxyPage : Gtk.Box { |
1345 | 3 | public Gtk.Stack stack; | 26 | public Gtk.Stack stack; |
1346 | @@ -34,7 +57,23 @@ | |||
1347 | 34 | } | 57 | } |
1348 | 35 | 58 | ||
1349 | 36 | public void update_mode () { | 59 | public void update_mode () { |
1351 | 37 | owner.switch_status (null, proxy_settings.mode); | 60 | var mode = Utils.CustomMode.INVALID; |
1352 | 61 | switch (proxy_settings.mode) { | ||
1353 | 62 | case "none": | ||
1354 | 63 | mode = Utils.CustomMode.PROXY_NONE; | ||
1355 | 64 | break; | ||
1356 | 65 | case "manual": | ||
1357 | 66 | mode = Utils.CustomMode.PROXY_MANUAL; | ||
1358 | 67 | break; | ||
1359 | 68 | case "auto": | ||
1360 | 69 | mode = Utils.CustomMode.PROXY_AUTO; | ||
1361 | 70 | break; | ||
1362 | 71 | default: | ||
1363 | 72 | mode = Utils.CustomMode.INVALID; | ||
1364 | 73 | break; | ||
1365 | 74 | } | ||
1366 | 75 | |||
1367 | 76 | owner.switch_status (mode); | ||
1368 | 38 | } | 77 | } |
1369 | 39 | } | 78 | } |
1370 | 40 | } | 79 | } |
1371 | 41 | 80 | ||
1372 | === modified file 'src/Widgets/WifiInterface.vala' | |||
1373 | --- src/Widgets/WifiInterface.vala 2015-10-09 19:12:42 +0000 | |||
1374 | +++ src/Widgets/WifiInterface.vala 2015-11-07 23:35:34 +0000 | |||
1375 | @@ -1,6 +1,6 @@ | |||
1376 | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | // -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*- |
1377 | 2 | /*- | 2 | /*- |
1379 | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-network-plug) | 3 | * Copyright (c) 2015 Adam Bieńkowski (http://launchpad.net/switchboard-plug-networking) |
1380 | 4 | * | 4 | * |
1381 | 5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
1382 | 6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
1383 | @@ -17,7 +17,7 @@ | |||
1384 | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
1385 | 18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
1386 | 19 | * | 19 | * |
1388 | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com | 20 | * Authored by: Adam Bieńkowski <donadigos159@gmail.com> |
1389 | 21 | */ | 21 | */ |
1390 | 22 | 22 | ||
1391 | 23 | using Network.Widgets; | 23 | using Network.Widgets; |
1392 | @@ -25,6 +25,9 @@ | |||
1393 | 25 | namespace Network { | 25 | namespace Network { |
1394 | 26 | public class WifiInterface : AbstractWifiInterface { | 26 | public class WifiInterface : AbstractWifiInterface { |
1395 | 27 | protected Gtk.Frame connected_frame; | 27 | protected Gtk.Frame connected_frame; |
1396 | 28 | protected Gtk.Stack list_stack; | ||
1397 | 29 | protected Gtk.ScrolledWindow scrolled; | ||
1398 | 30 | protected Gtk.Box hotspot_mode_box; | ||
1399 | 28 | protected Gtk.Box? connected_box = null; | 31 | protected Gtk.Box? connected_box = null; |
1400 | 29 | protected Gtk.Revealer top_revealer; | 32 | protected Gtk.Revealer top_revealer; |
1401 | 30 | protected Gtk.Button disconnect_btn; | 33 | protected Gtk.Button disconnect_btn; |
1402 | @@ -32,17 +35,10 @@ | |||
1403 | 32 | protected Gtk.ToggleButton info_btn; | 35 | protected Gtk.ToggleButton info_btn; |
1404 | 33 | protected Gtk.Popover popover; | 36 | protected Gtk.Popover popover; |
1405 | 34 | 37 | ||
1408 | 35 | public WifiInterface (NM.Client nm_client, NM.RemoteSettings settings, NM.Device device_) { | 38 | public WifiInterface (NM.Client nm_client, NM.RemoteSettings settings, NM.Device _device) { |
1409 | 36 | info_box = new InfoBox.from_device (device_); | 39 | info_box = new InfoBox.from_device (_device); |
1410 | 37 | info_box.margin = 12; | 40 | info_box.margin = 12; |
1419 | 38 | this.init (device_, info_box); | 41 | this.init (_device, info_box); |
1412 | 39 | |||
1413 | 40 | var css_provider = new Gtk.CssProvider (); | ||
1414 | 41 | try { | ||
1415 | 42 | css_provider.load_from_data ("GtkFrame {\nbackground: #ffffff;\n}", -1); | ||
1416 | 43 | } catch (Error e) { | ||
1417 | 44 | warning ("%s\n", e.message); | ||
1418 | 45 | } | ||
1420 | 46 | 42 | ||
1421 | 47 | popover = new Gtk.Popover (info_btn); | 43 | popover = new Gtk.Popover (info_btn); |
1422 | 48 | popover.position = Gtk.PositionType.BOTTOM; | 44 | popover.position = Gtk.PositionType.BOTTOM; |
1423 | @@ -52,13 +48,13 @@ | |||
1424 | 52 | }); | 48 | }); |
1425 | 53 | 49 | ||
1426 | 54 | connected_frame = new Gtk.Frame (null); | 50 | connected_frame = new Gtk.Frame (null); |
1428 | 55 | connected_frame.get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); | 51 | connected_frame.override_background_color (0, { 255, 255, 255, 255 }); |
1429 | 56 | 52 | ||
1430 | 57 | top_revealer = new Gtk.Revealer (); | 53 | top_revealer = new Gtk.Revealer (); |
1431 | 58 | top_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN; | 54 | top_revealer.transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN; |
1432 | 59 | top_revealer.add (connected_frame); | 55 | top_revealer.add (connected_frame); |
1433 | 60 | 56 | ||
1435 | 61 | init_wifi_interface (nm_client, settings, device_); | 57 | init_wifi_interface (nm_client, settings, device); |
1436 | 62 | 58 | ||
1437 | 63 | this.icon_name = "network-wireless"; | 59 | this.icon_name = "network-wireless"; |
1438 | 64 | this.title = _("Wireless"); | 60 | this.title = _("Wireless"); |
1439 | @@ -66,15 +62,35 @@ | |||
1440 | 66 | 62 | ||
1441 | 67 | control_box.margin_bottom = 12; | 63 | control_box.margin_bottom = 12; |
1442 | 68 | 64 | ||
1443 | 65 | list_stack = new Gtk.Stack (); | ||
1444 | 66 | |||
1445 | 67 | hotspot_mode_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); | ||
1446 | 68 | hotspot_mode_box.visible = true; | ||
1447 | 69 | hotspot_mode_box.valign = Gtk.Align.CENTER; | ||
1448 | 70 | |||
1449 | 71 | var main_frame = new Gtk.Frame (null); | ||
1450 | 72 | main_frame.margin_bottom = 24; | ||
1451 | 73 | main_frame.margin_top = 12; | ||
1452 | 74 | main_frame.vexpand = true; | ||
1453 | 75 | main_frame.override_background_color (0, { 255, 255, 255, 255 }); | ||
1454 | 76 | |||
1455 | 77 | var hotspot_mode = construct_placeholder_label (_("This device is in Hotspot Mode"), true); | ||
1456 | 78 | var hotspot_mode_desc = construct_placeholder_label (_("Turn off the Hotspot Mode to connect to other Access Points."), false); | ||
1457 | 79 | hotspot_mode_box.add (hotspot_mode); | ||
1458 | 80 | hotspot_mode_box.add (hotspot_mode_desc); | ||
1459 | 81 | |||
1460 | 69 | wifi_list.selection_mode = Gtk.SelectionMode.SINGLE; | 82 | wifi_list.selection_mode = Gtk.SelectionMode.SINGLE; |
1462 | 70 | wifi_list.activate_on_single_click = false; | 83 | wifi_list.activate_on_single_click = false; |
1463 | 84 | wifi_list.visible = true; | ||
1464 | 71 | 85 | ||
1468 | 72 | var scrolled = new Gtk.ScrolledWindow (null, null); | 86 | scrolled = new Gtk.ScrolledWindow (null, null); |
1466 | 73 | scrolled.margin_bottom = 24; | ||
1467 | 74 | scrolled.margin_top = 12; | ||
1469 | 75 | scrolled.add (wifi_list); | 87 | scrolled.add (wifi_list); |
1472 | 76 | scrolled.vexpand = true; | 88 | |
1473 | 77 | scrolled.shadow_type = Gtk.ShadowType.OUT; | 89 | list_stack.add (hotspot_mode_box); |
1474 | 90 | list_stack.add (scrolled); | ||
1475 | 91 | list_stack.visible_child = scrolled; | ||
1476 | 92 | |||
1477 | 93 | main_frame.add (list_stack); | ||
1478 | 78 | 94 | ||
1479 | 79 | var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); | 95 | var button_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6); |
1480 | 80 | 96 | ||
1481 | @@ -83,14 +99,18 @@ | |||
1482 | 83 | 99 | ||
1483 | 84 | button_box.pack_start (hidden_btn, false, false, 0); | 100 | button_box.pack_start (hidden_btn, false, false, 0); |
1484 | 85 | 101 | ||
1485 | 86 | update (); | ||
1486 | 87 | |||
1487 | 88 | bottom_box.add (button_box); | 102 | bottom_box.add (button_box); |
1488 | 89 | 103 | ||
1489 | 90 | this.add (top_revealer); | 104 | this.add (top_revealer); |
1491 | 91 | this.add (scrolled); | 105 | this.add (main_frame); |
1492 | 92 | this.add (bottom_revealer); | 106 | this.add (bottom_revealer); |
1493 | 93 | this.show_all (); | 107 | this.show_all (); |
1494 | 108 | |||
1495 | 109 | update (); | ||
1496 | 110 | } | ||
1497 | 111 | |||
1498 | 112 | public NM.RemoteSettings get_nm_settings () { | ||
1499 | 113 | return nm_settings; | ||
1500 | 94 | } | 114 | } |
1501 | 95 | 115 | ||
1502 | 96 | public override void update () { | 116 | public override void update () { |
1503 | @@ -111,7 +131,15 @@ | |||
1504 | 111 | 131 | ||
1505 | 112 | base.update (); | 132 | base.update (); |
1506 | 113 | 133 | ||
1508 | 114 | top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null); | 134 | bool is_hotspot = Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings); |
1509 | 135 | |||
1510 | 136 | top_revealer.set_reveal_child (wifi_device.get_active_access_point () != null && !is_hotspot); | ||
1511 | 137 | |||
1512 | 138 | if (is_hotspot) { | ||
1513 | 139 | list_stack.visible_child = hotspot_mode_box; | ||
1514 | 140 | } else { | ||
1515 | 141 | list_stack.visible_child = scrolled; | ||
1516 | 142 | } | ||
1517 | 115 | 143 | ||
1518 | 116 | if (wifi_device.get_active_access_point () == null && old_active != null) { | 144 | if (wifi_device.get_active_access_point () == null && old_active != null) { |
1519 | 117 | old_active.no_show_all = false; | 145 | old_active.no_show_all = false; |
1520 | @@ -186,7 +214,7 @@ | |||
1521 | 186 | 214 | ||
1522 | 187 | protected override void control_switch_activated () { | 215 | protected override void control_switch_activated () { |
1523 | 188 | var active = control_switch.active; | 216 | var active = control_switch.active; |
1525 | 189 | if (active != !software_locked) { | 217 | if (active == software_locked) { |
1526 | 190 | rfkill.set_software_lock (RFKillDeviceType.WLAN, !active); | 218 | rfkill.set_software_lock (RFKillDeviceType.WLAN, !active); |
1527 | 191 | client.wireless_set_enabled (active); | 219 | client.wireless_set_enabled (active); |
1528 | 192 | } | 220 | } |
1529 | 193 | 221 | ||
1530 | === modified file 'src/common/Widgets/AbstractWifiInterface.vala' | |||
1531 | --- src/common/Widgets/AbstractWifiInterface.vala 2015-10-22 16:46:13 +0000 | |||
1532 | +++ src/common/Widgets/AbstractWifiInterface.vala 2015-11-07 23:35:34 +0000 | |||
1533 | @@ -39,7 +39,7 @@ | |||
1534 | 39 | this.nm_client = nm_client; | 39 | this.nm_client = nm_client; |
1535 | 40 | this.nm_settings = nm_settings; | 40 | this.nm_settings = nm_settings; |
1536 | 41 | device = _device; | 41 | device = _device; |
1538 | 42 | wifi_device = device as NM.DeviceWifi; | 42 | wifi_device = (NM.DeviceWifi)device; |
1539 | 43 | blank_item = new WifiMenuItem.blank (); | 43 | blank_item = new WifiMenuItem.blank (); |
1540 | 44 | active_wifi_item = null; | 44 | active_wifi_item = null; |
1541 | 45 | 45 | ||
1542 | @@ -82,7 +82,6 @@ | |||
1543 | 82 | scanning_box.visible = true; | 82 | scanning_box.visible = true; |
1544 | 83 | scanning_box.valign = Gtk.Align.CENTER; | 83 | scanning_box.valign = Gtk.Align.CENTER; |
1545 | 84 | 84 | ||
1546 | 85 | |||
1547 | 86 | placeholder.add_named (no_aps_box, "no-aps"); | 85 | placeholder.add_named (no_aps_box, "no-aps"); |
1548 | 87 | placeholder.add_named (wireless_off_box, "wireless-off"); | 86 | placeholder.add_named (wireless_off_box, "wireless-off"); |
1549 | 88 | placeholder.add_named (scanning_box, "scanning"); | 87 | placeholder.add_named (scanning_box, "scanning"); |
1550 | @@ -99,7 +98,9 @@ | |||
1551 | 99 | rfkill.device_changed.connect (update); | 98 | rfkill.device_changed.connect (update); |
1552 | 100 | rfkill.device_deleted.connect (update); | 99 | rfkill.device_deleted.connect (update); |
1553 | 101 | 100 | ||
1555 | 102 | wifi_device.notify["active-access-point"].connect (() => { update (); }); | 101 | nm_settings.connections_read.connect (update); |
1556 | 102 | |||
1557 | 103 | wifi_device.notify["active-access-point"].connect (update); | ||
1558 | 103 | wifi_device.access_point_added.connect (access_point_added_cb); | 104 | wifi_device.access_point_added.connect (access_point_added_cb); |
1559 | 104 | wifi_device.access_point_removed.connect (access_point_removed_cb); | 105 | wifi_device.access_point_removed.connect (access_point_removed_cb); |
1560 | 105 | wifi_device.state_changed.connect (update); | 106 | wifi_device.state_changed.connect (update); |
1561 | @@ -112,7 +113,7 @@ | |||
1562 | 112 | update(); | 113 | update(); |
1563 | 113 | } | 114 | } |
1564 | 114 | 115 | ||
1566 | 115 | Gtk.Label construct_placeholder_label (string text, bool title) { | 116 | protected Gtk.Label construct_placeholder_label (string text, bool title) { |
1567 | 116 | var label = new Gtk.Label (text); | 117 | var label = new Gtk.Label (text); |
1568 | 117 | label.visible = true; | 118 | label.visible = true; |
1569 | 118 | label.use_markup = true; | 119 | label.use_markup = true; |
1570 | @@ -157,7 +158,6 @@ | |||
1571 | 157 | item.user_action.connect (wifi_activate_cb); | 158 | item.user_action.connect (wifi_activate_cb); |
1572 | 158 | 159 | ||
1573 | 159 | wifi_list.add (item); | 160 | wifi_list.add (item); |
1574 | 160 | |||
1575 | 161 | wifi_list.show_all (); | 161 | wifi_list.show_all (); |
1576 | 162 | 162 | ||
1577 | 163 | update (); | 163 | update (); |
1578 | @@ -241,6 +241,13 @@ | |||
1579 | 241 | } | 241 | } |
1580 | 242 | 242 | ||
1581 | 243 | public override void update () { | 243 | public override void update () { |
1582 | 244 | #if PLUG_NETWORK | ||
1583 | 245 | if (Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) { | ||
1584 | 246 | state = State.DISCONNECTED; | ||
1585 | 247 | return; | ||
1586 | 248 | } | ||
1587 | 249 | #endif | ||
1588 | 250 | |||
1589 | 244 | switch (wifi_device.state) { | 251 | switch (wifi_device.state) { |
1590 | 245 | case NM.DeviceState.UNKNOWN: | 252 | case NM.DeviceState.UNKNOWN: |
1591 | 246 | case NM.DeviceState.UNMANAGED: | 253 | case NM.DeviceState.UNMANAGED: |
1592 | @@ -275,6 +282,7 @@ | |||
1593 | 275 | 282 | ||
1594 | 276 | case NM.DeviceState.ACTIVATED: | 283 | case NM.DeviceState.ACTIVATED: |
1595 | 277 | set_scan_placeholder (); | 284 | set_scan_placeholder (); |
1596 | 285 | |||
1597 | 278 | /* That can happen if active_ap has not been added yet, at startup. */ | 286 | /* That can happen if active_ap has not been added yet, at startup. */ |
1598 | 279 | if (active_ap != null) { | 287 | if (active_ap != null) { |
1599 | 280 | state = strength_to_state(active_ap.get_strength()); | 288 | state = strength_to_state(active_ap.get_strength()); |
1600 | @@ -298,6 +306,7 @@ | |||
1601 | 298 | if (device.hardware_lock) | 306 | if (device.hardware_lock) |
1602 | 299 | hardware_locked = true; | 307 | hardware_locked = true; |
1603 | 300 | } | 308 | } |
1604 | 309 | |||
1605 | 301 | locked = hardware_locked || software_locked; | 310 | locked = hardware_locked || software_locked; |
1606 | 302 | 311 | ||
1607 | 303 | update_active_ap (); | 312 | update_active_ap (); |
1608 | @@ -319,6 +328,12 @@ | |||
1609 | 319 | cancel_scan (); | 328 | cancel_scan (); |
1610 | 320 | wifi_device.request_scan_simple (null); | 329 | wifi_device.request_scan_simple (null); |
1611 | 321 | timeout_scan = Timeout.add(5000, () => { | 330 | timeout_scan = Timeout.add(5000, () => { |
1612 | 331 | #if PLUG_NETWORK | ||
1613 | 332 | if (Utils.Hotspot.get_device_is_hotspot (wifi_device, nm_settings)) { | ||
1614 | 333 | return false; | ||
1615 | 334 | } | ||
1616 | 335 | #endif | ||
1617 | 336 | |||
1618 | 322 | timeout_scan = 0; | 337 | timeout_scan = 0; |
1619 | 323 | placeholder.visible_child_name = "no-aps"; | 338 | placeholder.visible_child_name = "no-aps"; |
1620 | 324 | return false; | 339 | return false; |
Your email address is missing the closing ">"