status/network: Special-case wireless hotspots
If any device is in hotspot mode, use the corresponding item as primary. Disable the (future QuickMenuToggle) menu in that case, and turn off the hotspot when activated rather than toggling the global wireless switch. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2408>
This commit is contained in:
parent
3a1ebd86d2
commit
8e685246e2
@ -1124,6 +1124,14 @@ const NMWirelessDeviceItem = GObject.registerClass({
|
|||||||
return ip4config.get_method() === NM.SETTING_IP4_CONFIG_METHOD_SHARED;
|
return ip4config.get_method() === NM.SETTING_IP4_CONFIG_METHOD_SHARED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
activate() {
|
||||||
|
if (!this.is_hotspot)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const {activeConnection} = this._device;
|
||||||
|
this._client.deactivate_connection_async(activeConnection, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
_activeApChanged() {
|
_activeApChanged() {
|
||||||
this._activeAccessPoint?.disconnectObject(this);
|
this._activeAccessPoint?.disconnectObject(this);
|
||||||
this._activeAccessPoint = this._device.active_access_point;
|
this._activeAccessPoint = this._device.active_access_point;
|
||||||
@ -1690,11 +1698,20 @@ class NMDeviceSection extends NMSection {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const NMWirelessSection = GObject.registerClass(
|
const NMWirelessSection = GObject.registerClass({
|
||||||
class NMWirelessSection extends NMDeviceSection {
|
Properties: {
|
||||||
|
'menu-enabled': GObject.ParamSpec.boolean('menu-enabled', '', '',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
false),
|
||||||
|
},
|
||||||
|
}, class NMWirelessSection extends NMDeviceSection {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(NM.DeviceType.WIFI);
|
super(NM.DeviceType.WIFI);
|
||||||
|
|
||||||
|
this._itemBinding.bind('is-hotspot',
|
||||||
|
this, 'menu-enabled',
|
||||||
|
GObject.BindingFlags.INVERT_BOOLEAN);
|
||||||
|
|
||||||
this.menu.addSettingsAction(_('All Networks'),
|
this.menu.addSettingsAction(_('All Networks'),
|
||||||
'gnome-wifi-panel.desktop');
|
'gnome-wifi-panel.desktop');
|
||||||
}
|
}
|
||||||
@ -1711,6 +1728,10 @@ class NMWirelessSection extends NMDeviceSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
|
const primaryItem = this._itemBinding.source;
|
||||||
|
if (primaryItem?.is_hotspot)
|
||||||
|
primaryItem.activate();
|
||||||
|
else
|
||||||
this._client.wireless_enabled = !this._client.wireless_enabled;
|
this._client.wireless_enabled = !this._client.wireless_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1722,6 +1743,14 @@ class NMWirelessSection extends NMDeviceSection {
|
|||||||
// handled via a property binding
|
// handled via a property binding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getPrimaryItem() {
|
||||||
|
const hotspot = [...this._items.values()].find(i => i.is_hotspot);
|
||||||
|
if (hotspot)
|
||||||
|
return hotspot;
|
||||||
|
|
||||||
|
return super._getPrimaryItem();
|
||||||
|
}
|
||||||
|
|
||||||
_shouldShowDevice(device) {
|
_shouldShowDevice(device) {
|
||||||
// don't disappear if wireless-enabled is false
|
// don't disappear if wireless-enabled is false
|
||||||
if (device.state === NM.DeviceState.UNAVAILABLE)
|
if (device.state === NM.DeviceState.UNAVAILABLE)
|
||||||
|
Loading…
Reference in New Issue
Block a user