status/network: Expose WirelessDeviceItem:is-hotspot
Whether the device is used as a hotspot is currently only used internally for the name and icon-name properties. But hotspots need special treatment in the toggle as well, so turn the method into a GObject property. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2408>
This commit is contained in:
parent
88262a1042
commit
1cc07716fa
@ -1009,6 +1009,9 @@ class NMWirelessNetworkItem extends PopupMenu.PopupBaseMenuItem {
|
|||||||
|
|
||||||
const NMWirelessDeviceItem = GObject.registerClass({
|
const NMWirelessDeviceItem = GObject.registerClass({
|
||||||
Properties: {
|
Properties: {
|
||||||
|
'is-hotspot': GObject.ParamSpec.boolean('is-hotspot', '', '',
|
||||||
|
GObject.ParamFlags.READABLE,
|
||||||
|
false),
|
||||||
'single-device-mode': GObject.ParamSpec.boolean('single-device-mode', '', '',
|
'single-device-mode': GObject.ParamSpec.boolean('single-device-mode', '', '',
|
||||||
GObject.ParamFlags.READWRITE,
|
GObject.ParamFlags.READWRITE,
|
||||||
false),
|
false),
|
||||||
@ -1037,6 +1040,7 @@ const NMWirelessDeviceItem = GObject.registerClass({
|
|||||||
'notify::active-access-point', this._activeApChanged.bind(this),
|
'notify::active-access-point', this._activeApChanged.bind(this),
|
||||||
'notify::active-connection', () => this._activeConnectionChanged(),
|
'notify::active-connection', () => this._activeConnectionChanged(),
|
||||||
'notify::available-connections', () => this._availableConnectionsChanged(),
|
'notify::available-connections', () => this._availableConnectionsChanged(),
|
||||||
|
'state-changed', () => this.notify('is-hotspot'),
|
||||||
'access-point-added', (d, ap) => {
|
'access-point-added', (d, ap) => {
|
||||||
this._addAccessPoint(ap);
|
this._addAccessPoint(ap);
|
||||||
this._updateItemsVisibility();
|
this._updateItemsVisibility();
|
||||||
@ -1072,7 +1076,7 @@ const NMWirelessDeviceItem = GObject.registerClass({
|
|||||||
return 'network-wireless-acquiring-symbolic';
|
return 'network-wireless-acquiring-symbolic';
|
||||||
|
|
||||||
case NM.ActiveConnectionState.ACTIVATED: {
|
case NM.ActiveConnectionState.ACTIVATED: {
|
||||||
if (this._isHotSpotMaster())
|
if (this.is_hotspot)
|
||||||
return 'network-wireless-hotspot-symbolic';
|
return 'network-wireless-hotspot-symbolic';
|
||||||
|
|
||||||
if (!this._canReachInternet())
|
if (!this._canReachInternet())
|
||||||
@ -1094,7 +1098,7 @@ const NMWirelessDeviceItem = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
get name() {
|
||||||
if (this._isHotSpotMaster())
|
if (this.is_hotspot)
|
||||||
/* Translators: %s is a network identifier */
|
/* Translators: %s is a network identifier */
|
||||||
return _('%s Hotspot').format(this._deviceName);
|
return _('%s Hotspot').format(this._deviceName);
|
||||||
|
|
||||||
@ -1105,6 +1109,21 @@ const NMWirelessDeviceItem = GObject.registerClass({
|
|||||||
return this._deviceName;
|
return this._deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get is_hotspot() {
|
||||||
|
if (!this._device.active_connection)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const {connection} = this._device.active_connection;
|
||||||
|
if (!connection)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
let ip4config = connection.get_setting_ip4_config();
|
||||||
|
if (!ip4config)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ip4config.get_method() === NM.SETTING_IP4_CONFIG_METHOD_SHARED;
|
||||||
|
}
|
||||||
|
|
||||||
_activeApChanged() {
|
_activeApChanged() {
|
||||||
this._activeAccessPoint?.disconnectObject(this);
|
this._activeAccessPoint?.disconnectObject(this);
|
||||||
this._activeAccessPoint = this._device.active_access_point;
|
this._activeAccessPoint = this._device.active_access_point;
|
||||||
@ -1207,21 +1226,6 @@ const NMWirelessDeviceItem = GObject.registerClass({
|
|||||||
|
|
||||||
return this._client.connectivity === NM.ConnectivityState.FULL;
|
return this._client.connectivity === NM.ConnectivityState.FULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
_isHotSpotMaster() {
|
|
||||||
if (!this._device.active_connection)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
let connection = this._device.active_connection.connection;
|
|
||||||
if (!connection)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
let ip4config = connection.get_setting_ip4_config();
|
|
||||||
if (!ip4config)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return ip4config.get_method() === NM.SETTING_IP4_CONFIG_METHOD_SHARED;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const NMVpnConnectionItem = GObject.registerClass({
|
const NMVpnConnectionItem = GObject.registerClass({
|
||||||
|
Loading…
Reference in New Issue
Block a user