Review actions – remove Lang use plus enable/disable testing fixes
This commit is contained in:
parent
4d2923ae78
commit
74f7529cf7
3 changed files with 32 additions and 33 deletions
|
@ -2,7 +2,6 @@
|
||||||
const { Atk, Gio, GLib, GObject, Gtk, Soup, St } = imports.gi;
|
const { Atk, Gio, GLib, GObject, Gtk, Soup, St } = imports.gi;
|
||||||
const { main, panelMenu, popupMenu } = imports.ui;
|
const { main, panelMenu, popupMenu } = imports.ui;
|
||||||
const ExtensionUtils = imports.misc.extensionUtils
|
const ExtensionUtils = imports.misc.extensionUtils
|
||||||
const Lang = imports.lang;
|
|
||||||
const Mainloop = imports.mainloop;
|
const Mainloop = imports.mainloop;
|
||||||
|
|
||||||
const IndicatorName = 'pi-hole';
|
const IndicatorName = 'pi-hole';
|
||||||
|
@ -127,17 +126,17 @@ class PiHole extends panelMenu.Button
|
||||||
|
|
||||||
// .. control buttons
|
// .. control buttons
|
||||||
this.PauseButton = new popupMenu.PopupMenuItem(_("Pause temporarily"), {style_class:"pihole-indent"});
|
this.PauseButton = new popupMenu.PopupMenuItem(_("Pause temporarily"), {style_class:"pihole-indent"});
|
||||||
this.PauseButton.connect('activate', Lang.bind(this, function() {
|
this.PauseButton.connect('activate', () => {
|
||||||
this.onPauseButton();
|
this.onPauseButton();
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
});
|
||||||
this.menu.addMenuItem(this.PauseButton);
|
this.menu.addMenuItem(this.PauseButton);
|
||||||
//
|
//
|
||||||
this.EnableDisableButton = new popupMenu.PopupMenuItem(_("Disable"), {style_class:"pihole-indent"});
|
this.EnableDisableButton = new popupMenu.PopupMenuItem(_("Disable"), {style_class:"pihole-indent"});
|
||||||
this.EnableDisableButton.connect('activate', Lang.bind(this, function() {
|
this.EnableDisableButton.connect('activate', () => {
|
||||||
this.onEnableDisableButton();
|
this.onEnableDisableButton();
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
});
|
||||||
this.menu.addMenuItem(this.EnableDisableButton);
|
this.menu.addMenuItem(this.EnableDisableButton);
|
||||||
|
|
||||||
// .. sep
|
// .. sep
|
||||||
|
@ -145,10 +144,10 @@ class PiHole extends panelMenu.Button
|
||||||
|
|
||||||
// .. settings
|
// .. settings
|
||||||
this.SettingsButton = new popupMenu.PopupMenuItem(_("Settings"), {style_class:"pihole-indent"});
|
this.SettingsButton = new popupMenu.PopupMenuItem(_("Settings"), {style_class:"pihole-indent"});
|
||||||
this.SettingsButton.connect('activate', Lang.bind(this, function() {
|
this.SettingsButton.connect('activate', () => {
|
||||||
this.onSettingsButton();
|
this.onSettingsButton();
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
});
|
||||||
this.menu.addMenuItem(this.SettingsButton);
|
this.menu.addMenuItem(this.SettingsButton);
|
||||||
|
|
||||||
// Get initial status (starts timer for next)
|
// Get initial status (starts timer for next)
|
||||||
|
@ -156,18 +155,18 @@ class PiHole extends panelMenu.Button
|
||||||
|
|
||||||
// Watch for settings changes
|
// Watch for settings changes
|
||||||
this.SettingChangedHandlerIds = [
|
this.SettingChangedHandlerIds = [
|
||||||
PiHoleExt.Settings.connect("changed::" + Common.URL_SETTING, Lang.bind(this, function() {
|
PiHoleExt.Settings.connect("changed::" + Common.URL_SETTING, () => {
|
||||||
PiHoleExt.Button.Url = PiHoleExt.Settings.get_string( Common.URL_SETTING );
|
PiHoleExt.Button.Url = PiHoleExt.Settings.get_string( Common.URL_SETTING );
|
||||||
})),
|
}),
|
||||||
PiHoleExt.Settings.connect("changed::" + Common.API_KEY_SETTING, Lang.bind(this, function() {
|
PiHoleExt.Settings.connect("changed::" + Common.API_KEY_SETTING, () =>{
|
||||||
PiHoleExt.Button.ApiKey = PiHoleExt.Settings.get_string( Common.API_KEY_SETTING);
|
PiHoleExt.Button.ApiKey = PiHoleExt.Settings.get_string( Common.API_KEY_SETTING);
|
||||||
})),
|
}),
|
||||||
PiHoleExt.Settings.connect("changed::" + Common.UPDATE_RATE_SETTING, Lang.bind(this, function() {
|
PiHoleExt.Settings.connect("changed::" + Common.UPDATE_RATE_SETTING, () => {
|
||||||
PiHoleExt.Button.UpdateTime = PiHoleExt.Settings.get_uint( Common.UPDATE_RATE_SETTING );
|
PiHoleExt.Button.UpdateTime = PiHoleExt.Settings.get_uint( Common.UPDATE_RATE_SETTING );
|
||||||
})),
|
}),
|
||||||
PiHoleExt.Settings.connect("changed::" + Common.DISABLE_TIME_SETTING, Lang.bind(this, function() {
|
PiHoleExt.Settings.connect("changed::" + Common.DISABLE_TIME_SETTING, () => {
|
||||||
PiHoleExt.Button.DisableTime = PiHoleExt.Settings.get_uint( Common.DISABLE_TIME_SETTING );
|
PiHoleExt.Button.DisableTime = PiHoleExt.Settings.get_uint( Common.DISABLE_TIME_SETTING );
|
||||||
}))
|
})
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,10 +250,10 @@ class PiHole extends panelMenu.Button
|
||||||
});
|
});
|
||||||
|
|
||||||
// Now do it again in a bit
|
// Now do it again in a bit
|
||||||
this.StatusEvent = GLib.timeout_add_seconds(0, this.UpdateTime, Lang.bind(this, function() {
|
this.StatusEvent = GLib.timeout_add_seconds(0, this.UpdateTime, () => {
|
||||||
this.getPiHoleStatus();
|
this.getPiHoleStatus();
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
catch (err)
|
catch (err)
|
||||||
{
|
{
|
||||||
|
@ -272,10 +271,10 @@ class PiHole extends panelMenu.Button
|
||||||
|
|
||||||
// Now ask for status again a second after it should be re-enabled
|
// Now ask for status again a second after it should be re-enabled
|
||||||
Mainloop.source_remove(PiHoleExt.Button.StatusEvent);
|
Mainloop.source_remove(PiHoleExt.Button.StatusEvent);
|
||||||
this.StatusEvent = GLib.timeout_add_seconds(0, this.DisableTime + 1, Lang.bind(this, function() {
|
this.StatusEvent = GLib.timeout_add_seconds(0, this.DisableTime + 1, () => {
|
||||||
this.getPiHoleStatus();
|
this.getPiHoleStatus();
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,10 +297,10 @@ class PiHole extends panelMenu.Button
|
||||||
|
|
||||||
// Restart status request cycle since we just got an up-to-date status
|
// Restart status request cycle since we just got an up-to-date status
|
||||||
Mainloop.source_remove(PiHoleExt.Button.StatusEvent);
|
Mainloop.source_remove(PiHoleExt.Button.StatusEvent);
|
||||||
this.StatusEvent = GLib.timeout_add_seconds(0, this.UpdateTime, Lang.bind(this, function() {
|
this.StatusEvent = GLib.timeout_add_seconds(0, this.UpdateTime, () => {
|
||||||
this.getPiHoleStatus();
|
this.getPiHoleStatus();
|
||||||
return 0;
|
return 0;
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -405,7 +404,7 @@ function disable()
|
||||||
this.SettingChangedHandlerIds = null;
|
this.SettingChangedHandlerIds = null;
|
||||||
|
|
||||||
// Finish off
|
// Finish off
|
||||||
mainloop.source_remove(PiHoleExt.Button.StatusEvent);
|
Mainloop.source_remove(PiHoleExt.Button.StatusEvent);
|
||||||
PiHoleExt.Button.destroy();
|
PiHoleExt.Button.destroy();
|
||||||
PiHoleExt.Button = null;
|
PiHoleExt.Button = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
"description": "Status and basic controls of local Pi-Hole",
|
"description": "Status and basic controls of local Pi-Hole",
|
||||||
"settings-schema": "org.gnome.shell.extensions.fnxweb-pi-hole",
|
"settings-schema": "org.gnome.shell.extensions.fnxweb-pi-hole",
|
||||||
"gettext-domain": "gnome-shell-extension-fnxweb-pi-hole",
|
"gettext-domain": "gnome-shell-extension-fnxweb-pi-hole",
|
||||||
"version": 2
|
"version": 3
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ const Common = Metadata.imports.common;
|
||||||
|
|
||||||
|
|
||||||
// Settings instance
|
// Settings instance
|
||||||
let settings;
|
let PiHoleSettings = null;
|
||||||
|
|
||||||
|
|
||||||
// Prep
|
// Prep
|
||||||
function init()
|
function init()
|
||||||
{
|
{
|
||||||
settings = Common.getSettings(Metadata);
|
PiHoleSettings = Common.getSettings(Metadata);
|
||||||
Common.initTranslations(Metadata);
|
Common.initTranslations(Metadata);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ function buildPrefsWidget()
|
||||||
let widget = new Gtk.SpinButton({ tooltip_text: _("How long to pause Pi-Hole for when it is paused") });
|
let widget = new Gtk.SpinButton({ tooltip_text: _("How long to pause Pi-Hole for when it is paused") });
|
||||||
widget.set_range( 1, 900 );
|
widget.set_range( 1, 900 );
|
||||||
widget.set_increments( 1, 5 );
|
widget.set_increments( 1, 5 );
|
||||||
widget.set_value( settings.get_uint( Common.DISABLE_TIME_SETTING ) );
|
widget.set_value( PiHoleSettings.get_uint( Common.DISABLE_TIME_SETTING ) );
|
||||||
widget.connect( 'value-changed', function() {
|
widget.connect( 'value-changed', function() {
|
||||||
settings.set_uint( Common.DISABLE_TIME_SETTING, widget.get_value() );
|
PiHoleSettings.set_uint( Common.DISABLE_TIME_SETTING, widget.get_value() );
|
||||||
});
|
});
|
||||||
_addSetting( prefs, _("Pause time (seconds)"), widget );
|
_addSetting( prefs, _("Pause time (seconds)"), widget );
|
||||||
}
|
}
|
||||||
|
@ -49,27 +49,27 @@ function buildPrefsWidget()
|
||||||
let widget = new Gtk.SpinButton({ tooltip_text: _("Rate at which Pi-Hole is normally polled for its status") });
|
let widget = new Gtk.SpinButton({ tooltip_text: _("Rate at which Pi-Hole is normally polled for its status") });
|
||||||
widget.set_range( 1, 900 );
|
widget.set_range( 1, 900 );
|
||||||
widget.set_increments( 1, 5 );
|
widget.set_increments( 1, 5 );
|
||||||
widget.set_value( settings.get_uint( Common.UPDATE_RATE_SETTING ) );
|
widget.set_value( PiHoleSettings.get_uint( Common.UPDATE_RATE_SETTING ) );
|
||||||
widget.connect( 'value-changed', function() {
|
widget.connect( 'value-changed', function() {
|
||||||
settings.set_uint( Common.UPDATE_RATE_SETTING, widget.get_value() );
|
PiHoleSettings.set_uint( Common.UPDATE_RATE_SETTING, widget.get_value() );
|
||||||
});
|
});
|
||||||
_addSetting( prefs, _("Update rate (seconds)"), widget );
|
_addSetting( prefs, _("Update rate (seconds)"), widget );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let widget = new Gtk.Entry({ width_chars: 50, tooltip_text: _("API key of pi-hole from settings/api page") });
|
let widget = new Gtk.Entry({ width_chars: 50, tooltip_text: _("API key of pi-hole from settings/api page") });
|
||||||
widget.set_text( settings.get_string( Common.API_KEY_SETTING ) );
|
widget.set_text( PiHoleSettings.get_string( Common.API_KEY_SETTING ) );
|
||||||
widget.connect( 'changed', function() {
|
widget.connect( 'changed', function() {
|
||||||
settings.set_string( Common.API_KEY_SETTING, widget.get_text() );
|
PiHoleSettings.set_string( Common.API_KEY_SETTING, widget.get_text() );
|
||||||
});
|
});
|
||||||
_addSetting( prefs, _("API key"), widget );
|
_addSetting( prefs, _("API key"), widget );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let widget = new Gtk.Entry({ width_chars: 50, tooltip_text: _("URL of pi-hole admin page for API access") });
|
let widget = new Gtk.Entry({ width_chars: 50, tooltip_text: _("URL of pi-hole admin page for API access") });
|
||||||
widget.set_text( settings.get_string( Common.URL_SETTING ) );
|
widget.set_text( PiHoleSettings.get_string( Common.URL_SETTING ) );
|
||||||
widget.connect( 'changed', function() {
|
widget.connect( 'changed', function() {
|
||||||
settings.set_string( Common.URL_SETTING, widget.get_text() );
|
PiHoleSettings.set_string( Common.URL_SETTING, widget.get_text() );
|
||||||
});
|
});
|
||||||
_addSetting( prefs, _("Pi-Hole URL"), widget );
|
_addSetting( prefs, _("Pi-Hole URL"), widget );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue