mirror of
https://github.com/morgan9e/gnome-shell-extension-freon
synced 2026-04-14 00:14:14 +09:00
update UI every 250ms if necessary, resolve #74
This commit is contained in:
@@ -7,6 +7,7 @@ const CommandLineUtil = new Lang.Class({
|
||||
|
||||
_init: function(){
|
||||
this._argv = null;
|
||||
this._updated = false;
|
||||
},
|
||||
|
||||
execute: function(callback) {
|
||||
@@ -35,6 +36,7 @@ const CommandLineUtil = new Lang.Class({
|
||||
stdout.close(null);
|
||||
GLib.source_remove(childWatch);
|
||||
this._output = output;
|
||||
this._updated = true;
|
||||
callback();
|
||||
}));
|
||||
} catch(e){
|
||||
@@ -46,6 +48,14 @@ const CommandLineUtil = new Lang.Class({
|
||||
return this._argv != null;
|
||||
},
|
||||
|
||||
get updated (){
|
||||
return this._updated;
|
||||
},
|
||||
|
||||
set updated (updated){
|
||||
this._updated = updated;
|
||||
},
|
||||
|
||||
destroy: function(){
|
||||
this._argv = null;
|
||||
}
|
||||
|
||||
@@ -84,6 +84,11 @@ const FreonMenuButton = new Lang.Class({
|
||||
this._querySensors();
|
||||
|
||||
this._addTimer();
|
||||
this._updateUITimeoutId = Mainloop.timeout_add(250, Lang.bind(this, function (){
|
||||
this._updateUI();
|
||||
// readd to update queue
|
||||
return true;
|
||||
}));
|
||||
},
|
||||
|
||||
_createHotItem: function(s, showIcon, gicon){
|
||||
@@ -218,6 +223,7 @@ const FreonMenuButton = new Lang.Class({
|
||||
this._destroyDriveUtility();
|
||||
this._destroyGpuUtility();
|
||||
Mainloop.source_remove(this._timeoutId);
|
||||
Mainloop.source_remove(this._updateUITimeoutId);
|
||||
|
||||
for each (let signal in this._settingChangedSignals){
|
||||
this._settings.disconnect(signal);
|
||||
@@ -232,7 +238,21 @@ const FreonMenuButton = new Lang.Class({
|
||||
}));
|
||||
}
|
||||
}
|
||||
this._updateDisplay(); // #74
|
||||
},
|
||||
|
||||
_updateUI: function(){
|
||||
let needUpdate = false;
|
||||
for each (let sensor in this._utils) {
|
||||
if (sensor.available && sensor.updated) {
|
||||
// global.log(sensor + ' updated');
|
||||
sensor.updated = false;
|
||||
needUpdate = true;
|
||||
}
|
||||
}
|
||||
if(needUpdate) {
|
||||
this._updateDisplay(); // #74
|
||||
// global.log('update display');
|
||||
}
|
||||
},
|
||||
|
||||
_fixNames: function(sensors){
|
||||
|
||||
@@ -41,12 +41,21 @@ const UDisks2 = new Lang.Class({
|
||||
this._udisksProxies = proxies;
|
||||
callback();
|
||||
}));
|
||||
this._updated = true;
|
||||
},
|
||||
|
||||
get available(){
|
||||
return this._udisksProxies.length > 0;
|
||||
},
|
||||
|
||||
get updated (){
|
||||
return this._updated;
|
||||
},
|
||||
|
||||
set updated (updated){
|
||||
this._updated = updated;
|
||||
},
|
||||
|
||||
// creates a list of sensor objects from the list of proxies given
|
||||
get temp() {
|
||||
return this._udisksProxies.filter(function(proxy) {
|
||||
@@ -112,6 +121,8 @@ const UDisks2 = new Lang.Class({
|
||||
this._udisksProxies = [];
|
||||
},
|
||||
|
||||
execute: function(callback) {},
|
||||
execute: function(callback) {
|
||||
this._updated = true;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user