Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code style cleanup, support for window stealing, support for right-click for settings #300

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
70 changes: 35 additions & 35 deletions convenience.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ function getSettings(schema) {
throw new Error('Schema ' + schema + ' could not be found for extension '
+ extension.metadata.uuid + '. Please check your installation.');

return new Gio.Settings({ settings_schema: schemaObj });
return new Gio.Settings({
settings_schema: schemaObj
});
}

/**
Expand All @@ -84,11 +86,10 @@ const BasicHandler = new Lang.Class({
this._storage = new Object();
},

add: function(/*unlimited 3-long array arguments*/) {

// convert arguments object to array, concatenate with generic
add: function(/* unlimited 3-long array arguments */) {
// Convert arguments object to array, concatenate with generic
let args = Array.concat('generic', Array.slice(arguments));
// call addWithLabel with ags as if they were passed arguments
// Call addWithLabel with ags as if they were passed arguments
this.addWithLabel.apply(this, args);
},

Expand All @@ -97,38 +98,39 @@ const BasicHandler = new Lang.Class({
this.removeWithLabel(label);
},

addWithLabel: function( label /* plus unlimited 3-long array arguments*/) {

if(this._storage[label] == undefined)
addWithLabel: function(label /* plus unlimited 3-long array arguments*/) {
if (this._storage[label] == undefined)
this._storage[label] = new Array();

// skip first element of the arguments
for( let i = 1; i < arguments.length; i++ ) {
this._storage[label].push( this._create(arguments[i]) );
// Skip first element of the arguments
for (let i = 1; i < arguments.length; i++) {
this._storage[label].push( this._create(arguments[i]));
}

},

removeWithLabel: function(label) {

if(this._storage[label]) {
for( let i = 0; i < this._storage[label].length; i++ ) {
if (this._storage[label]) {
for (let i = 0; i < this._storage[label].length; i++)
this._remove(this._storage[label][i]);
}

delete this._storage[label];
}
},

/* Virtual methods to be implemented by subclass */
// create single element to be stored in the storage structure
// Virtual methods to be implemented by subclass

/**
* Create single element to be stored in the storage structure
*/
_create: function(item) {
throw new Error('no implementation of _create in ' + this);
throw new Error('no implementation of _create in ' + this);
},

// correctly delete single element
/**
* Correctly delete single element
*/
_remove: function(item) {
throw new Error('no implementation of _remove in ' + this);
throw new Error('no implementation of _remove in ' + this);
}
});

Expand All @@ -140,17 +142,16 @@ const GlobalSignalsHandler = new Lang.Class({
Extends: BasicHandler,

_create: function(item) {
let object = item[0];
let event = item[1];
let callback = item[2]
let id = object.connect(event, callback);

let object = item[0];
let event = item[1];
let callback = item[2]
let id = object.connect(event, callback);

return [object, id];
return [object, id];
},

_remove: function(item) {
item[0].disconnect(item[1]);
item[0].disconnect(item[1]);
}
});

Expand All @@ -163,14 +164,13 @@ const InjectionsHandler = new Lang.Class({
Extends: BasicHandler,

_create: function(item) {
let object = item[0];
let name = item[1];
let injectedFunction = item[2];
let original = object[name];

let object = item[0];
let name = item[1];
let injectedFunction = item[2];
let original = object[name];

object[name] = injectedFunction;
return [object, name, injectedFunction, original];
object[name] = injectedFunction;
return [object, name, injectedFunction, original];
},

_remove: function(item) {
Expand Down
Loading