summaryrefslogtreecommitdiffstats
path: root/extension.js
diff options
context:
space:
mode:
Diffstat (limited to 'extension.js')
-rw-r--r--extension.js45
1 files changed, 27 insertions, 18 deletions
diff --git a/extension.js b/extension.js
index 491e935..d52ccb6 100644
--- a/extension.js
+++ b/extension.js
@@ -1,9 +1,9 @@
/* jshint moz: true, multistr: true */
/* global imports */
const Gio = imports.gi.Gio;
-const Mainloop = imports.mainloop;
const GObject = imports.gi.GObject;
const GLib = imports.gi.GLib;
+const Clutter = imports.gi.Clutter;
const Lang = imports.lang;
const St = imports.gi.St;
const Main = imports.ui.main;
@@ -60,9 +60,10 @@ const LocationProxy = Gio.DBusProxy.makeProxyWrapper(LocationInterface);
// global variables
let client;
-const ISS_Above = new GObject.Class({
+const ISS_Above = new Lang.Class({
Name: 'ISS_Above',
Extends: GObject.Object,
+
Signals: {
'processed_data': {
param_types: [
@@ -72,7 +73,7 @@ const ISS_Above = new GObject.Class({
},
_init: function(params) {
- this.parent(params);
+ this.parent();
this.managerProxy = new ManagerProxy(Gio.DBus.system,
'org.freedesktop.GeoClue2', '/org/freedesktop/GeoClue2/Manager');
@@ -84,6 +85,7 @@ const ISS_Above = new GObject.Class({
this.button = null;
this.label = null;
this.task_queue = 2; // number of async process to complete
+ print('_init, task_queue = ' + this.task_queue);
this.timeout_source = null;
this.clientProxy = new ClientProxy(Gio.DBus.system,
@@ -94,30 +96,31 @@ const ISS_Above = new GObject.Class({
this.clientProxy.connectSignal('LocationUpdated',
Lang.bind(this, this.onLocationUpdated));
this.clientProxy.StartRemote();
- this.connect('processed_data', Lang.bind(this, this.processResult));
+ this.connect('processed_data', () => this.processResult());
},
getISScoords: function (cb_process) {
- let self = this;
let iss_api = Gio.file_new_for_uri(API_URL);
- iss_api.load_contents_async(null, function(iss_api, result) {
- self.iss_coords = JSON.parse(iss_api.load_contents_finish(result)[1]);
- print('self.iss_coords = ' + self.iss_coords.toSource());
+ iss_api.load_contents_async(null, (iss_api, result) => {
+ this.iss_coords = JSON.parse(iss_api.load_contents_finish(result)[1]);
+ print('this.iss_coords = ' + this.iss_coords.toSource());
+ print('cb_process = ' + cb_process);
if (cb_process !== undefined) {
cb_process();
}
else {
- self.emit('processed_data');
+ print('emitting "processed_data" signal');
+ this.emit('processed_data');
}
});
},
run: function() {
- let self = this;
- this.getISScoords(function () {
+ this.getISScoords(() => {
print('run: processing new coords');
- self.task_queue = 1;
- self.processResult();
+ this.task_queue = 1;
+ print('run, task_queue = ' + this.task_queue);
+ this.processResult();
});
return GLib.SOURCE_CONTINUE;
},
@@ -183,6 +186,7 @@ const ISS_Above = new GObject.Class({
print('processResult, start: task_queue = ' + this.task_queue);
this.task_queue--;
+ print('processResult, deciding: task_queue = ' + this.task_queue);
if (this.task_queue === 0) {
print('processResult: our location: ' +
this.current_location.toSource());
@@ -198,15 +202,20 @@ const ISS_Above = new GObject.Class({
// https://developer.gnome.org/clutter/stable/ClutterActor.html
if (dist < SOUGHT_DISTANCE) {
// Make the label text completely opaque
- this.label.set_opacity(255);
+ // this.label.set_opacity(255);
+ this.label.set_background_color(
+ Clutter.Color.get_static(Clutter.StaticColor.RED));
print('Make label opaque');
}
else {
// Make the label text completely transparent
- this.label.set_opacity(0);
+ // this.label.set_opacity(0);
+ this.label.set_background_color(
+ Clutter.Color.get_static(Clutter.StaticColor.GREEN));
print('Make label transparent');
}
}
+ return false;
}
});
@@ -237,12 +246,12 @@ function enable() {
client.button = button;
client.label = label;
- client.timeout_source = Mainloop.timeout_add_seconds(
- CHECK_INTERVAL, Lang.bind(client, client.run));
+ client.timeout_source = GLib.timeout_add_seconds(
+ CHECK_INTERVAL, () => client.run());
}
function disable() {
print('DISABLING ISS Above');
Main.panel._rightBox.remove_child(client.button);
- Mainloop.source_remove(client.timeout_source);
+ GLib.Source.destroy(client.timeout_source);
}