Review actions – remove prefs global var
This commit is contained in:
parent
bc259fadb7
commit
95fe445880
1 changed files with 9 additions and 13 deletions
|
@ -10,14 +10,9 @@ const _ = Gettext.gettext;
|
|||
const Common = Metadata.imports.common;
|
||||
|
||||
|
||||
// Settings instance
|
||||
let PiHoleSettings = null;
|
||||
|
||||
|
||||
// Prep
|
||||
function init()
|
||||
{
|
||||
PiHoleSettings = Common.getSettings(Metadata);
|
||||
Common.initTranslations(Metadata);
|
||||
}
|
||||
|
||||
|
@ -26,6 +21,7 @@ function init()
|
|||
function buildPrefsWidget()
|
||||
{
|
||||
// Create
|
||||
let settings = Common.getSettings(Metadata);
|
||||
let prefs = new Gtk.Box({
|
||||
orientation: Gtk.Orientation.VERTICAL,
|
||||
margin_top: 8,
|
||||
|
@ -38,9 +34,9 @@ function buildPrefsWidget()
|
|||
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_increments( 1, 5 );
|
||||
widget.set_value( PiHoleSettings.get_uint( Common.DISABLE_TIME_SETTING ) );
|
||||
widget.set_value( settings.get_uint( Common.DISABLE_TIME_SETTING ) );
|
||||
widget.connect( 'value-changed', function() {
|
||||
PiHoleSettings.set_uint( Common.DISABLE_TIME_SETTING, widget.get_value() );
|
||||
settings.set_uint( Common.DISABLE_TIME_SETTING, widget.get_value() );
|
||||
});
|
||||
_addSetting( prefs, _("Pause time (seconds)"), widget );
|
||||
}
|
||||
|
@ -49,27 +45,27 @@ function buildPrefsWidget()
|
|||
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_increments( 1, 5 );
|
||||
widget.set_value( PiHoleSettings.get_uint( Common.UPDATE_RATE_SETTING ) );
|
||||
widget.set_value( settings.get_uint( Common.UPDATE_RATE_SETTING ) );
|
||||
widget.connect( 'value-changed', function() {
|
||||
PiHoleSettings.set_uint( Common.UPDATE_RATE_SETTING, widget.get_value() );
|
||||
settings.set_uint( Common.UPDATE_RATE_SETTING, widget.get_value() );
|
||||
});
|
||||
_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") });
|
||||
widget.set_text( PiHoleSettings.get_string( Common.API_KEY_SETTING ) );
|
||||
widget.set_text( settings.get_string( Common.API_KEY_SETTING ) );
|
||||
widget.connect( 'changed', function() {
|
||||
PiHoleSettings.set_string( Common.API_KEY_SETTING, widget.get_text() );
|
||||
settings.set_string( Common.API_KEY_SETTING, widget.get_text() );
|
||||
});
|
||||
_addSetting( prefs, _("API key"), widget );
|
||||
}
|
||||
|
||||
{
|
||||
let widget = new Gtk.Entry({ width_chars: 50, tooltip_text: _("URL of pi-hole admin page for API access") });
|
||||
widget.set_text( PiHoleSettings.get_string( Common.URL_SETTING ) );
|
||||
widget.set_text( settings.get_string( Common.URL_SETTING ) );
|
||||
widget.connect( 'changed', function() {
|
||||
PiHoleSettings.set_string( Common.URL_SETTING, widget.get_text() );
|
||||
settings.set_string( Common.URL_SETTING, widget.get_text() );
|
||||
});
|
||||
_addSetting( prefs, _("Pi-Hole URL"), widget );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue