status/network: Split out NMDeviceConnectionItem
When not in radio-mode - that is, when the connection is the only connection for its device - we want the item to represent the device as a whole. Achieve this with a small ConnectionItem subclass that adds a :device-name property for that purpose. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2407>
This commit is contained in:
parent
64ae6ae7b3
commit
a62ac495a3
@ -192,7 +192,7 @@ const NMConnectionItem = GObject.registerClass({
|
|||||||
|
|
||||||
_sync() {
|
_sync() {
|
||||||
if (this.radioMode) {
|
if (this.radioMode) {
|
||||||
this._label.text = this._connection.get_id();
|
this._label.text = this.name;
|
||||||
this.accessible_role = Atk.Role.CHECK_MENU_ITEM;
|
this.accessible_role = Atk.Role.CHECK_MENU_ITEM;
|
||||||
} else {
|
} else {
|
||||||
this._label.text = this._getRegularLabel();
|
this._label.text = this._getRegularLabel();
|
||||||
@ -232,6 +232,29 @@ const NMConnectionItem = GObject.registerClass({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const NMDeviceConnectionItem = GObject.registerClass({
|
||||||
|
Properties: {
|
||||||
|
'device-name': GObject.ParamSpec.string('device-name', '', '',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
''),
|
||||||
|
},
|
||||||
|
}, class NMDeviceConnectionItem extends NMConnectionItem {
|
||||||
|
constructor(section, connection) {
|
||||||
|
super(section, connection);
|
||||||
|
|
||||||
|
this.connectObject(
|
||||||
|
'notify::radio-mode', () => this.notify('name'),
|
||||||
|
'notify::device-name', () => this.notify('name'),
|
||||||
|
this);
|
||||||
|
}
|
||||||
|
|
||||||
|
get name() {
|
||||||
|
return this.radioMode
|
||||||
|
? this._connection.get_id()
|
||||||
|
: this.deviceName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter {
|
var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
super();
|
super();
|
||||||
@ -259,6 +282,8 @@ var NMConnectionSection = class NMConnectionSection extends Signals.EventEmitter
|
|||||||
}
|
}
|
||||||
|
|
||||||
_iconChanged() {
|
_iconChanged() {
|
||||||
|
this._connectionItems.forEach(
|
||||||
|
item => (item.icon_name = this.getIndicatorIcon()));
|
||||||
this._sync();
|
this._sync();
|
||||||
this.emit('icon-changed');
|
this.emit('icon-changed');
|
||||||
}
|
}
|
||||||
@ -422,6 +447,10 @@ var NMDeviceItem = class NMDeviceItem extends NMConnectionSection {
|
|||||||
return this._device.connection_valid(connection);
|
return this._device.connection_valid(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_makeConnectionItem(connection) {
|
||||||
|
return new NMDeviceConnectionItem(this, connection);
|
||||||
|
}
|
||||||
|
|
||||||
activateConnection(connection) {
|
activateConnection(connection) {
|
||||||
this._client.activate_connection_async(connection, this._device, null, null, null);
|
this._client.activate_connection_async(connection, this._device, null, null, null);
|
||||||
}
|
}
|
||||||
@ -432,6 +461,8 @@ var NMDeviceItem = class NMDeviceItem extends NMConnectionSection {
|
|||||||
|
|
||||||
setDeviceName(name) {
|
setDeviceName(name) {
|
||||||
this._deviceName = name;
|
this._deviceName = name;
|
||||||
|
this._connectionItems.forEach(
|
||||||
|
item => (item.deviceName = this._getDescription()));
|
||||||
this._sync();
|
this._sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1448,10 +1479,6 @@ class NMVpnConnectionItem extends NMConnectionItem {
|
|||||||
GObject.BindingFlags.SYNC_CREATE);
|
GObject.BindingFlags.SYNC_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
get name() {
|
|
||||||
return this._connection?.get_id() ?? '';
|
|
||||||
}
|
|
||||||
|
|
||||||
_updateOrnament() {
|
_updateOrnament() {
|
||||||
this.setOrnament(PopupMenu.Ornament.NONE);
|
this.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
}
|
}
|
||||||
@ -1488,6 +1515,9 @@ class NMVpnConnectionItem extends NMConnectionItem {
|
|||||||
return 'network-vpn-disabled-symbolic';
|
return 'network-vpn-disabled-symbolic';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set icon_name(_ignored) {
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var NMVpnSection = class extends NMConnectionSection {
|
var NMVpnSection = class extends NMConnectionSection {
|
||||||
|
Loading…
Reference in New Issue
Block a user