diff --git a/nightscout-follower@treehouse.org.za/extension.js b/nightscout-follower@treehouse.org.za/extension.js index 3a7e6e7..4705b17 100644 --- a/nightscout-follower@treehouse.org.za/extension.js +++ b/nightscout-follower@treehouse.org.za/extension.js @@ -36,6 +36,7 @@ export default class NightscoutExtension extends Extension { this._httpSession = new Soup.Session(); this._indicator = new PanelMenu.Button(0.0, this.metadata.name, false); this._systemSource = MessageTray.getSystemSource(); + this._active = this._settings.get_boolean('update-data'); this._label = new St.Label({ text: "Loading...", @@ -44,8 +45,8 @@ export default class NightscoutExtension extends Extension { }); this._indicator.add_child(this._label); - //this._indicator.menu.addAction(_('Preferences'), - // () => this.openPreferences()); + this._indicator.menu.addAction(_('Preferences'), + () => this.openPreferences()); Main.panel.addToStatusArea(this.uuid, this._indicator); @@ -61,6 +62,9 @@ export default class NightscoutExtension extends Extension { return GLib.SOURCE_CONTINUE; }); + this._settings.connect('changed::update-data', (settings, key) => { + this._active = settings.get_boolean(key); + }); this._settings.connect('changed::url', () => { this._update(); }); @@ -85,6 +89,11 @@ export default class NightscoutExtension extends Extension { }; _update() { + if (!this._active) { + this._label.set_text("Disabled"); + return; + } + //console.log("nightscout-follower: updating...") // Watch for changes to a specific setting this._fetch((status, data) => { diff --git a/nightscout-follower@treehouse.org.za/prefs.js b/nightscout-follower@treehouse.org.za/prefs.js index 3de352a..71d576a 100644 --- a/nightscout-follower@treehouse.org.za/prefs.js +++ b/nightscout-follower@treehouse.org.za/prefs.js @@ -19,6 +19,16 @@ export default class NightscoutPreferences extends ExtensionPreferences { page.add(group); + const update_row = new Adw.SwitchRow({ + title: _('Connect to Nightscout'), + subtitle: _('Update current data from Nightscout'), + }); + group.add(update_row); + + window._settings.bind('update-data', update_row, 'active', + Gio.SettingsBindFlags.DEFAULT); + + const url_row = new Adw.EntryRow({ title: _('Nightscout URL'), }); @@ -26,8 +36,6 @@ export default class NightscoutPreferences extends ExtensionPreferences { url_row.set_show_apply_button(true); group.add(url_row); - //window._settings.bind('url', url_row, 'text', - // Gio.SettingsBindFlags.DEFAULT); url_row.set_text(window._settings.get_string('url')); url_row.connect('apply', () => { window._settings.set_string('url', url_row.text); diff --git a/nightscout-follower@treehouse.org.za/schemas/org.gnome.shell.extensions.nightscout-follower.gschema.xml b/nightscout-follower@treehouse.org.za/schemas/org.gnome.shell.extensions.nightscout-follower.gschema.xml index ade58e6..9885061 100644 --- a/nightscout-follower@treehouse.org.za/schemas/org.gnome.shell.extensions.nightscout-follower.gschema.xml +++ b/nightscout-follower@treehouse.org.za/schemas/org.gnome.shell.extensions.nightscout-follower.gschema.xml @@ -1,6 +1,11 @@ + + false + Connect to Nightscout + Update current data + "https://API_SECRET@sitename.yourprovider.com" Nightscout URL