[gnome-shell] status/network: Add NMSection:checked property
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] status/network: Add NMSection:checked property
- Date: Wed, 10 Aug 2022 16:41:15 +0000 (UTC)
commit b0df35babf32afc5ba27b68d58df3127ae8ed6c1
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Aug 3 03:40:40 2022 +0200
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>
js/ui/status/network.js | 12 ++++++++++++
1 file changed, 12 insertions(+)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index a3a8d8faaf..20b44da1c3 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -1275,6 +1275,11 @@ const NMVpnConnectionItem = GObject.registerClass({
});
const NMSection = GObject.registerClass({
+ Properties: {
+ 'checked': GObject.ParamSpec.boolean('checked', '', '',
+ GObject.ParamFlags.READWRITE,
+ false),
+ },
Signals: {
'activation-failed': {},
'icon-changed': {},
@@ -1322,6 +1327,11 @@ const NMSection = GObject.registerClass({
(item, i) => (item.visible = i < MAX_VISIBLE_NETWORKS));
}
+ _updateChecked() {
+ const [firstActive] = this._getActiveItems();
+ this.checked = !!firstActive;
+ }
+
_resortItem(item) {
const pos = this._itemSorter.upsert(item);
this._itemsSection.moveMenuItem(item, pos);
@@ -1332,6 +1342,7 @@ const NMSection = GObject.registerClass({
`${this} already has an item for ${key}`);
item.connectObject(
+ 'notify::is-active', () => this._updateChecked(),
'notify::name', () => this._resortItem(item),
'destroy', () => this._removeItem(key),
this);
@@ -1357,6 +1368,7 @@ const NMSection = GObject.registerClass({
_sync() {
this.visible = this._items.size > 0;
this._updateItemsVisibility();
+ this._updateChecked();
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]