@@ -23,6 +23,7 @@ public class Network.Indicator : Wingpanel.Indicator {
2323 NetworkMonitor network_monitor;
2424
2525 private Gtk . GestureMultiPress gesture_click;
26+ private SimpleAction airplane_action;
2627
2728 public bool is_in_session { get ; set ; default = false ; }
2829
@@ -60,20 +61,30 @@ public class Network.Indicator : Wingpanel.Indicator {
6061 };
6162
6263 gesture_click. pressed. connect (() = > {
63- popover_widget. nm_client. dbus_call. begin (
64- NM. DBUS_PATH , NM. DBUS_INTERFACE ,
65- " Enable" , new Variant .tuple ({new Variant .boolean (! popover_widget. nm_client. networking_get_enabled ())}),
66- null , - 1 , null , (obj, res) = > {
67- try {
68- ((NM . Client ) obj). dbus_set_property. end (res);
69- } catch (Error e) {
70- warning (" Error setting airplane mode: %s " , e. message);
71- }
72- }
73- );
64+ airplane_action. activate (null );
7465 });
7566 }
7667
68+ airplane_action = new SimpleAction .stateful (" airplane-mode" , null , new Variant .boolean (popover_widget. nm_client. networking_get_enabled ()));
69+ airplane_action. activate. connect (() = > {
70+ popover_widget. nm_client. dbus_call. begin (
71+ NM. DBUS_PATH , NM. DBUS_INTERFACE ,
72+ " Enable" , new Variant .tuple ({new Variant .boolean (! popover_widget. nm_client. networking_get_enabled ())}),
73+ null , - 1 , null , (obj, res) = > {
74+ try {
75+ ((NM . Client ) obj). dbus_set_property. end (res);
76+ } catch (Error e) {
77+ warning (" Error setting airplane mode: %s " , e. message);
78+ }
79+ }
80+ );
81+ });
82+
83+ var action_group = new SimpleActionGroup ();
84+ action_group. add_action (airplane_action);
85+
86+ popover_widget. insert_action_group (" network" , action_group);
87+
7788 update_tooltip ();
7889 on_state_changed ();
7990 start_monitor ();
@@ -93,6 +104,8 @@ public class Network.Indicator : Wingpanel.Indicator {
93104
94105 display_widget. update_state (popover_widget. state, popover_widget. secure, popover_widget. extra_info);
95106
107+ airplane_action. set_state (new Variant .boolean (! popover_widget. nm_client. networking_get_enabled ()));
108+
96109 update_tooltip ();
97110 }
98111
0 commit comments