Kaydet (Commit) 27fb5d63 authored tarafından franglais125's avatar franglais125

Finalize the password-less check for updates

üst 10285df8
......@@ -137,6 +137,7 @@ const AptUpdateIndicator = new Lang.Class({
},
_applySettings: function() {
// Parse the various commands
if (this._settings.get_string('update-cmd') !== "")
UPDATE_CMD = PREPEND_CMD + this._settings.get_string('update-cmd');
else
......@@ -147,14 +148,24 @@ const AptUpdateIndicator = new Lang.Class({
else
CHECK_CMD = PREPEND_CMD + STOCK_CHECK_CMD;
if (this._settings.get_boolean('allow-no-passwd'))
CHECK_CMD = this._settings.get_string('check-cmd-no-passwd');
// Remove the periodic check before adding a new one
if (this._TimeoutId)
GLib.source_remove(this._TimeoutId);
let that = this;
let CHECK_INTERVAL = this._settings.get_int('check-interval') * 60;
if (CHECK_INTERVAL)
this._TimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, CHECK_INTERVAL, function(){that._checkUpdates();});
this._TimeoutId = GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT,
CHECK_INTERVAL,
function() {
that._checkUpdates();
return true;
});
// Finalize application of settings
this._checkShowHide();
},
......
......@@ -50,10 +50,25 @@ function buildPrefsWidget(){
settings.bind('transient', buildable.get_object('field_transient'), 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('strip-versions' , buildable.get_object('field_stripversions') , 'active' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('check-cmd' , buildable.get_object('field_checkcmd') , 'text' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('check-cmd-no-passwd' , buildable.get_object('field_checkcmd_no_password') , 'text' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('allow-no-passwd' , buildable.get_object('checkcmd_no_password_checkbutton') , 'active' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('allow-no-passwd' , buildable.get_object('field_checkcmd_no_password') , 'sensitive' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('update-cmd' , buildable.get_object('field_updatecmd') , 'text' , Gio.SettingsBindFlags.DEFAULT);
settings.bind('auto-expand-list', buildable.get_object('field_autoexpandlist'), 'value', Gio.SettingsBindFlags.DEFAULT);
box.show_all();
buildable.get_object('reset_button').connect('clicked', Lang.bind(this, function() {
// restore default settings for the relevant keys
let keys = ['update-cmd',
'check-cmd',
'allow-no-passwd',
'check-cmd-no-passwd'];
keys.forEach(function(val) {
settings.set_value(val, settings.get_default_value(val));
}, this);
}));
return box;
};
......@@ -23,7 +23,7 @@
</object>
<object class="GtkAdjustment" id="Adjust_2">
<property name="lower">0</property>
<property name="upper">2000</property>
<property name="upper">100000</property>
<property name="step_increment">5</property>
</object>
<object class="GtkAdjustment" id="Adjust_3">
......@@ -282,6 +282,30 @@
<property name="row-homogeneous">false</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<property translatable="yes" name="label">Reset to default values</property>
<property name="hexpand">true</property>
<property name="halign">1</property>
<attributes>
<attribute name="weight" value="PANGO_WEIGHT_BOLD"/>
</attributes>
</object>
</child>
<child>
<object class="GtkButton" id="reset_button">
<property name="visible">True</property>
<property name="label">Reset</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkVBox">
<property name="spacing">6</property>
......@@ -314,8 +338,77 @@
</object>
</child>
</object>
</child>
<child>
<object class="GtkGrid">
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Check for updates without a password. Please read the wiki for instructions:</property>
<property name="hexpand">true</property>
<property name="wrap">True</property>
<property name="halign">1</property>
</object>
<packing>
<property name="top_attach">0</property>
<property name="left_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLinkButton" id="homepage_link">
<property name="label" translatable="yes">Wiki</property>
<property name="hexpand">true</property>
<property name="halign">1</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events"/>
<property name="relief">none</property>
<property name="uri">https://github.com/franglais125/apt-update-indicator/wiki</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="left_attach">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="checkcmd_no_password_checkbutton">
<property name="label" translatable="yes">Enabled</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="draw_indicator">True</property>
<property name="margin_top">12</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="left_attach">0</property>
</packing>
</child>
<child>
<object class="GtkVBox">
<property name="spacing">6</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Command to check for updates with no password</property>
<property name="hexpand">true</property>
<property name="halign">1</property>
</object>
</child>
<child>
<object class="GtkEntry" id="field_checkcmd_no_password">
</object>
</child>
</object>
<packing>
<property name="top_attach">3</property>
<property name="left_attach">0</property>
</packing>
</child>
</object>
</child>
</object>
</child>
......
......@@ -56,6 +56,18 @@
<description>Command to run to check for updated packages.</description>
</key>
<key name="allow-no-passwd" type="b">
<default>false</default>
<summary>Allow checks for updates without a passwrd</summary>
<description></description>
</key>
<key name="check-cmd-no-passwd" type="s">
<default>"/usr/bin/sudo /usr/local/bin/updater"</default>
<summary>Command to run to check for updates without password.</summary>
<description>Command to run to check for updates without passowrd.</description>
</key>
<key name="update-cmd" type="s">
<default>"apt upgrade -y"</default>
<summary>Command to run to update packages.</summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment