@@ -27,6 +27,7 @@ public class Network.MainView : Gtk.Box {
2727 private Gtk . ListBox device_list;
2828 private Gtk . Stack content;
2929 private NM . Device current_device = null ;
30+ private RFKillManager rfkill;
3031 private VPNPage vpn_page;
3132
3233 construct {
@@ -61,28 +62,17 @@ public class Network.MainView : Gtk.Box {
6162 device_list. append (proxy);
6263 device_list. append (vpn);
6364
64- var label = new Gtk .Label (_(" Airplane Mode" ));
65-
66- var airplane_switch = new Gtk .Switch () {
65+ var airplane_switch = new Granite .SwitchModelButton (_(" Airplane Mode" )) {
66+ hexpand = true ,
6767 valign = CENTER
6868 };
6969
7070 var footer = new Gtk .ActionBar ();
71- footer. pack_start (label);
72- footer. pack_end (airplane_switch);
73-
74- var airplane_mode = new Granite .Placeholder (
75- _(" Airplane Mode Is Enabled" )) {
76- description = _ ("While in Airplane Mode your device 's Internet access and any wireless and ethernet connections , will be suspended .\n \n ") +
77- _ ("You will be unable to browse the web or use applications that require a network connection or Internet access .\n ") +
78- _ ("Applications and other functions that do not require the Internet will be unaffected ."),
79- icon = new ThemedIcon ("airplane -mode ")
80- };
71+ footer. pack_start (airplane_switch);
8172
8273 content = new Gtk .Stack () {
8374 hexpand = true
8475 };
85- content.add_named (airplane_mode , "airplane -mode -info ");
8676 content. add_child (vpn_page);
8777 content. add_child (proxy. page);
8878
@@ -141,24 +131,9 @@ public class Network.MainView : Gtk.Box {
141131 update_networking_state ();
142132 nm_client. notify[" networking-enabled" ]. connect (update_networking_state);
143133
144- airplane_switch.notify["active"].connect (() => {
145- nm_client. dbus_call. begin (
146- NM. DBUS_PATH , NM. DBUS_INTERFACE , " Enable" ,
147- new GLib .Variant .tuple ({! airplane_switch. active}),
148- null , - 1 , null ,
149- (obj, res) = > {
150- try {
151- nm_client. dbus_call. end (res);
152- } catch (Error e) {
153- warning (e. message);
154- }
155- }
156- );
157- });
158-
159- if (!airplane_switch .active && !nm_client .networking_enabled ) {
160- airplane_switch. activate ();
161- }
134+ rfkill = new RFKillManager ();
135+ rfkill. open ();
136+ rfkill. bind_property (" airplane-mode" , airplane_switch, " active" , BIDIRECTIONAL | SYNC_CREATE );
162137 }
163138
164139 private void device_removed_cb (NM .Device device ) {
@@ -339,7 +314,6 @@ public class Network.MainView : Gtk.Box {
339314 device_list. sensitive = false ;
340315 current_device = null ;
341316 device_list. select_row (null );
342- content. set_visible_child_name (" airplane-mode-info" );
343317 }
344318 }
345319
0 commit comments