Skip to content

Commit

Permalink
update UI every 250ms if necessary, resolve #74
Browse files Browse the repository at this point in the history
  • Loading branch information
UshakovVasilii committed Jan 20, 2018
1 parent 74a5662 commit bf029d7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
10 changes: 10 additions & 0 deletions freon@UshakovVasilii_Github.yahoo.com/commandLineUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const CommandLineUtil = new Lang.Class({

_init: function(){
this._argv = null;
this._updated = false;
},

execute: function(callback) {
Expand Down Expand Up @@ -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){
Expand All @@ -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;
}
Expand Down
22 changes: 21 additions & 1 deletion freon@UshakovVasilii_Github.yahoo.com/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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);
Expand All @@ -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){
Expand Down
13 changes: 12 additions & 1 deletion freon@UshakovVasilii_Github.yahoo.com/udisks2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -112,6 +121,8 @@ const UDisks2 = new Lang.Class({
this._udisksProxies = [];
},

execute: function(callback) {},
execute: function(callback) {
this._updated = true;
},

});

0 comments on commit bf029d7

Please sign in to comment.