status/network: Add NMSection:checked property
Unsurprisingly, this will become the quick toggles 'checked' state. Equally unsurprising, it is set when at least one item is active. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2408>
This commit is contained in:
parent
16b63af441
commit
b0df35babf
@ -1275,6 +1275,11 @@ const NMVpnConnectionItem = GObject.registerClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const NMSection = GObject.registerClass({
|
const NMSection = GObject.registerClass({
|
||||||
|
Properties: {
|
||||||
|
'checked': GObject.ParamSpec.boolean('checked', '', '',
|
||||||
|
GObject.ParamFlags.READWRITE,
|
||||||
|
false),
|
||||||
|
},
|
||||||
Signals: {
|
Signals: {
|
||||||
'activation-failed': {},
|
'activation-failed': {},
|
||||||
'icon-changed': {},
|
'icon-changed': {},
|
||||||
@ -1322,6 +1327,11 @@ const NMSection = GObject.registerClass({
|
|||||||
(item, i) => (item.visible = i < MAX_VISIBLE_NETWORKS));
|
(item, i) => (item.visible = i < MAX_VISIBLE_NETWORKS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_updateChecked() {
|
||||||
|
const [firstActive] = this._getActiveItems();
|
||||||
|
this.checked = !!firstActive;
|
||||||
|
}
|
||||||
|
|
||||||
_resortItem(item) {
|
_resortItem(item) {
|
||||||
const pos = this._itemSorter.upsert(item);
|
const pos = this._itemSorter.upsert(item);
|
||||||
this._itemsSection.moveMenuItem(item, pos);
|
this._itemsSection.moveMenuItem(item, pos);
|
||||||
@ -1332,6 +1342,7 @@ const NMSection = GObject.registerClass({
|
|||||||
`${this} already has an item for ${key}`);
|
`${this} already has an item for ${key}`);
|
||||||
|
|
||||||
item.connectObject(
|
item.connectObject(
|
||||||
|
'notify::is-active', () => this._updateChecked(),
|
||||||
'notify::name', () => this._resortItem(item),
|
'notify::name', () => this._resortItem(item),
|
||||||
'destroy', () => this._removeItem(key),
|
'destroy', () => this._removeItem(key),
|
||||||
this);
|
this);
|
||||||
@ -1357,6 +1368,7 @@ const NMSection = GObject.registerClass({
|
|||||||
_sync() {
|
_sync() {
|
||||||
this.visible = this._items.size > 0;
|
this.visible = this._items.size > 0;
|
||||||
this._updateItemsVisibility();
|
this._updateItemsVisibility();
|
||||||
|
this._updateChecked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user