Compare commits

..

1 Commits

Author SHA1 Message Date
Florian Müllner
9d133d8ebb st: Guard against spec being invalided during shadow creation
If an actor is pending a relaying when get_allocation_box() is called,
the method forces an allocation update. In case of StWidget, this might
then result in a style update and a consecutive invalidation of the
shadow spec - we will then try to create a shadow specified by random
memory, with undefined (though likely fatal) consequences.

Guard against this by taking a temporary reference during the function
call.

https://bugzilla.gnome.org/show_bug.cgi?id=788908
2018-02-20 17:40:40 +01:00
138 changed files with 6660 additions and 6431 deletions

30
HACKING
View File

@@ -136,13 +136,13 @@ GObjects, although this feature isn't used very often in the Shell itself.
Name: 'IconLabelMenuItem',
Extends: PopupMenu.PopupMenuBaseItem,
_init(icon, label) {
_init: function(icon, label) {
this.parent({ reactive: false });
this.actor.add_child(icon);
this.actor.add_child(label);
},
open() {
open: function() {
log("menu opened!");
}
});
@@ -173,15 +173,15 @@ you to inherit from a type to use it, you can do so:
Name: 'MyClutterActor',
Extends: Clutter.Actor,
vfunc_get_preferred_width(actor, forHeight) {
vfunc_get_preferred_width: function(actor, forHeight) {
return [100, 100];
},
vfunc_get_preferred_height(actor, forWidth) {
vfunc_get_preferred_height: function(actor, forWidth) {
return [100, 100];
},
vfunc_paint(actor) {
vfunc_paint: function(actor) {
let alloc = this.get_allocation_box();
Cogl.set_source_color4ub(255, 0, 0, 255);
Cogl.rectangle(alloc.x1, alloc.y1,
@@ -218,14 +218,14 @@ the actor itself:
var MyClass = new Lang.Class({
Name: 'MyClass',
_init() {
_init: function() {
this.actor = new St.Button({ text: "This is a button" });
this.actor._delegate = this;
this.actor.connect('clicked', this._onClicked.bind(this));
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
},
_onClicked(actor) {
_onClicked: function(actor) {
actor.set_label("You clicked the button!");
}
});
@@ -252,13 +252,11 @@ invoked, not to the value of this where the closure is created, because "this"
is a keyword with a value passed in at function invocation time, it is not a
variable that can be captured in closures.
All closures should be wrapped with Function.prototype.bind or use arrow
notation.
All closures should be wrapped with a Lang.bind.
const Lang = imports.lang;
let closure1 = () => { this._fnorbate(); };
let closure2 = this._fnorbate.bind(this);
let closure = Lang.bind(this, function() { this._fnorbate(); });
A more realistic example would be connecting to a signal on a method of a
prototype:
@@ -267,12 +265,12 @@ prototype:
const FnorbLib = imports.fborbLib;
var MyClass = new Lang.Class({
_init() {
_init: function() {
let fnorb = new FnorbLib.Fnorb();
fnorb.connect('frobate', this._onFnorbFrobate.bind(this));
fnorb.connect('frobate', Lang.bind(this, this._onFnorbFrobate));
},
_onFnorbFrobate(fnorb) {
_onFnorbFrobate: function(fnorb) {
this._updateFnorb();
}
});
@@ -311,7 +309,7 @@ property.
var MyClass = new Lang.Class({
Name: 'MyClass',
_init() {
_init: function() {
this.actor = new St.BoxLayout();
this._position = 0;
},

42
NEWS
View File

@@ -1,45 +1,3 @@
3.27.91
=======
* Fix wrong bluetooth state when disabled by HW airplane mode [Mario; #789110]
* Dump javascript stack on aborts, traps and segfaults [Marco; #789237]
* Allow Escape to "cancel" top bar focus [Stefano; #671121]
* Fix leaving the overview erroneously on window hover [Carlos; #784545]
* Add keyboard accessibility dialog [Olivier; #788564]
* Port to libnm [Lubomir, Florian; #789811]
* Don't pop up on-screen-keyboard on touch events [Florian, Carlos; #788188]
* Improve the on-screen-keyboard [Carlos; !9, #46]
* Add Thunderbolt support [Christian; !14]
* Don't lock immediately on login after a wayland session crash [Florian; !17]
* Respect cursor's hot x/y coordinates when recording [Florian Z.; #792860]
* Allow closing windows and apps during <alt>Tab [Florian, Mario; #620106]
* Fix small app folder icons when using HiDPI [Nikita; #792259]
* Make sassc a mandatory build dependency [Mario; #792822]
* Misc. bug fixes [Florian, Marco, Alessandro, Gautier, Jeremy, Bastien, Ray,
Carlos, Didier, Exalm, Rafal; #789231, #789277, #788542, #789103, #779974,
#788931, #776940, #786987, #791007, #791233, #791148, #706191, #791655,
#791487, #779413, #787845, #10, #788627, #792354, #792616, #781329, #780957,
#33, #740142, !38, !23]
Contributors:
Jeremy Bicha, Alessandro Bono, Nikita Churaev, Piotr Drąg, Exalm,
Stefano Facchini, Olivier Fourdan, Carlos Garnacho, Christian Kellner,
Rafal Luzynski, Iñigo Martínez, Florian Müllner, Bastien Nocera,
Gautier Pelloux-Prayer, Mario Sanchez Prada, Lubomir Rintel, Didier Roche,
Jakub Steiner, Ray Strode, Marco Trevisan (Treviño), Florian Zwoch
Translators:
Mingcong Bai [zh_CN], Hannie Dumoleyn [nl], Khaled Hosny [ar],
Kjartan Maraas [nb], Petr Kovar [cs], Marek Cernocky [cs],
Aurimas Černius [lt], Yosef Or Boczko [he], Kukuh Syafaat [id],
Sveinn í Felli [is], Jordi Mas [ca], Daniel Mustieles [es], Fabio Tomat [fur],
Rūdolfs Mazurs [lv], Emin Tufan Çetin [tr], Anders Jonsson [sv],
Matej Urbančič [sl], Jiri Grönroos [fi], Tim Sabsch [de], Gil Forcada [ca],
Dušan Kazik [sk], Balázs Meskó [hu], Piotr Drąg [pl], Tong Hui [zh_CN],
Fran Dieguez [gl], Enrico Nicoletto [pt_BR], gogo [hr],
Baurzhan Muftakhidinov [kk], Robert Antoni Buj Gelonch [ca],
Bruce Cowan [en_GB], Борисав Живановић [sr], Милош Поповић [sr@latin],
Марко Костић [sr]
3.27.1
======
* Fix using icon-name strings with PopupImageMenuItems [Florian; #789018]

View File

@@ -34,16 +34,16 @@ function stripPrefix(string, prefix) {
var Application = new Lang.Class({
Name: 'Application',
_init() {
_init: function() {
GLib.set_prgname('gnome-shell-extension-prefs');
this.application = new Gtk.Application({
application_id: 'org.gnome.shell.ExtensionPrefs',
flags: Gio.ApplicationFlags.HANDLES_COMMAND_LINE
});
this.application.connect('activate', this._onActivate.bind(this));
this.application.connect('command-line', this._onCommandLine.bind(this));
this.application.connect('startup', this._onStartup.bind(this));
this.application.connect('activate', Lang.bind(this, this._onActivate));
this.application.connect('command-line', Lang.bind(this, this._onCommandLine));
this.application.connect('startup', Lang.bind(this, this._onStartup));
this._extensionPrefsModules = {};
@@ -52,7 +52,7 @@ var Application = new Lang.Class({
this._skipMainWindow = false;
},
_extensionAvailable(uuid) {
_extensionAvailable: function(uuid) {
let extension = ExtensionUtils.extensions[uuid];
if (!extension)
@@ -64,7 +64,7 @@ var Application = new Lang.Class({
return true;
},
_getExtensionPrefsModule(extension) {
_getExtensionPrefsModule: function(extension) {
let uuid = extension.metadata.uuid;
if (this._extensionPrefsModules.hasOwnProperty(uuid))
@@ -79,7 +79,7 @@ var Application = new Lang.Class({
return prefsModule;
},
_selectExtension(uuid) {
_selectExtension: function(uuid) {
if (!this._extensionAvailable(uuid))
return;
@@ -114,7 +114,7 @@ var Application = new Lang.Class({
dialog.show();
},
_buildErrorUI(extension, exc) {
_buildErrorUI: function(extension, exc) {
let box = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL });
let label = new Gtk.Label({
label: _("There was an error loading the preferences dialog for %s:").format(extension.metadata.name)
@@ -127,7 +127,9 @@ var Application = new Lang.Class({
errortext += 'Stack trace:\n';
// Indent stack trace.
errortext += exc.stack.split('\n').map(line => ' ' + line).join('\n');
errortext += exc.stack.split('\n').map(function(line) {
return ' ' + line;
}).join('\n');
let scroll = new Gtk.ScrolledWindow({ vexpand: true });
let buffer = new Gtk.TextBuffer({ text: errortext });
@@ -140,7 +142,7 @@ var Application = new Lang.Class({
return box;
},
_buildUI(app) {
_buildUI: function(app) {
this._window = new Gtk.ApplicationWindow({ application: app,
window_position: Gtk.WindowPosition.CENTER });
@@ -162,28 +164,28 @@ var Application = new Lang.Class({
this._window.add(scroll);
this._extensionSelector = new Gtk.ListBox({ selection_mode: Gtk.SelectionMode.NONE });
this._extensionSelector.set_sort_func(this._sortList.bind(this));
this._extensionSelector.set_header_func(this._updateHeader.bind(this));
this._extensionSelector.set_sort_func(Lang.bind(this, this._sortList));
this._extensionSelector.set_header_func(Lang.bind(this, this._updateHeader));
scroll.add(this._extensionSelector);
this._shellProxy = new GnomeShellProxy(Gio.DBus.session, 'org.gnome.Shell', '/org/gnome/Shell');
this._shellProxy.connectSignal('ExtensionStatusChanged', (proxy, senderName, [uuid, state, error]) => {
this._shellProxy.connectSignal('ExtensionStatusChanged', Lang.bind(this, function(proxy, senderName, [uuid, state, error]) {
if (ExtensionUtils.extensions[uuid] !== undefined)
this._scanExtensions();
});
}));
this._window.show_all();
},
_sortList(row1, row2) {
_sortList: function(row1, row2) {
let name1 = ExtensionUtils.extensions[row1.uuid].metadata.name;
let name2 = ExtensionUtils.extensions[row2.uuid].metadata.name;
return name1.localeCompare(name2);
},
_updateHeader(row, before) {
_updateHeader: function(row, before) {
if (!before || row.get_header())
return;
@@ -191,26 +193,27 @@ var Application = new Lang.Class({
row.set_header(sep);
},
_scanExtensions() {
_scanExtensions: function() {
let finder = new ExtensionUtils.ExtensionFinder();
finder.connect('extension-found', this._extensionFound.bind(this));
finder.connect('extension-found', Lang.bind(this, this._extensionFound));
finder.scanExtensions();
this._extensionsLoaded();
},
_extensionFound(finder, extension) {
_extensionFound: function(finder, extension) {
let row = new ExtensionRow(extension.uuid);
row.prefsButton.visible = this._extensionAvailable(row.uuid);
row.prefsButton.connect('clicked', () => {
this._selectExtension(row.uuid);
});
row.prefsButton.connect('clicked', Lang.bind(this,
function() {
this._selectExtension(row.uuid);
}));
row.show_all();
this._extensionSelector.add(row);
},
_extensionsLoaded() {
_extensionsLoaded: function() {
if (this._startupUuid && this._extensionAvailable(this._startupUuid))
this._selectExtension(this._startupUuid);
this._startupUuid = null;
@@ -218,16 +221,16 @@ var Application = new Lang.Class({
this._loaded = true;
},
_onActivate() {
_onActivate: function() {
this._window.present();
},
_onStartup(app) {
_onStartup: function(app) {
this._buildUI(app);
this._scanExtensions();
},
_onCommandLine(app, commandLine) {
_onCommandLine: function(app, commandLine) {
app.activate();
let args = commandLine.get_arguments();
@@ -254,7 +257,7 @@ var DescriptionLabel = new Lang.Class({
Name: 'DescriptionLabel',
Extends: Gtk.Label,
vfunc_get_preferred_height_for_width(width) {
vfunc_get_preferred_height_for_width: function(width) {
// Hack: Request the maximum height allowed by the line limit
if (this.lines > 0)
return this.parent(0);
@@ -266,28 +269,29 @@ var ExtensionRow = new Lang.Class({
Name: 'ExtensionRow',
Extends: Gtk.ListBoxRow,
_init(uuid) {
_init: function(uuid) {
this.parent();
this.uuid = uuid;
this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell' });
this._settings.connect('changed::enabled-extensions', () => {
this._switch.state = this._isEnabled();
});
this._settings.connect('changed::enabled-extensions', Lang.bind(this,
function() {
this._switch.state = this._isEnabled();
}));
this._settings.connect('changed::disable-extension-version-validation',
() => {
Lang.bind(this, function() {
this._switch.sensitive = this._canEnable();
});
}));
this._settings.connect('changed::disable-user-extensions',
() => {
Lang.bind(this, function() {
this._switch.sensitive = this._canEnable();
});
}));
this._buildUI();
},
_buildUI() {
_buildUI: function() {
let extension = ExtensionUtils.extensions[this.uuid];
let hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL,
@@ -324,17 +328,18 @@ var ExtensionRow = new Lang.Class({
this._switch = new Gtk.Switch({ valign: Gtk.Align.CENTER,
sensitive: this._canEnable(),
state: this._isEnabled() });
this._switch.connect('notify::active', () => {
if (this._switch.active)
this._enable();
else
this._disable();
});
this._switch.connect('state-set', () => true);
this._switch.connect('notify::active', Lang.bind(this,
function() {
if (this._switch.active)
this._enable();
else
this._disable();
}));
this._switch.connect('state-set', function() { return true; });
hbox.add(this._switch);
},
_canEnable() {
_canEnable: function() {
let extension = ExtensionUtils.extensions[this.uuid];
let checkVersion = !this._settings.get_boolean('disable-extension-version-validation');
@@ -342,12 +347,12 @@ var ExtensionRow = new Lang.Class({
!(checkVersion && ExtensionUtils.isOutOfDate(extension));
},
_isEnabled() {
_isEnabled: function() {
let extensions = this._settings.get_strv('enabled-extensions');
return extensions.indexOf(this.uuid) != -1;
},
_enable() {
_enable: function() {
let extensions = this._settings.get_strv('enabled-extensions');
if (extensions.indexOf(this.uuid) != -1)
return;
@@ -356,7 +361,7 @@ var ExtensionRow = new Lang.Class({
this._settings.set_strv('enabled-extensions', extensions);
},
_disable() {
_disable: function() {
let extensions = this._settings.get_strv('enabled-extensions');
let pos = extensions.indexOf(this.uuid);
if (pos == -1)
@@ -373,11 +378,11 @@ function initEnvironment() {
// Monkey-patch in a "global" object that fakes some Shell utilities
// that ExtensionUtils depends on.
window.global = {
log() {
log: function() {
print([].join.call(arguments, ', '));
},
logError(s) {
logError: function(s) {
log('ERROR: ' + s);
},

View File

@@ -41,7 +41,7 @@ var BeginRequestType = {
var AuthPrompt = new Lang.Class({
Name: 'AuthPrompt',
_init(gdmClient, mode) {
_init: function(gdmClient, mode) {
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
this._gdmClient = gdmClient;
@@ -55,33 +55,35 @@ var AuthPrompt = new Lang.Class({
this._userVerifier = new GdmUtil.ShellUserVerifier(this._gdmClient, { reauthenticationOnly: reauthenticationOnly });
this._userVerifier.connect('ask-question', this._onAskQuestion.bind(this));
this._userVerifier.connect('show-message', this._onShowMessage.bind(this));
this._userVerifier.connect('verification-failed', this._onVerificationFailed.bind(this));
this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
this._userVerifier.connect('reset', this._onReset.bind(this));
this._userVerifier.connect('smartcard-status-changed', this._onSmartcardStatusChanged.bind(this));
this._userVerifier.connect('ovirt-user-authenticated', this._onOVirtUserAuthenticated.bind(this));
this._userVerifier.connect('ask-question', Lang.bind(this, this._onAskQuestion));
this._userVerifier.connect('show-message', Lang.bind(this, this._onShowMessage));
this._userVerifier.connect('verification-failed', Lang.bind(this, this._onVerificationFailed));
this._userVerifier.connect('verification-complete', Lang.bind(this, this._onVerificationComplete));
this._userVerifier.connect('reset', Lang.bind(this, this._onReset));
this._userVerifier.connect('smartcard-status-changed', Lang.bind(this, this._onSmartcardStatusChanged));
this._userVerifier.connect('ovirt-user-authenticated', Lang.bind(this, this._onOVirtUserAuthenticated));
this.smartcardDetected = this._userVerifier.smartcardDetected;
this.connect('next', () => {
this.updateSensitivity(false);
this.startSpinning();
if (this._queryingService) {
this._userVerifier.answerQuery(this._queryingService, this._entry.text);
} else {
this._preemptiveAnswer = this._entry.text;
}
});
this.connect('next', Lang.bind(this, function() {
this.updateSensitivity(false);
this.startSpinning();
if (this._queryingService) {
this._userVerifier.answerQuery(this._queryingService, this._entry.text);
} else {
this._preemptiveAnswer = this._entry.text;
}
}));
this.actor = new St.BoxLayout({ style_class: 'login-dialog-prompt-layout',
vertical: true });
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('key-press-event', (actor, event) => {
if (event.get_key_symbol() == Clutter.KEY_Escape)
this.cancel();
return Clutter.EVENT_PROPAGATE;
});
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this.actor.connect('key-press-event',
Lang.bind(this, function(actor, event) {
if (event.get_key_symbol() == Clutter.KEY_Escape) {
this.cancel();
}
return Clutter.EVENT_PROPAGATE;
}));
this._userWell = new St.Bin({ x_fill: true,
x_align: St.Align.START });
@@ -134,18 +136,21 @@ var AuthPrompt = new Lang.Class({
this._defaultButtonWell.add_child(this._spinner.actor);
},
_onDestroy() {
_onDestroy: function() {
this._userVerifier.destroy();
this._userVerifier = null;
},
_initButtons() {
_initButtons: function() {
this.cancelButton = new St.Button({ style_class: 'modal-dialog-button button',
button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
reactive: true,
can_focus: true,
label: _("Cancel") });
this.cancelButton.connect('clicked', () => { this.cancel(); });
this.cancelButton.connect('clicked',
Lang.bind(this, function() {
this.cancel();
}));
this._buttonBox.add(this.cancelButton,
{ expand: false,
x_fill: false,
@@ -164,7 +169,10 @@ var AuthPrompt = new Lang.Class({
reactive: true,
can_focus: true,
label: _("Next") });
this.nextButton.connect('clicked', () => { this.emit('next'); });
this.nextButton.connect('clicked',
Lang.bind(this, function() {
this.emit('next');
}));
this.nextButton.add_style_pseudo_class('default');
this._buttonBox.add(this.nextButton,
{ expand: false,
@@ -175,19 +183,20 @@ var AuthPrompt = new Lang.Class({
this._updateNextButtonSensitivity(this._entry.text.length > 0);
this._entry.clutter_text.connect('text-changed', () => {
if (!this._userVerifier.hasPendingMessages)
this._fadeOutMessage();
this._entry.clutter_text.connect('text-changed',
Lang.bind(this, function() {
if (!this._userVerifier.hasPendingMessages)
this._fadeOutMessage();
this._updateNextButtonSensitivity(this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING);
});
this._entry.clutter_text.connect('activate', () => {
this._updateNextButtonSensitivity(this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING);
}));
this._entry.clutter_text.connect('activate', Lang.bind(this, function() {
if (this.nextButton.reactive)
this.emit('next');
});
}));
},
_onAskQuestion(verifier, serviceName, question, passwordChar) {
_onAskQuestion: function(verifier, serviceName, question, passwordChar) {
if (this._queryingService)
this.clear();
@@ -213,12 +222,12 @@ var AuthPrompt = new Lang.Class({
this.emit('prompted');
},
_onOVirtUserAuthenticated() {
_onOVirtUserAuthenticated: function() {
if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
this.reset();
},
_onSmartcardStatusChanged() {
_onSmartcardStatusChanged: function() {
this.smartcardDetected = this._userVerifier.smartcardDetected;
// Most of the time we want to reset if the user inserts or removes
@@ -237,12 +246,12 @@ var AuthPrompt = new Lang.Class({
this.reset();
},
_onShowMessage(userVerifier, message, type) {
_onShowMessage: function(userVerifier, message, type) {
this.setMessage(message, type);
this.emit('prompted');
},
_onVerificationFailed() {
_onVerificationFailed: function() {
this._queryingService = null;
this.clear();
@@ -251,22 +260,22 @@ var AuthPrompt = new Lang.Class({
this.verificationStatus = AuthPromptStatus.VERIFICATION_FAILED;
},
_onVerificationComplete() {
_onVerificationComplete: function() {
this.setActorInDefaultButtonWell(null);
this.verificationStatus = AuthPromptStatus.VERIFICATION_SUCCEEDED;
this.cancelButton.reactive = false;
},
_onReset() {
_onReset: function() {
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
this.reset();
},
addActorToDefaultButtonWell(actor) {
addActorToDefaultButtonWell: function(actor) {
this._defaultButtonWell.add_child(actor);
},
setActorInDefaultButtonWell(actor, animate) {
setActorInDefaultButtonWell: function(actor, animate) {
if (!this._defaultButtonWellActor &&
!actor)
return;
@@ -303,7 +312,7 @@ var AuthPrompt = new Lang.Class({
delay: DEFAULT_BUTTON_WELL_ANIMATION_DELAY,
transition: 'linear',
onCompleteScope: this,
onComplete() {
onComplete: function() {
if (wasSpinner) {
if (this._spinner)
this._spinner.stop();
@@ -330,25 +339,25 @@ var AuthPrompt = new Lang.Class({
this._defaultButtonWellActor = actor;
},
startSpinning() {
startSpinning: function() {
this.setActorInDefaultButtonWell(this._spinner.actor, true);
},
stopSpinning() {
stopSpinning: function() {
this.setActorInDefaultButtonWell(null, false);
},
clear() {
clear: function() {
this._entry.text = '';
this.stopSpinning();
},
setPasswordChar(passwordChar) {
setPasswordChar: function(passwordChar) {
this._entry.clutter_text.set_password_char(passwordChar);
this._entry.menu.isPassword = passwordChar != '';
},
setQuestion(question) {
setQuestion: function(question) {
this._label.set_text(question);
this._label.show();
@@ -357,7 +366,7 @@ var AuthPrompt = new Lang.Class({
this._entry.grab_key_focus();
},
getAnswer() {
getAnswer: function() {
let text;
if (this._preemptiveAnswer) {
@@ -370,7 +379,7 @@ var AuthPrompt = new Lang.Class({
return text;
},
_fadeOutMessage() {
_fadeOutMessage: function() {
if (this._message.opacity == 0)
return;
Tweener.removeTweens(this._message);
@@ -381,7 +390,7 @@ var AuthPrompt = new Lang.Class({
});
},
setMessage(message, type) {
setMessage: function(message, type) {
if (type == GdmUtil.MessageType.ERROR)
this._message.add_style_class_name('login-dialog-message-warning');
else
@@ -401,18 +410,18 @@ var AuthPrompt = new Lang.Class({
}
},
_updateNextButtonSensitivity(sensitive) {
_updateNextButtonSensitivity: function(sensitive) {
this.nextButton.reactive = sensitive;
this.nextButton.can_focus = sensitive;
},
updateSensitivity(sensitive) {
updateSensitivity: function(sensitive) {
this._updateNextButtonSensitivity(sensitive && (this._entry.text.length > 0 || this.verificationStatus == AuthPromptStatus.VERIFYING));
this._entry.reactive = sensitive;
this._entry.clutter_text.editable = sensitive;
},
hide() {
hide: function() {
this.setActorInDefaultButtonWell(null, true);
this.actor.hide();
this._message.opacity = 0;
@@ -423,7 +432,7 @@ var AuthPrompt = new Lang.Class({
this._entry.set_text('');
},
setUser(user) {
setUser: function(user) {
let oldChild = this._userWell.get_child();
if (oldChild)
oldChild.destroy();
@@ -434,7 +443,7 @@ var AuthPrompt = new Lang.Class({
}
},
reset() {
reset: function() {
let oldStatus = this.verificationStatus;
this.verificationStatus = AuthPromptStatus.NOT_VERIFYING;
this.cancelButton.reactive = true;
@@ -471,7 +480,7 @@ var AuthPrompt = new Lang.Class({
this.emit('reset', beginRequestType);
},
addCharacter(unichar) {
addCharacter: function(unichar) {
if (!this._entry.visible)
return;
@@ -479,7 +488,7 @@ var AuthPrompt = new Lang.Class({
this._entry.clutter_text.insert_unichar(unichar);
},
begin(params) {
begin: function(params) {
params = Params.parse(params, { userName: null,
hold: null });
@@ -493,21 +502,22 @@ var AuthPrompt = new Lang.Class({
this.verificationStatus = AuthPromptStatus.VERIFYING;
},
finish(onComplete) {
finish: function(onComplete) {
if (!this._userVerifier.hasPendingMessages) {
this._userVerifier.clear();
onComplete();
return;
}
let signalId = this._userVerifier.connect('no-more-messages', () => {
this._userVerifier.disconnect(signalId);
this._userVerifier.clear();
onComplete();
});
let signalId = this._userVerifier.connect('no-more-messages',
Lang.bind(this, function() {
this._userVerifier.disconnect(signalId);
this._userVerifier.clear();
onComplete();
}));
},
cancel() {
cancel: function() {
if (this.verificationStatus == AuthPromptStatus.VERIFICATION_SUCCEEDED) {
return;
}

View File

@@ -50,7 +50,7 @@ const Signals = imports.signals;
var Task = new Lang.Class({
Name: 'Task',
_init(scope, handler) {
_init: function(scope, handler) {
if (scope)
this.scope = scope;
else
@@ -59,7 +59,7 @@ var Task = new Lang.Class({
this.handler = handler;
},
run() {
run: function() {
if (this.handler)
return this.handler.call(this.scope);
@@ -72,37 +72,39 @@ var Hold = new Lang.Class({
Name: 'Hold',
Extends: Task,
_init() {
this.parent(this, () => this);
_init: function() {
this.parent(this, function () {
return this;
});
this._acquisitions = 1;
},
acquire() {
acquire: function() {
if (this._acquisitions <= 0)
throw new Error("Cannot acquire hold after it's been released");
this._acquisitions++;
},
acquireUntilAfter(hold) {
acquireUntilAfter: function(hold) {
if (!hold.isAcquired())
return;
this.acquire();
let signalId = hold.connect('release', () => {
hold.disconnect(signalId);
this.release();
});
let signalId = hold.connect('release', Lang.bind(this, function() {
hold.disconnect(signalId);
this.release();
}));
},
release() {
release: function() {
this._acquisitions--;
if (this._acquisitions == 0)
this.emit('release');
},
isAcquired() {
isAcquired: function() {
return this._acquisitions > 0;
}
});
@@ -112,7 +114,7 @@ var Batch = new Lang.Class({
Name: 'Batch',
Extends: Task,
_init(scope, tasks) {
_init: function(scope, tasks) {
this.parent();
this.tasks = [];
@@ -132,11 +134,11 @@ var Batch = new Lang.Class({
}
},
process() {
process: function() {
throw new Error('Not implemented');
},
runTask() {
runTask: function() {
if (!(this._currentTaskIndex in this.tasks)) {
return null;
}
@@ -144,11 +146,11 @@ var Batch = new Lang.Class({
return this.tasks[this._currentTaskIndex].run();
},
_finish() {
_finish: function() {
this.hold.release();
},
nextTask() {
nextTask: function() {
this._currentTaskIndex++;
// if the entire batch of tasks is finished, release
@@ -161,7 +163,7 @@ var Batch = new Lang.Class({
this.process();
},
_start() {
_start: function() {
// acquire a hold to get released when the entire
// batch of tasks is finished
this.hold = new Hold();
@@ -169,7 +171,7 @@ var Batch = new Lang.Class({
this.process();
},
run() {
run: function() {
this._start();
// hold may be destroyed at this point
@@ -177,7 +179,7 @@ var Batch = new Lang.Class({
return this.hold;
},
cancel() {
cancel: function() {
this.tasks = this.tasks.splice(0, this._currentTaskIndex + 1);
}
});
@@ -187,7 +189,7 @@ var ConcurrentBatch = new Lang.Class({
Name: 'ConcurrentBatch',
Extends: Batch,
process() {
process: function() {
let hold = this.runTask();
if (hold) {
@@ -206,16 +208,17 @@ var ConsecutiveBatch = new Lang.Class({
Name: 'ConsecutiveBatch',
Extends: Batch,
process() {
process: function() {
let hold = this.runTask();
if (hold && hold.isAcquired()) {
// This task is inhibiting the batch. Wait on it
// before processing the next one.
let signalId = hold.connect('release', () => {
hold.disconnect(signalId);
this.nextTask();
});
let signalId = hold.connect('release',
Lang.bind(this, function() {
hold.disconnect(signalId);
this.nextTask();
}));
return;
} else {
// This task finished, process the next one

View File

@@ -54,10 +54,10 @@ const _MAX_BOTTOM_MENU_ITEMS = 5;
var UserListItem = new Lang.Class({
Name: 'UserListItem',
_init(user) {
_init: function(user) {
this.user = user;
this._userChangedId = this.user.connect('changed',
this._onUserChanged.bind(this));
Lang.bind(this, this._onUserChanged));
let layout = new St.BoxLayout({ vertical: true });
this.actor = new St.Button({ style_class: 'login-dialog-user-list-item',
@@ -67,7 +67,8 @@ var UserListItem = new Lang.Class({
reactive: true,
x_align: St.Align.START,
x_fill: true });
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('destroy',
Lang.bind(this, this._onDestroy));
this.actor.connect('key-focus-in', () => {
this._setSelected(true);
@@ -89,30 +90,30 @@ var UserListItem = new Lang.Class({
scale_x: 0 });
layout.add(this._timedLoginIndicator);
this.actor.connect('clicked', this._onClicked.bind(this));
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
this._onUserChanged();
},
_onUserChanged() {
_onUserChanged: function() {
this._updateLoggedIn();
},
_updateLoggedIn() {
_updateLoggedIn: function() {
if (this.user.is_logged_in())
this.actor.add_style_pseudo_class('logged-in');
else
this.actor.remove_style_pseudo_class('logged-in');
},
_onDestroy() {
_onDestroy: function() {
this.user.disconnect(this._userChangedId);
},
_onClicked() {
_onClicked: function() {
this.emit('activate');
},
_setSelected(selected) {
_setSelected: function(selected) {
if (selected) {
this.actor.add_style_pseudo_class('selected');
this.actor.grab_key_focus();
@@ -121,37 +122,24 @@ var UserListItem = new Lang.Class({
}
},
showTimedLoginIndicator(time) {
showTimedLoginIndicator: function(time) {
let hold = new Batch.Hold();
this.hideTimedLoginIndicator();
let startTime = GLib.get_monotonic_time();
this._timedLoginTimeoutId = GLib.timeout_add (GLib.PRIORITY_DEFAULT, 33,
() => {
let currentTime = GLib.get_monotonic_time();
let elapsedTime = (currentTime - startTime) / GLib.USEC_PER_SEC;
this._timedLoginIndicator.scale_x = elapsedTime / time;
if (elapsedTime >= time) {
this._timedLoginTimeoutId = 0;
hold.release();
return GLib.SOURCE_REMOVE;
}
return GLib.SOURCE_CONTINUE;
});
GLib.Source.set_name_by_id(this._timedLoginTimeoutId, '[gnome-shell] this._timedLoginTimeoutId');
Tweener.addTween(this._timedLoginIndicator,
{ scale_x: 1.,
time: time,
transition: 'linear',
onComplete: function() {
hold.release();
},
onCompleteScope: this
});
return hold;
},
hideTimedLoginIndicator() {
if (this._timedLoginTimeoutId) {
GLib.source_remove(this._timedLoginTimeoutId);
this._timedLoginTimeoutId = 0;
}
hideTimedLoginIndicator: function() {
Tweener.removeTweens(this._timedLoginIndicator);
this._timedLoginIndicator.scale_x = 0.;
}
});
@@ -160,7 +148,7 @@ Signals.addSignalMethods(UserListItem.prototype);
var UserList = new Lang.Class({
Name: 'UserList',
_init() {
_init: function() {
this.actor = new St.ScrollView({ style_class: 'login-dialog-user-list-view'});
this.actor.set_policy(Gtk.PolicyType.NEVER,
Gtk.PolicyType.AUTOMATIC);
@@ -172,10 +160,10 @@ var UserList = new Lang.Class({
this.actor.add_actor(this._box);
this._items = {};
this.actor.connect('key-focus-in', this._moveFocusToItems.bind(this));
this.actor.connect('key-focus-in', Lang.bind(this, this._moveFocusToItems));
},
_moveFocusToItems() {
_moveFocusToItems: function() {
let hasItems = Object.keys(this._items).length > 0;
if (!hasItems)
@@ -186,18 +174,18 @@ var UserList = new Lang.Class({
let focusSet = this.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
if (!focusSet) {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
this._moveFocusToItems();
return false;
});
}));
}
},
_onItemActivated(activatedItem) {
_onItemActivated: function(activatedItem) {
this.emit('activate', activatedItem);
},
updateStyle(isExpanded) {
updateStyle: function(isExpanded) {
let tasks = [];
if (isExpanded)
@@ -211,7 +199,7 @@ var UserList = new Lang.Class({
}
},
scrollToItem(item) {
scrollToItem: function(item) {
let box = item.actor.get_allocation_box();
let adjustment = this.actor.get_vscroll_bar().get_adjustment();
@@ -224,7 +212,7 @@ var UserList = new Lang.Class({
transition: 'easeOutQuad' });
},
jumpToItem(item) {
jumpToItem: function(item) {
let box = item.actor.get_allocation_box();
let adjustment = this.actor.get_vscroll_bar().get_adjustment();
@@ -234,7 +222,7 @@ var UserList = new Lang.Class({
adjustment.set_value(value);
},
getItemFromUserName(userName) {
getItemFromUserName: function(userName) {
let item = this._items[userName];
if (!item)
@@ -243,11 +231,11 @@ var UserList = new Lang.Class({
return item;
},
containsUser(user) {
containsUser: function(user) {
return this._items[user.get_user_name()] != null;
},
addUser(user) {
addUser: function(user) {
if (!user.is_loaded)
return;
@@ -269,17 +257,22 @@ var UserList = new Lang.Class({
this._items[userName] = item;
item.connect('activate', this._onItemActivated.bind(this));
item.connect('activate',
Lang.bind(this, this._onItemActivated));
// Try to keep the focused item front-and-center
item.actor.connect('key-focus-in', () => { this.scrollToItem(item); });
item.actor.connect('key-focus-in',
Lang.bind(this,
function() {
this.scrollToItem(item);
}));
this._moveFocusToItems();
this.emit('item-added', item);
},
removeUser(user) {
removeUser: function(user) {
if (!user.is_loaded)
return;
@@ -297,7 +290,7 @@ var UserList = new Lang.Class({
delete this._items[userName];
},
numItems() {
numItems: function() {
return Object.keys(this._items).length;
}
});
@@ -306,7 +299,7 @@ Signals.addSignalMethods(UserList.prototype);
var SessionMenuButton = new Lang.Class({
Name: 'SessionMenuButton',
_init() {
_init: function() {
let gearIcon = new St.Icon({ icon_name: 'emblem-system-symbolic' });
this._button = new St.Button({ style_class: 'login-dialog-session-list-button',
reactive: true,
@@ -331,30 +324,33 @@ var SessionMenuButton = new Lang.Class({
Main.uiGroup.add_actor(this._menu.actor);
this._menu.actor.hide();
this._menu.connect('open-state-changed', (menu, isOpen) => {
if (isOpen)
this._button.add_style_pseudo_class('active');
else
this._button.remove_style_pseudo_class('active');
});
this._menu.connect('open-state-changed',
Lang.bind(this, function(menu, isOpen) {
if (isOpen)
this._button.add_style_pseudo_class('active');
else
this._button.remove_style_pseudo_class('active');
}));
this._manager = new PopupMenu.PopupMenuManager({ actor: this._button });
this._manager.addMenu(this._menu);
this._button.connect('clicked', () => { this._menu.toggle(); });
this._button.connect('clicked', Lang.bind(this, function() {
this._menu.toggle();
}));
this._items = {};
this._activeSessionId = null;
this._populate();
},
updateSensitivity(sensitive) {
updateSensitivity: function(sensitive) {
this._button.reactive = sensitive;
this._button.can_focus = sensitive;
this._menu.close(BoxPointer.PopupAnimation.NONE);
},
_updateOrnament() {
_updateOrnament: function() {
let itemIds = Object.keys(this._items);
for (let i = 0; i < itemIds.length; i++) {
if (itemIds[i] == this._activeSessionId)
@@ -364,19 +360,21 @@ var SessionMenuButton = new Lang.Class({
}
},
setActiveSession(sessionId) {
setActiveSession: function(sessionId) {
if (sessionId == this._activeSessionId)
return;
this._activeSessionId = sessionId;
this._updateOrnament();
this.emit('session-activated', this._activeSessionId);
},
close() {
close: function() {
this._menu.close();
},
_populate() {
_populate: function() {
let ids = Gdm.get_session_ids();
ids.sort();
@@ -393,10 +391,12 @@ var SessionMenuButton = new Lang.Class({
this._menu.addMenuItem(item);
this._items[id] = item;
item.connect('activate', () => {
if (!this._activeSessionId)
this.setActiveSession(id);
this.emit('session-activated', this._activeSessionId);
});
item.connect('activate', Lang.bind(this, function() {
this.setActiveSession(id);
}));
}
}
});
@@ -405,14 +405,14 @@ Signals.addSignalMethods(SessionMenuButton.prototype);
var LoginDialog = new Lang.Class({
Name: 'LoginDialog',
_init(parentActor) {
_init: function(parentActor) {
this.actor = new Shell.GenericContainer({ style_class: 'login-dialog',
visible: false });
this.actor.get_accessible().set_role(Atk.Role.WINDOW);
this.actor.add_constraint(new Layout.MonitorConstraint({ primary: true }));
this.actor.connect('allocate', this._onAllocate.bind(this));
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('allocate', Lang.bind(this, this._onAllocate));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
parentActor.add_child(this.actor);
this._userManager = AccountsService.UserManager.get_default()
@@ -421,17 +421,17 @@ var LoginDialog = new Lang.Class({
this._settings = new Gio.Settings({ schema_id: GdmUtil.LOGIN_SCREEN_SCHEMA });
this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_KEY,
this._updateBanner.bind(this));
Lang.bind(this, this._updateBanner));
this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_TEXT_KEY,
this._updateBanner.bind(this));
Lang.bind(this, this._updateBanner));
this._settings.connect('changed::' + GdmUtil.DISABLE_USER_LIST_KEY,
this._updateDisableUserList.bind(this));
Lang.bind(this, this._updateDisableUserList));
this._settings.connect('changed::' + GdmUtil.LOGO_KEY,
this._updateLogo.bind(this));
Lang.bind(this, this._updateLogo));
this._textureCache = St.TextureCache.get_default();
this._updateLogoTextureId = this._textureCache.connect('texture-file-changed',
this._updateLogoTexture.bind(this));
Lang.bind(this, this._updateLogoTexture));
this._userSelectionBox = new St.BoxLayout({ style_class: 'login-dialog-user-selection-box',
x_align: Clutter.ActorAlign.CENTER,
@@ -447,8 +447,8 @@ var LoginDialog = new Lang.Class({
y_fill: true });
this._authPrompt = new AuthPrompt.AuthPrompt(this._gdmClient, AuthPrompt.AuthPromptMode.UNLOCK_OR_LOG_IN);
this._authPrompt.connect('prompted', this._onPrompted.bind(this));
this._authPrompt.connect('reset', this._onReset.bind(this));
this._authPrompt.connect('prompted', Lang.bind(this, this._onPrompted));
this._authPrompt.connect('reset', Lang.bind(this, this._onReset));
this._authPrompt.hide();
this.actor.add_child(this._authPrompt.actor);
@@ -465,7 +465,7 @@ var LoginDialog = new Lang.Class({
x_align: St.Align.START,
x_fill: true });
this._notListedButton.connect('clicked', this._hideUserListAskForUsernameAndBeginVerification.bind(this));
this._notListedButton.connect('clicked', Lang.bind(this, this._hideUserListAskForUsernameAndBeginVerification));
this._notListedButton.hide();
@@ -496,16 +496,17 @@ var LoginDialog = new Lang.Class({
this.actor.add_child(this._logoBin);
this._updateLogo();
this._userList.connect('activate', (userList, item) => {
this._onUserListActivated(item);
});
this._userList.connect('activate',
Lang.bind(this, function(userList, item) {
this._onUserListActivated(item);
}));
this._sessionMenuButton = new SessionMenuButton();
this._sessionMenuButton.connect('session-activated',
(list, sessionId) => {
this._greeter.call_select_session_sync (sessionId, null);
});
Lang.bind(this, function(list, sessionId) {
this._greeter.call_select_session_sync (sessionId, null);
}));
this._sessionMenuButton.actor.opacity = 0;
this._sessionMenuButton.actor.show();
this._authPrompt.addActorToDefaultButtonWell(this._sessionMenuButton.actor);
@@ -515,18 +516,18 @@ var LoginDialog = new Lang.Class({
this._realmManager = new Realmd.Manager();
this._realmSignalId = this._realmManager.connect('login-format-changed',
this._showRealmLoginHint.bind(this));
Lang.bind(this, this._showRealmLoginHint));
LoginManager.getLoginManager().getCurrentSessionProxy(this._gotGreeterSessionProxy.bind(this));
LoginManager.getLoginManager().getCurrentSessionProxy(Lang.bind(this, this._gotGreeterSessionProxy));
// If the user list is enabled, it should take key focus; make sure the
// screen shield is initialized first to prevent it from stealing the
// focus later
this._startupCompleteId = Main.layoutManager.connect('startup-complete',
this._updateDisableUserList.bind(this));
Lang.bind(this, this._updateDisableUserList));
},
_getBannerAllocation(dialogBox) {
_getBannerAllocation: function (dialogBox) {
let actorBox = new Clutter.ActorBox();
let [minWidth, minHeight, natWidth, natHeight] = this._bannerView.get_preferred_size();
@@ -540,7 +541,7 @@ var LoginDialog = new Lang.Class({
return actorBox;
},
_getLogoBinAllocation(dialogBox) {
_getLogoBinAllocation: function (dialogBox) {
let actorBox = new Clutter.ActorBox();
let [minWidth, minHeight, natWidth, natHeight] = this._logoBin.get_preferred_size();
@@ -554,7 +555,7 @@ var LoginDialog = new Lang.Class({
return actorBox;
},
_getCenterActorAllocation(dialogBox, actor) {
_getCenterActorAllocation: function (dialogBox, actor) {
let actorBox = new Clutter.ActorBox();
let [minWidth, minHeight, natWidth, natHeight] = actor.get_preferred_size();
@@ -572,7 +573,7 @@ var LoginDialog = new Lang.Class({
return actorBox;
},
_onAllocate(actor, dialogBox, flags) {
_onAllocate: function (actor, dialogBox, flags) {
let dialogWidth = dialogBox.x2 - dialogBox.x1;
let dialogHeight = dialogBox.y2 - dialogBox.y1;
@@ -710,23 +711,23 @@ var LoginDialog = new Lang.Class({
this._logoBin.allocate(logoAllocation, flags);
},
_ensureUserListLoaded() {
_ensureUserListLoaded: function() {
if (!this._userManager.is_loaded) {
this._userManagerLoadedId = this._userManager.connect('notify::is-loaded',
() => {
if (this._userManager.is_loaded) {
this._loadUserList();
this._userManager.disconnect(this._userManagerLoadedId);
this._userManagerLoadedId = 0;
}
});
Lang.bind(this, function() {
if (this._userManager.is_loaded) {
this._loadUserList();
this._userManager.disconnect(this._userManagerLoadedId);
this._userManagerLoadedId = 0;
}
}));
} else {
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, this._loadUserList.bind(this));
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, this._loadUserList));
GLib.Source.set_name_by_id(id, '[gnome-shell] _loadUserList');
}
},
_updateDisableUserList() {
_updateDisableUserList: function() {
let disableUserList = this._settings.get_boolean(GdmUtil.DISABLE_USER_LIST_KEY);
// Disable user list when there are no users.
@@ -741,7 +742,7 @@ var LoginDialog = new Lang.Class({
}
},
_updateCancelButton() {
_updateCancelButton: function() {
let cancelVisible;
// Hide the cancel button if the user list is disabled and we're asking for
@@ -754,7 +755,7 @@ var LoginDialog = new Lang.Class({
this._authPrompt.cancelButton.visible = cancelVisible;
},
_updateBanner() {
_updateBanner: function() {
let enabled = this._settings.get_boolean(GdmUtil.BANNER_MESSAGE_KEY);
let text = this._settings.get_string(GdmUtil.BANNER_MESSAGE_TEXT_KEY);
@@ -766,7 +767,7 @@ var LoginDialog = new Lang.Class({
}
},
_fadeInBannerView() {
_fadeInBannerView: function() {
this._bannerView.show();
Tweener.addTween(this._bannerView,
{ opacity: 255,
@@ -774,13 +775,13 @@ var LoginDialog = new Lang.Class({
transition: 'easeOutQuad' });
},
_hideBannerView() {
_hideBannerView: function() {
Tweener.removeTweens(this._bannerView);
this._bannerView.opacity = 0;
this._bannerView.hide();
},
_updateLogoTexture(cache, file) {
_updateLogoTexture: function(cache, file) {
if (this._logoFile && !this._logoFile.equal(file))
return;
@@ -793,14 +794,14 @@ var LoginDialog = new Lang.Class({
}
},
_updateLogo() {
_updateLogo: function() {
let path = this._settings.get_string(GdmUtil.LOGO_KEY);
this._logoFile = path ? Gio.file_new_for_path(path) : null;
this._updateLogoTexture(this._textureCache, this._logoFile);
},
_onPrompted() {
_onPrompted: function() {
if (this._shouldShowSessionMenuButton()) {
this._sessionMenuButton.updateSensitivity(true);
this._authPrompt.setActorInDefaultButtonWell(this._sessionMenuButton.actor);
@@ -810,7 +811,7 @@ var LoginDialog = new Lang.Class({
this._showPrompt();
},
_resetGreeterProxy() {
_resetGreeterProxy: function() {
if (GLib.getenv('GDM_GREETER_TEST') != '1') {
if (this._greeter) {
this._greeter.run_dispose();
@@ -818,15 +819,15 @@ var LoginDialog = new Lang.Class({
this._greeter = this._gdmClient.get_greeter_sync(null);
this._defaultSessionChangedId = this._greeter.connect('default-session-name-changed',
this._onDefaultSessionChanged.bind(this));
Lang.bind(this, this._onDefaultSessionChanged));
this._sessionOpenedId = this._greeter.connect('session-opened',
this._onSessionOpened.bind(this));
Lang.bind(this, this._onSessionOpened));
this._timedLoginRequestedId = this._greeter.connect('timed-login-requested',
this._onTimedLoginRequested.bind(this));
Lang.bind(this, this._onTimedLoginRequested));
}
},
_onReset(authPrompt, beginRequest) {
_onReset: function(authPrompt, beginRequest) {
this._resetGreeterProxy();
this._sessionMenuButton.updateSensitivity(true);
@@ -847,11 +848,11 @@ var LoginDialog = new Lang.Class({
}
},
_onDefaultSessionChanged(client, sessionId) {
_onDefaultSessionChanged: function(client, sessionId) {
this._sessionMenuButton.setActiveSession(sessionId);
},
_shouldShowSessionMenuButton() {
_shouldShowSessionMenuButton: function() {
if (this._authPrompt.verificationStatus != AuthPrompt.AuthPromptStatus.VERIFYING &&
this._authPrompt.verificationStatus != AuthPrompt.AuthPromptStatus.VERIFICATION_FAILED)
return false;
@@ -862,7 +863,7 @@ var LoginDialog = new Lang.Class({
return true;
},
_showPrompt() {
_showPrompt: function() {
if (this._authPrompt.actor.visible)
return;
this._authPrompt.actor.opacity = 0;
@@ -874,7 +875,7 @@ var LoginDialog = new Lang.Class({
this._fadeInBannerView();
},
_showRealmLoginHint(realmManager, hint) {
_showRealmLoginHint: function(realmManager, hint) {
if (!hint)
return;
@@ -887,7 +888,7 @@ var LoginDialog = new Lang.Class({
this._authPrompt.setMessage(_("(e.g., user or %s)").format(hint), GdmUtil.MessageType.HINT);
},
_askForUsernameAndBeginVerification() {
_askForUsernameAndBeginVerification: function() {
this._authPrompt.setPasswordChar('');
this._authPrompt.setQuestion(_("Username: "));
@@ -896,17 +897,17 @@ var LoginDialog = new Lang.Class({
if (this._nextSignalId)
this._authPrompt.disconnect(this._nextSignalId);
this._nextSignalId = this._authPrompt.connect('next',
() => {
this._authPrompt.disconnect(this._nextSignalId);
this._nextSignalId = 0;
this._authPrompt.updateSensitivity(false);
let answer = this._authPrompt.getAnswer();
this._user = this._userManager.get_user(answer);
this._authPrompt.clear();
this._authPrompt.startSpinning();
this._authPrompt.begin({ userName: answer });
this._updateCancelButton();
});
Lang.bind(this, function() {
this._authPrompt.disconnect(this._nextSignalId);
this._nextSignalId = 0;
this._authPrompt.updateSensitivity(false);
let answer = this._authPrompt.getAnswer();
this._user = this._userManager.get_user(answer);
this._authPrompt.clear();
this._authPrompt.startSpinning();
this._authPrompt.begin({ userName: answer });
this._updateCancelButton();
}));
this._updateCancelButton();
this._sessionMenuButton.updateSensitivity(false);
@@ -914,7 +915,7 @@ var LoginDialog = new Lang.Class({
this._showPrompt();
},
_loginScreenSessionActivated() {
_loginScreenSessionActivated: function() {
if (this.actor.opacity == 255 && this._authPrompt.verificationStatus == AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
return;
@@ -922,7 +923,7 @@ var LoginDialog = new Lang.Class({
{ opacity: 255,
time: _FADE_ANIMATION_TIME,
transition: 'easeOutQuad',
onUpdate() {
onUpdate: function() {
let children = Main.layoutManager.uiGroup.get_children();
for (let i = 0; i < children.length; i++) {
@@ -931,28 +932,28 @@ var LoginDialog = new Lang.Class({
}
},
onUpdateScope: this,
onComplete() {
onComplete: function() {
if (this._authPrompt.verificationStatus != AuthPrompt.AuthPromptStatus.NOT_VERIFYING)
this._authPrompt.reset();
},
onCompleteScope: this });
},
_gotGreeterSessionProxy(proxy) {
_gotGreeterSessionProxy: function(proxy) {
this._greeterSessionProxy = proxy;
this._greeterSessionProxyChangedId =
proxy.connect('g-properties-changed', () => {
proxy.connect('g-properties-changed', Lang.bind(this, function() {
if (proxy.Active)
this._loginScreenSessionActivated();
});
}));
},
_startSession(serviceName) {
_startSession: function(serviceName) {
Tweener.addTween(this.actor,
{ opacity: 0,
time: _FADE_ANIMATION_TIME,
transition: 'easeOutQuad',
onUpdate() {
onUpdate: function() {
let children = Main.layoutManager.uiGroup.get_children();
for (let i = 0; i < children.length; i++) {
@@ -961,17 +962,19 @@ var LoginDialog = new Lang.Class({
}
},
onUpdateScope: this,
onComplete() {
onComplete: function() {
this._greeter.call_start_session_when_ready_sync(serviceName, true, null);
},
onCompleteScope: this });
},
_onSessionOpened(client, serviceName) {
this._authPrompt.finish(() => { this._startSession(serviceName); });
_onSessionOpened: function(client, serviceName) {
this._authPrompt.finish(Lang.bind(this, function() {
this._startSession(serviceName);
}));
},
_waitForItemForUser(userName) {
_waitForItemForUser: function(userName) {
let item = this._userList.getItemFromUserName(userName);
if (item)
@@ -979,24 +982,26 @@ var LoginDialog = new Lang.Class({
let hold = new Batch.Hold();
let signalId = this._userList.connect('item-added',
() => {
let item = this._userList.getItemFromUserName(userName);
Lang.bind(this, function() {
let item = this._userList.getItemFromUserName(userName);
if (item)
hold.release();
});
if (item)
hold.release();
}));
hold.connect('release', () => { this._userList.disconnect(signalId); });
hold.connect('release', Lang.bind(this, function() {
this._userList.disconnect(signalId);
}));
return hold;
},
_showTimedLoginAnimation() {
_showTimedLoginAnimation: function() {
this._timedLoginItem.actor.grab_key_focus();
return this._timedLoginItem.showTimedLoginIndicator(this._timedLoginAnimationTime);
},
_blockTimedLoginUntilIdle() {
_blockTimedLoginUntilIdle: function() {
// This blocks timed login from starting until a few
// seconds after the user stops interacting with the
// login screen.
@@ -1009,27 +1014,29 @@ var LoginDialog = new Lang.Class({
let hold = new Batch.Hold();
this._timedLoginIdleTimeOutId = Mainloop.timeout_add_seconds(_TIMED_LOGIN_IDLE_THRESHOLD,
() => {
this._timedLoginAnimationTime -= _TIMED_LOGIN_IDLE_THRESHOLD;
hold.release();
return GLib.SOURCE_REMOVE;
});
function() {
this._timedLoginAnimationTime -= _TIMED_LOGIN_IDLE_THRESHOLD;
hold.release();
return GLib.SOURCE_REMOVE;
});
GLib.Source.set_name_by_id(this._timedLoginIdleTimeOutId, '[gnome-shell] this._timedLoginAnimationTime');
return hold;
},
_startTimedLogin(userName, delay) {
_startTimedLogin: function(userName, delay) {
this._timedLoginItem = null;
this._timedLoginDelay = delay;
this._timedLoginAnimationTime = delay;
let tasks = [() => this._waitForItemForUser(userName),
let tasks = [function() {
return this._waitForItemForUser(userName);
},
() => {
function() {
this._timedLoginItem = this._userList.getItemFromUserName(userName);
},
() => {
function() {
// If we're just starting out, start on the right
// item.
if (!this._userManager.is_loaded) {
@@ -1039,13 +1046,13 @@ var LoginDialog = new Lang.Class({
this._blockTimedLoginUntilIdle,
() => {
function() {
this._userList.scrollToItem(this._timedLoginItem);
},
this._showTimedLoginAnimation,
() => {
function() {
this._timedLoginBatch = null;
this._greeter.call_begin_auto_login_sync(userName, null);
}];
@@ -1055,7 +1062,7 @@ var LoginDialog = new Lang.Class({
return this._timedLoginBatch.run();
},
_resetTimedLogin() {
_resetTimedLogin: function() {
if (this._timedLoginBatch) {
this._timedLoginBatch.cancel();
this._timedLoginBatch = null;
@@ -1070,50 +1077,51 @@ var LoginDialog = new Lang.Class({
this._startTimedLogin(userName, this._timedLoginDelay);
},
_onTimedLoginRequested(client, userName, seconds) {
_onTimedLoginRequested: function(client, userName, seconds) {
this._startTimedLogin(userName, seconds);
global.stage.connect('captured-event', (actor, event) => {
if (this._timedLoginDelay == undefined)
return Clutter.EVENT_PROPAGATE;
global.stage.connect('captured-event',
Lang.bind(this, function(actor, event) {
if (this._timedLoginDelay == undefined)
return Clutter.EVENT_PROPAGATE;
if (event.type() == Clutter.EventType.KEY_PRESS ||
event.type() == Clutter.EventType.BUTTON_PRESS) {
if (this._timedLoginBatch) {
this._timedLoginBatch.cancel();
this._timedLoginBatch = null;
}
} else if (event.type() == Clutter.EventType.KEY_RELEASE ||
event.type() == Clutter.EventType.BUTTON_RELEASE) {
this._resetTimedLogin();
}
if (event.type() == Clutter.EventType.KEY_PRESS ||
event.type() == Clutter.EventType.BUTTON_PRESS) {
if (this._timedLoginBatch) {
this._timedLoginBatch.cancel();
this._timedLoginBatch = null;
}
} else if (event.type() == Clutter.EventType.KEY_RELEASE ||
event.type() == Clutter.EventType.BUTTON_RELEASE) {
this._resetTimedLogin();
}
return Clutter.EVENT_PROPAGATE;
});
return Clutter.EVENT_PROPAGATE;
}));
},
_setUserListExpanded(expanded) {
_setUserListExpanded: function(expanded) {
this._userList.updateStyle(expanded);
this._userSelectionBox.visible = expanded;
},
_hideUserList() {
_hideUserList: function() {
this._setUserListExpanded(false);
if (this._userSelectionBox.visible)
GdmUtil.cloneAndFadeOutActor(this._userSelectionBox);
},
_hideUserListAskForUsernameAndBeginVerification() {
_hideUserListAskForUsernameAndBeginVerification: function() {
this._hideUserList();
this._askForUsernameAndBeginVerification();
},
_hideUserListAndBeginVerification() {
_hideUserListAndBeginVerification: function() {
this._hideUserList();
this._authPrompt.begin();
},
_showUserList() {
_showUserList: function() {
this._ensureUserListLoaded();
this._authPrompt.hide();
this._hideBannerView();
@@ -1123,7 +1131,7 @@ var LoginDialog = new Lang.Class({
this._userList.actor.grab_key_focus();
},
_beginVerificationForItem(item) {
_beginVerificationForItem: function(item) {
this._authPrompt.setUser(item.user);
let userName = item.user.get_user_name();
@@ -1134,7 +1142,7 @@ var LoginDialog = new Lang.Class({
return hold;
},
_onUserListActivated(activatedItem) {
_onUserListActivated: function(activatedItem) {
this._user = activatedItem.user;
this._updateCancelButton();
@@ -1144,7 +1152,7 @@ var LoginDialog = new Lang.Class({
batch.run();
},
_onDestroy() {
_onDestroy: function() {
if (this._userManagerLoadedId) {
this._userManager.disconnect(this._userManagerLoadedId);
this._userManagerLoadedId = 0;
@@ -1185,7 +1193,7 @@ var LoginDialog = new Lang.Class({
}
},
_loadUserList() {
_loadUserList: function() {
if (this._userListLoaded)
return GLib.SOURCE_REMOVE;
@@ -1200,30 +1208,30 @@ var LoginDialog = new Lang.Class({
this._updateDisableUserList();
this._userAddedId = this._userManager.connect('user-added',
(userManager, user) => {
this._userList.addUser(user);
this._updateDisableUserList();
});
Lang.bind(this, function(userManager, user) {
this._userList.addUser(user);
this._updateDisableUserList();
}));
this._userRemovedId = this._userManager.connect('user-removed',
(userManager, user) => {
this._userList.removeUser(user);
this._updateDisableUserList();
});
Lang.bind(this, function(userManager, user) {
this._userList.removeUser(user);
this._updateDisableUserList();
}));
this._userChangedId = this._userManager.connect('user-changed',
(userManager, user) => {
if (this._userList.containsUser(user) && user.locked)
this._userList.removeUser(user);
else if (!this._userList.containsUser(user) && !user.locked)
this._userList.addUser(user);
this._updateDisableUserList();
});
Lang.bind(this, function(userManager, user) {
if (this._userList.containsUser(user) && user.locked)
this._userList.removeUser(user);
else if (!this._userList.containsUser(user) && !user.locked)
this._userList.addUser(user);
this._updateDisableUserList();
}));
return GLib.SOURCE_REMOVE;
},
open() {
open: function() {
Main.ctrlAltTabManager.addGroup(this.actor,
_("Login Window"),
'dialog-password-symbolic',
@@ -1242,20 +1250,20 @@ var LoginDialog = new Lang.Class({
return true;
},
close() {
close: function() {
Main.popModal(this.actor);
Main.ctrlAltTabManager.removeGroup(this.actor);
},
cancel() {
cancel: function() {
this._authPrompt.cancel();
},
addCharacter(unichar) {
addCharacter: function(unichar) {
// Don't allow type ahead at the login screen
},
finish(onComplete) {
finish: function(onComplete) {
this._authPrompt.finish(onComplete);
},
});

View File

@@ -29,28 +29,28 @@ function OVirtCredentials() {
var OVirtCredentialsManager = new Lang.Class({
Name: 'OVirtCredentialsManager',
_init() {
_init: function() {
this._token = null;
this._credentials = new OVirtCredentials();
this._credentials.connectSignal('UserAuthenticated',
this._onUserAuthenticated.bind(this));
Lang.bind(this, this._onUserAuthenticated));
},
_onUserAuthenticated(proxy, sender, [token]) {
_onUserAuthenticated: function(proxy, sender, [token]) {
this._token = token;
this.emit('user-authenticated', token);
},
hasToken() {
hasToken: function() {
return this._token != null;
},
getToken() {
getToken: function() {
return this._token;
},
resetToken() {
resetToken: function() {
this._token = null;
}
});

View File

@@ -62,21 +62,21 @@ const Realm = Gio.DBusProxy.makeProxyWrapper(RealmIface);
var Manager = new Lang.Class({
Name: 'Manager',
_init(parentActor) {
_init: function(parentActor) {
this._aggregateProvider = Provider(Gio.DBus.system,
'org.freedesktop.realmd',
'/org/freedesktop/realmd',
this._reloadRealms.bind(this))
Lang.bind(this, this._reloadRealms))
this._realms = {};
this._signalId = this._aggregateProvider.connect('g-properties-changed',
(proxy, properties) => {
if ('Realms' in properties.deep_unpack())
this._reloadRealms();
});
Lang.bind(this, function(proxy, properties) {
if ('Realms' in properties.deep_unpack())
this._reloadRealms();
}));
},
_reloadRealms() {
_reloadRealms: function() {
let realmPaths = this._aggregateProvider.Realms;
if (!realmPaths)
@@ -86,11 +86,11 @@ var Manager = new Lang.Class({
let realm = Realm(Gio.DBus.system,
'org.freedesktop.realmd',
realmPaths[i],
this._onRealmLoaded.bind(this));
Lang.bind(this, this._onRealmLoaded));
}
},
_reloadRealm(realm) {
_reloadRealm: function(realm) {
if (!realm.Configured) {
if (this._realms[realm.get_object_path()])
delete this._realms[realm.get_object_path()];
@@ -103,19 +103,20 @@ var Manager = new Lang.Class({
this._updateLoginFormat();
},
_onRealmLoaded(realm, error) {
_onRealmLoaded: function(realm, error) {
if (error)
return;
this._reloadRealm(realm);
realm.connect('g-properties-changed', (proxy, properties) => {
if ('Configured' in properties.deep_unpack())
this._reloadRealm(realm);
});
realm.connect('g-properties-changed',
Lang.bind(this, function(proxy, properties) {
if ('Configured' in properties.deep_unpack())
this._reloadRealm(realm);
}));
},
_updateLoginFormat() {
_updateLoginFormat: function() {
let newLoginFormat;
for (let realmPath in this._realms) {
@@ -141,11 +142,13 @@ var Manager = new Lang.Class({
return this._loginFormat;
},
release() {
release: function() {
Service(Gio.DBus.system,
'org.freedesktop.realmd',
'/org/freedesktop/realmd',
service => { service.ReleaseRemote(); });
function(service) {
service.ReleaseRemote();
});
this._aggregateProvider.disconnect(this._signalId);
this._realms = { };
this._updateLoginFormat();

View File

@@ -60,7 +60,7 @@ function fadeInActor(actor) {
height: naturalHeight,
time: FADE_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
this.set_height(-1);
hold.release();
},
@@ -82,7 +82,7 @@ function fadeOutActor(actor) {
height: 0,
time: FADE_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
this.hide();
this.set_height(-1);
hold.release();
@@ -111,7 +111,7 @@ function cloneAndFadeOutActor(actor) {
{ opacity: 0,
time: CLONE_FADE_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
clone.destroy();
hold.release();
}
@@ -122,7 +122,7 @@ function cloneAndFadeOutActor(actor) {
var ShellUserVerifier = new Lang.Class({
Name: 'ShellUserVerifier',
_init(client, params) {
_init: function(client, params) {
params = Params.parse(params, { reauthenticationOnly: false });
this._reauthOnly = params.reauthenticationOnly;
@@ -133,7 +133,7 @@ var ShellUserVerifier = new Lang.Class({
this._settings = new Gio.Settings({ schema_id: LOGIN_SCREEN_SCHEMA });
this._settings.connect('changed',
this._updateDefaultService.bind(this));
Lang.bind(this, this._updateDefaultService));
this._updateDefaultService();
this._fprintManager = Fprint.FprintManager();
@@ -147,9 +147,9 @@ var ShellUserVerifier = new Lang.Class({
this._checkForSmartcard();
this._smartcardInsertedId = this._smartcardManager.connect('smartcard-inserted',
this._checkForSmartcard.bind(this));
Lang.bind(this, this._checkForSmartcard));
this._smartcardRemovedId = this._smartcardManager.connect('smartcard-removed',
this._checkForSmartcard.bind(this));
Lang.bind(this, this._checkForSmartcard));
this._messageQueue = [];
this._messageQueueTimeoutId = 0;
@@ -164,10 +164,10 @@ var ShellUserVerifier = new Lang.Class({
this._oVirtUserAuthenticated(this._oVirtCredentialsManager.getToken());
this._oVirtUserAuthenticatedId = this._oVirtCredentialsManager.connect('user-authenticated',
this._oVirtUserAuthenticated.bind(this));
Lang.bind(this, this._oVirtUserAuthenticated));
},
begin(userName, hold) {
begin: function(userName, hold) {
this._cancellable = new Gio.Cancellable();
this._hold = hold;
this._userName = userName;
@@ -179,13 +179,13 @@ var ShellUserVerifier = new Lang.Class({
// If possible, reauthenticate an already running session,
// so any session specific credentials get updated appropriately
this._client.open_reauthentication_channel(userName, this._cancellable,
this._reauthenticationChannelOpened.bind(this));
Lang.bind(this, this._reauthenticationChannelOpened));
} else {
this._client.get_user_verifier(this._cancellable, this._userVerifierGot.bind(this));
this._client.get_user_verifier(this._cancellable, Lang.bind(this, this._userVerifierGot));
}
},
cancel() {
cancel: function() {
if (this._cancellable)
this._cancellable.cancel();
@@ -195,14 +195,14 @@ var ShellUserVerifier = new Lang.Class({
}
},
_clearUserVerifier() {
_clearUserVerifier: function() {
if (this._userVerifier) {
this._userVerifier.run_dispose();
this._userVerifier = null;
}
},
clear() {
clear: function() {
if (this._cancellable) {
this._cancellable.cancel();
this._cancellable = null;
@@ -212,7 +212,7 @@ var ShellUserVerifier = new Lang.Class({
this._clearMessageQueue();
},
destroy() {
destroy: function() {
this.clear();
this._settings.run_dispose();
@@ -226,23 +226,24 @@ var ShellUserVerifier = new Lang.Class({
this._oVirtCredentialsManager = null;
},
answerQuery(serviceName, answer) {
answerQuery: function(serviceName, answer) {
if (!this.hasPendingMessages) {
this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
} else {
let signalId = this.connect('no-more-messages', () => {
this.disconnect(signalId);
this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
});
let signalId = this.connect('no-more-messages',
Lang.bind(this, function() {
this.disconnect(signalId);
this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
}));
}
},
_getIntervalForMessage(message) {
_getIntervalForMessage: function(message) {
// We probably could be smarter here
return message.length * USER_READ_TIME;
},
finishMessageQueue() {
finishMessageQueue: function() {
if (!this.hasPendingMessages)
return;
@@ -252,7 +253,7 @@ var ShellUserVerifier = new Lang.Class({
this.emit('no-more-messages');
},
_queueMessageTimeout() {
_queueMessageTimeout: function() {
if (this._messageQueue.length == 0) {
this.finishMessageQueue();
return;
@@ -267,15 +268,15 @@ var ShellUserVerifier = new Lang.Class({
this._messageQueueTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
message.interval,
() => {
Lang.bind(this, function() {
this._messageQueueTimeoutId = 0;
this._queueMessageTimeout();
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._messageQueueTimeoutId, '[gnome-shell] this._queueMessageTimeout');
},
_queueMessage(message, messageType) {
_queueMessage: function(message, messageType) {
let interval = this._getIntervalForMessage(message);
this.hasPendingMessages = true;
@@ -283,7 +284,7 @@ var ShellUserVerifier = new Lang.Class({
this._queueMessageTimeout();
},
_clearMessageQueue() {
_clearMessageQueue: function() {
this.finishMessageQueue();
if (this._messageQueueTimeoutId != 0) {
@@ -293,7 +294,7 @@ var ShellUserVerifier = new Lang.Class({
this.emit('show-message', null, MessageType.NONE);
},
_checkForFingerprintReader() {
_checkForFingerprintReader: function() {
this._haveFingerprintReader = false;
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY) ||
@@ -302,21 +303,21 @@ var ShellUserVerifier = new Lang.Class({
return;
}
this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable,
(device, error) => {
this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable, Lang.bind(this,
function(device, error) {
if (!error && device) {
this._haveFingerprintReader = true;
this._updateDefaultService();
}
});
}));
},
_oVirtUserAuthenticated(token) {
_oVirtUserAuthenticated: function(token) {
this._preemptingService = OVIRT_SERVICE_NAME;
this.emit('ovirt-user-authenticated');
},
_checkForSmartcard() {
_checkForSmartcard: function() {
let smartcardDetected;
if (!this._settings.get_boolean(SMARTCARD_AUTHENTICATION_KEY))
@@ -338,7 +339,7 @@ var ShellUserVerifier = new Lang.Class({
}
},
_reportInitError(where, error) {
_reportInitError: function(where, error) {
logError(error, where);
this._hold.release();
@@ -346,7 +347,7 @@ var ShellUserVerifier = new Lang.Class({
this._verificationFailed(false);
},
_reauthenticationChannelOpened(client, result) {
_reauthenticationChannelOpened: function(client, result) {
try {
this._clearUserVerifier();
this._userVerifier = client.open_reauthentication_channel_finish(result);
@@ -357,7 +358,7 @@ var ShellUserVerifier = new Lang.Class({
// Gdm emits org.freedesktop.DBus.Error.AccessDenied when there is
// no session to reauthenticate. Fall back to performing verification
// from this login session
client.get_user_verifier(this._cancellable, this._userVerifierGot.bind(this));
client.get_user_verifier(this._cancellable, Lang.bind(this, this._userVerifierGot));
return;
} catch(e) {
this._reportInitError('Failed to open reauthentication channel', e);
@@ -370,7 +371,7 @@ var ShellUserVerifier = new Lang.Class({
this._hold.release();
},
_userVerifierGot(client, result) {
_userVerifierGot: function(client, result) {
try {
this._clearUserVerifier();
this._userVerifier = client.get_user_verifier_finish(result);
@@ -386,52 +387,47 @@ var ShellUserVerifier = new Lang.Class({
this._hold.release();
},
_connectSignals() {
this._userVerifier.connect('info', this._onInfo.bind(this));
this._userVerifier.connect('problem', this._onProblem.bind(this));
this._userVerifier.connect('info-query', this._onInfoQuery.bind(this));
this._userVerifier.connect('secret-info-query', this._onSecretInfoQuery.bind(this));
this._userVerifier.connect('conversation-stopped', this._onConversationStopped.bind(this));
this._userVerifier.connect('reset', this._onReset.bind(this));
this._userVerifier.connect('verification-complete', this._onVerificationComplete.bind(this));
_connectSignals: function() {
this._userVerifier.connect('info', Lang.bind(this, this._onInfo));
this._userVerifier.connect('problem', Lang.bind(this, this._onProblem));
this._userVerifier.connect('info-query', Lang.bind(this, this._onInfoQuery));
this._userVerifier.connect('secret-info-query', Lang.bind(this, this._onSecretInfoQuery));
this._userVerifier.connect('conversation-stopped', Lang.bind(this, this._onConversationStopped));
this._userVerifier.connect('reset', Lang.bind(this, this._onReset));
this._userVerifier.connect('verification-complete', Lang.bind(this, this._onVerificationComplete));
},
_getForegroundService() {
_getForegroundService: function() {
if (this._preemptingService)
return this._preemptingService;
return this._defaultService;
},
serviceIsForeground(serviceName) {
serviceIsForeground: function(serviceName) {
return serviceName == this._getForegroundService();
},
serviceIsDefault(serviceName) {
serviceIsDefault: function(serviceName) {
return serviceName == this._defaultService;
},
_updateDefaultService() {
_updateDefaultService: function() {
if (this._settings.get_boolean(PASSWORD_AUTHENTICATION_KEY))
this._defaultService = PASSWORD_SERVICE_NAME;
else if (this._settings.get_boolean(SMARTCARD_AUTHENTICATION_KEY))
this._defaultService = SMARTCARD_SERVICE_NAME;
else if (this._haveFingerprintReader)
this._defaultService = FINGERPRINT_SERVICE_NAME;
if (!this._defaultService) {
log("no authentication service is enabled, using password authentication");
this._defaultService = PASSWORD_SERVICE_NAME;
}
},
_startService(serviceName) {
_startService: function(serviceName) {
this._hold.acquire();
if (this._userName) {
this._userVerifier.call_begin_verification_for_user(serviceName,
this._userName,
this._cancellable,
(obj, result) => {
Lang.bind(this, function(obj, result) {
try {
obj.call_begin_verification_for_user_finish(result);
} catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
@@ -442,11 +438,11 @@ var ShellUserVerifier = new Lang.Class({
}
this._hold.release();
});
}));
} else {
this._userVerifier.call_begin_verification(serviceName,
this._cancellable,
(obj, result) => {
Lang.bind(this, function(obj, result) {
try {
obj.call_begin_verification_finish(result);
} catch(e if e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED)) {
@@ -457,18 +453,18 @@ var ShellUserVerifier = new Lang.Class({
}
this._hold.release();
});
}));
}
},
_beginVerification() {
_beginVerification: function() {
this._startService(this._getForegroundService());
if (this._userName && this._haveFingerprintReader && !this.serviceIsForeground(FINGERPRINT_SERVICE_NAME))
this._startService(FINGERPRINT_SERVICE_NAME);
},
_onInfo(client, serviceName, info) {
_onInfo: function(client, serviceName, info) {
if (this.serviceIsForeground(serviceName)) {
this._queueMessage(info, MessageType.INFO);
} else if (serviceName == FINGERPRINT_SERVICE_NAME &&
@@ -483,21 +479,21 @@ var ShellUserVerifier = new Lang.Class({
}
},
_onProblem(client, serviceName, problem) {
_onProblem: function(client, serviceName, problem) {
if (!this.serviceIsForeground(serviceName))
return;
this._queueMessage(problem, MessageType.ERROR);
},
_onInfoQuery(client, serviceName, question) {
_onInfoQuery: function(client, serviceName, question) {
if (!this.serviceIsForeground(serviceName))
return;
this.emit('ask-question', serviceName, question, '');
},
_onSecretInfoQuery(client, serviceName, secretQuestion) {
_onSecretInfoQuery: function(client, serviceName, secretQuestion) {
if (!this.serviceIsForeground(serviceName))
return;
@@ -510,7 +506,7 @@ var ShellUserVerifier = new Lang.Class({
this.emit('ask-question', serviceName, secretQuestion, '\u25cf');
},
_onReset() {
_onReset: function() {
// Clear previous attempts to authenticate
this._failCounter = 0;
this._updateDefaultService();
@@ -518,20 +514,20 @@ var ShellUserVerifier = new Lang.Class({
this.emit('reset');
},
_onVerificationComplete() {
_onVerificationComplete: function() {
this.emit('verification-complete');
},
_cancelAndReset() {
_cancelAndReset: function() {
this.cancel();
this._onReset();
},
_retry() {
_retry: function() {
this.begin(this._userName, new Batch.Hold());
},
_verificationFailed(retry) {
_verificationFailed: function(retry) {
// For Not Listed / enterprise logins, immediately reset
// the dialog
// Otherwise, we allow ALLOWED_FAILURES attempts. After that, we
@@ -545,27 +541,29 @@ var ShellUserVerifier = new Lang.Class({
if (!this.hasPendingMessages) {
this._retry();
} else {
let signalId = this.connect('no-more-messages', () => {
this.disconnect(signalId);
if (this._cancellable && !this._cancellable.is_cancelled())
this._retry();
});
let signalId = this.connect('no-more-messages',
Lang.bind(this, function() {
this.disconnect(signalId);
if (this._cancellable && !this._cancellable.is_cancelled())
this._retry();
}));
}
} else {
if (!this.hasPendingMessages) {
this._cancelAndReset();
} else {
let signalId = this.connect('no-more-messages', () => {
this.disconnect(signalId);
this._cancelAndReset();
});
let signalId = this.connect('no-more-messages',
Lang.bind(this, function() {
this.disconnect(signalId);
this._cancelAndReset();
}));
}
}
this.emit('verification-failed');
},
_onConversationStopped(client, serviceName) {
_onConversationStopped: function(client, serviceName) {
// If the login failed with the preauthenticated oVirt credentials
// then discard the credentials and revert to default authentication
// mechanism.

View File

@@ -161,7 +161,7 @@ function installImporter(extension) {
var ExtensionFinder = new Lang.Class({
Name: 'ExtensionFinder',
_loadExtension(extensionDir, info, perUserDir) {
_loadExtension: function(extensionDir, info, perUserDir) {
let fileType = info.get_file_type();
if (fileType != Gio.FileType.DIRECTORY)
return;
@@ -184,11 +184,9 @@ var ExtensionFinder = new Lang.Class({
this.emit('extension-found', extension);
},
scanExtensions() {
scanExtensions: function() {
let perUserDir = Gio.File.new_for_path(global.userdatadir);
FileUtils.collectFromDatadirs('extensions', true, (dir, info) => {
this._loadExtension(dir, info, perUserDir);
});
FileUtils.collectFromDatadirs('extensions', true, Lang.bind(this, this._loadExtension, perUserDir));
}
});
Signals.addSignalMethods(ExtensionFinder.prototype);

View File

@@ -10,7 +10,7 @@ var DEFAULT_LIMIT = 512;
var HistoryManager = new Lang.Class({
Name: 'HistoryManager',
_init(params) {
_init: function(params) {
params = Params.parse(params, { gsettingsKey: null,
limit: DEFAULT_LIMIT,
entry: null });
@@ -22,7 +22,7 @@ var HistoryManager = new Lang.Class({
if (this._key) {
this._history = global.settings.get_strv(this._key);
global.settings.connect('changed::' + this._key,
this._historyChanged.bind(this));
Lang.bind(this, this._historyChanged));
} else {
this._history = [];
@@ -32,16 +32,16 @@ var HistoryManager = new Lang.Class({
if (this._entry) {
this._entry.connect('key-press-event',
this._onEntryKeyPress.bind(this));
Lang.bind(this, this._onEntryKeyPress));
}
},
_historyChanged() {
_historyChanged: function() {
this._history = global.settings.get_strv(this._key);
this._historyIndex = this._history.length;
},
_setPrevItem(text) {
_setPrevItem: function(text) {
if (this._historyIndex <= 0)
return false;
@@ -52,7 +52,7 @@ var HistoryManager = new Lang.Class({
return true;
},
_setNextItem(text) {
_setNextItem: function(text) {
if (this._historyIndex >= this._history.length)
return false;
@@ -63,7 +63,7 @@ var HistoryManager = new Lang.Class({
return true;
},
lastItem() {
lastItem: function() {
if (this._historyIndex != this._history.length) {
this._historyIndex = this._history.length;
this._indexChanged();
@@ -72,7 +72,7 @@ var HistoryManager = new Lang.Class({
return this._historyIndex ? this._history[this._historyIndex -1] : null;
},
addItem(input) {
addItem: function(input) {
if (this._history.length == 0 ||
this._history[this._history.length - 1] != input) {
@@ -82,7 +82,7 @@ var HistoryManager = new Lang.Class({
this._historyIndex = this._history.length;
},
_onEntryKeyPress(entry, event) {
_onEntryKeyPress: function(entry, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Up) {
return this._setPrevItem(entry.get_text());
@@ -92,7 +92,7 @@ var HistoryManager = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_indexChanged() {
_indexChanged: function() {
let current = this._history[this._historyIndex] || '';
this.emit('changed', current);
@@ -100,7 +100,7 @@ var HistoryManager = new Lang.Class({
this._entry.set_text(current);
},
_save() {
_save: function() {
if (this._history.length > this._limit)
this._history.splice(0, this._history.length - this._limit);

View File

@@ -40,7 +40,7 @@ var IBusManager = new Lang.Class({
_MAX_INPUT_SOURCE_ACTIVATION_TIME: 4000, // ms
_PRELOAD_ENGINES_DELAY_TIME: 30, // sec
_init() {
_init: function() {
IBus.init();
this._candidatePopup = new IBusCandidatePopup.CandidatePopup();
@@ -53,16 +53,16 @@ var IBusManager = new Lang.Class({
this._preloadEnginesId = 0;
this._ibus = IBus.Bus.new_async();
this._ibus.connect('connected', this._onConnected.bind(this));
this._ibus.connect('disconnected', this._clear.bind(this));
this._ibus.connect('connected', Lang.bind(this, this._onConnected));
this._ibus.connect('disconnected', Lang.bind(this, this._clear));
// Need to set this to get 'global-engine-changed' emitions
this._ibus.set_watch_ibus_signal(true);
this._ibus.connect('global-engine-changed', this._engineChanged.bind(this));
this._ibus.connect('global-engine-changed', Lang.bind(this, this._engineChanged));
this._spawn();
},
_spawn() {
_spawn: function() {
try {
Gio.Subprocess.new(['ibus-daemon', '--xim', '--panel', 'disable'],
Gio.SubprocessFlags.NONE);
@@ -71,7 +71,7 @@ var IBusManager = new Lang.Class({
}
},
_clear() {
_clear: function() {
if (this._panelService)
this._panelService.destroy();
@@ -87,15 +87,15 @@ var IBusManager = new Lang.Class({
this._spawn();
},
_onConnected() {
this._ibus.list_engines_async(-1, null, this._initEngines.bind(this));
_onConnected: function() {
this._ibus.list_engines_async(-1, null, Lang.bind(this, this._initEngines));
this._ibus.request_name_async(IBus.SERVICE_PANEL,
IBus.BusNameFlag.REPLACE_EXISTING,
-1, null,
this._initPanelService.bind(this));
Lang.bind(this, this._initPanelService));
},
_initEngines(ibus, result) {
_initEngines: function(ibus, result) {
let enginesList = this._ibus.list_engines_async_finish(result);
if (enginesList) {
for (let i = 0; i < enginesList.length; ++i) {
@@ -108,13 +108,13 @@ var IBusManager = new Lang.Class({
}
},
_initPanelService(ibus, result) {
_initPanelService: function(ibus, result) {
let success = this._ibus.request_name_async_finish(result);
if (success) {
this._panelService = new IBus.PanelService({ connection: this._ibus.get_connection(),
object_path: IBus.PATH_PANEL });
this._candidatePopup.setPanelService(this._panelService);
this._panelService.connect('update-property', this._updateProperty.bind(this));
this._panelService.connect('update-property', Lang.bind(this, this._updateProperty));
try {
// IBus versions older than 1.5.10 have a bug which
// causes spurious set-content-type emissions when
@@ -122,11 +122,11 @@ var IBusManager = new Lang.Class({
// and hints defeating its intended semantics and
// confusing users. We thus don't use it in that case.
_checkIBusVersion(1, 5, 10);
this._panelService.connect('set-content-type', this._setContentType.bind(this));
this._panelService.connect('set-content-type', Lang.bind(this, this._setContentType));
} catch (e) {
}
// If an engine is already active we need to get its properties
this._ibus.get_global_engine_async(-1, null, (i, result) => {
this._ibus.get_global_engine_async(-1, null, Lang.bind(this, function(i, result) {
let engine;
try {
engine = this._ibus.get_global_engine_async_finish(result);
@@ -136,20 +136,20 @@ var IBusManager = new Lang.Class({
return;
}
this._engineChanged(this._ibus, engine.get_name());
});
}));
this._updateReadiness();
} else {
this._clear();
}
},
_updateReadiness() {
_updateReadiness: function() {
this._ready = (Object.keys(this._engines).length > 0 &&
this._panelService != null);
this.emit('ready', this._ready);
},
_engineChanged(bus, engineName) {
_engineChanged: function(bus, engineName) {
if (!this._ready)
return;
@@ -159,7 +159,7 @@ var IBusManager = new Lang.Class({
return;
this._registerPropertiesId =
this._panelService.connect('register-properties', (p, props) => {
this._panelService.connect('register-properties', Lang.bind(this, function(p, props) {
if (!props.get(0))
return;
@@ -167,29 +167,29 @@ var IBusManager = new Lang.Class({
this._registerPropertiesId = 0;
this.emit('properties-registered', this._currentEngineName, props);
});
}));
},
_updateProperty(panel, prop) {
_updateProperty: function(panel, prop) {
this.emit('property-updated', this._currentEngineName, prop);
},
_setContentType(panel, purpose, hints) {
_setContentType: function(panel, purpose, hints) {
this.emit('set-content-type', purpose, hints);
},
activateProperty(key, state) {
activateProperty: function(key, state) {
this._panelService.property_activate(key, state);
},
getEngineDesc(id) {
getEngineDesc: function(id) {
if (!this._ready || !this._engines.hasOwnProperty(id))
return null;
return this._engines[id];
},
setEngine(id, callback) {
setEngine: function(id, callback) {
// Send id even if id == this._currentEngineName
// because 'properties-registered' signal can be emitted
// while this._ibusSources == null on a lock screen.
@@ -203,7 +203,7 @@ var IBusManager = new Lang.Class({
null, callback);
},
preloadEngines(ids) {
preloadEngines: function(ids) {
if (!this._ibus || ids.length == 0)
return;
@@ -214,7 +214,7 @@ var IBusManager = new Lang.Class({
this._preloadEnginesId =
Mainloop.timeout_add_seconds(this._PRELOAD_ENGINES_DELAY_TIME,
() => {
Lang.bind(this, function() {
this._ibus.preload_engines_async(
ids,
-1,
@@ -222,7 +222,7 @@ var IBusManager = new Lang.Class({
null);
this._preloadEnginesId = 0;
return GLib.SOURCE_REMOVE;
});
}));
},
});
Signals.addSignalMethods(IBusManager.prototype);

View File

@@ -9,20 +9,20 @@ var InputMethod = new Lang.Class({
Name: 'InputMethod',
Extends: Clutter.InputMethod,
_init() {
_init: function() {
this.parent();
this._hints = 0;
this._purpose = 0;
this._enabled = true;
this._currentFocus = null;
this._ibus = IBus.Bus.new_async();
this._ibus.connect('connected', this._onConnected.bind(this));
this._ibus.connect('disconnected', this._clear.bind(this));
this.connect('notify::can-show-preedit', this._updateCapabilities.bind(this));
this._ibus.connect('connected', Lang.bind(this, this._onConnected));
this._ibus.connect('disconnected', Lang.bind(this, this._clear));
this.connect('notify::can-show-preedit', Lang.bind(this, this._updateCapabilities));
this._inputSourceManager = Keyboard.getInputSourceManager();
this._sourceChangedId = this._inputSourceManager.connect('current-source-changed',
this._onSourceChanged.bind(this));
Lang.bind(this, this._onSourceChanged));
this._currentSource = this._inputSourceManager.currentSource;
if (this._ibus.is_connected())
@@ -33,7 +33,7 @@ var InputMethod = new Lang.Class({
return this._currentFocus;
},
_updateCapabilities() {
_updateCapabilities: function() {
let caps = 0;
if (this.can_show_preedit)
@@ -48,47 +48,47 @@ var InputMethod = new Lang.Class({
this._context.set_capabilities(caps);
},
_onSourceChanged() {
_onSourceChanged: function() {
this._currentSource = this._inputSourceManager.currentSource;
},
_onConnected() {
_onConnected: function() {
this._ibus.create_input_context_async ('gnome-shell', -1, null,
this._setContext.bind(this));
Lang.bind(this, this._setContext));
},
_setContext(bus, res) {
_setContext: function(bus, res) {
this._context = this._ibus.create_input_context_async_finish(res);
this._context.connect('enabled', () => { this._enabled = true });
this._context.connect('disabled', () => { this._enabled = false });
this._context.connect('commit-text', this._onCommitText.bind(this));
this._context.connect('delete-surrounding-text', this._onDeleteSurroundingText.bind(this));
this._context.connect('update-preedit-text', this._onUpdatePreeditText.bind(this));
this._context.connect('enabled', Lang.bind(this, function () { this._enabled = true }));
this._context.connect('disabled', Lang.bind(this, function () { this._enabled = false }));
this._context.connect('commit-text', Lang.bind(this, this._onCommitText));
this._context.connect('delete-surrounding-text', Lang.bind(this, this._onDeleteSurroundingText));
this._context.connect('update-preedit-text', Lang.bind(this, this._onUpdatePreeditText));
this._updateCapabilities();
},
_clear() {
_clear: function() {
this._context = null;
this._hints = 0;
this._purpose = 0;
this._enabled = false;
},
_emitRequestSurrounding() {
_emitRequestSurrounding: function() {
if (this._context.needs_surrounding_text())
this.emit('request-surrounding');
},
_onCommitText(context, text) {
_onCommitText: function(context, text) {
this.commit(text.get_text());
},
_onDeleteSurroundingText(context) {
_onDeleteSurroundingText: function (context) {
this.delete_surrounding();
},
_onUpdatePreeditText(context, text, pos, visible) {
_onUpdatePreeditText: function (context, text, pos, visible) {
let str = null;
if (visible && text != null)
str = text.get_text();
@@ -96,7 +96,7 @@ var InputMethod = new Lang.Class({
this.set_preedit_text(str, pos);
},
vfunc_focus_in(focus) {
vfunc_focus_in: function(focus) {
this._currentFocus = focus;
if (this._context) {
this._context.focus_in();
@@ -105,7 +105,7 @@ var InputMethod = new Lang.Class({
}
},
vfunc_focus_out() {
vfunc_focus_out: function() {
this._currentFocus = null;
if (this._context) {
this._context.focus_out();
@@ -116,7 +116,7 @@ var InputMethod = new Lang.Class({
this.set_preedit_text(null, 0);
},
vfunc_reset() {
vfunc_reset: function() {
if (this._context) {
this._context.reset();
this._emitRequestSurrounding();
@@ -126,7 +126,7 @@ var InputMethod = new Lang.Class({
this.set_preedit_text(null, 0);
},
vfunc_set_cursor_location(rect) {
vfunc_set_cursor_location: function(rect) {
if (this._context) {
this._context.set_cursor_location(rect.get_x(), rect.get_y(),
rect.get_width(), rect.get_height());
@@ -134,12 +134,12 @@ var InputMethod = new Lang.Class({
}
},
vfunc_set_surrounding(text, cursor, anchor) {
vfunc_set_surrounding: function(text, cursor, anchor) {
if (this._context)
this._context.set_surrounding_text(text, cursor, anchor);
},
vfunc_update_content_hints(hints) {
vfunc_update_content_hints: function(hints) {
let ibusHints = 0;
if (hints & Clutter.InputContentHintFlags.COMPLETION)
ibusHints |= IBus.InputHints.WORD_COMPLETION;
@@ -159,7 +159,7 @@ var InputMethod = new Lang.Class({
this._context.set_content_type(this._purpose, this._hints);
},
vfunc_update_content_purpose(purpose) {
vfunc_update_content_purpose: function(purpose) {
let ibusPurpose = 0;
if (purpose == Clutter.InputContentPurpose.NORMAL)
ibusPurpose = IBus.InputPurpose.FREE_FORM;
@@ -185,7 +185,7 @@ var InputMethod = new Lang.Class({
this._context.set_content_type(this._purpose, this._hints);
},
vfunc_filter_key_event(event) {
vfunc_filter_key_event: function(event) {
if (!this._context || !this._enabled)
return false;
if (!this._currentSource ||
@@ -201,14 +201,14 @@ var InputMethod = new Lang.Class({
this._context.process_key_event_async(event.get_key_symbol(),
event.get_key_code() - 8, // Convert XKB keycodes to evcodes
state, -1, null,
(context, res) => {
Lang.bind(this, (context, res) => {
try {
let retval = context.process_key_event_async_finish(res);
this.notify_key_event(event, retval);
} catch (e) {
log('Error processing key on IM: ' + e.message);
}
});
}));
return true;
},
});

View File

@@ -23,9 +23,9 @@ function getCompletions(text, commandHeader, globalCompletionList) {
if (matches) {
[expr, base, attrHead] = matches;
methods = getPropertyNamesFromExpression(base, commandHeader).filter(
attr => attr.slice(0, attrHead.length) == attrHead
);
methods = getPropertyNamesFromExpression(base, commandHeader).filter(function(attr) {
return attr.slice(0, attrHead.length) == attrHead;
});
}
// Look for the empty expression or partially entered words
@@ -33,9 +33,9 @@ function getCompletions(text, commandHeader, globalCompletionList) {
matches = text.match(/^(\w*)$/);
if (text == '' || matches) {
[expr, attrHead] = matches;
methods = globalCompletionList.filter(
attr => attr.slice(0, attrHead.length) == attrHead
);
methods = globalCompletionList.filter(function(attr) {
return attr.slice(0, attrHead.length) == attrHead;
});
}
}
@@ -175,7 +175,7 @@ function getPropertyNamesFromExpression(expr, commandHeader) {
// Make sure propsUnique contains one key for every
// property so we end up with a unique list of properties
allProps.map(p => propsUnique[p] = null);
allProps.map(function(p){ propsUnique[p] = null; });
}
return Object.keys(propsUnique).sort();
}
@@ -233,7 +233,7 @@ function isUnsafeExpression(str) {
// Returns a list of global keywords derived from str
function getDeclaredConstants(str) {
let ret = [];
str.split(';').forEach(s => {
str.split(';').forEach(function(s) {
let base, keyword;
let match = s.match(/const\s+(\w+)\s*=/);
if (match) {

View File

@@ -47,24 +47,24 @@ var KeyboardManager = new Lang.Class({
// even as a Wayland compositor, we can't bump this.
MAX_LAYOUTS_PER_GROUP: 4,
_init() {
_init: function() {
this._xkbInfo = getXkbInfo();
this._current = null;
this._localeLayoutInfo = this._getLocaleLayout();
this._layoutInfos = {};
},
_applyLayoutGroup(group) {
_applyLayoutGroup: function(group) {
let options = this._buildOptionsString();
let [layouts, variants] = this._buildGroupStrings(group);
Meta.get_backend().set_keymap(layouts, variants, options);
},
_applyLayoutGroupIndex(idx) {
_applyLayoutGroupIndex: function(idx) {
Meta.get_backend().lock_layout_group(idx);
},
apply(id) {
apply: function(id) {
let info = this._layoutInfos[id];
if (!info)
return;
@@ -80,7 +80,7 @@ var KeyboardManager = new Lang.Class({
this._current = info;
},
reapply() {
reapply: function() {
if (!this._current)
return;
@@ -88,7 +88,7 @@ var KeyboardManager = new Lang.Class({
this._applyLayoutGroupIndex(this._current.groupIndex);
},
setUserLayouts(ids) {
setUserLayouts: function(ids) {
this._current = null;
this._layoutInfos = {};
@@ -119,7 +119,7 @@ var KeyboardManager = new Lang.Class({
}
},
_getLocaleLayout() {
_getLocaleLayout: function() {
let locale = GLib.get_language_names()[0];
if (locale.indexOf('_') == -1)
locale = DEFAULT_LOCALE;
@@ -136,18 +136,18 @@ var KeyboardManager = new Lang.Class({
return { layout: DEFAULT_LAYOUT, variant: DEFAULT_VARIANT };
},
_buildGroupStrings(_group) {
_buildGroupStrings: function(_group) {
let group = _group.concat(this._localeLayoutInfo);
let layouts = group.map(g => g.layout).join(',');
let variants = group.map(g => g.variant).join(',');
let layouts = group.map(function(g) { return g.layout; }).join(',');
let variants = group.map(function(g) { return g.variant; }).join(',');
return [layouts, variants];
},
setKeyboardOptions(options) {
setKeyboardOptions: function(options) {
this._xkbOptions = options;
},
_buildOptionsString() {
_buildOptionsString: function() {
let options = this._xkbOptions.join(',');
return options;
}

View File

@@ -105,15 +105,15 @@ function getLoginManager() {
var LoginManagerSystemd = new Lang.Class({
Name: 'LoginManagerSystemd',
_init() {
_init: function() {
this._proxy = new SystemdLoginManager(Gio.DBus.system,
'org.freedesktop.login1',
'/org/freedesktop/login1');
this._proxy.connectSignal('PrepareForSleep',
this._prepareForSleep.bind(this));
Lang.bind(this, this._prepareForSleep));
},
getCurrentSessionProxy(callback) {
getCurrentSessionProxy: function(callback) {
if (this._currentSession) {
callback (this._currentSession);
return;
@@ -125,20 +125,21 @@ var LoginManagerSystemd = new Lang.Class({
return;
}
this._proxy.GetSessionRemote(sessionId, (result, error) => {
if (error) {
logError(error, 'Could not get a proxy for the current session');
} else {
this._currentSession = new SystemdLoginSession(Gio.DBus.system,
'org.freedesktop.login1',
result[0]);
callback(this._currentSession);
}
});
this._proxy.GetSessionRemote(sessionId, Lang.bind(this,
function(result, error) {
if (error) {
logError(error, 'Could not get a proxy for the current session');
} else {
this._currentSession = new SystemdLoginSession(Gio.DBus.system,
'org.freedesktop.login1',
result[0]);
callback(this._currentSession);
}
}));
},
canSuspend(asyncCallback) {
this._proxy.CanSuspendRemote((result, error) => {
canSuspend: function(asyncCallback) {
this._proxy.CanSuspendRemote(function(result, error) {
if (error) {
asyncCallback(false, false);
} else {
@@ -149,8 +150,8 @@ var LoginManagerSystemd = new Lang.Class({
});
},
listSessions(asyncCallback) {
this._proxy.ListSessionsRemote((result, error) => {
listSessions: function(asyncCallback) {
this._proxy.ListSessionsRemote(function(result, error) {
if (error)
asyncCallback([]);
else
@@ -158,18 +159,18 @@ var LoginManagerSystemd = new Lang.Class({
});
},
suspend() {
suspend: function() {
this._proxy.SuspendRemote(true);
},
inhibit(reason, callback) {
inhibit: function(reason, callback) {
let inVariant = GLib.Variant.new('(ssss)',
['sleep',
'GNOME Shell',
reason,
'delay']);
this._proxy.call_with_unix_fd_list('Inhibit', inVariant, 0, -1, null, null,
(proxy, result) => {
Lang.bind(this, function(proxy, result) {
let fd = -1;
try {
let [outVariant, fdList] = proxy.call_with_unix_fd_list_finish(result);
@@ -179,10 +180,10 @@ var LoginManagerSystemd = new Lang.Class({
logError(e, "Error getting systemd inhibitor");
callback(null);
}
});
}));
},
_prepareForSleep(proxy, sender, [aboutToSuspend]) {
_prepareForSleep: function(proxy, sender, [aboutToSuspend]) {
this.emit('prepare-for-sleep', aboutToSuspend);
}
});
@@ -191,26 +192,26 @@ Signals.addSignalMethods(LoginManagerSystemd.prototype);
var LoginManagerDummy = new Lang.Class({
Name: 'LoginManagerDummy',
getCurrentSessionProxy(callback) {
getCurrentSessionProxy: function(callback) {
// we could return a DummySession object that fakes whatever callers
// expect (at the time of writing: connect() and connectSignal()
// methods), but just never calling the callback should be safer
},
canSuspend(asyncCallback) {
canSuspend: function(asyncCallback) {
asyncCallback(false, false);
},
listSessions(asyncCallback) {
listSessions: function(asyncCallback) {
asyncCallback([]);
},
suspend() {
suspend: function() {
this.emit('prepare-for-sleep', true);
this.emit('prepare-for-sleep', false);
},
inhibit(reason, callback) {
inhibit: function(reason, callback) {
callback(null);
}
});

View File

@@ -133,22 +133,22 @@ const ModemCdmaProxy = Gio.DBusProxy.makeProxyWrapper(ModemCdmaInterface);
var ModemGsm = new Lang.Class({
Name: 'ModemGsm',
_init(path) {
_init: function(path) {
this._proxy = new ModemGsmNetworkProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
this.signal_quality = 0;
this.operator_name = null;
// Code is duplicated because the function have different signatures
this._proxy.connectSignal('SignalQuality', (proxy, sender, [quality]) => {
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, [quality]) {
this.signal_quality = quality;
this.emit('notify::signal-quality');
});
this._proxy.connectSignal('RegistrationInfo', (proxy, sender, [status, code, name]) => {
}));
this._proxy.connectSignal('RegistrationInfo', Lang.bind(this, function(proxy, sender, [status, code, name]) {
this.operator_name = _findProviderForMccMnc(name, code);
this.emit('notify::operator-name');
});
this._proxy.GetRegistrationInfoRemote(([result], err) => {
}));
this._proxy.GetRegistrationInfoRemote(Lang.bind(this, function([result], err) {
if (err) {
log(err);
return;
@@ -157,8 +157,8 @@ var ModemGsm = new Lang.Class({
let [status, code, name] = result;
this.operator_name = _findProviderForMccMnc(name, code);
this.emit('notify::operator-name');
});
this._proxy.GetSignalQualityRemote((result, err) => {
}));
this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
if (err) {
// it will return an error if the device is not connected
this.signal_quality = 0;
@@ -167,7 +167,7 @@ var ModemGsm = new Lang.Class({
this.signal_quality = quality;
}
this.emit('notify::signal-quality');
});
}));
}
});
Signals.addSignalMethods(ModemGsm.prototype);
@@ -175,12 +175,12 @@ Signals.addSignalMethods(ModemGsm.prototype);
var ModemCdma = new Lang.Class({
Name: 'ModemCdma',
_init(path) {
_init: function(path) {
this._proxy = new ModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager', path);
this.signal_quality = 0;
this.operator_name = null;
this._proxy.connectSignal('SignalQuality', (proxy, sender, params) => {
this._proxy.connectSignal('SignalQuality', Lang.bind(this, function(proxy, sender, params) {
this.signal_quality = params[0];
this.emit('notify::signal-quality');
@@ -188,8 +188,8 @@ var ModemCdma = new Lang.Class({
// and we can finally call GetServingSystem
if (this.operator_name == null)
this._refreshServingSystem();
});
this._proxy.GetSignalQualityRemote((result, err) => {
}));
this._proxy.GetSignalQualityRemote(Lang.bind(this, function(result, err) {
if (err) {
// it will return an error if the device is not connected
this.signal_quality = 0;
@@ -198,11 +198,11 @@ var ModemCdma = new Lang.Class({
this.signal_quality = quality;
}
this.emit('notify::signal-quality');
});
}));
},
_refreshServingSystem() {
this._proxy.GetServingSystemRemote(([result], err) => {
_refreshServingSystem: function() {
this._proxy.GetServingSystemRemote(Lang.bind(this, function([result], err) {
if (err) {
// it will return an error if the device is not connected
this.operator_name = null;
@@ -212,7 +212,7 @@ var ModemCdma = new Lang.Class({
this.operator_name = _findProviderForSid(sid)
}
this.emit('notify::operator-name');
});
}));
}
});
Signals.addSignalMethods(ModemCdma.prototype);
@@ -247,40 +247,40 @@ const BroadbandModemCdmaProxy = Gio.DBusProxy.makeProxyWrapper(BroadbandModemCdm
var BroadbandModem = new Lang.Class({
Name: 'BroadbandModem',
_init(path, capabilities) {
_init: function(path, capabilities) {
this._proxy = new BroadbandModemProxy(Gio.DBus.system, 'org.freedesktop.ModemManager1', path);
this._proxy_3gpp = new BroadbandModem3gppProxy(Gio.DBus.system, 'org.freedesktop.ModemManager1', path);
this._proxy_cdma = new BroadbandModemCdmaProxy(Gio.DBus.system, 'org.freedesktop.ModemManager1', path);
this._capabilities = capabilities;
this._proxy.connect('g-properties-changed', (proxy, properties) => {
this._proxy.connect('g-properties-changed', Lang.bind(this, function(proxy, properties) {
if ('SignalQuality' in properties.deep_unpack())
this._reloadSignalQuality();
});
}));
this._reloadSignalQuality();
this._proxy_3gpp.connect('g-properties-changed', (proxy, properties) => {
this._proxy_3gpp.connect('g-properties-changed', Lang.bind(this, function(proxy, properties) {
let unpacked = properties.deep_unpack();
if ('OperatorName' in unpacked || 'OperatorCode' in unpacked)
this._reload3gppOperatorName();
});
}));
this._reload3gppOperatorName();
this._proxy_cdma.connect('g-properties-changed', (proxy, properties) => {
this._proxy_cdma.connect('g-properties-changed', Lang.bind(this, function(proxy, properties) {
let unpacked = properties.deep_unpack();
if ('Nid' in unpacked || 'Sid' in unpacked)
this._reloadCdmaOperatorName();
});
}));
this._reloadCdmaOperatorName();
},
_reloadSignalQuality() {
_reloadSignalQuality: function() {
let [quality, recent] = this._proxy.SignalQuality;
this.signal_quality = quality;
this.emit('notify::signal-quality');
},
_reloadOperatorName() {
_reloadOperatorName: function() {
let new_name = "";
if (this.operator_name_3gpp && this.operator_name_3gpp.length > 0)
new_name += this.operator_name_3gpp;
@@ -295,14 +295,14 @@ var BroadbandModem = new Lang.Class({
this.emit('notify::operator-name');
},
_reload3gppOperatorName() {
_reload3gppOperatorName: function() {
let name = this._proxy_3gpp.OperatorName;
let code = this._proxy_3gpp.OperatorCode;
this.operator_name_3gpp = _findProviderForMccMnc(name, code);
this._reloadOperatorName();
},
_reloadCdmaOperatorName() {
_reloadCdmaOperatorName: function() {
let sid = this._proxy_cdma.Sid;
this.operator_name_cdma = _findProviderForSid(sid);
this._reloadOperatorName();

View File

@@ -28,7 +28,7 @@ const ObjectManagerInfo = Gio.DBusInterfaceInfo.new_for_xml(ObjectManagerIface);
var ObjectManager = new Lang.Class({
Name: 'ObjectManager',
_init(params) {
_init: function(params) {
params = Params.parse(params, { connection: null,
name: null,
objectPath: null,
@@ -61,10 +61,10 @@ var ObjectManager = new Lang.Class({
this._numLoadInhibitors = 1;
this._managerProxy.init_async(GLib.PRIORITY_DEFAULT,
this._cancellable,
this._onManagerProxyLoaded.bind(this));
Lang.bind(this, this._onManagerProxyLoaded));
},
_tryToCompleteLoad() {
_tryToCompleteLoad: function() {
if (this._numLoadInhibitors == 0)
return;
@@ -75,7 +75,7 @@ var ObjectManager = new Lang.Class({
}
},
_addInterface(objectPath, interfaceName, onFinished) {
_addInterface: function(objectPath, interfaceName, onFinished) {
let info = this._interfaceInfos[interfaceName];
if (!info) {
@@ -93,7 +93,7 @@ var ObjectManager = new Lang.Class({
proxy.init_async(GLib.PRIORITY_DEFAULT,
this._cancellable,
(initable, result) => {
Lang.bind(this, function(initable, result) {
let error = null;
try {
initable.init_finish(result);
@@ -127,10 +127,10 @@ var ObjectManager = new Lang.Class({
if (onFinished)
onFinished();
});
}));
},
_removeInterface(objectPath, interfaceName) {
_removeInterface: function(objectPath, interfaceName) {
if (!this._objects[objectPath])
return;
@@ -156,7 +156,7 @@ var ObjectManager = new Lang.Class({
}
},
_onManagerProxyLoaded(initable, result) {
_onManagerProxyLoaded: function(initable, result) {
let error = null;
try {
initable.init_finish(result);
@@ -168,35 +168,35 @@ var ObjectManager = new Lang.Class({
}
this._managerProxy.connectSignal('InterfacesAdded',
(objectManager, sender, [objectPath, interfaces]) => {
Lang.bind(this, function(objectManager, sender, [objectPath, interfaces]) {
let interfaceNames = Object.keys(interfaces);
for (let i = 0; i < interfaceNames.length; i++)
this._addInterface(objectPath, interfaceNames[i]);
});
}));
this._managerProxy.connectSignal('InterfacesRemoved',
(objectManager, sender, [objectPath, interfaceNames]) => {
Lang.bind(this, function(objectManager, sender, [objectPath, interfaceNames]) {
for (let i = 0; i < interfaceNames.length; i++)
this._removeInterface(objectPath, interfaceNames[i]);
});
}));
if (Object.keys(this._interfaceInfos).length == 0) {
this._tryToCompleteLoad();
return;
}
this._managerProxy.connect('notify::g-name-owner', () => {
this._managerProxy.connect('notify::g-name-owner', Lang.bind(this, function() {
if (this._managerProxy.g_name_owner)
this._onNameAppeared();
else
this._onNameVanished();
});
}));
if (this._managerProxy.g_name_owner)
this._onNameAppeared();
},
_onNameAppeared() {
this._managerProxy.GetManagedObjectsRemote((result, error) => {
_onNameAppeared: function() {
this._managerProxy.GetManagedObjectsRemote(Lang.bind(this, function(result, error) {
if (!result) {
if (error) {
logError(error, 'could not get remote objects for service ' + this._serviceName + ' path ' + this._managerPath);
@@ -226,14 +226,14 @@ var ObjectManager = new Lang.Class({
this._numLoadInhibitors++;
this._addInterface(objectPath,
interfaceName,
this._tryToCompleteLoad.bind(this));
Lang.bind(this, this._tryToCompleteLoad));
}
}
this._tryToCompleteLoad();
});
}));
},
_onNameVanished() {
_onNameVanished: function() {
let objectPaths = Object.keys(this._objects);
for (let i = 0; i < objectPaths.length; i++) {
let object = this._objects[objectPaths];
@@ -248,14 +248,14 @@ var ObjectManager = new Lang.Class({
}
},
_registerInterfaces(interfaces) {
_registerInterfaces: function(interfaces) {
for (let i = 0; i < interfaces.length; i++) {
let info = Gio.DBusInterfaceInfo.new_for_xml(interfaces[i]);
this._interfaceInfos[info.name] = info;
}
},
getProxy(objectPath, interfaceName) {
getProxy: function(objectPath, interfaceName) {
let object = this._objects[objectPath];
if (!object)
@@ -264,7 +264,7 @@ var ObjectManager = new Lang.Class({
return object[interfaceName];
},
getProxiesForInterface(interfaceName) {
getProxiesForInterface: function(interfaceName) {
let proxyList = this._interfaces[interfaceName];
if (!proxyList)
@@ -273,7 +273,7 @@ var ObjectManager = new Lang.Class({
return proxyList;
},
getAllProxies() {
getAllProxies: function() {
let proxies = [];
let objectPaths = Object.keys(this._objects);

View File

@@ -2,7 +2,7 @@
// parse:
// @params: caller-provided parameter object, or %null
// @defaults-provided defaults object
// @defaults: function-provided defaults object
// @allowExtras: whether or not to allow properties not in @default
//
// Examines @params and fills in default values from @defaults for

View File

@@ -27,34 +27,34 @@ function getSmartcardManager() {
var SmartcardManager = new Lang.Class({
Name: 'SmartcardManager',
_init() {
_init: function() {
this._objectManager = new ObjectManager.ObjectManager({ connection: Gio.DBus.session,
name: "org.gnome.SettingsDaemon.Smartcard",
objectPath: '/org/gnome/SettingsDaemon/Smartcard',
knownInterfaces: [ SmartcardTokenIface ],
onLoaded: this._onLoaded.bind(this) });
onLoaded: Lang.bind(this, this._onLoaded) });
this._insertedTokens = {};
this._loginToken = null;
},
_onLoaded() {
_onLoaded: function() {
let tokens = this._objectManager.getProxiesForInterface('org.gnome.SettingsDaemon.Smartcard.Token');
for (let i = 0; i < tokens.length; i++)
this._addToken(tokens[i]);
this._objectManager.connect('interface-added', (objectManager, interfaceName, proxy) => {
this._objectManager.connect('interface-added', Lang.bind(this, function(objectManager, interfaceName, proxy) {
if (interfaceName == 'org.gnome.SettingsDaemon.Smartcard.Token')
this._addToken(proxy);
});
}));
this._objectManager.connect('interface-removed', (objectManager, interfaceName, proxy) => {
this._objectManager.connect('interface-removed', Lang.bind(this, function(objectManager, interfaceName, proxy) {
if (interfaceName == 'org.gnome.SettingsDaemon.Smartcard.Token')
this._removeToken(proxy);
});
}));
},
_updateToken(token) {
_updateToken: function(token) {
let objectPath = token.get_object_path();
delete this._insertedTokens[objectPath];
@@ -66,27 +66,28 @@ var SmartcardManager = new Lang.Class({
this._loginToken = token;
},
_addToken(token) {
_addToken: function(token) {
this._updateToken(token);
token.connect('g-properties-changed', (proxy, properties) => {
if ('IsInserted' in properties.deep_unpack()) {
this._updateToken(token);
token.connect('g-properties-changed',
Lang.bind(this, function(proxy, properties) {
if ('IsInserted' in properties.deep_unpack()) {
this._updateToken(token);
if (token.IsInserted) {
this.emit('smartcard-inserted', token);
} else {
this.emit('smartcard-removed', token);
}
}
});
if (token.IsInserted) {
this.emit('smartcard-inserted', token);
} else {
this.emit('smartcard-removed', token);
}
}
}));
// Emit a smartcard-inserted at startup if it's already plugged in
if (token.IsInserted)
this.emit('smartcard-inserted', token);
},
_removeToken(token) {
_removeToken: function(token) {
let objectPath = token.get_object_path();
if (this._insertedTokens[objectPath] == token) {
@@ -100,11 +101,11 @@ var SmartcardManager = new Lang.Class({
token.disconnectAll();
},
hasInsertedTokens() {
hasInsertedTokens: function() {
return Object.keys(this._insertedTokens).length > 0;
},
hasInsertedLoginToken() {
hasInsertedLoginToken: function() {
if (!this._loginToken)
return false;

View File

@@ -87,7 +87,7 @@ const SystemActions = new Lang.Class({
null)
},
_init() {
_init: function() {
this.parent();
this._canHavePowerOff = true;
@@ -218,7 +218,7 @@ const SystemActions = new Lang.Class({
return this._actions.get(LOCK_ORIENTATION_ACTION_ID).iconName;
},
_sensorProxyAppeared() {
_sensorProxyAppeared: function() {
this._sensorProxy = new SensorProxy(Gio.DBus.system, SENSOR_BUS_NAME, SENSOR_OBJECT_PATH,
(proxy, error) => {
if (error) {
@@ -231,7 +231,7 @@ const SystemActions = new Lang.Class({
});
},
_updateOrientationLock() {
_updateOrientationLock: function() {
let available = false;
if (this._sensorProxy)
available = this._sensorProxy.HasAccelerometer &&
@@ -242,7 +242,7 @@ const SystemActions = new Lang.Class({
this.notify('can-lock-orientation');
},
_updateOrientationLockIcon() {
_updateOrientationLockIcon: function() {
let locked = this._orientationSettings.get_boolean('orientation-lock');
let iconName = locked ? 'rotation-locked-symbolic'
: 'rotation-allowed-symbolic';
@@ -251,14 +251,14 @@ const SystemActions = new Lang.Class({
this.notify('orientation-lock-icon');
},
_sessionUpdated() {
_sessionUpdated: function() {
this._updateLockScreen();
this._updatePowerOff();
this._updateSuspend();
this._updateMultiUser();
},
forceUpdate() {
forceUpdate: function() {
// Whether those actions are available or not depends on both lockdown
// settings and Polkit policy - we don't get change notifications for the
// latter, so their value may be outdated; force an update now
@@ -266,7 +266,7 @@ const SystemActions = new Lang.Class({
this._updateHaveSuspend();
},
getMatchingActions(terms) {
getMatchingActions: function(terms) {
// terms is a list of strings
terms = terms.map((term) => { return term.toLowerCase(); });
@@ -279,15 +279,15 @@ const SystemActions = new Lang.Class({
return results;
},
getName(id) {
getName: function(id) {
return this._actions.get(id).name;
},
getIconName(id) {
getIconName: function(id) {
return this._actions.get(id).iconName;
},
activateAction(id) {
activateAction: function(id) {
switch (id) {
case POWER_OFF_ACTION_ID:
this.activatePowerOff();
@@ -317,7 +317,7 @@ const SystemActions = new Lang.Class({
this.notify('can-lock-screen');
},
_updateHaveShutdown() {
_updateHaveShutdown: function() {
this._session.CanShutdownRemote((result, error) => {
if (error)
return;
@@ -327,7 +327,7 @@ const SystemActions = new Lang.Class({
});
},
_updatePowerOff() {
_updatePowerOff: function() {
let disabled = Main.sessionMode.isLocked ||
(Main.sessionMode.isGreeter &&
this._loginScreenSettings.get_boolean(DISABLE_RESTART_KEY));
@@ -335,7 +335,7 @@ const SystemActions = new Lang.Class({
this.notify('can-power-off');
},
_updateHaveSuspend() {
_updateHaveSuspend: function() {
this._loginManager.canSuspend(
(canSuspend, needsAuth) => {
this._canHaveSuspend = canSuspend;
@@ -344,7 +344,7 @@ const SystemActions = new Lang.Class({
});
},
_updateSuspend() {
_updateSuspend: function() {
let disabled = (Main.sessionMode.isLocked &&
this._suspendNeedsAuth) ||
(Main.sessionMode.isGreeter &&
@@ -353,12 +353,12 @@ const SystemActions = new Lang.Class({
this.notify('can-suspend');
},
_updateMultiUser() {
_updateMultiUser: function() {
this._updateLogout();
this._updateSwitchUser();
},
_updateSwitchUser() {
_updateSwitchUser: function() {
let allowSwitch = !this._lockdownSettings.get_boolean(DISABLE_USER_SWITCH_KEY);
let multiUser = this._userManager.can_switch() && this._userManager.has_multiple_users;
let shouldShowInMode = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
@@ -370,7 +370,7 @@ const SystemActions = new Lang.Class({
return visible;
},
_updateLogout() {
_updateLogout: function() {
let user = this._userManager.get_user(GLib.get_user_name());
let allowLogout = !this._lockdownSettings.get_boolean(DISABLE_LOG_OUT_KEY);
@@ -388,7 +388,7 @@ const SystemActions = new Lang.Class({
return visible;
},
activateLockOrientation() {
activateLockOrientation: function() {
if (!this._actions.get(LOCK_ORIENTATION_ACTION_ID).available)
throw new Error('The lock-orientation action is not available!');
@@ -396,27 +396,27 @@ const SystemActions = new Lang.Class({
this._orientationSettings.set_boolean('orientation-lock', !locked);
},
activateLockScreen() {
activateLockScreen: function() {
if (!this._actions.get(LOCK_SCREEN_ACTION_ID).available)
throw new Error('The lock-screen action is not available!');
Main.screenShield.lock(true);
},
activateSwitchUser() {
activateSwitchUser: function() {
if (!this._actions.get(SWITCH_USER_ACTION_ID).available)
throw new Error('The switch-user action is not available!');
if (Main.screenShield)
Main.screenShield.lock(false);
Clutter.threads_add_repaint_func_full(Clutter.RepaintFlags.POST_PAINT, () => {
Clutter.threads_add_repaint_func_full(Clutter.RepaintFlags.POST_PAINT, function() {
Gdm.goto_login_session_sync(null);
return false;
});
},
activateLogout() {
activateLogout: function() {
if (!this._actions.get(LOGOUT_ACTION_ID).available)
throw new Error('The logout action is not available!');
@@ -424,14 +424,14 @@ const SystemActions = new Lang.Class({
this._session.LogoutRemote(0);
},
activatePowerOff() {
activatePowerOff: function() {
if (!this._actions.get(POWER_OFF_ACTION_ID).available)
throw new Error('The power-off action is not available!');
this._session.ShutdownRemote(0);
},
activateSuspend() {
activateSuspend: function() {
if (!this._actions.get(SUSPEND_ACTION_ID).available)
throw new Error('The suspend action is not available!');

View File

@@ -136,7 +136,7 @@ function trySpawn(argv)
// Dummy child watch; we don't want to double-fork internally
// because then we lose the parent-child relationship, which
// can break polkit. See https://bugzilla.redhat.com//show_bug.cgi?id=819275
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, () => {});
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, function () {});
}
// trySpawnCommandLine:
@@ -291,10 +291,12 @@ function createTimeLabel(date, params) {
_desktopSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.interface' });
let label = new St.Label({ text: formatTime(date, params) });
let id = _desktopSettings.connect('changed::clock-format', () => {
let id = _desktopSettings.connect('changed::clock-format', function() {
label.text = formatTime(date, params);
});
label.connect('destroy', () => { _desktopSettings.disconnect(id); });
label.connect('destroy', function() {
_desktopSettings.disconnect(id);
});
return label;
}
@@ -314,7 +316,7 @@ function createTimeLabel(date, params) {
function lowerBound(array, val, cmp) {
let min, max, mid, v;
cmp = cmp || ((a, b) => a - b);
cmp = cmp || function(a, b) { return a - b; };
if (array.length == 0)
return 0;
@@ -352,7 +354,7 @@ var CloseButton = new Lang.Class({
Name: 'CloseButton',
Extends: St.Button,
_init(boxpointer) {
_init: function(boxpointer) {
this.parent({ style_class: 'notification-close'});
// This is a bit tricky. St.Bin has its own x-align/y-align properties
@@ -369,10 +371,10 @@ var CloseButton = new Lang.Class({
this._boxPointer = boxpointer;
if (boxpointer)
this._boxPointer.connect('arrow-side-changed', this._sync.bind(this));
this._boxPointer.connect('arrow-side-changed', Lang.bind(this, this._sync));
},
_computeBoxPointerOffset() {
_computeBoxPointerOffset: function() {
if (!this._boxPointer || !this._boxPointer.actor.get_stage())
return 0;
@@ -383,7 +385,7 @@ var CloseButton = new Lang.Class({
return 0;
},
_sync() {
_sync: function() {
let themeNode = this.get_theme_node();
let offY = this._computeBoxPointerOffset();
@@ -391,7 +393,7 @@ var CloseButton = new Lang.Class({
this.translation_y = themeNode.get_length('-shell-close-overlap-y') + offY;
},
vfunc_style_changed() {
vfunc_style_changed: function() {
this._sync();
this.parent();
},
@@ -440,7 +442,7 @@ function ensureActorVisibleInScrollView(scrollView, actor) {
var AppSettingsMonitor = new Lang.Class({
Name: 'AppSettingsMonitor',
_init(appId, schemaId) {
_init: function(appId, schemaId) {
this._appId = appId;
this._schemaId = schemaId;
@@ -452,7 +454,7 @@ var AppSettingsMonitor = new Lang.Class({
this._appSystem = Shell.AppSystem.get_default();
this._appSystem.connect('installed-changed',
this._onInstalledChanged.bind(this));
Lang.bind(this, this._onInstalledChanged));
this._onInstalledChanged();
},
@@ -460,19 +462,19 @@ var AppSettingsMonitor = new Lang.Class({
return this._app != null && this._settings != null;
},
activateApp() {
activateApp: function() {
if (this._app)
this._app.activate();
},
watchSetting(key, callback) {
watchSetting: function(key, callback) {
let handler = { id: 0, key: key, callback: callback };
this._handlers.push(handler);
this._connectHandler(handler);
},
_connectHandler(handler) {
_connectHandler: function(handler) {
if (!this._settings || handler.id > 0)
return;
@@ -481,13 +483,13 @@ var AppSettingsMonitor = new Lang.Class({
handler.callback(this._settings, handler.key);
},
_disconnectHandler(handler) {
_disconnectHandler: function(handler) {
if (this._settings && handler.id > 0)
this._settings.disconnect(handler.id);
handler.id = 0;
},
_onInstalledChanged() {
_onInstalledChanged: function() {
let hadApp = (this._app != null);
this._app = this._appSystem.lookup_app(this._appId);
let haveApp = (this._app != null);
@@ -501,7 +503,7 @@ var AppSettingsMonitor = new Lang.Class({
this._setSettings(null);
},
_setSettings(settings) {
_setSettings: function(settings) {
this._handlers.forEach((handler) => { this._disconnectHandler(handler); });
let hadSettings = (this._settings != null);
@@ -514,7 +516,7 @@ var AppSettingsMonitor = new Lang.Class({
this.emit('available-changed');
},
_checkSettings() {
_checkSettings: function() {
let schema = this._schemaSource.lookup(this._schemaId, true);
if (schema) {
this._setSettings(new Gio.Settings({ settings_schema: schema }));

View File

@@ -16,7 +16,7 @@ var UPDATE_THRESHOLD = 10 * GLib.TIME_SPAN_MINUTE;
var WeatherClient = new Lang.Class({
Name: 'WeatherClient',
_init() {
_init: function() {
this._loading = false;
this._locationValid = false;
this._lastUpdate = GLib.DateTime.new_from_unix_local(0);
@@ -46,11 +46,11 @@ var WeatherClient = new Lang.Class({
});
});
this._permStore.connectSignal('Changed',
this._onPermStoreChanged.bind(this));
Lang.bind(this, this._onPermStoreChanged));
this._locationSettings = new Gio.Settings({ schema_id: 'org.gnome.system.location' });
this._locationSettings.connect('changed::enabled',
this._updateAutoLocation.bind(this));
Lang.bind(this, this._updateAutoLocation));
this._world = GWeather.Location.get_world();
@@ -68,9 +68,9 @@ var WeatherClient = new Lang.Class({
'org.gnome.Weather.Application');
this._weatherAppMon.connect('available-changed', () => { this.emit('changed'); });
this._weatherAppMon.watchSetting('automatic-location',
this._onAutomaticLocationChanged.bind(this));
Lang.bind(this, this._onAutomaticLocationChanged));
this._weatherAppMon.watchSetting('locations',
this._onLocationsChanged.bind(this));
Lang.bind(this, this._onLocationsChanged));
},
get available() {
@@ -89,11 +89,11 @@ var WeatherClient = new Lang.Class({
return this._weatherInfo;
},
activateApp() {
activateApp: function() {
this._weatherAppMon.activateApp();
},
update() {
update: function() {
if (!this._locationValid)
return;
@@ -112,7 +112,7 @@ var WeatherClient = new Lang.Class({
this._weatherAuthorized;
},
_loadInfo() {
_loadInfo: function() {
let id = this._weatherInfo.connect('updated', () => {
this._weatherInfo.disconnect(id);
this._loading = false;
@@ -124,7 +124,7 @@ var WeatherClient = new Lang.Class({
this._weatherInfo.update();
},
_locationsEqual(loc1, loc2) {
_locationsEqual: function(loc1, loc2) {
if (loc1 == loc2)
return true;
@@ -134,7 +134,7 @@ var WeatherClient = new Lang.Class({
return loc1.equal(loc2);
},
_setLocation(location) {
_setLocation: function(location) {
if (this._locationsEqual(this._weatherInfo.location, location))
return;
@@ -150,14 +150,14 @@ var WeatherClient = new Lang.Class({
this.emit('changed');
},
_updateLocationMonitoring() {
_updateLocationMonitoring: function() {
if (this._useAutoLocation) {
if (this._gclueLocationChangedId != 0 || this._gclueService == null)
return;
this._gclueLocationChangedId =
this._gclueService.connect('notify::location',
this._onGClueLocationChanged.bind(this));
Lang.bind(this, this._onGClueLocationChanged));
this._onGClueLocationChanged();
} else {
if (this._gclueLocationChangedId)
@@ -166,7 +166,7 @@ var WeatherClient = new Lang.Class({
}
},
_startGClueService() {
_startGClueService: function() {
if (this._gclueStarting)
return;
@@ -187,7 +187,7 @@ var WeatherClient = new Lang.Class({
});
},
_onGClueLocationChanged() {
_onGClueLocationChanged: function() {
let geoLocation = this._gclueService.location;
let location = GWeather.Location.new_detached(geoLocation.description,
null,
@@ -196,7 +196,7 @@ var WeatherClient = new Lang.Class({
this._setLocation(location);
},
_onAutomaticLocationChanged(settings, key) {
_onAutomaticLocationChanged: function(settings, key) {
let useAutoLocation = settings.get_boolean(key);
if (this._autoLocationRequested == useAutoLocation)
return;
@@ -206,7 +206,7 @@ var WeatherClient = new Lang.Class({
this._updateAutoLocation();
},
_updateAutoLocation() {
_updateAutoLocation: function() {
this._updateLocationMonitoring();
if (this._useAutoLocation)
@@ -215,7 +215,7 @@ var WeatherClient = new Lang.Class({
this._setLocation(this._mostRecentLocation);
},
_onLocationsChanged(settings, key) {
_onLocationsChanged: function(settings, key) {
let serialized = settings.get_value(key).deep_unpack().shift();
let mostRecentLocation = null;
@@ -231,7 +231,7 @@ var WeatherClient = new Lang.Class({
this._setLocation(this._mostRecentLocation);
},
_onPermStoreChanged(proxy, sender, params) {
_onPermStoreChanged: function(proxy, sender, params) {
let [table, id, deleted, data, perms] = params;
if (table != 'gnome' || id != 'geolocation')

View File

@@ -75,9 +75,9 @@ function run() {
// Enable recording of timestamps for different points in the frame cycle
global.frame_timestamps = true;
Main.overview.connect('shown', () => {
Scripting.scriptEvent('overviewShowDone');
});
Main.overview.connect('shown', function() {
Scripting.scriptEvent('overviewShowDone');
});
yield Scripting.sleep(1000);

View File

@@ -42,29 +42,35 @@ function waitAndDraw(milliseconds) {
let timeline = new Clutter.Timeline({ duration: milliseconds });
timeline.start();
timeline.connect('new-frame', (timeline, frame) => {
global.stage.queue_redraw();
});
timeline.connect('new-frame',
function(timeline, frame) {
global.stage.queue_redraw();
});
timeline.connect('completed', () => {
timeline.stop();
if (cb)
cb();
});
timeline.connect('completed',
function() {
timeline.stop();
if (cb)
cb();
});
return callback => { cb = callback; };
return function(callback) {
cb = callback;
};
}
function waitSignal(object, signal) {
let cb;
let id = object.connect(signal, () => {
let id = object.connect(signal, function() {
object.disconnect(id);
if (cb)
cb();
});
return callback => { cb = callback; };
return function(callback) {
cb = callback;
};
}
function extractBootTimestamp() {
@@ -264,7 +270,7 @@ function script_redrawTestDone(time) {
function script_collectTimings(time) {
for (let timing in redrawTimes) {
let times = redrawTimes[timing];
times.sort((a, b) => a - b);
times.sort(function(a, b) { return a - b });
let len = times.length;
let median;

View File

@@ -54,7 +54,7 @@ var PortalHeaderBar = new Lang.Class({
Name: 'PortalHeaderBar',
Extends: Gtk.HeaderBar,
_init() {
_init: function() {
this.parent({ show_close_button: true });
// See ephy-title-box.c in epiphany for the layout
@@ -92,11 +92,11 @@ var PortalHeaderBar = new Lang.Class({
vbox.show_all();
},
setSubtitle(label) {
setSubtitle: function(label) {
this.subtitleLabel.set_text(label);
},
setSecurityIcon(securityLevel) {
setSecurityIcon: function(securityLevel) {
switch (securityLevel) {
case PortalHelperSecurityLevel.NOT_YET_DETERMINED:
this._lockImage.hide();
@@ -119,10 +119,10 @@ var PortalWindow = new Lang.Class({
Name: 'PortalWindow',
Extends: Gtk.ApplicationWindow,
_init(application, url, timestamp, doneCallback) {
_init: function(application, url, timestamp, doneCallback) {
this.parent({ application: application });
this.connect('delete-event', this.destroyWindow.bind(this));
this.connect('delete-event', Lang.bind(this, this.destroyWindow));
this._headerBar = new PortalHeaderBar();
this._headerBar.setSecurityIcon(PortalHelperSecurityLevel.NOT_YET_DETERMINED);
this.set_titlebar(this._headerBar);
@@ -146,12 +146,12 @@ var PortalWindow = new Lang.Class({
this._webContext.set_network_proxy_settings(WebKit.NetworkProxyMode.NO_PROXY, null);
this._webView = WebKit.WebView.new_with_context(this._webContext);
this._webView.connect('decide-policy', this._onDecidePolicy.bind(this));
this._webView.connect('load-changed', this._onLoadChanged.bind(this));
this._webView.connect('insecure-content-detected', this._onInsecureContentDetected.bind(this));
this._webView.connect('load-failed-with-tls-errors', this._onLoadFailedWithTlsErrors.bind(this));
this._webView.connect('decide-policy', Lang.bind(this, this._onDecidePolicy));
this._webView.connect('load-changed', Lang.bind(this, this._onLoadChanged));
this._webView.connect('insecure-content-detected', Lang.bind(this, this._onInsecureContentDetected));
this._webView.connect('load-failed-with-tls-errors', Lang.bind(this, this._onLoadFailedWithTlsErrors));
this._webView.load_uri(url);
this._webView.connect('notify::uri', this._syncUri.bind(this));
this._webView.connect('notify::uri', Lang.bind(this, this._syncUri));
this._syncUri();
this.add(this._webView);
@@ -163,11 +163,11 @@ var PortalWindow = new Lang.Class({
this.application.set_accels_for_action('app.quit', ['<Primary>q', '<Primary>w']);
},
destroyWindow() {
destroyWindow: function() {
this.destroy();
},
_syncUri() {
_syncUri: function() {
let uri = this._webView.uri;
if (uri)
this._headerBar.setSubtitle(GLib.uri_unescape_string(uri, null));
@@ -175,12 +175,12 @@ var PortalWindow = new Lang.Class({
this._headerBar.setSubtitle('');
},
refresh() {
refresh: function() {
this._everSeenRedirect = false;
this._webView.load_uri(this._originalUrl);
},
vfunc_delete_event(event) {
vfunc_delete_event: function(event) {
if (this._recheckAtExit)
this._doneCallback(PortalHelperResult.RECHECK);
else
@@ -188,7 +188,7 @@ var PortalWindow = new Lang.Class({
return false;
},
_onLoadChanged(view, loadEvent) {
_onLoadChanged: function(view, loadEvent) {
if (loadEvent == WebKit.LoadEvent.STARTED) {
this._headerBar.setSecurityIcon(PortalHelperSecurityLevel.NOT_YET_DETERMINED);
} else if (loadEvent == WebKit.LoadEvent.COMMITTED) {
@@ -202,11 +202,11 @@ var PortalWindow = new Lang.Class({
}
},
_onInsecureContentDetected() {
_onInsecureContentDetected: function () {
this._headerBar.setSecurityIcon(PortalHelperSecurityLevel.INSECURE);
},
_onLoadFailedWithTlsErrors(view, failingURI, certificate, errors) {
_onLoadFailedWithTlsErrors: function (view, failingURI, certificate, errors) {
this._headerBar.setSecurityIcon(PortalHelperSecurityLevel.INSECURE);
let uri = new Soup.URI(failingURI);
this._webContext.allow_tls_certificate_for_host(certificate, uri.get_host());
@@ -214,7 +214,7 @@ var PortalWindow = new Lang.Class({
return true;
},
_onDecidePolicy(view, decision, type) {
_onDecidePolicy: function(view, decision, type) {
if (type == WebKit.PolicyDecisionType.NEW_WINDOW_ACTION) {
let navigationAction = decision.get_navigation_action();
if (navigationAction.is_user_gesture()) {
@@ -286,7 +286,7 @@ var WebPortalHelper = new Lang.Class({
Name: 'WebPortalHelper',
Extends: Gtk.Application,
_init() {
_init: function() {
this.parent({ application_id: 'org.gnome.Shell.PortalHelper',
flags: Gio.ApplicationFlags.IS_SERVICE,
inactivity_timeout: 30000 });
@@ -299,30 +299,30 @@ var WebPortalHelper = new Lang.Class({
this.add_action(action);
},
vfunc_dbus_register(connection, path) {
vfunc_dbus_register: function(connection, path) {
this._dbusImpl.export(connection, path);
this.parent(connection, path);
return true;
},
vfunc_dbus_unregister(connection, path) {
vfunc_dbus_unregister: function(connection, path) {
this._dbusImpl.unexport_from_connection(connection);
this.parent(connection, path);
},
vfunc_activate() {
vfunc_activate: function() {
// If launched manually (for example for testing), force a dummy authentication
// session with the default url
this.Authenticate('/org/gnome/dummy', '', 0);
},
Authenticate(connection, url, timestamp) {
Authenticate: function(connection, url, timestamp) {
this._queue.push({ connection: connection, url: url, timestamp: timestamp });
this._processQueue();
},
Close(connection) {
Close: function(connection) {
for (let i = 0; i < this._queue.length; i++) {
let obj = this._queue[i];
@@ -337,7 +337,7 @@ var WebPortalHelper = new Lang.Class({
this._processQueue();
},
Refresh(connection) {
Refresh: function(connection) {
for (let i = 0; i < this._queue.length; i++) {
let obj = this._queue[i];
@@ -349,7 +349,7 @@ var WebPortalHelper = new Lang.Class({
}
},
_processQueue() {
_processQueue: function() {
if (this._queue.length == 0)
return;
@@ -357,9 +357,9 @@ var WebPortalHelper = new Lang.Class({
if (top.window != null)
return;
top.window = new PortalWindow(this, top.url, top.timestamp, result => {
top.window = new PortalWindow(this, top.url, top.timestamp, Lang.bind(this, function(result) {
this._dbusImpl.emit_signal('Done', new GLib.Variant('(ou)', [top.connection, result]));
});
}));
},
});

View File

@@ -42,7 +42,7 @@ var AccessDialog = new Lang.Class({
Name: 'AccessDialog',
Extends: ModalDialog.ModalDialog,
_init(invocation, handle, title, subtitle, body, options) {
_init: function(invocation, handle, title, subtitle, body, options) {
this.parent({ styleClass: 'access-dialog' });
this._invocation = invocation;
@@ -57,7 +57,7 @@ var AccessDialog = new Lang.Class({
this._buildLayout(title, subtitle, body, options);
},
_buildLayout(title, subtitle, body, options) {
_buildLayout: function(title, subtitle, body, options) {
// No support for non-modal system dialogs, so ignore the option
//let modal = options['modal'] || true;
let denyLabel = options['deny_label'] || _("Deny Access");
@@ -97,14 +97,14 @@ var AccessDialog = new Lang.Class({
}});
},
open() {
open: function() {
this.parent();
let connection = this._invocation.get_connection();
this._requestExported = this._request.export(connection, this._handle);
},
CloseAsync(invocation, params) {
CloseAsync: function(invocation, params) {
if (this._invocation.get_sender() != invocation.get_sender()) {
invocation.return_error_literal(Gio.DBusError,
Gio.DBusError.ACCESS_DENIED,
@@ -115,7 +115,7 @@ var AccessDialog = new Lang.Class({
this._sendResponse(DialogResponse.CLOSED);
},
_sendResponse(response) {
_sendResponse: function(response) {
if (this._requestExported)
this._request.unexport();
this._requestExported = false;
@@ -140,7 +140,7 @@ var AccessDialog = new Lang.Class({
var AccessDialogDBus = new Lang.Class({
Name: 'AccessDialogDBus',
_init() {
_init: function() {
this._accessDialog = null;
this._windowTracker = Shell.WindowTracker.get_default();
@@ -151,7 +151,7 @@ var AccessDialogDBus = new Lang.Class({
Gio.DBus.session.own_name('org.freedesktop.impl.portal.desktop.gnome', Gio.BusNameOwnerFlags.REPLACE, null, null);
},
AccessDialogAsync(params, invocation) {
AccessDialogAsync: function(params, invocation) {
if (this._accessDialog) {
invocation.return_error_literal(Gio.DBusError,
Gio.DBusError.LIMITS_EXCEEDED,

View File

@@ -62,7 +62,7 @@ var AppSwitcherPopup = new Lang.Class({
Name: 'AppSwitcherPopup',
Extends: SwitcherPopup.SwitcherPopup,
_init() {
_init : function() {
this.parent();
this._thumbnails = null;
@@ -80,7 +80,7 @@ var AppSwitcherPopup = new Lang.Class({
this._items = this._switcherList.icons;
},
_allocate(actor, box, flags) {
_allocate: function (actor, box, flags) {
this.parent(actor, box, flags);
// Allocate the thumbnails
@@ -118,7 +118,7 @@ var AppSwitcherPopup = new Lang.Class({
}
},
_initialSelection(backward, binding) {
_initialSelection: function(backward, binding) {
if (binding == 'switch-group') {
if (backward) {
this._select(0, this._items[0].cachedWindows.length - 1);
@@ -141,14 +141,14 @@ var AppSwitcherPopup = new Lang.Class({
}
},
_nextWindow() {
_nextWindow : function() {
// We actually want the second window if we're in the unset state
if (this._currentWindow == -1)
this._currentWindow = 0;
return SwitcherPopup.mod(this._currentWindow + 1,
this._items[this._selectedIndex].cachedWindows.length);
},
_previousWindow() {
_previousWindow : function() {
// Also assume second window here
if (this._currentWindow == -1)
this._currentWindow = 1;
@@ -156,7 +156,7 @@ var AppSwitcherPopup = new Lang.Class({
this._items[this._selectedIndex].cachedWindows.length);
},
_closeAppWindow(appIndex, windowIndex) {
_closeAppWindow: function(appIndex, windowIndex) {
let appIcon = this._items[appIndex];
if (!appIcon)
return;
@@ -168,7 +168,7 @@ var AppSwitcherPopup = new Lang.Class({
window.delete(global.get_current_time());
},
_quitApplication(appIndex) {
_quitApplication: function(appIndex) {
let appIcon = this._items[appIndex];
if (!appIcon)
return;
@@ -176,7 +176,7 @@ var AppSwitcherPopup = new Lang.Class({
appIcon.app.request_quit();
},
_keyPressHandler(keysym, action) {
_keyPressHandler: function(keysym, action) {
if (action == Meta.KeyBindingAction.SWITCH_GROUP) {
if (!this._thumbnailsFocused)
this._select(this._selectedIndex, 0);
@@ -215,7 +215,7 @@ var AppSwitcherPopup = new Lang.Class({
return Clutter.EVENT_STOP;
},
_scrollHandler(direction) {
_scrollHandler: function(direction) {
if (direction == Clutter.ScrollDirection.UP) {
if (this._thumbnailsFocused) {
if (this._currentWindow == 0 || this._currentWindow == -1)
@@ -245,7 +245,7 @@ var AppSwitcherPopup = new Lang.Class({
}
},
_itemActivatedHandler(n) {
_itemActivatedHandler: function(n) {
// If the user clicks on the selected app, activate the
// selected window; otherwise (eg, they click on an app while
// !mouseActive) activate the clicked-on app.
@@ -255,24 +255,24 @@ var AppSwitcherPopup = new Lang.Class({
this._select(n);
},
_itemEnteredHandler(n) {
_itemEnteredHandler: function(n) {
this._select(n);
},
_windowActivated(thumbnailList, n) {
_windowActivated : function(thumbnailList, n) {
let appIcon = this._items[this._selectedIndex];
Main.activateWindow(appIcon.cachedWindows[n]);
this.destroy();
},
_windowEntered(thumbnailList, n) {
_windowEntered : function(thumbnailList, n) {
if (!this.mouseActive)
return;
this._select(this._selectedIndex, n);
},
_windowRemoved(thumbnailList, n) {
_windowRemoved : function(thumbnailList, n) {
let appIcon = this._items[this._selectedIndex];
if (!appIcon)
return;
@@ -283,7 +283,7 @@ var AppSwitcherPopup = new Lang.Class({
}
},
_finish(timestamp) {
_finish : function(timestamp) {
let appIcon = this._items[this._selectedIndex];
if (this._currentWindow < 0)
appIcon.app.activate_window(appIcon.cachedWindows[0], timestamp);
@@ -293,7 +293,7 @@ var AppSwitcherPopup = new Lang.Class({
this.parent();
},
_onDestroy() {
_onDestroy : function() {
this.parent();
if (this._thumbnails)
@@ -327,7 +327,7 @@ var AppSwitcherPopup = new Lang.Class({
* then @app will be highlighted, and @window outlined, and the
* app list will have the keyboard focus.
*/
_select(app, window, forceAppFocus) {
_select : function(app, window, forceAppFocus) {
if (app != this._selectedIndex || window == null) {
if (this._thumbnails)
this._destroyThumbnails();
@@ -353,12 +353,12 @@ var AppSwitcherPopup = new Lang.Class({
!forceAppFocus) {
this._thumbnailTimeoutId = Mainloop.timeout_add (
THUMBNAIL_POPUP_TIME,
this._timeoutPopupThumbnails.bind(this));
Lang.bind(this, this._timeoutPopupThumbnails));
GLib.Source.set_name_by_id(this._thumbnailTimeoutId, '[gnome-shell] this._timeoutPopupThumbnails');
}
},
_timeoutPopupThumbnails() {
_timeoutPopupThumbnails: function() {
if (!this._thumbnails)
this._createThumbnails();
this._thumbnailTimeoutId = 0;
@@ -366,27 +366,27 @@ var AppSwitcherPopup = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
_destroyThumbnails() {
_destroyThumbnails : function() {
let thumbnailsActor = this._thumbnails.actor;
Tweener.addTween(thumbnailsActor,
{ opacity: 0,
time: THUMBNAIL_FADE_TIME,
transition: 'easeOutQuad',
onComplete: () => {
thumbnailsActor.destroy();
this.thumbnailsVisible = false;
}
onComplete: Lang.bind(this, function() {
thumbnailsActor.destroy();
this.thumbnailsVisible = false;
})
});
this._thumbnails = null;
if (this._switcherList._items[this._selectedIndex])
this._switcherList._items[this._selectedIndex].remove_accessible_state (Atk.StateType.EXPANDED);
},
_createThumbnails() {
_createThumbnails : function() {
this._thumbnails = new ThumbnailList (this._items[this._selectedIndex].cachedWindows);
this._thumbnails.connect('item-activated', this._windowActivated.bind(this));
this._thumbnails.connect('item-entered', this._windowEntered.bind(this));
this._thumbnails.connect('item-removed', this._windowRemoved.bind(this));
this._thumbnails.connect('item-activated', Lang.bind(this, this._windowActivated));
this._thumbnails.connect('item-entered', Lang.bind(this, this._windowEntered));
this._thumbnails.connect('item-removed', Lang.bind(this, this._windowRemoved));
this._thumbnails.actor.connect('destroy', () => {
this._thumbnails = null;
this._thumbnailsFocused = false;
@@ -403,7 +403,7 @@ var AppSwitcherPopup = new Lang.Class({
{ opacity: 255,
time: THUMBNAIL_FADE_TIME,
transition: 'easeOutQuad',
onComplete: () => { this.thumbnailsVisible = true; }
onComplete: Lang.bind(this, function () { this.thumbnailsVisible = true; })
});
this._switcherList._items[this._selectedIndex].add_accessible_state (Atk.StateType.EXPANDED);
@@ -413,7 +413,7 @@ var AppSwitcherPopup = new Lang.Class({
var CyclerHighlight = new Lang.Class({
Name: 'CyclerHighlight',
_init() {
_init: function() {
this._window = null;
this.actor = new St.Widget({ layout_manager: new Clutter.BinLayout() });
@@ -431,8 +431,8 @@ var CyclerHighlight = new Lang.Class({
this.actor.add_constraint(constraint);
this.actor.connect('notify::allocation',
this._onAllocationChanged.bind(this));
this.actor.connect('destroy', this._onDestroy.bind(this));
Lang.bind(this, this._onAllocationChanged));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
},
set window(w) {
@@ -453,7 +453,7 @@ var CyclerHighlight = new Lang.Class({
this._clone.source = windowActor;
},
_onAllocationChanged() {
_onAllocationChanged: function() {
if (!this._window) {
this._highlight.set_size(0, 0);
this._highlight.hide();
@@ -466,7 +466,7 @@ var CyclerHighlight = new Lang.Class({
}
},
_onDestroy() {
_onDestroy: function() {
this.window = null;
}
});
@@ -476,7 +476,7 @@ var CyclerPopup = new Lang.Class({
Extends: SwitcherPopup.SwitcherPopup,
Abstract: true,
_init() {
_init : function() {
this.parent();
this._items = this._getWindows();
@@ -490,16 +490,16 @@ var CyclerPopup = new Lang.Class({
// We don't show an actual popup, so just provide what SwitcherPopup
// expects instead of inheriting from SwitcherList
this._switcherList = { actor: new St.Widget(),
highlight: this._highlightItem.bind(this),
connect() {} };
highlight: Lang.bind(this, this._highlightItem),
connect: function() {} };
},
_highlightItem(index, justOutline) {
_highlightItem: function(index, justOutline) {
this._highlight.window = this._items[index];
global.window_group.set_child_above_sibling(this._highlight.actor, null);
},
_finish() {
_finish: function() {
let window = this._items[this._selectedIndex];
let ws = window.get_workspace();
let activeWs = global.screen.get_active_workspace();
@@ -524,7 +524,7 @@ var CyclerPopup = new Lang.Class({
this.parent();
},
_onDestroy() {
_onDestroy: function() {
this._highlight.actor.destroy();
this.parent();
@@ -536,12 +536,12 @@ var GroupCyclerPopup = new Lang.Class({
Name: 'GroupCyclerPopup',
Extends: CyclerPopup,
_getWindows() {
_getWindows: function() {
let app = Shell.WindowTracker.get_default().focus_app;
return app ? app.get_windows() : [];
},
_keyPressHandler(keysym, action) {
_keyPressHandler: function(keysym, action) {
if (action == Meta.KeyBindingAction.CYCLE_GROUP)
this._select(this._next());
else if (action == Meta.KeyBindingAction.CYCLE_GROUP_BACKWARD)
@@ -557,7 +557,7 @@ var WindowSwitcherPopup = new Lang.Class({
Name: 'WindowSwitcherPopup',
Extends: SwitcherPopup.SwitcherPopup,
_init() {
_init: function() {
this.parent();
this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell.window-switcher' });
@@ -571,12 +571,12 @@ var WindowSwitcherPopup = new Lang.Class({
this._items = this._switcherList.icons;
},
_getWindowList() {
_getWindowList: function() {
let workspace = this._settings.get_boolean('current-workspace-only') ? global.screen.get_active_workspace() : null;
return getWindows(workspace);
},
_closeWindow(windowIndex) {
_closeWindow: function(windowIndex) {
let windowIcon = this._items[windowIndex];
if (!windowIcon)
return;
@@ -584,7 +584,7 @@ var WindowSwitcherPopup = new Lang.Class({
windowIcon.window.delete(global.get_current_time());
},
_keyPressHandler(keysym, action) {
_keyPressHandler: function(keysym, action) {
if (action == Meta.KeyBindingAction.SWITCH_WINDOWS) {
this._select(this._next());
} else if (action == Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD) {
@@ -603,7 +603,7 @@ var WindowSwitcherPopup = new Lang.Class({
return Clutter.EVENT_STOP;
},
_finish() {
_finish: function() {
Main.activateWindow(this._items[this._selectedIndex].window);
this.parent();
@@ -614,17 +614,17 @@ var WindowCyclerPopup = new Lang.Class({
Name: 'WindowCyclerPopup',
Extends: CyclerPopup,
_init() {
_init: function() {
this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell.window-switcher' });
this.parent();
},
_getWindows() {
_getWindows: function() {
let workspace = this._settings.get_boolean('current-workspace-only') ? global.screen.get_active_workspace() : null;
return getWindows(workspace);
},
_keyPressHandler(keysym, action) {
_keyPressHandler: function(keysym, action) {
if (action == Meta.KeyBindingAction.CYCLE_WINDOWS)
this._select(this._next());
else if (action == Meta.KeyBindingAction.CYCLE_WINDOWS_BACKWARD)
@@ -639,7 +639,7 @@ var WindowCyclerPopup = new Lang.Class({
var AppIcon = new Lang.Class({
Name: 'AppIcon',
_init(app) {
_init: function(app) {
this.app = app;
this.actor = new St.BoxLayout({ style_class: 'alt-tab-app',
vertical: true });
@@ -651,7 +651,7 @@ var AppIcon = new Lang.Class({
this.actor.add(this.label, { x_fill: false });
},
set_size(size) {
set_size: function(size) {
this.icon = this.app.create_icon_texture(size);
this._iconBin.child = this.icon;
}
@@ -661,7 +661,7 @@ var AppSwitcher = new Lang.Class({
Name: 'AppSwitcher',
Extends: SwitcherPopup.SwitcherList,
_init(apps, altTabPopup) {
_init : function(apps, altTabPopup) {
this.parent(true);
this.icons = [];
@@ -678,9 +678,9 @@ var AppSwitcher = new Lang.Class({
let appIcon = new AppIcon(apps[i]);
// Cache the window list now; we don't handle dynamic changes here,
// and we don't want to be continually retrieving it
appIcon.cachedWindows = allWindows.filter(
w => windowTracker.get_window_app (w) == appIcon.app
);
appIcon.cachedWindows = allWindows.filter(function(w) {
return windowTracker.get_window_app (w) == appIcon.app;
});
if (appIcon.cachedWindows.length > 0)
this._addIcon(appIcon);
}
@@ -690,10 +690,10 @@ var AppSwitcher = new Lang.Class({
this._altTabPopup = altTabPopup;
this._mouseTimeOutId = 0;
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
},
_onDestroy() {
_onDestroy: function() {
if (this._mouseTimeOutId != 0)
Mainloop.source_remove(this._mouseTimeOutId);
@@ -702,7 +702,7 @@ var AppSwitcher = new Lang.Class({
});
},
_setIconSize() {
_setIconSize: function() {
let j = 0;
while(this._items.length > 1 && this._items[j].style_class != 'item-box') {
j++;
@@ -721,7 +721,9 @@ var AppSwitcher = new Lang.Class({
let availWidth = primary.width - parentPadding - this.actor.get_theme_node().get_horizontal_padding();
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let iconSizes = baseIconSizes.map(s => s * scaleFactor);
let iconSizes = baseIconSizes.map(function(s) {
return s * scaleFactor;
});
if (this._items.length == 1) {
this._iconSize = baseIconSizes[0];
@@ -742,12 +744,12 @@ var AppSwitcher = new Lang.Class({
}
},
_getPreferredHeight(actor, forWidth, alloc) {
_getPreferredHeight: function (actor, forWidth, alloc) {
this._setIconSize();
this.parent(actor, forWidth, alloc);
},
_allocate(actor, box, flags) {
_allocate: function (actor, box, flags) {
// Allocate the main list items
this.parent(actor, box, flags);
@@ -768,22 +770,22 @@ var AppSwitcher = new Lang.Class({
// We override SwitcherList's _onItemEnter method to delay
// activation when the thumbnail list is open
_onItemEnter(index) {
_onItemEnter: function (index) {
if (this._mouseTimeOutId != 0)
Mainloop.source_remove(this._mouseTimeOutId);
if (this._altTabPopup.thumbnailsVisible) {
this._mouseTimeOutId = Mainloop.timeout_add(APP_ICON_HOVER_TIMEOUT,
() => {
this._enterItem(index);
this._mouseTimeOutId = 0;
return GLib.SOURCE_REMOVE;
});
Lang.bind(this, function () {
this._enterItem(index);
this._mouseTimeOutId = 0;
return GLib.SOURCE_REMOVE;
}));
GLib.Source.set_name_by_id(this._mouseTimeOutId, '[gnome-shell] this._enterItem');
} else
this._itemEntered(index);
},
_enterItem(index) {
_enterItem: function(index) {
let [x, y, mask] = global.get_pointer();
let pickedActor = global.stage.get_actor_at_pos(Clutter.PickMode.ALL, x, y);
if (this._items[index].contains(pickedActor))
@@ -797,7 +799,7 @@ var AppSwitcher = new Lang.Class({
// in justOutline mode). Apps with multiple windows will normally
// show a dim arrow, but show a bright arrow when they are
// highlighted.
highlight(n, justOutline) {
highlight : function(n, justOutline) {
if (this.icons[this._curApp]) {
if (this.icons[this._curApp].cachedWindows.length == 1)
this._arrows[this._curApp].hide();
@@ -816,7 +818,7 @@ var AppSwitcher = new Lang.Class({
}
},
_addIcon(appIcon) {
_addIcon : function(appIcon) {
this.icons.push(appIcon);
let item = this.addItem(appIcon.actor, appIcon.label);
@@ -827,7 +829,7 @@ var AppSwitcher = new Lang.Class({
let n = this._arrows.length;
let arrow = new St.DrawingArea({ style_class: 'switcher-arrow' });
arrow.connect('repaint', () => { SwitcherPopup.drawArrow(arrow, St.Side.BOTTOM); });
arrow.connect('repaint', function() { SwitcherPopup.drawArrow(arrow, St.Side.BOTTOM); });
this._list.add_actor(arrow);
this._arrows.push(arrow);
@@ -837,7 +839,7 @@ var AppSwitcher = new Lang.Class({
item.add_accessible_state (Atk.StateType.EXPANDABLE);
},
_removeIcon(app) {
_removeIcon: function(app) {
let index = this.icons.findIndex(icon => {
return icon.app == app;
});
@@ -853,7 +855,7 @@ var ThumbnailList = new Lang.Class({
Name: 'ThumbnailList',
Extends: SwitcherPopup.SwitcherList,
_init(windows) {
_init : function(windows) {
this.parent(false);
this._labels = new Array();
@@ -889,7 +891,7 @@ var ThumbnailList = new Lang.Class({
this.actor.connect('destroy', this._onDestroy.bind(this));
},
addClones(availHeight) {
addClones : function (availHeight) {
if (!this._thumbnailBins.length)
return;
let totalPadding = this._items[0].get_theme_node().get_horizontal_padding() + this._items[0].get_theme_node().get_vertical_padding();
@@ -912,9 +914,7 @@ var ThumbnailList = new Lang.Class({
this._thumbnailBins[i].set_height(binHeight);
this._thumbnailBins[i].add_actor(clone);
clone._destroyId = mutterWindow.connect('destroy', source => {
this._removeThumbnail(source, clone);
});
clone._destroyId = mutterWindow.connect('destroy', Lang.bind(this, this._removeThumbnail, clone));
this._clones.push(clone);
}
@@ -922,7 +922,7 @@ var ThumbnailList = new Lang.Class({
this._thumbnailBins = new Array();
},
_removeThumbnail(source, clone) {
_removeThumbnail: function(source, clone) {
let index = this._clones.indexOf(clone);
if (index === -1)
return;
@@ -938,7 +938,7 @@ var ThumbnailList = new Lang.Class({
this.actor.destroy();
},
_onDestroy() {
_onDestroy: function() {
this._clones.forEach(clone => {
if (clone.source)
clone.source.disconnect(clone._destroyId);
@@ -950,7 +950,7 @@ var ThumbnailList = new Lang.Class({
var WindowIcon = new Lang.Class({
Name: 'WindowIcon',
_init(window, mode) {
_init: function(window, mode) {
this.window = window;
this.actor = new St.BoxLayout({ style_class: 'alt-tab-app',
@@ -993,7 +993,7 @@ var WindowIcon = new Lang.Class({
this._icon.set_size(size * scaleFactor, size * scaleFactor);
},
_createAppIcon(app, size) {
_createAppIcon: function(app, size) {
let appIcon = app ? app.create_icon_texture(size)
: new St.Icon({ icon_name: 'icon-missing',
icon_size: size });
@@ -1008,7 +1008,7 @@ var WindowList = new Lang.Class({
Name: 'WindowList',
Extends: SwitcherPopup.SwitcherList,
_init(windows, mode) {
_init : function(windows, mode) {
this.parent(true);
this._label = new St.Label({ x_align: Clutter.ActorAlign.CENTER,
@@ -1033,13 +1033,13 @@ var WindowList = new Lang.Class({
this.actor.connect('destroy', () => { this._onDestroy(); });
},
_onDestroy() {
_onDestroy: function() {
this.icons.forEach(icon => {
icon.window.disconnect(icon._unmanagedSignalId);
});
},
_getPreferredHeight(actor, forWidth, alloc) {
_getPreferredHeight: function(actor, forWidth, alloc) {
this.parent(actor, forWidth, alloc);
let spacing = this.actor.get_theme_node().get_padding(St.Side.BOTTOM);
@@ -1048,7 +1048,7 @@ var WindowList = new Lang.Class({
alloc.natural_size += labelNat + spacing;
},
_allocateTop(actor, box, flags) {
_allocateTop: function(actor, box, flags) {
let childBox = new Clutter.ActorBox();
childBox.x1 = box.x1;
childBox.x2 = box.x2;
@@ -1061,13 +1061,13 @@ var WindowList = new Lang.Class({
this.parent(actor, box, flags);
},
highlight(index, justOutline) {
highlight: function(index, justOutline) {
this.parent(index, justOutline);
this._label.set_text(index == -1 ? '' : this.icons[index].label.text);
},
_removeWindow(window) {
_removeWindow: function(window) {
let index = this.icons.findIndex(icon => {
return icon.window == window;
});

View File

@@ -12,9 +12,9 @@ var ANIMATED_ICON_UPDATE_TIMEOUT = 16;
var Animation = new Lang.Class({
Name: 'Animation',
_init(file, width, height, speed) {
_init: function(file, width, height, speed) {
this.actor = new St.Bin();
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this._speed = speed;
this._isLoaded = false;
@@ -24,23 +24,23 @@ var Animation = new Lang.Class({
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
this._animations = St.TextureCache.get_default().load_sliced_image (file, width, height, scaleFactor,
this._animationsLoaded.bind(this));
Lang.bind(this, this._animationsLoaded));
this.actor.set_child(this._animations);
},
play() {
play: function() {
if (this._isLoaded && this._timeoutId == 0) {
if (this._frame == 0)
this._showFrame(0);
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_LOW, this._speed, this._update.bind(this));
this._timeoutId = GLib.timeout_add(GLib.PRIORITY_LOW, this._speed, Lang.bind(this, this._update));
GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._update');
}
this._isPlaying = true;
},
stop() {
stop: function() {
if (this._timeoutId > 0) {
Mainloop.source_remove(this._timeoutId);
this._timeoutId = 0;
@@ -49,7 +49,7 @@ var Animation = new Lang.Class({
this._isPlaying = false;
},
_showFrame(frame) {
_showFrame: function(frame) {
let oldFrameActor = this._animations.get_child_at_index(this._frame);
if (oldFrameActor)
oldFrameActor.hide();
@@ -61,19 +61,19 @@ var Animation = new Lang.Class({
newFrameActor.show();
},
_update() {
_update: function() {
this._showFrame(this._frame + 1);
return GLib.SOURCE_CONTINUE;
},
_animationsLoaded() {
_animationsLoaded: function() {
this._isLoaded = this._animations.get_n_children() > 0;
if (this._isPlaying)
this.play();
},
_onDestroy() {
_onDestroy: function() {
this.stop();
}
});
@@ -82,7 +82,7 @@ var AnimatedIcon = new Lang.Class({
Name: 'AnimatedIcon',
Extends: Animation,
_init(file, size) {
_init: function(file, size) {
this.parent(file, size, size, ANIMATED_ICON_UPDATE_TIMEOUT);
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -49,24 +49,24 @@ var AppFavorites = new Lang.Class({
FAVORITE_APPS_KEY: 'favorite-apps',
_init() {
_init: function() {
this._favorites = {};
global.settings.connect('changed::' + this.FAVORITE_APPS_KEY, this._onFavsChanged.bind(this));
global.settings.connect('changed::' + this.FAVORITE_APPS_KEY, Lang.bind(this, this._onFavsChanged));
this.reload();
},
_onFavsChanged() {
_onFavsChanged: function() {
this.reload();
this.emit('changed');
},
reload() {
reload: function() {
let ids = global.settings.get_strv(this.FAVORITE_APPS_KEY);
let appSys = Shell.AppSystem.get_default();
// Map old desktop file names to the current ones
let updated = false;
ids = ids.map(id => {
ids = ids.map(function (id) {
let newId = RENAMED_DESKTOP_IDS[id];
if (newId !== undefined &&
appSys.lookup_app(newId) != null) {
@@ -79,8 +79,11 @@ var AppFavorites = new Lang.Class({
if (updated)
global.settings.set_strv(this.FAVORITE_APPS_KEY, ids);
let apps = ids.map(id => appSys.lookup_app(id))
.filter(app => app != null);
let apps = ids.map(function (id) {
return appSys.lookup_app(id);
}).filter(function (app) {
return app != null;
});
this._favorites = {};
for (let i = 0; i < apps.length; i++) {
let app = apps[i];
@@ -88,29 +91,29 @@ var AppFavorites = new Lang.Class({
}
},
_getIds() {
_getIds: function() {
let ret = [];
for (let id in this._favorites)
ret.push(id);
return ret;
},
getFavoriteMap() {
getFavoriteMap: function() {
return this._favorites;
},
getFavorites() {
getFavorites: function() {
let ret = [];
for (let id in this._favorites)
ret.push(this._favorites[id]);
return ret;
},
isFavorite(appId) {
isFavorite: function(appId) {
return appId in this._favorites;
},
_addFavorite(appId, pos) {
_addFavorite: function(appId, pos) {
if (appId in this._favorites)
return false;
@@ -129,7 +132,7 @@ var AppFavorites = new Lang.Class({
return true;
},
addFavoriteAtPos(appId, pos) {
addFavoriteAtPos: function(appId, pos) {
if (!this._addFavorite(appId, pos))
return;
@@ -137,31 +140,31 @@ var AppFavorites = new Lang.Class({
Main.overview.setMessage(_("%s has been added to your favorites.").format(app.get_name()),
{ forFeedback: true,
undoCallback: () => {
this._removeFavorite(appId);
}
undoCallback: Lang.bind(this, function () {
this._removeFavorite(appId);
})
});
},
addFavorite(appId) {
addFavorite: function(appId) {
this.addFavoriteAtPos(appId, -1);
},
moveFavoriteToPos(appId, pos) {
moveFavoriteToPos: function(appId, pos) {
this._removeFavorite(appId);
this._addFavorite(appId, pos);
},
_removeFavorite(appId) {
_removeFavorite: function(appId) {
if (!appId in this._favorites)
return false;
let ids = this._getIds().filter(id => id != appId);
let ids = this._getIds().filter(function (id) { return id != appId; });
global.settings.set_strv(this.FAVORITE_APPS_KEY, ids);
return true;
},
removeFavorite(appId) {
removeFavorite: function(appId) {
let ids = this._getIds();
let pos = ids.indexOf(appId);
@@ -171,9 +174,9 @@ var AppFavorites = new Lang.Class({
Main.overview.setMessage(_("%s has been removed from your favorites.").format(app.get_name()),
{ forFeedback: true,
undoCallback: () => {
this._addFavorite(appId, pos);
}
undoCallback: Lang.bind(this, function () {
this._addFavorite(appId, pos);
})
});
}
});

View File

@@ -32,7 +32,7 @@ var AudioDeviceSelectionDialog = new Lang.Class({
Name: 'AudioDeviceSelectionDialog',
Extends: ModalDialog.ModalDialog,
_init(devices) {
_init: function(devices) {
this.parent({ styleClass: 'audio-device-selection-dialog' });
this._deviceItems = {};
@@ -50,11 +50,11 @@ var AudioDeviceSelectionDialog = new Lang.Class({
throw new Error('Too few devices for a selection');
},
destroy() {
destroy: function() {
this.parent();
},
_buildLayout(devices) {
_buildLayout: function(devices) {
let title = new St.Label({ style_class: 'audio-selection-title',
text: _("Select Audio Device"),
x_align: Clutter.ActorAlign.CENTER });
@@ -65,14 +65,14 @@ var AudioDeviceSelectionDialog = new Lang.Class({
this._selectionBox = new St.BoxLayout({ style_class: 'audio-selection-box' });
this.contentLayout.add(this._selectionBox, { expand: true });
this.addButton({ action: this._openSettings.bind(this),
this.addButton({ action: Lang.bind(this, this._openSettings),
label: _("Sound Settings") });
this.addButton({ action: this.close.bind(this),
this.addButton({ action: Lang.bind(this, this.close),
label: _("Cancel"),
key: Clutter.Escape });
},
_getDeviceLabel(device) {
_getDeviceLabel: function(device) {
switch(device) {
case AudioDevice.HEADPHONES:
return _("Headphones");
@@ -85,7 +85,7 @@ var AudioDeviceSelectionDialog = new Lang.Class({
}
},
_getDeviceIcon(device) {
_getDeviceIcon: function(device) {
switch(device) {
case AudioDevice.HEADPHONES:
return 'audio-headphones-symbolic';
@@ -98,14 +98,16 @@ var AudioDeviceSelectionDialog = new Lang.Class({
}
},
_addDevice(device) {
_addDevice: function(device) {
let box = new St.BoxLayout({ style_class: 'audio-selection-device-box',
vertical: true });
box.connect('notify::height', () => {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
box.width = box.height;
box.connect('notify::height',
function() {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
function() {
box.width = box.height;
});
});
});
let icon = new St.Icon({ style_class: 'audio-selection-device-icon',
icon_name: this._getDeviceIcon(device) });
@@ -121,14 +123,15 @@ var AudioDeviceSelectionDialog = new Lang.Class({
child: box });
this._selectionBox.add(button);
button.connect('clicked', () => {
this.emit('device-selected', device);
this.close();
Main.overview.hide();
});
button.connect('clicked', Lang.bind(this,
function() {
this.emit('device-selected', device);
this.close();
Main.overview.hide();
}));
},
_openSettings() {
_openSettings: function() {
let desktopFile = 'gnome-sound-panel.desktop'
let app = Shell.AppSystem.get_default().lookup_app(desktopFile);
@@ -146,7 +149,7 @@ var AudioDeviceSelectionDialog = new Lang.Class({
var AudioDeviceSelectionDBus = new Lang.Class({
Name: 'AudioDeviceSelectionDBus',
_init() {
_init: function() {
this._audioSelectionDialog = null;
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(AudioDeviceSelectionIface, this);
@@ -155,16 +158,17 @@ var AudioDeviceSelectionDBus = new Lang.Class({
Gio.DBus.session.own_name('org.gnome.Shell.AudioDeviceSelection', Gio.BusNameOwnerFlags.REPLACE, null, null);
},
_onDialogClosed() {
_onDialogClosed: function() {
this._audioSelectionDialog = null;
},
_onDeviceSelected(dialog, device) {
_onDeviceSelected: function(dialog, device) {
let connection = this._dbusImpl.get_connection();
let info = this._dbusImpl.get_info();
let deviceName = Object.keys(AudioDevice).filter(
dev => AudioDevice[dev] == device
)[0].toLowerCase();
function(dev) {
return AudioDevice[dev] == device;
})[0].toLowerCase();
connection.emit_signal(this._audioSelectionDialog._sender,
this._dbusImpl.get_object_path(),
info ? info.name : null,
@@ -172,7 +176,7 @@ var AudioDeviceSelectionDBus = new Lang.Class({
GLib.Variant.new('(s)', [deviceName]));
},
OpenAsync(params, invocation) {
OpenAsync: function(params, invocation) {
if (this._audioSelectionDialog) {
invocation.return_value(null);
return;
@@ -180,7 +184,9 @@ var AudioDeviceSelectionDBus = new Lang.Class({
let [deviceNames] = params;
let devices = 0;
deviceNames.forEach(n => { devices |= AudioDevice[n.toUpperCase()]; });
deviceNames.forEach(function(n) {
devices |= AudioDevice[n.toUpperCase()];
});
let dialog;
try {
@@ -191,16 +197,16 @@ var AudioDeviceSelectionDBus = new Lang.Class({
}
dialog._sender = invocation.get_sender();
dialog.connect('closed', this._onDialogClosed.bind(this));
dialog.connect('closed', Lang.bind(this, this._onDialogClosed));
dialog.connect('device-selected',
this._onDeviceSelected.bind(this));
Lang.bind(this, this._onDeviceSelected));
dialog.open();
this._audioSelectionDialog = dialog;
invocation.return_value(null);
},
CloseAsync(params, invocation) {
CloseAsync: function(params, invocation) {
if (this._audioSelectionDialog &&
this._audioSelectionDialog._sender == invocation.get_sender())
this._audioSelectionDialog.close();

View File

@@ -141,31 +141,31 @@ function _fileEqual0(file1, file2) {
var BackgroundCache = new Lang.Class({
Name: 'BackgroundCache',
_init() {
_init: function() {
this._fileMonitors = {};
this._backgroundSources = {};
this._animations = {};
},
monitorFile(file) {
monitorFile: function(file) {
let key = file.hash();
if (this._fileMonitors[key])
return;
let monitor = file.monitor(Gio.FileMonitorFlags.NONE, null);
monitor.connect('changed',
(obj, file, otherFile, eventType) => {
Lang.bind(this, function(obj, file, otherFile, eventType) {
// Ignore CHANGED and CREATED events, since in both cases
// we'll get a CHANGES_DONE_HINT event when done.
if (eventType != Gio.FileMonitorEvent.CHANGED &&
eventType != Gio.FileMonitorEvent.CREATED)
this.emit('file-changed', file);
});
}));
this._fileMonitors[key] = monitor;
},
getAnimation(params) {
getAnimation: function(params) {
params = Params.parse(params, { file: null,
settingsSchema: null,
onLoaded: null });
@@ -173,10 +173,10 @@ var BackgroundCache = new Lang.Class({
let animation = this._animations[params.settingsSchema];
if (animation && _fileEqual0(animation.file, params.file)) {
if (params.onLoaded) {
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
params.onLoaded(this._animations[params.settingsSchema]);
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
}
return;
@@ -184,20 +184,20 @@ var BackgroundCache = new Lang.Class({
animation = new Animation({ file: params.file });
animation.load(() => {
this._animations[params.settingsSchema] = animation;
animation.load(Lang.bind(this, function() {
this._animations[params.settingsSchema] = animation;
if (params.onLoaded) {
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
params.onLoaded(this._animations[params.settingsSchema]);
return GLib.SOURCE_REMOVE;
});
GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
}
});
if (params.onLoaded) {
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
params.onLoaded(this._animations[params.settingsSchema]);
return GLib.SOURCE_REMOVE;
}));
GLib.Source.set_name_by_id(id, '[gnome-shell] params.onLoaded');
}
}));
},
getBackgroundSource(layoutManager, settingsSchema) {
getBackgroundSource: function(layoutManager, settingsSchema) {
// The layoutManager is always the same one; we pass in it since
// Main.layoutManager may not be set yet
@@ -211,7 +211,7 @@ var BackgroundCache = new Lang.Class({
return this._backgroundSources[settingsSchema];
},
releaseBackgroundSource(settingsSchema) {
releaseBackgroundSource: function(settingsSchema) {
if (settingsSchema in this._backgroundSources) {
let source = this._backgroundSources[settingsSchema];
source._useCount--;
@@ -233,7 +233,7 @@ function getBackgroundCache() {
var Background = new Lang.Class({
Name: 'Background',
_init(params) {
_init: function(params) {
params = Params.parse(params, { monitorIndex: 0,
layoutManager: Main.layoutManager,
settings: null,
@@ -254,10 +254,10 @@ var Background = new Lang.Class({
this._clock = new GnomeDesktop.WallClock();
this._timezoneChangedId = this._clock.connect('notify::timezone',
() => {
Lang.bind(this, function() {
if (this._animation)
this._loadAnimation(this._animation.file);
});
}));
let loginManager = LoginManager.getLoginManager();
this._prepareForSleepId = loginManager.connect('prepare-for-sleep',
@@ -267,14 +267,14 @@ var Background = new Lang.Class({
this._refreshAnimation();
});
this._settingsChangedSignalId = this._settings.connect('changed', () => {
this.emit('changed');
});
this._settingsChangedSignalId = this._settings.connect('changed', Lang.bind(this, function() {
this.emit('changed');
}));
this._load();
},
destroy() {
destroy: function() {
this._cancellable.cancel();
this._removeAnimationTimeout();
@@ -300,12 +300,12 @@ var Background = new Lang.Class({
this._settingsChangedSignalId = 0;
},
updateResolution() {
updateResolution: function() {
if (this._animation)
this._refreshAnimation();
},
_refreshAnimation() {
_refreshAnimation: function() {
if (!this._animation)
return;
@@ -313,20 +313,20 @@ var Background = new Lang.Class({
this._updateAnimation();
},
_setLoaded() {
_setLoaded: function() {
if (this.isLoaded)
return;
this.isLoaded = true;
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
this.emit('loaded');
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(id, '[gnome-shell] this.emit');
},
_loadPattern() {
_loadPattern: function() {
let colorString, res, color, secondColor;
colorString = this._settings.get_string(PRIMARY_COLOR_KEY);
@@ -342,37 +342,37 @@ var Background = new Lang.Class({
this.background.set_gradient(shadingType, color, secondColor);
},
_watchFile(file) {
_watchFile: function(file) {
let key = file.hash();
if (this._fileWatches[key])
return;
this._cache.monitorFile(file);
let signalId = this._cache.connect('file-changed',
(cache, changedFile) => {
Lang.bind(this, function(cache, changedFile) {
if (changedFile.equal(file)) {
let imageCache = Meta.BackgroundImageCache.get_default();
imageCache.purge(changedFile);
this.emit('changed');
}
});
}));
this._fileWatches[key] = signalId;
},
_removeAnimationTimeout() {
_removeAnimationTimeout: function() {
if (this._updateAnimationTimeoutId) {
GLib.source_remove(this._updateAnimationTimeoutId);
this._updateAnimationTimeoutId = 0;
}
},
_updateAnimation() {
_updateAnimation: function() {
this._updateAnimationTimeoutId = 0;
this._animation.update(this._layoutManager.monitors[this._monitorIndex]);
let files = this._animation.keyFrameFiles;
let finish = () => {
let finish = Lang.bind(this, function() {
this._setLoaded();
if (files.length > 1) {
this.background.set_blend(files[0], files[1],
@@ -384,7 +384,7 @@ var Background = new Lang.Class({
this.background.set_file(null, this._style);
}
this._queueUpdateAnimation();
};
});
let cache = Meta.BackgroundImageCache.get_default();
let numPendingImages = files.length;
@@ -396,17 +396,18 @@ var Background = new Lang.Class({
if (numPendingImages == 0)
finish();
} else {
let id = image.connect('loaded', () => {
image.disconnect(id);
numPendingImages--;
if (numPendingImages == 0)
finish();
});
let id = image.connect('loaded',
Lang.bind(this, function() {
image.disconnect(id);
numPendingImages--;
if (numPendingImages == 0)
finish();
}));
}
}
},
_queueUpdateAnimation() {
_queueUpdateAnimation: function() {
if (this._updateAnimationTimeoutId != 0)
return;
@@ -427,18 +428,18 @@ var Background = new Lang.Class({
this._updateAnimationTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
interval,
() => {
this._updateAnimationTimeoutId = 0;
this._updateAnimation();
return GLib.SOURCE_REMOVE;
});
Lang.bind(this, function() {
this._updateAnimationTimeoutId = 0;
this._updateAnimation();
return GLib.SOURCE_REMOVE;
}));
GLib.Source.set_name_by_id(this._updateAnimationTimeoutId, '[gnome-shell] this._updateAnimation');
},
_loadAnimation(file) {
_loadAnimation: function(file) {
this._cache.getAnimation({ file: file,
settingsSchema: this._settings.schema_id,
onLoaded: animation => {
onLoaded: Lang.bind(this, function(animation) {
this._animation = animation;
if (!this._animation || this._cancellable.is_cancelled()) {
@@ -448,11 +449,11 @@ var Background = new Lang.Class({
this._updateAnimation();
this._watchFile(file);
}
})
});
},
_loadImage(file) {
_loadImage: function(file) {
this.background.set_file(file, this._style);
this._watchFile(file);
@@ -461,21 +462,22 @@ var Background = new Lang.Class({
if (image.is_loaded())
this._setLoaded();
else {
let id = image.connect('loaded', () => {
this._setLoaded();
image.disconnect(id);
});
let id = image.connect('loaded',
Lang.bind(this, function() {
this._setLoaded();
image.disconnect(id);
}));
}
},
_loadFile(file) {
_loadFile: function(file) {
if (file.get_basename().endsWith('.xml'))
this._loadAnimation(file);
else
this._loadImage(file);
},
_load() {
_load: function () {
this._cache = getBackgroundCache();
this._loadPattern();
@@ -495,7 +497,7 @@ let _systemBackground;
var SystemBackground = new Lang.Class({
Name: 'SystemBackground',
_init() {
_init: function() {
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/noise-texture.png');
if (_systemBackground == null) {
@@ -512,17 +514,18 @@ var SystemBackground = new Lang.Class({
let image = cache.load(file);
if (image.is_loaded()) {
image = null;
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this, function() {
this.emit('loaded');
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(id, '[gnome-shell] SystemBackground.loaded');
} else {
let id = image.connect('loaded', () => {
this.emit('loaded');
image.disconnect(id);
image = null;
});
let id = image.connect('loaded',
Lang.bind(this, function() {
this.emit('loaded');
image.disconnect(id);
image = null;
}));
}
},
});
@@ -531,7 +534,7 @@ Signals.addSignalMethods(SystemBackground.prototype);
var BackgroundSource = new Lang.Class({
Name: 'BackgroundSource',
_init(layoutManager, settingsSchema) {
_init: function(layoutManager, settingsSchema) {
// Allow override the background image setting for performance testing
this._layoutManager = layoutManager;
this._overrideImage = GLib.getenv('SHELL_BACKGROUND_IMAGE');
@@ -539,10 +542,10 @@ var BackgroundSource = new Lang.Class({
this._backgrounds = [];
this._monitorsChangedId = global.screen.connect('monitors-changed',
this._onMonitorsChanged.bind(this));
Lang.bind(this, this._onMonitorsChanged));
},
_onMonitorsChanged() {
_onMonitorsChanged: function() {
for (let monitorIndex in this._backgrounds) {
let background = this._backgrounds[monitorIndex];
@@ -556,7 +559,7 @@ var BackgroundSource = new Lang.Class({
}
},
getBackground(monitorIndex) {
getBackground: function(monitorIndex) {
let file = null;
let style;
@@ -591,11 +594,11 @@ var BackgroundSource = new Lang.Class({
style: style
});
background._changedId = background.connect('changed', () => {
background._changedId = background.connect('changed', Lang.bind(this, function() {
background.disconnect(background._changedId);
background.destroy();
delete this._backgrounds[monitorIndex];
});
}));
this._backgrounds[monitorIndex] = background;
}
@@ -603,7 +606,7 @@ var BackgroundSource = new Lang.Class({
return this._backgrounds[monitorIndex];
},
destroy() {
destroy: function() {
global.screen.disconnect(this._monitorsChangedId);
for (let monitorIndex in this._backgrounds) {
@@ -619,7 +622,7 @@ var BackgroundSource = new Lang.Class({
var Animation = new Lang.Class({
Name: 'Animation',
_init(params) {
_init: function(params) {
params = Params.parse(params, { file: null });
this.file = params.file;
@@ -629,17 +632,19 @@ var Animation = new Lang.Class({
this.loaded = false;
},
load(callback) {
load: function(callback) {
this._show = new GnomeDesktop.BGSlideShow({ filename: this.file.get_path() });
this._show.load_async(null, (object, result) => {
this.loaded = true;
if (callback)
callback();
});
this._show.load_async(null,
Lang.bind(this,
function(object, result) {
this.loaded = true;
if (callback)
callback();
}));
},
update(monitor) {
update: function(monitor) {
this.keyFrameFiles = [];
if (!this._show)
@@ -665,7 +670,7 @@ Signals.addSignalMethods(Animation.prototype);
var BackgroundManager = new Lang.Class({
Name: 'BackgroundManager',
_init(params) {
_init: function(params) {
params = Params.parse(params, { container: null,
layoutManager: Main.layoutManager,
monitorIndex: null,
@@ -687,7 +692,7 @@ var BackgroundManager = new Lang.Class({
this._newBackgroundActor = null;
},
destroy() {
destroy: function() {
let cache = getBackgroundCache();
cache.releaseBackgroundSource(this._settingsSchema);
this._backgroundSource = null;
@@ -703,7 +708,7 @@ var BackgroundManager = new Lang.Class({
}
},
_swapBackgroundActor() {
_swapBackgroundActor: function() {
let oldBackgroundActor = this.backgroundActor;
this.backgroundActor = this._newBackgroundActor;
this._newBackgroundActor = null;
@@ -713,14 +718,14 @@ var BackgroundManager = new Lang.Class({
{ opacity: 0,
time: FADE_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
oldBackgroundActor.background.run_dispose();
oldBackgroundActor.destroy();
}
});
},
_updateBackgroundActor() {
_updateBackgroundActor: function() {
if (this._newBackgroundActor) {
/* Skip displaying existing background queued for load */
this._newBackgroundActor.destroy();
@@ -740,16 +745,17 @@ var BackgroundManager = new Lang.Class({
this._swapBackgroundActor();
} else {
newBackgroundActor.loadedSignalId = background.connect('loaded',
() => {
Lang.bind(this, function() {
background.disconnect(newBackgroundActor.loadedSignalId);
newBackgroundActor.loadedSignalId = 0;
this._swapBackgroundActor();
});
}));
}
},
_createBackgroundActor() {
_createBackgroundActor: function() {
let background = this._backgroundSource.getBackground(this._monitorIndex);
let backgroundActor = new Meta.BackgroundActor({ meta_screen: global.screen,
monitor: this._monitorIndex,
@@ -769,19 +775,19 @@ var BackgroundManager = new Lang.Class({
backgroundActor.lower_bottom();
}
let changeSignalId = background.connect('changed', () => {
let changeSignalId = background.connect('changed', Lang.bind(this, function() {
background.disconnect(changeSignalId);
changeSignalId = null;
this._updateBackgroundActor();
});
}));
backgroundActor.connect('destroy', () => {
backgroundActor.connect('destroy', Lang.bind(this, function() {
if (changeSignalId)
background.disconnect(changeSignalId);
if (backgroundActor.loadedSignalId)
background.disconnect(backgroundActor.loadedSignalId);
});
}));
return backgroundActor;
},

View File

@@ -13,7 +13,7 @@ var BackgroundMenu = new Lang.Class({
Name: 'BackgroundMenu',
Extends: PopupMenu.PopupMenu,
_init(layoutManager) {
_init: function(layoutManager) {
this.parent(layoutManager.dummyCursor, 0, St.Side.TOP);
this.addSettingsAction(_("Change Background…"), 'gnome-background-panel.desktop');
@@ -40,7 +40,7 @@ function addBackgroundMenu(actor, layoutManager) {
}
let clickAction = new Clutter.ClickAction();
clickAction.connect('long-press', (action, actor, state) => {
clickAction.connect('long-press', function(action, actor, state) {
if (state == Clutter.LongPressState.QUERY)
return ((action.get_button() == 0 ||
action.get_button() == 1) &&
@@ -52,7 +52,7 @@ function addBackgroundMenu(actor, layoutManager) {
}
return true;
});
clickAction.connect('clicked', action => {
clickAction.connect('clicked', function(action) {
if (action.get_button() == 3) {
let [x, y] = action.get_coords();
openMenu(x, y);
@@ -60,11 +60,11 @@ function addBackgroundMenu(actor, layoutManager) {
});
actor.add_action(clickAction);
let grabOpBeginId = global.display.connect('grab-op-begin', () => {
let grabOpBeginId = global.display.connect('grab-op-begin', function () {
clickAction.release();
});
actor.connect('destroy', () => {
actor.connect('destroy', function() {
actor._backgroundMenu.destroy();
actor._backgroundMenu = null;
actor._backgroundManager = null;

View File

@@ -35,7 +35,7 @@ var POPUP_ANIMATION_TIME = 0.15;
var BoxPointer = new Lang.Class({
Name: 'BoxPointer',
_init(arrowSide, binProperties) {
_init: function(arrowSide, binProperties) {
this._arrowSide = arrowSide;
this._userArrowSide = arrowSide;
this._arrowOrigin = 0;
@@ -44,13 +44,13 @@ var BoxPointer = new Lang.Class({
y_fill: true });
this._container = new Shell.GenericContainer();
this.actor.set_child(this._container);
this._container.connect('get-preferred-width', this._getPreferredWidth.bind(this));
this._container.connect('get-preferred-height', this._getPreferredHeight.bind(this));
this._container.connect('allocate', this._allocate.bind(this));
this._container.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this._container.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this._container.connect('allocate', Lang.bind(this, this._allocate));
this.bin = new St.Bin(binProperties);
this._container.add_actor(this.bin);
this._border = new St.DrawingArea();
this._border.connect('repaint', this._drawBorder.bind(this));
this._border.connect('repaint', Lang.bind(this, this._drawBorder));
this._container.add_actor(this._border);
this.bin.raise(this._border);
this._xOffset = 0;
@@ -66,20 +66,20 @@ var BoxPointer = new Lang.Class({
return this._arrowSide;
},
_muteInput() {
_muteInput: function() {
if (this._capturedEventId == 0)
this._capturedEventId = this.actor.connect('captured-event',
() => Clutter.EVENT_STOP);
function() { return Clutter.EVENT_STOP; });
},
_unmuteInput() {
_unmuteInput: function() {
if (this._capturedEventId != 0) {
this.actor.disconnect(this._capturedEventId);
this._capturedEventId = 0;
}
},
show(animate, onComplete) {
show: function(animate, onComplete) {
let themeNode = this.actor.get_theme_node();
let rise = themeNode.get_length('-arrow-rise');
let animationTime = (animate & PopupAnimation.FULL) ? POPUP_ANIMATION_TIME : 0;
@@ -112,15 +112,15 @@ var BoxPointer = new Lang.Class({
xOffset: 0,
yOffset: 0,
transition: 'linear',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this._unmuteInput();
if (onComplete)
onComplete();
},
}),
time: animationTime });
},
hide(animate, onComplete) {
hide: function(animate, onComplete) {
if (!this.actor.visible)
return;
@@ -156,18 +156,18 @@ var BoxPointer = new Lang.Class({
yOffset: yOffset,
transition: 'linear',
time: animationTime,
onComplete: () => {
onComplete: Lang.bind(this, function () {
this.actor.hide();
this.opacity = 0;
this.xOffset = 0;
this.yOffset = 0;
if (onComplete)
onComplete();
}
})
});
},
_adjustAllocationForArrow(isWidth, alloc) {
_adjustAllocationForArrow: function(isWidth, alloc) {
let themeNode = this.actor.get_theme_node();
let borderWidth = themeNode.get_length('-arrow-border-width');
alloc.min_size += borderWidth * 2;
@@ -180,14 +180,14 @@ var BoxPointer = new Lang.Class({
}
},
_getPreferredWidth(actor, forHeight, alloc) {
_getPreferredWidth: function(actor, forHeight, alloc) {
let [minInternalSize, natInternalSize] = this.bin.get_preferred_width(forHeight);
alloc.min_size = minInternalSize;
alloc.natural_size = natInternalSize;
this._adjustAllocationForArrow(true, alloc);
},
_getPreferredHeight(actor, forWidth, alloc) {
_getPreferredHeight: function(actor, forWidth, alloc) {
let themeNode = this.actor.get_theme_node();
let borderWidth = themeNode.get_length('-arrow-border-width');
let [minSize, naturalSize] = this.bin.get_preferred_height(forWidth - 2 * borderWidth);
@@ -196,7 +196,7 @@ var BoxPointer = new Lang.Class({
this._adjustAllocationForArrow(false, alloc);
},
_allocate(actor, box, flags) {
_allocate: function(actor, box, flags) {
let themeNode = this.actor.get_theme_node();
let borderWidth = themeNode.get_length('-arrow-border-width');
let rise = themeNode.get_length('-arrow-rise');
@@ -236,7 +236,7 @@ var BoxPointer = new Lang.Class({
}
},
_drawBorder(area) {
_drawBorder: function(area) {
let themeNode = this.actor.get_theme_node();
if (this._arrowActor) {
@@ -418,7 +418,7 @@ var BoxPointer = new Lang.Class({
cr.$dispose();
},
setPosition(sourceActor, alignment) {
setPosition: function(sourceActor, alignment) {
// We need to show it now to force an allocation,
// so that we can query the correct size.
this.actor.show();
@@ -430,7 +430,7 @@ var BoxPointer = new Lang.Class({
this._updateFlip();
},
setSourceAlignment(alignment) {
setSourceAlignment: function(alignment) {
this._sourceAlignment = alignment;
if (!this._sourceActor)
@@ -439,7 +439,7 @@ var BoxPointer = new Lang.Class({
this.setPosition(this._sourceActor, this._arrowAlignment);
},
_reposition() {
_reposition: function() {
let sourceActor = this._sourceActor;
let alignment = this._arrowAlignment;
@@ -556,7 +556,7 @@ var BoxPointer = new Lang.Class({
// @origin: Coordinate specifying middle of the arrow, along
// the Y axis for St.Side.LEFT, St.Side.RIGHT from the top and X axis from
// the left for St.Side.TOP and St.Side.BOTTOM.
setArrowOrigin(origin) {
setArrowOrigin: function(origin) {
if (this._arrowOrigin != origin) {
this._arrowOrigin = origin;
this._border.queue_repaint();
@@ -566,14 +566,14 @@ var BoxPointer = new Lang.Class({
// @actor: an actor relative to which the arrow is positioned.
// Differently from setPosition, this will not move the boxpointer itself,
// on the arrow
setArrowActor(actor) {
setArrowActor: function(actor) {
if (this._arrowActor != actor) {
this._arrowActor = actor;
this._border.queue_repaint();
}
},
_shiftActor() {
_shiftActor : function() {
// Since the position of the BoxPointer depends on the allocated size
// of the BoxPointer and the position of the source actor, trying
// to position the BoxPointer via the x/y properties will result in
@@ -584,7 +584,7 @@ var BoxPointer = new Lang.Class({
-(this._yPosition + this._yOffset));
},
_calculateArrowSide(arrowSide) {
_calculateArrowSide: function(arrowSide) {
let sourceAllocation = Shell.util_get_transformed_allocation(this._sourceActor);
let [minWidth, minHeight, boxWidth, boxHeight] = this._container.get_preferred_size();
let monitorActor = this.sourceActor;
@@ -618,15 +618,15 @@ var BoxPointer = new Lang.Class({
return arrowSide;
},
_updateFlip() {
_updateFlip: function() {
let arrowSide = this._calculateArrowSide(this._userArrowSide);
if (this._arrowSide != arrowSide) {
this._arrowSide = arrowSide;
this._reposition();
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
this._container.queue_relayout();
return false;
});
}));
this.emit('arrow-side-changed');
}
@@ -658,18 +658,18 @@ var BoxPointer = new Lang.Class({
return this.actor.opacity;
},
updateArrowSide(side) {
updateArrowSide: function(side) {
this._arrowSide = side;
this._border.queue_repaint();
this.emit('arrow-side-changed');
},
getPadding(side) {
getPadding: function(side) {
return this.bin.get_theme_node().get_padding(side);
},
getArrowHeight() {
getArrowHeight: function() {
return this.actor.get_theme_node().get_length('-arrow-rise');
}
});

View File

@@ -21,7 +21,7 @@ var ELLIPSIS_CHAR = '\u2026';
var MESSAGE_ICON_SIZE = -1; // pick up from CSS
var NC_ = (context, str) => context + '\u0004' + str;
var NC_ = function(context, str) { return context + '\u0004' + str; };
function sameYear(dateA, dateB) {
return (dateA.getYear() == dateB.getYear());
@@ -92,7 +92,7 @@ function _getCalendarDayAbbreviation(dayNumber) {
var CalendarEvent = new Lang.Class({
Name: 'CalendarEvent',
_init(id, date, end, summary, allDay) {
_init: function(id, date, end, summary, allDay) {
this.id = id;
this.date = date;
this.end = end;
@@ -108,27 +108,27 @@ var CalendarEvent = new Lang.Class({
var EmptyEventSource = new Lang.Class({
Name: 'EmptyEventSource',
_init() {
_init: function() {
this.isLoading = false;
this.isDummy = true;
this.hasCalendars = false;
},
destroy() {
destroy: function() {
},
ignoreEvent(event) {
ignoreEvent: function(event) {
},
requestRange(begin, end) {
requestRange: function(begin, end) {
},
getEvents(begin, end) {
getEvents: function(begin, end) {
let result = [];
return result;
},
hasEvents(day) {
hasEvents: function(day) {
return false;
}
});
@@ -179,7 +179,7 @@ function _dateIntervalsOverlap(a0, a1, b0, b1)
var DBusEventSource = new Lang.Class({
Name: 'DBusEventSource',
_init() {
_init: function() {
this._resetCache();
this.isLoading = false;
this.isDummy = false;
@@ -188,13 +188,14 @@ var DBusEventSource = new Lang.Class({
let savedState = global.get_persistent_state('as', 'ignored_events');
if (savedState)
savedState.deep_unpack().forEach(eventId => {
this._ignoredEvents.set(eventId, true);
});
savedState.deep_unpack().forEach(Lang.bind(this,
function(eventId) {
this._ignoredEvents.set(eventId, true);
}));
this._initialized = false;
this._dbusProxy = new CalendarServer();
this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, (object, result) => {
this._dbusProxy.init_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(object, result) {
let loaded = false;
try {
@@ -215,28 +216,28 @@ var DBusEventSource = new Lang.Class({
}
}
this._dbusProxy.connectSignal('Changed', this._onChanged.bind(this));
this._dbusProxy.connectSignal('Changed', Lang.bind(this, this._onChanged));
this._dbusProxy.connect('notify::g-name-owner', () => {
this._dbusProxy.connect('notify::g-name-owner', Lang.bind(this, function() {
if (this._dbusProxy.g_name_owner)
this._onNameAppeared();
else
this._onNameVanished();
});
}));
this._dbusProxy.connect('g-properties-changed', () => {
this._dbusProxy.connect('g-properties-changed', Lang.bind(this, function() {
this.emit('notify::has-calendars');
});
}));
this._initialized = loaded;
if (loaded) {
this.emit('notify::has-calendars');
this._onNameAppeared();
}
});
}));
},
destroy() {
destroy: function() {
this._dbusProxy.run_dispose();
},
@@ -247,28 +248,28 @@ var DBusEventSource = new Lang.Class({
return false;
},
_resetCache() {
_resetCache: function() {
this._events = [];
this._lastRequestBegin = null;
this._lastRequestEnd = null;
},
_onNameAppeared(owner) {
_onNameAppeared: function(owner) {
this._initialized = true;
this._resetCache();
this._loadEvents(true);
},
_onNameVanished(oldOwner) {
_onNameVanished: function(oldOwner) {
this._resetCache();
this.emit('changed');
},
_onChanged() {
_onChanged: function() {
this._loadEvents(false);
},
_onEventsReceived(results, error) {
_onEventsReceived: function(results, error) {
let newEvents = [];
let appointments = results ? results[0] : null;
if (appointments != null) {
@@ -282,7 +283,9 @@ var DBusEventSource = new Lang.Class({
let event = new CalendarEvent(id, date, end, summary, allDay);
newEvents.push(event);
}
newEvents.sort((ev1, ev2) => ev1.date.getTime() - ev2.date.getTime());
newEvents.sort(function(event1, event2) {
return event1.date.getTime() - event2.date.getTime();
});
}
this._events = newEvents;
@@ -290,7 +293,7 @@ var DBusEventSource = new Lang.Class({
this.emit('changed');
},
_loadEvents(forceReload) {
_loadEvents: function(forceReload) {
// Ignore while loading
if (!this._initialized)
return;
@@ -299,12 +302,12 @@ var DBusEventSource = new Lang.Class({
this._dbusProxy.GetEventsRemote(this._curRequestBegin.getTime() / 1000,
this._curRequestEnd.getTime() / 1000,
forceReload,
this._onEventsReceived.bind(this),
Lang.bind(this, this._onEventsReceived),
Gio.DBusCallFlags.NONE);
}
},
ignoreEvent(event) {
ignoreEvent: function(event) {
if (this._ignoredEvents.get(event.id))
return;
@@ -314,7 +317,7 @@ var DBusEventSource = new Lang.Class({
this.emit('changed');
},
requestRange(begin, end) {
requestRange: function(begin, end) {
if (!(_datesEqual(begin, this._lastRequestBegin) && _datesEqual(end, this._lastRequestEnd))) {
this.isLoading = true;
this._lastRequestBegin = begin;
@@ -325,7 +328,7 @@ var DBusEventSource = new Lang.Class({
}
},
getEvents(begin, end) {
getEvents: function(begin, end) {
let result = [];
for(let n = 0; n < this._events.length; n++) {
let event = this._events[n];
@@ -337,7 +340,7 @@ var DBusEventSource = new Lang.Class({
result.push(event);
}
}
result.sort((event1, event2) => {
result.sort(function(event1, event2) {
// sort events by end time on ending day
let d1 = event1.date < begin && event1.end <= end ? event1.end : event1.date;
let d2 = event2.date < begin && event2.end <= end ? event2.end : event2.date;
@@ -346,7 +349,7 @@ var DBusEventSource = new Lang.Class({
return result;
},
hasEvents(day) {
hasEvents: function(day) {
let dayBegin = _getBeginningOfDay(day);
let dayEnd = _getEndOfDay(day);
@@ -363,11 +366,11 @@ Signals.addSignalMethods(DBusEventSource.prototype);
var Calendar = new Lang.Class({
Name: 'Calendar',
_init() {
_init: function() {
this._weekStart = Shell.util_get_week_start();
this._settings = new Gio.Settings({ schema_id: 'org.gnome.desktop.calendar' });
this._settings.connect('changed::' + SHOW_WEEKDATE_KEY, this._onSettingsChange.bind(this));
this._settings.connect('changed::' + SHOW_WEEKDATE_KEY, Lang.bind(this, this._onSettingsChange));
this._useWeekdate = this._settings.get_boolean(SHOW_WEEKDATE_KEY);
/**
@@ -398,25 +401,25 @@ var Calendar = new Lang.Class({
reactive: true });
this.actor.connect('scroll-event',
this._onScroll.bind(this));
Lang.bind(this, this._onScroll));
this._buildHeader ();
},
// @eventSource: is an object implementing the EventSource API, e.g. the
// requestRange(), getEvents(), hasEvents() methods and the ::changed signal.
setEventSource(eventSource) {
setEventSource: function(eventSource) {
this._eventSource = eventSource;
this._eventSource.connect('changed', () => {
this._eventSource.connect('changed', Lang.bind(this, function() {
this._rebuildCalendar();
this._update();
});
}));
this._rebuildCalendar();
this._update();
},
// Sets the calendar to show a specific date
setDate(date) {
setDate: function(date) {
if (sameDay(date, this._selectedDate))
return;
@@ -425,14 +428,14 @@ var Calendar = new Lang.Class({
this.emit('selected-date-changed', new Date(this._selectedDate));
},
updateTimeZone() {
updateTimeZone: function() {
// The calendar need to be rebuilt after a time zone update because
// the date might have changed.
this._rebuildCalendar();
this._update();
},
_buildHeader() {
_buildHeader: function() {
let layout = this.actor.layout_manager;
let offsetCols = this._useWeekdate ? 1 : 0;
this.actor.destroy_all_children();
@@ -446,7 +449,7 @@ var Calendar = new Lang.Class({
accessible_name: _("Previous month"),
can_focus: true });
this._topBox.add(this._backButton);
this._backButton.connect('clicked', this._onPrevMonthButtonClicked.bind(this));
this._backButton.connect('clicked', Lang.bind(this, this._onPrevMonthButtonClicked));
this._monthLabel = new St.Label({style_class: 'calendar-month-label',
can_focus: true });
@@ -456,7 +459,7 @@ var Calendar = new Lang.Class({
accessible_name: _("Next month"),
can_focus: true });
this._topBox.add(this._forwardButton);
this._forwardButton.connect('clicked', this._onNextMonthButtonClicked.bind(this));
this._forwardButton.connect('clicked', Lang.bind(this, this._onNextMonthButtonClicked));
// Add weekday labels...
//
@@ -487,7 +490,7 @@ var Calendar = new Lang.Class({
this._firstDayIndex = this.actor.get_n_children();
},
_onScroll(actor, event) {
_onScroll : function(actor, event) {
switch (event.get_scroll_direction()) {
case Clutter.ScrollDirection.UP:
case Clutter.ScrollDirection.LEFT:
@@ -501,7 +504,7 @@ var Calendar = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onPrevMonthButtonClicked() {
_onPrevMonthButtonClicked: function() {
let newDate = new Date(this._selectedDate);
let oldMonth = newDate.getMonth();
if (oldMonth == 0) {
@@ -525,7 +528,7 @@ var Calendar = new Lang.Class({
this.setDate(newDate);
},
_onNextMonthButtonClicked() {
_onNextMonthButtonClicked: function() {
let newDate = new Date(this._selectedDate);
let oldMonth = newDate.getMonth();
if (oldMonth == 11) {
@@ -549,14 +552,14 @@ var Calendar = new Lang.Class({
this.setDate(newDate);
},
_onSettingsChange() {
_onSettingsChange: function() {
this._useWeekdate = this._settings.get_boolean(SHOW_WEEKDATE_KEY);
this._buildHeader();
this._rebuildCalendar();
this._update();
},
_rebuildCalendar() {
_rebuildCalendar: function() {
let now = new Date();
// Remove everything but the topBox and the weekday labels
@@ -614,11 +617,11 @@ var Calendar = new Lang.Class({
button.reactive = false;
button._date = new Date(iter);
button.connect('clicked', () => {
button.connect('clicked', Lang.bind(this, function() {
this._shouldDateGrabFocus = true;
this.setDate(button._date);
this._shouldDateGrabFocus = false;
});
}));
let hasEvents = this._eventSource.hasEvents(iter);
let styleClass = 'calendar-day-base calendar-day';
@@ -677,7 +680,7 @@ var Calendar = new Lang.Class({
this._eventSource.requestRange(beginDate, iter);
},
_update() {
_update: function() {
let now = new Date();
if (sameYear(this._selectedDate, now))
@@ -688,7 +691,7 @@ var Calendar = new Lang.Class({
if (!this._calendarBegin || !sameMonth(this._selectedDate, this._calendarBegin) || !sameDay(now, this._markedAsToday))
this._rebuildCalendar();
this._buttons.forEach(button => {
this._buttons.forEach(Lang.bind(this, function(button) {
if (sameDay(button._date, this._selectedDate)) {
button.add_style_pseudo_class('selected');
if (this._shouldDateGrabFocus)
@@ -696,7 +699,7 @@ var Calendar = new Lang.Class({
}
else
button.remove_style_pseudo_class('selected');
});
}));
}
});
Signals.addSignalMethods(Calendar.prototype);
@@ -705,7 +708,7 @@ var EventMessage = new Lang.Class({
Name: 'EventMessage',
Extends: MessageList.Message,
_init(event, date) {
_init: function(event, date) {
this._event = event;
this._date = date;
@@ -720,7 +723,7 @@ var EventMessage = new Lang.Class({
});
},
_formatEventTime() {
_formatEventTime: function() {
let periodBegin = _getBeginningOfDay(this._date);
let periodEnd = _getEndOfDay(this._date);
let allDay = (this._event.allDay || (this._event.date <= periodBegin &&
@@ -753,7 +756,7 @@ var EventMessage = new Lang.Class({
return title;
},
canClose() {
canClose: function() {
return isToday(this._date);
}
});
@@ -762,7 +765,7 @@ var NotificationMessage = new Lang.Class({
Name: 'NotificationMessage',
Extends: MessageList.Message,
_init(notification) {
_init: function(notification) {
this.notification = notification;
this.parent(notification.title, notification.bannerBodyText);
@@ -770,19 +773,21 @@ var NotificationMessage = new Lang.Class({
this.setIcon(this._getIcon());
this.connect('close', () => {
this._closed = true;
this.notification.destroy(MessageTray.NotificationDestroyedReason.DISMISSED);
});
this._destroyId = notification.connect('destroy', () => {
if (!this._closed)
this.close();
});
this.connect('close', Lang.bind(this,
function() {
this._closed = true;
this.notification.destroy(MessageTray.NotificationDestroyedReason.DISMISSED);
}));
this._destroyId = notification.connect('destroy', Lang.bind(this,
function() {
if (!this._closed)
this.close();
}));
this._updatedId = notification.connect('updated',
this._onUpdated.bind(this));
Lang.bind(this, this._onUpdated));
},
_getIcon() {
_getIcon: function() {
if (this.notification.gicon)
return new St.Icon({ gicon: this.notification.gicon,
icon_size: MESSAGE_ICON_SIZE });
@@ -790,18 +795,18 @@ var NotificationMessage = new Lang.Class({
return this.notification.source.createIcon(MESSAGE_ICON_SIZE);
},
_onUpdated(n, clear) {
_onUpdated: function(n, clear) {
this.setIcon(this._getIcon());
this.setTitle(n.title);
this.setBody(n.bannerBodyText);
this.setUseBodyMarkup(n.bannerBodyMarkup);
},
_onClicked() {
_onClicked: function() {
this.notification.activate();
},
_onDestroy() {
_onDestroy: function() {
if (this._updatedId)
this.notification.disconnect(this._updatedId);
this._updatedId = 0;
@@ -816,9 +821,9 @@ var EventsSection = new Lang.Class({
Name: 'EventsSection',
Extends: MessageList.MessageListSection,
_init() {
_init: function() {
this._desktopSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.interface' });
this._desktopSettings.connect('changed', this._reloadEvents.bind(this));
this._desktopSettings.connect('changed', Lang.bind(this, this._reloadEvents));
this._eventSource = new EmptyEventSource();
this.parent();
@@ -829,28 +834,28 @@ var EventsSection = new Lang.Class({
can_focus: true });
this.actor.insert_child_below(this._title, null);
this._title.connect('clicked', this._onTitleClicked.bind(this));
this._title.connect('key-focus-in', this._onKeyFocusIn.bind(this));
this._title.connect('clicked', Lang.bind(this, this._onTitleClicked));
this._title.connect('key-focus-in', Lang.bind(this, this._onKeyFocusIn));
Shell.AppSystem.get_default().connect('installed-changed',
this._appInstalledChanged.bind(this));
Lang.bind(this, this._appInstalledChanged));
this._appInstalledChanged();
},
_ignoreEvent(event) {
_ignoreEvent: function(event) {
this._eventSource.ignoreEvent(event);
},
setEventSource(eventSource) {
setEventSource: function(eventSource) {
this._eventSource = eventSource;
this._eventSource.connect('changed', this._reloadEvents.bind(this));
this._eventSource.connect('changed', Lang.bind(this, this._reloadEvents));
},
get allowed() {
return Main.sessionMode.showCalendarEvents;
},
_updateTitle() {
_updateTitle: function() {
this._title.visible = !isToday(this._date);
if (!this._title.visible)
@@ -869,7 +874,7 @@ var EventsSection = new Lang.Class({
this._title.label = this._date.toLocaleFormat(dayFormat);
},
_reloadEvents() {
_reloadEvents: function() {
if (this._eventSource.isLoading)
return;
@@ -885,9 +890,9 @@ var EventsSection = new Lang.Class({
let event = events[i];
let message = new EventMessage(event, this._date);
message.connect('close', () => {
message.connect('close', Lang.bind(this, function() {
this._ignoreEvent(event);
});
}));
this.addMessage(message, false);
}
@@ -895,19 +900,19 @@ var EventsSection = new Lang.Class({
this._sync();
},
_appInstalledChanged() {
_appInstalledChanged: function() {
this._calendarApp = undefined;
this._title.reactive = (this._getCalendarApp() != null);
},
_getCalendarApp() {
_getCalendarApp: function() {
if (this._calendarApp !== undefined)
return this._calendarApp;
let apps = Gio.AppInfo.get_recommended_for_type('text/calendar');
if (apps && (apps.length > 0)) {
let app = Gio.AppInfo.get_default_for_type('text/calendar', false);
let defaultInRecommended = apps.some(a => a.equal(app));
let defaultInRecommended = apps.some(function(a) { return a.equal(app); });
this._calendarApp = defaultInRecommended ? app : apps[0];
} else {
this._calendarApp = null;
@@ -915,7 +920,7 @@ var EventsSection = new Lang.Class({
return this._calendarApp;
},
_onTitleClicked() {
_onTitleClicked: function() {
Main.overview.hide();
Main.panel.closeCalendar();
@@ -925,17 +930,17 @@ var EventsSection = new Lang.Class({
app.launch([], global.create_app_launch_context(0, -1));
},
setDate(date) {
setDate: function(date) {
this.parent(date);
this._updateTitle();
this._reloadEvents();
},
_shouldShow() {
_shouldShow: function() {
return !this.empty || !isToday(this._date);
},
_sync() {
_sync: function() {
if (this._reloading)
return;
@@ -947,18 +952,18 @@ var NotificationSection = new Lang.Class({
Name: 'NotificationSection',
Extends: MessageList.MessageListSection,
_init() {
_init: function() {
this.parent();
this._sources = new Map();
this._nUrgent = 0;
Main.messageTray.connect('source-added', this._sourceAdded.bind(this));
Main.messageTray.getSources().forEach(source => {
Main.messageTray.connect('source-added', Lang.bind(this, this._sourceAdded));
Main.messageTray.getSources().forEach(Lang.bind(this, function(source) {
this._sourceAdded(Main.messageTray, source);
});
}));
this.actor.connect('notify::mapped', this._onMapped.bind(this));
this.actor.connect('notify::mapped', Lang.bind(this, this._onMapped));
},
get allowed() {
@@ -966,7 +971,7 @@ var NotificationSection = new Lang.Class({
!Main.sessionMode.isGreeter;
},
_createTimeLabel(datetime) {
_createTimeLabel: function(datetime) {
let label = new St.Label({ style_class: 'event-time',
x_align: Clutter.ActorAlign.START,
y_align: Clutter.ActorAlign.END });
@@ -977,37 +982,39 @@ var NotificationSection = new Lang.Class({
return label;
},
_sourceAdded(tray, source) {
_sourceAdded: function(tray, source) {
let obj = {
destroyId: 0,
notificationAddedId: 0,
};
obj.destroyId = source.connect('destroy', source => {
obj.destroyId = source.connect('destroy', Lang.bind(this, function(source) {
this._onSourceDestroy(source, obj);
});
}));
obj.notificationAddedId = source.connect('notification-added',
this._onNotificationAdded.bind(this));
Lang.bind(this, this._onNotificationAdded));
this._sources.set(source, obj);
},
_onNotificationAdded(source, notification) {
_onNotificationAdded: function(source, notification) {
let message = new NotificationMessage(notification);
message.setSecondaryActor(this._createTimeLabel(notification.datetime));
let isUrgent = notification.urgency == MessageTray.Urgency.CRITICAL;
let updatedId = notification.connect('updated', () => {
message.setSecondaryActor(this._createTimeLabel(notification.datetime));
this.moveMessage(message, isUrgent ? 0 : this._nUrgent, this.actor.mapped);
});
let destroyId = notification.connect('destroy', () => {
notification.disconnect(destroyId);
notification.disconnect(updatedId);
if (isUrgent)
this._nUrgent--;
});
let updatedId = notification.connect('updated', Lang.bind(this,
function() {
message.setSecondaryActor(this._createTimeLabel(notification.datetime));
this.moveMessage(message, isUrgent ? 0 : this._nUrgent, this.actor.mapped);
}));
let destroyId = notification.connect('destroy', Lang.bind(this,
function() {
notification.disconnect(destroyId);
notification.disconnect(updatedId);
if (isUrgent)
this._nUrgent--;
}));
if (isUrgent) {
// Keep track of urgent notifications to keep them on top
@@ -1023,14 +1030,14 @@ var NotificationSection = new Lang.Class({
this.addMessageAtIndex(message, index, this.actor.mapped);
},
_onSourceDestroy(source, obj) {
_onSourceDestroy: function(source, obj) {
source.disconnect(obj.destroyId);
source.disconnect(obj.notificationAddedId);
this._sources.delete(source);
},
_onMapped() {
_onMapped: function() {
if (!this.actor.mapped)
return;
@@ -1039,7 +1046,7 @@ var NotificationSection = new Lang.Class({
message.notification.acknowledged = true;
},
_shouldShow() {
_shouldShow: function() {
return !this.empty && isToday(this._date);
}
});
@@ -1047,7 +1054,7 @@ var NotificationSection = new Lang.Class({
var Placeholder = new Lang.Class({
Name: 'Placeholder',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ style_class: 'message-list-placeholder',
vertical: true });
@@ -1067,14 +1074,14 @@ var Placeholder = new Lang.Class({
this._sync();
},
setDate(date) {
setDate: function(date) {
if (sameDay(this._date, date))
return;
this._date = date;
this._sync();
},
_sync() {
_sync: function() {
let today = isToday(this._date);
if (today && this._icon.gicon == this._todayIcon)
return;
@@ -1094,7 +1101,7 @@ var Placeholder = new Lang.Class({
var CalendarMessageList = new Lang.Class({
Name: 'CalendarMessageList',
_init() {
_init: function() {
this.actor = new St.Widget({ style_class: 'message-list',
layout_manager: new Clutter.BinLayout(),
x_expand: true, y_expand: true });
@@ -1139,10 +1146,10 @@ var CalendarMessageList = new Lang.Class({
this._eventsSection = new EventsSection();
this._addSection(this._eventsSection);
Main.sessionMode.connect('updated', this._sync.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._sync));
},
_addSection(section) {
_addSection: function(section) {
let obj = {
destroyId: 0,
visibleId: 0,
@@ -1150,24 +1157,25 @@ var CalendarMessageList = new Lang.Class({
canClearChangedId: 0,
keyFocusId: 0
};
obj.destroyId = section.actor.connect('destroy', () => {
this._removeSection(section);
});
obj.destroyId = section.actor.connect('destroy', Lang.bind(this,
function() {
this._removeSection(section);
}));
obj.visibleId = section.actor.connect('notify::visible',
this._sync.bind(this));
Lang.bind(this, this._sync));
obj.emptyChangedId = section.connect('empty-changed',
this._sync.bind(this));
Lang.bind(this, this._sync));
obj.canClearChangedId = section.connect('can-clear-changed',
this._sync.bind(this));
Lang.bind(this, this._sync));
obj.keyFocusId = section.connect('key-focus-in',
this._onKeyFocusIn.bind(this));
Lang.bind(this, this._onKeyFocusIn));
this._sections.set(section, obj);
this._sectionList.add_actor(section.actor);
this._sync();
},
_removeSection(section) {
_removeSection: function(section) {
let obj = this._sections.get(section);
section.actor.disconnect(obj.destroyId);
section.actor.disconnect(obj.visibleId);
@@ -1180,30 +1188,36 @@ var CalendarMessageList = new Lang.Class({
this._sync();
},
_onKeyFocusIn(section, actor) {
_onKeyFocusIn: function(section, actor) {
Util.ensureActorVisibleInScrollView(this._scrollView, actor);
},
_sync() {
_sync: function() {
let sections = [...this._sections.keys()];
let visible = sections.some(s => s.allowed);
let visible = sections.some(function(s) {
return s.allowed;
});
this.actor.visible = visible;
if (!visible)
return;
let empty = sections.every(s => s.empty || !s.actor.visible);
let empty = sections.every(function(s) {
return s.empty || !s.actor.visible;
});
this._placeholder.actor.visible = empty;
this._clearButton.visible = !empty;
let canClear = sections.some(s => s.canClear && s.actor.visible);
let canClear = sections.some(function(s) {
return s.canClear && s.actor.visible;
});
this._clearButton.reactive = canClear;
},
setEventSource(eventSource) {
setEventSource: function(eventSource) {
this._eventsSection.setEventSource(eventSource);
},
setDate(date) {
setDate: function(date) {
for (let section of this._sections.keys())
section.setDate(date);
this._placeholder.setDate(date);

View File

@@ -7,7 +7,7 @@ const Lang = imports.lang;
var CheckBox = new Lang.Class({
Name: 'CheckBox',
_init(label) {
_init: function(label) {
let container = new St.BoxLayout();
this.actor = new St.Button({ style_class: 'check-box',
child: container,
@@ -30,11 +30,11 @@ var CheckBox = new Lang.Class({
this.setLabel(label);
},
setLabel(label) {
setLabel: function(label) {
this._label.set_text(label);
},
getLabelActor() {
getLabelActor: function() {
return this._label;
}
});

View File

@@ -22,7 +22,7 @@ var CloseDialog = new Lang.Class({
'window': GObject.ParamSpec.override('window', Meta.CloseDialog)
},
_init(window) {
_init: function (window) {
this.parent();
this._window = window;
this._dialog = null;
@@ -36,7 +36,7 @@ var CloseDialog = new Lang.Class({
this._window = window;
},
_createDialogContent() {
_createDialogContent: function () {
let tracker = Shell.WindowTracker.get_default();
let windowApp = tracker.get_window_app(this._window);
@@ -48,7 +48,7 @@ var CloseDialog = new Lang.Class({
return new Dialog.MessageDialogContent({ icon, title, subtitle });
},
_initDialog() {
_initDialog: function () {
if (this._dialog)
return;
@@ -59,16 +59,16 @@ var CloseDialog = new Lang.Class({
this._dialog.addContent(this._createDialogContent());
this._dialog.addButton({ label: _('Force Quit'),
action: this._onClose.bind(this),
action: Lang.bind(this, this._onClose),
default: true });
this._dialog.addButton({ label: _('Wait'),
action: this._onWait.bind(this),
action: Lang.bind(this, this._onWait),
key: Clutter.Escape });
global.focus_manager.add_group(this._dialog);
},
_addWindowEffect() {
_addWindowEffect: function () {
// We set the effect on the surface actor, so the dialog itself
// (which is a child of the MetaWindowActor) does not get the
// effect applied itself.
@@ -79,21 +79,21 @@ var CloseDialog = new Lang.Class({
surfaceActor.add_effect_with_name("gnome-shell-frozen-window", effect);
},
_removeWindowEffect() {
_removeWindowEffect: function () {
let windowActor = this._window.get_compositor_private();
let surfaceActor = windowActor.get_first_child();
surfaceActor.remove_effect_by_name("gnome-shell-frozen-window");
},
_onWait() {
_onWait: function () {
this.response(Meta.CloseDialogResponse.WAIT);
},
_onClose() {
_onClose: function () {
this.response(Meta.CloseDialogResponse.FORCE_CLOSE);
},
vfunc_show() {
vfunc_show: function () {
if (this._dialog != null)
return;
@@ -107,13 +107,13 @@ var CloseDialog = new Lang.Class({
{ scale_y: 1,
transition: 'linear',
time: DIALOG_TRANSITION_TIME,
onComplete: () => {
onComplete: Lang.bind(this, function () {
Main.layoutManager.trackChrome(this._dialog, { affectsInputRegion: true });
}
})
});
},
vfunc_hide() {
vfunc_hide: function () {
if (this._dialog == null)
return;
@@ -125,13 +125,13 @@ var CloseDialog = new Lang.Class({
{ scale_y: 0,
transition: 'linear',
time: DIALOG_TRANSITION_TIME,
onComplete: () => {
onComplete: Lang.bind(this, function () {
dialog.destroy();
}
})
});
},
vfunc_focus() {
vfunc_focus: function () {
if (this._dialog)
this._dialog.grab_key_focus();
}

View File

@@ -5,38 +5,38 @@ const Main = imports.ui.main;
var ComponentManager = new Lang.Class({
Name: 'ComponentManager',
_init() {
_init: function() {
this._allComponents = {};
this._enabledComponents = [];
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
this._sessionUpdated();
},
_sessionUpdated() {
_sessionUpdated: function() {
let newEnabledComponents = Main.sessionMode.components;
newEnabledComponents.filter(
name => this._enabledComponents.indexOf(name) == -1
).forEach(name => {
newEnabledComponents.filter(Lang.bind(this, function(name) {
return this._enabledComponents.indexOf(name) == -1;
})).forEach(Lang.bind(this, function(name) {
this._enableComponent(name);
});
}));
this._enabledComponents.filter(
name => newEnabledComponents.indexOf(name) == -1
).forEach(name => {
this._enabledComponents.filter(Lang.bind(this, function(name) {
return newEnabledComponents.indexOf(name) == -1;
})).forEach(Lang.bind(this, function(name) {
this._disableComponent(name);
});
}));
this._enabledComponents = newEnabledComponents;
},
_importComponent(name) {
_importComponent: function(name) {
let module = imports.ui.components[name];
return module.Component;
},
_ensureComponent(name) {
_ensureComponent: function(name) {
let component = this._allComponents[name];
if (component)
return component;
@@ -50,13 +50,13 @@ var ComponentManager = new Lang.Class({
return component;
},
_enableComponent(name) {
_enableComponent: function(name) {
let component = this._ensureComponent(name);
if (component)
component.enable();
},
_disableComponent(name) {
_disableComponent: function(name) {
let component = this._allComponents[name];
if (component == null)
return;

View File

@@ -22,31 +22,31 @@ var AUTORUN_EXPIRE_TIMEOUT_SECS = 10;
var AutomountManager = new Lang.Class({
Name: 'AutomountManager',
_init() {
_init: function() {
this._settings = new Gio.Settings({ schema_id: SETTINGS_SCHEMA });
this._volumeQueue = [];
this._session = new GnomeSession.SessionManager();
this._session.connectSignal('InhibitorAdded',
this._InhibitorsChanged.bind(this));
Lang.bind(this, this._InhibitorsChanged));
this._session.connectSignal('InhibitorRemoved',
this._InhibitorsChanged.bind(this));
Lang.bind(this, this._InhibitorsChanged));
this._inhibited = false;
this._volumeMonitor = Gio.VolumeMonitor.get();
},
enable() {
this._volumeAddedId = this._volumeMonitor.connect('volume-added', this._onVolumeAdded.bind(this));
this._volumeRemovedId = this._volumeMonitor.connect('volume-removed', this._onVolumeRemoved.bind(this));
this._driveConnectedId = this._volumeMonitor.connect('drive-connected', this._onDriveConnected.bind(this));
this._driveDisconnectedId = this._volumeMonitor.connect('drive-disconnected', this._onDriveDisconnected.bind(this));
this._driveEjectButtonId = this._volumeMonitor.connect('drive-eject-button', this._onDriveEjectButton.bind(this));
enable: function() {
this._volumeAddedId = this._volumeMonitor.connect('volume-added', Lang.bind(this, this._onVolumeAdded));
this._volumeRemovedId = this._volumeMonitor.connect('volume-removed', Lang.bind(this, this._onVolumeRemoved));
this._driveConnectedId = this._volumeMonitor.connect('drive-connected', Lang.bind(this, this._onDriveConnected));
this._driveDisconnectedId = this._volumeMonitor.connect('drive-disconnected', Lang.bind(this, this._onDriveDisconnected));
this._driveEjectButtonId = this._volumeMonitor.connect('drive-eject-button', Lang.bind(this, this._onDriveEjectButton));
this._mountAllId = Mainloop.idle_add(this._startupMountAll.bind(this));
this._mountAllId = Mainloop.idle_add(Lang.bind(this, this._startupMountAll));
GLib.Source.set_name_by_id(this._mountAllId, '[gnome-shell] this._startupMountAll');
},
disable() {
disable: function() {
this._volumeMonitor.disconnect(this._volumeAddedId);
this._volumeMonitor.disconnect(this._volumeRemovedId);
this._volumeMonitor.disconnect(this._driveConnectedId);
@@ -59,28 +59,29 @@ var AutomountManager = new Lang.Class({
}
},
_InhibitorsChanged(object, senderName, [inhibtor]) {
_InhibitorsChanged: function(object, senderName, [inhibtor]) {
this._session.IsInhibitedRemote(GNOME_SESSION_AUTOMOUNT_INHIBIT,
(result, error) => {
if (!error) {
this._inhibited = result[0];
}
});
Lang.bind(this,
function(result, error) {
if (!error) {
this._inhibited = result[0];
}
}));
},
_startupMountAll() {
_startupMountAll: function() {
let volumes = this._volumeMonitor.get_volumes();
volumes.forEach(volume => {
volumes.forEach(Lang.bind(this, function(volume) {
this._checkAndMountVolume(volume, { checkSession: false,
useMountOp: false,
allowAutorun: false });
});
}));
this._mountAllId = 0;
return GLib.SOURCE_REMOVE;
},
_onDriveConnected() {
_onDriveConnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
if (!this._session.SessionIsActive)
@@ -91,7 +92,7 @@ var AutomountManager = new Lang.Class({
null);
},
_onDriveDisconnected() {
_onDriveDisconnected: function() {
// if we're not in the current ConsoleKit session,
// or screensaver is active, don't play sounds
if (!this._session.SessionIsActive)
@@ -102,7 +103,7 @@ var AutomountManager = new Lang.Class({
null);
},
_onDriveEjectButton(monitor, drive) {
_onDriveEjectButton: function(monitor, drive) {
// TODO: this code path is not tested, as the GVfs volume monitor
// doesn't emit this signal just yet.
if (!this._session.SessionIsActive)
@@ -113,31 +114,31 @@ var AutomountManager = new Lang.Class({
if (drive.can_stop()) {
drive.stop
(Gio.MountUnmountFlags.FORCE, null, null,
(drive, res) => {
Lang.bind(this, function(drive, res) {
try {
drive.stop_finish(res);
} catch (e) {
log("Unable to stop the drive after drive-eject-button " + e.toString());
}
});
}));
} else if (drive.can_eject()) {
drive.eject_with_operation
(Gio.MountUnmountFlags.FORCE, null, null,
(drive, res) => {
Lang.bind(this, function(drive, res) {
try {
drive.eject_with_operation_finish(res);
} catch (e) {
log("Unable to eject the drive after drive-eject-button " + e.toString());
}
});
}));
}
},
_onVolumeAdded(monitor, volume) {
_onVolumeAdded: function(monitor, volume) {
this._checkAndMountVolume(volume);
},
_checkAndMountVolume(volume, params) {
_checkAndMountVolume: function(volume, params) {
params = Params.parse(params, { checkSession: true,
useMountOp: true,
allowAutorun: true });
@@ -177,7 +178,7 @@ var AutomountManager = new Lang.Class({
}
},
_mountVolume(volume, operation, allowAutorun) {
_mountVolume: function(volume, operation, allowAutorun) {
if (allowAutorun)
this._allowAutorun(volume);
@@ -185,10 +186,10 @@ var AutomountManager = new Lang.Class({
volume._operation = operation;
volume.mount(0, mountOp, null,
this._onVolumeMounted.bind(this));
Lang.bind(this, this._onVolumeMounted));
},
_onVolumeMounted(volume, res) {
_onVolumeMounted: function(volume, res) {
this._allowAutorunExpire(volume);
try {
@@ -209,12 +210,14 @@ var AutomountManager = new Lang.Class({
}
},
_onVolumeRemoved(monitor, volume) {
_onVolumeRemoved: function(monitor, volume) {
this._volumeQueue =
this._volumeQueue.filter(element => (element != volume));
this._volumeQueue.filter(function(element) {
return (element != volume);
});
},
_reaskPassword(volume) {
_reaskPassword: function(volume) {
let existingDialog = volume._operation ? volume._operation.borrowDialog() : null;
let operation =
new ShellMountOperation.ShellMountOperation(volume,
@@ -222,17 +225,17 @@ var AutomountManager = new Lang.Class({
this._mountVolume(volume, operation);
},
_closeOperation(volume) {
_closeOperation: function(volume) {
if (volume._operation)
volume._operation.close();
},
_allowAutorun(volume) {
_allowAutorun: function(volume) {
volume.allowAutorun = true;
},
_allowAutorunExpire(volume) {
let id = Mainloop.timeout_add_seconds(AUTORUN_EXPIRE_TIMEOUT_SECS, () => {
_allowAutorunExpire: function(volume) {
let id = Mainloop.timeout_add_seconds(AUTORUN_EXPIRE_TIMEOUT_SECS, function() {
volume.allowAutorun = false;
return GLib.SOURCE_REMOVE;
});

View File

@@ -93,25 +93,26 @@ function HotplugSniffer() {
var ContentTypeDiscoverer = new Lang.Class({
Name: 'ContentTypeDiscoverer',
_init(callback) {
_init: function(callback) {
this._callback = callback;
this._settings = new Gio.Settings({ schema_id: SETTINGS_SCHEMA });
},
guessContentTypes(mount) {
guessContentTypes: function(mount) {
let autorunEnabled = !this._settings.get_boolean(SETTING_DISABLE_AUTORUN);
let shouldScan = autorunEnabled && !isMountNonLocal(mount);
if (shouldScan) {
// guess mount's content types using GIO
mount.guess_content_type(false, null,
this._onContentTypeGuessed.bind(this));
Lang.bind(this,
this._onContentTypeGuessed));
} else {
this._emitCallback(mount, []);
}
},
_onContentTypeGuessed(mount, res) {
_onContentTypeGuessed: function(mount, res) {
let contentTypes = [];
try {
@@ -128,23 +129,23 @@ var ContentTypeDiscoverer = new Lang.Class({
let hotplugSniffer = new HotplugSniffer();
hotplugSniffer.SniffURIRemote(root.get_uri(),
([contentTypes]) => {
Lang.bind(this, function([contentTypes]) {
this._emitCallback(mount, contentTypes);
});
}));
}
},
_emitCallback(mount, contentTypes) {
_emitCallback: function(mount, contentTypes) {
if (!contentTypes)
contentTypes = [];
// we're not interested in win32 software content types here
contentTypes = contentTypes.filter(
type => (type != 'x-content/win32-software')
);
contentTypes = contentTypes.filter(function(type) {
return (type != 'x-content/win32-software');
});
let apps = [];
contentTypes.forEach(type => {
contentTypes.forEach(function(type) {
let app = Gio.app_info_get_default_for_type(type, false);
if (app)
@@ -161,36 +162,36 @@ var ContentTypeDiscoverer = new Lang.Class({
var AutorunManager = new Lang.Class({
Name: 'AutorunManager',
_init() {
_init: function() {
this._session = new GnomeSession.SessionManager();
this._volumeMonitor = Gio.VolumeMonitor.get();
this._dispatcher = new AutorunDispatcher(this);
},
enable() {
this._mountAddedId = this._volumeMonitor.connect('mount-added', this._onMountAdded.bind(this));
this._mountRemovedId = this._volumeMonitor.connect('mount-removed', this._onMountRemoved.bind(this));
enable: function() {
this._mountAddedId = this._volumeMonitor.connect('mount-added', Lang.bind(this, this._onMountAdded));
this._mountRemovedId = this._volumeMonitor.connect('mount-removed', Lang.bind(this, this._onMountRemoved));
},
disable() {
disable: function() {
this._volumeMonitor.disconnect(this._mountAddedId);
this._volumeMonitor.disconnect(this._mountRemovedId);
},
_onMountAdded(monitor, mount) {
_onMountAdded: function(monitor, mount) {
// don't do anything if our session is not the currently
// active one
if (!this._session.SessionIsActive)
return;
let discoverer = new ContentTypeDiscoverer((mount, apps, contentTypes) => {
let discoverer = new ContentTypeDiscoverer(Lang.bind(this, function(mount, apps, contentTypes) {
this._dispatcher.addMount(mount, apps, contentTypes);
});
}));
discoverer.guessContentTypes(mount);
},
_onMountRemoved(monitor, mount) {
_onMountRemoved: function(monitor, mount) {
this._dispatcher.removeMount(mount);
}
});
@@ -198,13 +199,13 @@ var AutorunManager = new Lang.Class({
var AutorunDispatcher = new Lang.Class({
Name: 'AutorunDispatcher',
_init(manager) {
_init: function(manager) {
this._manager = manager;
this._sources = [];
this._settings = new Gio.Settings({ schema_id: SETTINGS_SCHEMA });
},
_getAutorunSettingForType(contentType) {
_getAutorunSettingForType: function(contentType) {
let runApp = this._settings.get_strv(SETTING_START_APP);
if (runApp.indexOf(contentType) != -1)
return AutorunSetting.RUN;
@@ -220,8 +221,11 @@ var AutorunDispatcher = new Lang.Class({
return AutorunSetting.ASK;
},
_getSourceForMount(mount) {
let filtered = this._sources.filter(source => (source.mount == mount));
_getSourceForMount: function(mount) {
let filtered =
this._sources.filter(function (source) {
return (source.mount == mount);
});
// we always make sure not to add two sources for the same
// mount in addMount(), so it's safe to assume filtered.length
@@ -232,7 +236,7 @@ var AutorunDispatcher = new Lang.Class({
return null;
},
_addSource(mount, apps) {
_addSource: function(mount, apps) {
// if we already have a source showing for this
// mount, return
if (this._getSourceForMount(mount))
@@ -242,7 +246,7 @@ var AutorunDispatcher = new Lang.Class({
this._sources.push(new AutorunSource(this._manager, mount, apps));
},
addMount(mount, apps, contentTypes) {
addMount: function(mount, apps, contentTypes) {
// if autorun is disabled globally, return
if (this._settings.get_boolean(SETTING_DISABLE_AUTORUN))
return;
@@ -280,7 +284,7 @@ var AutorunDispatcher = new Lang.Class({
this._addSource(mount, apps);
},
removeMount(mount) {
removeMount: function(mount) {
let source = this._getSourceForMount(mount);
// if we aren't tracking this mount, don't do anything
@@ -296,7 +300,7 @@ var AutorunSource = new Lang.Class({
Name: 'AutorunSource',
Extends: MessageTray.Source,
_init(manager, mount, apps) {
_init: function(manager, mount, apps) {
this._manager = manager;
this.mount = mount;
this.apps = apps;
@@ -310,11 +314,11 @@ var AutorunSource = new Lang.Class({
this.notify(this._notification);
},
getIcon() {
getIcon: function() {
return this.mount.get_icon();
},
_createPolicy() {
_createPolicy: function() {
return new MessageTray.NotificationApplicationPolicy('org.gnome.Nautilus');
}
});
@@ -323,27 +327,27 @@ var AutorunNotification = new Lang.Class({
Name: 'AutorunNotification',
Extends: MessageTray.Notification,
_init(manager, source) {
_init: function(manager, source) {
this.parent(source, source.title);
this._manager = manager;
this._mount = source.mount;
},
createBanner() {
createBanner: function() {
let banner = new MessageTray.NotificationBanner(this);
this.source.apps.forEach(app => {
this.source.apps.forEach(Lang.bind(this, function (app) {
let actor = this._buttonForApp(app);
if (actor)
banner.addButton(actor);
});
}));
return banner;
},
_buttonForApp(app) {
_buttonForApp: function(app) {
let box = new St.BoxLayout();
let icon = new St.Icon({ gicon: app.get_icon(),
style_class: 'hotplug-notification-item-icon' });
@@ -362,15 +366,15 @@ var AutorunNotification = new Lang.Class({
button_mask: St.ButtonMask.ONE,
style_class: 'hotplug-notification-item button' });
button.connect('clicked', () => {
button.connect('clicked', Lang.bind(this, function() {
startAppForMount(app, this._mount);
this.destroy();
});
}));
return button;
},
activate() {
activate: function() {
this.parent();
let app = Gio.app_info_get_default_for_type('inode/directory', false);

View File

@@ -24,13 +24,13 @@ var KeyringDialog = new Lang.Class({
Name: 'KeyringDialog',
Extends: ModalDialog.ModalDialog,
_init() {
_init: function() {
this.parent({ styleClass: 'prompt-dialog' });
this.prompt = new Shell.KeyringPrompt();
this.prompt.connect('show-password', this._onShowPassword.bind(this));
this.prompt.connect('show-confirm', this._onShowConfirm.bind(this));
this.prompt.connect('prompt-close', this._onHidePrompt.bind(this));
this.prompt.connect('show-password', Lang.bind(this, this._onShowPassword));
this.prompt.connect('show-confirm', Lang.bind(this, this._onShowConfirm));
this.prompt.connect('prompt-close', Lang.bind(this, this._onHidePrompt));
let icon = new Gio.ThemedIcon({ name: 'dialog-password-symbolic' });
this._content = new Dialog.MessageDialogContent({ icon });
@@ -55,17 +55,17 @@ var KeyringDialog = new Lang.Class({
this._controlTable = null;
this._cancelButton = this.addButton({ label: '',
action: this._onCancelButton.bind(this),
action: Lang.bind(this, this._onCancelButton),
key: Clutter.Escape });
this._continueButton = this.addButton({ label: '',
action: this._onContinueButton.bind(this),
action: Lang.bind(this, this._onContinueButton),
default: true });
this.prompt.bind_property('cancel-label', this._cancelButton, 'label', GObject.BindingFlags.SYNC_CREATE);
this.prompt.bind_property('continue-label', this._continueButton, 'label', GObject.BindingFlags.SYNC_CREATE);
},
_setWorking(working) {
_setWorking: function(working) {
if (!this._workSpinner)
return;
@@ -84,7 +84,7 @@ var KeyringDialog = new Lang.Class({
time: WORK_SPINNER_ANIMATION_TIME,
transition: 'linear',
onCompleteScope: this,
onComplete() {
onComplete: function() {
if (this._workSpinner)
this._workSpinner.stop();
}
@@ -92,7 +92,7 @@ var KeyringDialog = new Lang.Class({
}
},
_buildControlTable() {
_buildControlTable: function() {
let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL });
let table = new St.Widget({ style_class: 'keyring-dialog-control-table',
layout_manager: layout });
@@ -112,7 +112,7 @@ var KeyringDialog = new Lang.Class({
x_expand: true });
this._passwordEntry.clutter_text.set_password_char('\u25cf'); // ● U+25CF BLACK CIRCLE
ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
this._passwordEntry.clutter_text.connect('activate', this._onPasswordActivate.bind(this));
this._passwordEntry.clutter_text.connect('activate', Lang.bind(this, this._onPasswordActivate));
let spinnerIcon = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/process-working.svg');
this._workSpinner = new Animation.AnimatedIcon(spinnerIcon, WORK_SPINNER_ICON_SIZE);
@@ -144,7 +144,7 @@ var KeyringDialog = new Lang.Class({
x_expand: true });
this._confirmEntry.clutter_text.set_password_char('\u25cf'); // ● U+25CF BLACK CIRCLE
ShellEntry.addContextMenu(this._confirmEntry, { isPassword: true });
this._confirmEntry.clutter_text.connect('activate', this._onConfirmActivate.bind(this));
this._confirmEntry.clutter_text.connect('activate', Lang.bind(this, this._onConfirmActivate));
if (rtl) {
layout.attach(this._confirmEntry, 0, row, 1, 1);
layout.attach(label, 1, row, 1, 1);
@@ -185,7 +185,7 @@ var KeyringDialog = new Lang.Class({
this._content.messageBox.add(table, { x_fill: true, y_fill: true });
},
_updateSensitivity(sensitive) {
_updateSensitivity: function(sensitive) {
if (this._passwordEntry) {
this._passwordEntry.reactive = sensitive;
this._passwordEntry.clutter_text.editable = sensitive;
@@ -201,7 +201,7 @@ var KeyringDialog = new Lang.Class({
this._setWorking(!sensitive);
},
_ensureOpen() {
_ensureOpen: function() {
// NOTE: ModalDialog.open() is safe to call if the dialog is
// already open - it just returns true without side-effects
if (this.open())
@@ -219,41 +219,41 @@ var KeyringDialog = new Lang.Class({
return false;
},
_onShowPassword(prompt) {
_onShowPassword: function(prompt) {
this._buildControlTable();
this._ensureOpen();
this._updateSensitivity(true);
this._passwordEntry.grab_key_focus();
},
_onShowConfirm(prompt) {
_onShowConfirm: function(prompt) {
this._buildControlTable();
this._ensureOpen();
this._updateSensitivity(true);
this._continueButton.grab_key_focus();
},
_onHidePrompt(prompt) {
_onHidePrompt: function(prompt) {
this.close();
},
_onPasswordActivate() {
_onPasswordActivate: function() {
if (this.prompt.confirm_visible)
this._confirmEntry.grab_key_focus();
else
this._onContinueButton();
},
_onConfirmActivate() {
_onConfirmActivate: function() {
this._onContinueButton();
},
_onContinueButton() {
_onContinueButton: function() {
this._updateSensitivity(false);
this.prompt.complete();
},
_onCancelButton() {
_onCancelButton: function() {
this.prompt.cancel();
},
});
@@ -261,13 +261,15 @@ var KeyringDialog = new Lang.Class({
var KeyringDummyDialog = new Lang.Class({
Name: 'KeyringDummyDialog',
_init() {
_init: function() {
this.prompt = new Shell.KeyringPrompt();
this.prompt.connect('show-password', this._cancelPrompt.bind(this));
this.prompt.connect('show-confirm', this._cancelPrompt.bind(this));
this.prompt.connect('show-password',
Lang.bind(this, this._cancelPrompt));
this.prompt.connect('show-confirm', Lang.bind(this,
this._cancelPrompt));
},
_cancelPrompt() {
_cancelPrompt: function() {
this.prompt.cancel();
}
});
@@ -275,21 +277,22 @@ var KeyringDummyDialog = new Lang.Class({
var KeyringPrompter = new Lang.Class({
Name: 'KeyringPrompter',
_init() {
_init: function() {
this._prompter = new Gcr.SystemPrompter();
this._prompter.connect('new-prompt', () => {
let dialog = this._enabled ? new KeyringDialog()
: new KeyringDummyDialog();
this._currentPrompt = dialog.prompt;
return this._currentPrompt;
});
this._prompter.connect('new-prompt', Lang.bind(this,
function() {
let dialog = this._enabled ? new KeyringDialog()
: new KeyringDummyDialog();
this._currentPrompt = dialog.prompt;
return this._currentPrompt;
}));
this._dbusId = null;
this._registered = false;
this._enabled = false;
this._currentPrompt = null;
},
enable() {
enable: function() {
if (!this._registered) {
this._prompter.register(Gio.DBus.session);
this._dbusId = Gio.DBus.session.own_name('org.gnome.keyring.SystemPrompter',
@@ -299,7 +302,7 @@ var KeyringPrompter = new Lang.Class({
this._enabled = true;
},
disable() {
disable: function() {
this._enabled = false;
if (this._prompter.prompting)

View File

@@ -25,7 +25,7 @@ var NetworkSecretDialog = new Lang.Class({
Name: 'NetworkSecretDialog',
Extends: ModalDialog.ModalDialog,
_init(agent, requestId, connection, settingName, hints, contentOverride) {
_init: function(agent, requestId, connection, settingName, hints, contentOverride) {
this.parent({ styleClass: 'prompt-dialog' });
this._agent = agent;
@@ -82,15 +82,15 @@ var NetworkSecretDialog = new Lang.Class({
initialFocusSet = true;
}
secret.entry.clutter_text.connect('activate', this._onOk.bind(this));
secret.entry.clutter_text.connect('text-changed', () => {
secret.entry.clutter_text.connect('activate', Lang.bind(this, this._onOk));
secret.entry.clutter_text.connect('text-changed', Lang.bind(this, function() {
secret.value = secret.entry.get_text();
if (secret.validate)
secret.valid = secret.validate(secret);
else
secret.valid = secret.value.length > 0;
this._updateOkButton();
});
}));
} else
secret.valid = true;
@@ -110,12 +110,12 @@ var NetworkSecretDialog = new Lang.Class({
contentBox.messageBox.add(secretTable);
this._okButton = { label: _("Connect"),
action: this._onOk.bind(this),
action: Lang.bind(this, this._onOk),
default: true
};
this.setButtons([{ label: _("Cancel"),
action: this.cancel.bind(this),
action: Lang.bind(this, this.cancel),
key: Clutter.KEY_Escape,
},
this._okButton]);
@@ -123,7 +123,7 @@ var NetworkSecretDialog = new Lang.Class({
this._updateOkButton();
},
_updateOkButton() {
_updateOkButton: function() {
let valid = true;
for (let i = 0; i < this._content.secrets.length; i++) {
let secret = this._content.secrets[i];
@@ -134,7 +134,7 @@ var NetworkSecretDialog = new Lang.Class({
this._okButton.button.can_focus = valid;
},
_onOk() {
_onOk: function() {
let valid = true;
for (let i = 0; i < this._content.secrets.length; i++) {
let secret = this._content.secrets[i];
@@ -150,12 +150,12 @@ var NetworkSecretDialog = new Lang.Class({
// do nothing if not valid
},
cancel() {
cancel: function() {
this._agent.respond(this._requestId, Shell.NetworkAgentResponse.USER_CANCELED);
this.close(global.get_current_time());
},
_validateWpaPsk(secret) {
_validateWpaPsk: function(secret) {
let value = secret.value;
if (value.length == 64) {
// must be composed of hexadecimal digits only
@@ -171,7 +171,7 @@ var NetworkSecretDialog = new Lang.Class({
return (value.length >= 8 && value.length <= 63);
},
_validateStaticWep(secret) {
_validateStaticWep: function(secret) {
let value = secret.value;
if (secret.wep_key_type == NM.WepKeyType.KEY) {
if (value.length == 10 || value.length == 26) {
@@ -196,7 +196,7 @@ var NetworkSecretDialog = new Lang.Class({
return true;
},
_getWirelessSecrets(secrets, wirelessSetting) {
_getWirelessSecrets: function(secrets, wirelessSetting) {
let wirelessSecuritySetting = this._connection.get_setting_wireless_security();
switch (wirelessSecuritySetting.key_mgmt) {
// First the easy ones
@@ -227,7 +227,7 @@ var NetworkSecretDialog = new Lang.Class({
}
},
_get8021xSecrets(secrets) {
_get8021xSecrets: function(secrets) {
let ieee8021xSetting = this._connection.get_setting_802_1x();
let phase2method;
@@ -256,7 +256,7 @@ var NetworkSecretDialog = new Lang.Class({
}
},
_getPPPoESecrets(secrets) {
_getPPPoESecrets: function(secrets) {
let pppoeSetting = this._connection.get_setting_pppoe();
secrets.push({ label: _("Username: "), key: 'username',
value: pppoeSetting.username || '', password: false });
@@ -266,7 +266,7 @@ var NetworkSecretDialog = new Lang.Class({
value: pppoeSetting.password || '', password: true });
},
_getMobileSecrets(secrets, connectionType) {
_getMobileSecrets: function(secrets, connectionType) {
let setting;
if (connectionType == 'bluetooth')
setting = this._connection.get_setting_cdma() || this._connection.get_setting_gsm();
@@ -276,7 +276,7 @@ var NetworkSecretDialog = new Lang.Class({
value: setting.value || '', password: true });
},
_getContent() {
_getContent: function() {
let connectionSetting = this._connection.get_setting_connection();
let connectionType = connectionSetting.get_connection_type();
let wirelessSetting;
@@ -332,7 +332,7 @@ var NetworkSecretDialog = new Lang.Class({
var VPNRequestHandler = new Lang.Class({
Name: 'VPNRequestHandler',
_init(agent, requestId, authHelper, serviceType, connection, hints, flags) {
_init: function(agent, requestId, authHelper, serviceType, connection, hints, flags) {
this._agent = agent;
this._requestId = requestId;
this._connection = connection;
@@ -384,7 +384,7 @@ var VPNRequestHandler = new Lang.Class({
this._readStdoutOldStyle();
this._childWatch = GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid,
this._vpnChildFinished.bind(this));
Lang.bind(this, this._vpnChildFinished));
this._writeConnection();
} catch(e) {
@@ -394,7 +394,7 @@ var VPNRequestHandler = new Lang.Class({
}
},
cancel(respond) {
cancel: function(respond) {
if (respond)
this._agent.respond(this._requestId, Shell.NetworkAgentResponse.USER_CANCELED);
@@ -410,7 +410,7 @@ var VPNRequestHandler = new Lang.Class({
this.destroy();
},
destroy() {
destroy: function() {
if (this._destroyed)
return;
@@ -424,7 +424,7 @@ var VPNRequestHandler = new Lang.Class({
this._destroyed = true;
},
_vpnChildFinished(pid, status, requestObj) {
_vpnChildFinished: function(pid, status, requestObj) {
this._childWatch = 0;
if (this._newStylePlugin) {
// For new style plugin, all work is done in the async reading functions
@@ -445,7 +445,7 @@ var VPNRequestHandler = new Lang.Class({
this.destroy();
},
_vpnChildProcessLineOldStyle(line) {
_vpnChildProcessLineOldStyle: function(line) {
if (this._previousLine != undefined) {
// Two consecutive newlines mean that the child should be closed
// (the actual newlines are eaten by Gio.DataInputStream)
@@ -463,8 +463,8 @@ var VPNRequestHandler = new Lang.Class({
}
},
_readStdoutOldStyle() {
this._dataStdout.read_line_async(GLib.PRIORITY_DEFAULT, null, (stream, result) => {
_readStdoutOldStyle: function() {
this._dataStdout.read_line_async(GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(stream, result) {
let [line, len] = this._dataStdout.read_line_finish_utf8(result);
if (line == null) {
@@ -477,11 +477,11 @@ var VPNRequestHandler = new Lang.Class({
// try to read more!
this._readStdoutOldStyle();
});
}));
},
_readStdoutNewStyle() {
this._dataStdout.fill_async(-1, GLib.PRIORITY_DEFAULT, null, (stream, result) => {
_readStdoutNewStyle: function() {
this._dataStdout.fill_async(-1, GLib.PRIORITY_DEFAULT, null, Lang.bind(this, function(stream, result) {
let cnt = this._dataStdout.fill_finish(result);
if (cnt == 0) {
@@ -495,10 +495,10 @@ var VPNRequestHandler = new Lang.Class({
// Try to read more
this._dataStdout.set_buffer_size(2 * this._dataStdout.get_buffer_size());
this._readStdoutNewStyle();
});
}));
},
_showNewStyleDialog() {
_showNewStyleDialog: function() {
let keyfile = new GLib.KeyFile();
let data;
let contentOverride;
@@ -558,18 +558,18 @@ var VPNRequestHandler = new Lang.Class({
}
},
_writeConnection() {
_writeConnection: function() {
let vpnSetting = this._connection.get_setting_vpn();
try {
vpnSetting.foreach_data_item((key, value) => {
vpnSetting.foreach_data_item(Lang.bind(this, function(key, value) {
this._stdin.write('DATA_KEY=' + key + '\n', null);
this._stdin.write('DATA_VAL=' + (value || '') + '\n\n', null);
});
vpnSetting.foreach_secret((key, value) => {
}));
vpnSetting.foreach_secret(Lang.bind(this, function(key, value) {
this._stdin.write('SECRET_KEY=' + key + '\n', null);
this._stdin.write('SECRET_VAL=' + (value || '') + '\n\n', null);
});
}));
this._stdin.write('DONE\n\n', null);
} catch(e) {
logError(e, 'internal error while writing connection to helper');
@@ -584,7 +584,7 @@ Signals.addSignalMethods(VPNRequestHandler.prototype);
var NetworkAgent = new Lang.Class({
Name: 'NetworkAgent',
_init() {
_init: function() {
this._native = new Shell.NetworkAgent({ identifier: 'org.gnome.Shell.NetworkAgent',
capabilities: NM.SecretAgentCapabilities.VPN_HINTS,
auto_register: false
@@ -602,8 +602,8 @@ var NetworkAgent = new Lang.Class({
log('Failed to create monitor for VPN plugin dir: ' + e.message);
}
this._native.connect('new-request', this._newRequest.bind(this));
this._native.connect('cancel-request', this._cancelRequest.bind(this));
this._native.connect('new-request', Lang.bind(this, this._newRequest));
this._native.connect('cancel-request', Lang.bind(this, this._cancelRequest));
try {
this._native.init(null);
} catch(e) {
@@ -612,7 +612,7 @@ var NetworkAgent = new Lang.Class({
}
},
enable() {
enable: function() {
if (!this._native)
return;
@@ -621,7 +621,7 @@ var NetworkAgent = new Lang.Class({
this._native.register_async(null, null);
},
disable() {
disable: function() {
let requestId;
for (requestId in this._dialogs)
@@ -644,7 +644,7 @@ var NetworkAgent = new Lang.Class({
this._native.unregister_async(null, null);
},
_showNotification(requestId, connection, settingName, hints, flags) {
_showNotification: function(requestId, connection, settingName, hints, flags) {
let source = new MessageTray.Source(_("Network Manager"), 'network-transmit-receive');
source.policy = new MessageTray.NotificationApplicationPolicy('gnome-network-panel');
@@ -688,44 +688,44 @@ var NetworkAgent = new Lang.Class({
let notification = new MessageTray.Notification(source, title, body);
notification.connect('activated', () => {
notification.connect('activated', Lang.bind(this, function() {
notification.answered = true;
this._handleRequest(requestId, connection, settingName, hints, flags);
});
}));
this._notifications[requestId] = notification;
notification.connect('destroy', () => {
notification.connect('destroy', Lang.bind(this, function() {
if (!notification.answered)
this._native.respond(requestId, Shell.NetworkAgentResponse.USER_CANCELED);
delete this._notifications[requestId];
});
}));
Main.messageTray.add(source);
source.notify(notification);
},
_newRequest(agent, requestId, connection, settingName, hints, flags) {
_newRequest: function(agent, requestId, connection, settingName, hints, flags) {
if (!(flags & NM.SecretAgentGetSecretsFlags.USER_REQUESTED))
this._showNotification(requestId, connection, settingName, hints, flags);
else
this._handleRequest(requestId, connection, settingName, hints, flags);
},
_handleRequest(requestId, connection, settingName, hints, flags) {
_handleRequest: function(requestId, connection, settingName, hints, flags) {
if (settingName == 'vpn') {
this._vpnRequest(requestId, connection, hints, flags);
return;
}
let dialog = new NetworkSecretDialog(this._native, requestId, connection, settingName, hints);
dialog.connect('destroy', () => {
dialog.connect('destroy', Lang.bind(this, function() {
delete this._dialogs[requestId];
});
}));
this._dialogs[requestId] = dialog;
dialog.open(global.get_current_time());
},
_cancelRequest(agent, requestId) {
_cancelRequest: function(agent, requestId) {
if (this._dialogs[requestId]) {
this._dialogs[requestId].close(global.get_current_time());
this._dialogs[requestId].destroy();
@@ -736,7 +736,7 @@ var NetworkAgent = new Lang.Class({
}
},
_vpnRequest(requestId, connection, hints, flags) {
_vpnRequest: function(requestId, connection, hints, flags) {
let vpnSetting = connection.get_setting_vpn();
let serviceType = vpnSetting.service_type;
@@ -752,13 +752,13 @@ var NetworkAgent = new Lang.Class({
}
let vpnRequest = new VPNRequestHandler(this._native, requestId, binary, serviceType, connection, hints, flags);
vpnRequest.connect('destroy', () => {
vpnRequest.connect('destroy', Lang.bind(this, function() {
delete this._vpnRequests[requestId];
});
}));
this._vpnRequests[requestId] = vpnRequest;
},
_buildVPNServiceCache() {
_buildVPNServiceCache: function() {
if (this._vpnCacheBuilt)
return;

View File

@@ -31,7 +31,7 @@ var AuthenticationDialog = new Lang.Class({
Name: 'AuthenticationDialog',
Extends: ModalDialog.ModalDialog,
_init(actionId, body, cookie, userNames) {
_init: function(actionId, body, cookie, userNames) {
this.parent({ styleClass: 'prompt-dialog' });
this.actionId = actionId;
@@ -60,9 +60,9 @@ var AuthenticationDialog = new Lang.Class({
this._user = AccountsService.UserManager.get_default().get_user(userName);
let userRealName = this._user.get_real_name()
this._userLoadedId = this._user.connect('notify::is_loaded',
this._onUserChanged.bind(this));
Lang.bind(this, this._onUserChanged));
this._userChangedId = this._user.connect('changed',
this._onUserChanged.bind(this));
Lang.bind(this, this._onUserChanged));
// Special case 'root'
let userIsRoot = false;
@@ -108,7 +108,7 @@ var AuthenticationDialog = new Lang.Class({
text: "",
can_focus: true});
ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
this._passwordEntry.clutter_text.connect('activate', this._onEntryActivate.bind(this));
this._passwordEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivate));
this._passwordBox.add(this._passwordEntry,
{ expand: true });
@@ -146,10 +146,10 @@ var AuthenticationDialog = new Lang.Class({
this._nullMessageLabel.show();
this._cancelButton = this.addButton({ label: _("Cancel"),
action: this.cancel.bind(this),
action: Lang.bind(this, this.cancel),
key: Clutter.Escape });
this._okButton = this.addButton({ label: _("Authenticate"),
action: this._onAuthenticateButtonPressed.bind(this),
action: Lang.bind(this, this._onAuthenticateButtonPressed),
default: true });
this._doneEmitted = false;
@@ -158,7 +158,7 @@ var AuthenticationDialog = new Lang.Class({
this._cookie = cookie;
},
_setWorking(working) {
_setWorking: function(working) {
Tweener.removeTweens(this._workSpinner.actor);
if (working) {
this._workSpinner.play();
@@ -174,7 +174,7 @@ var AuthenticationDialog = new Lang.Class({
time: WORK_SPINNER_ANIMATION_TIME,
transition: 'linear',
onCompleteScope: this,
onComplete() {
onComplete: function() {
if (this._workSpinner)
this._workSpinner.stop();
}
@@ -182,18 +182,18 @@ var AuthenticationDialog = new Lang.Class({
}
},
performAuthentication() {
performAuthentication: function() {
this.destroySession();
this._session = new PolkitAgent.Session({ identity: this._identityToAuth,
cookie: this._cookie });
this._session.connect('completed', this._onSessionCompleted.bind(this));
this._session.connect('request', this._onSessionRequest.bind(this));
this._session.connect('show-error', this._onSessionShowError.bind(this));
this._session.connect('show-info', this._onSessionShowInfo.bind(this));
this._session.connect('completed', Lang.bind(this, this._onSessionCompleted));
this._session.connect('request', Lang.bind(this, this._onSessionRequest));
this._session.connect('show-error', Lang.bind(this, this._onSessionShowError));
this._session.connect('show-info', Lang.bind(this, this._onSessionShowInfo));
this._session.initiate();
},
_ensureOpen() {
_ensureOpen: function() {
// NOTE: ModalDialog.open() is safe to call if the dialog is
// already open - it just returns true without side-effects
if (!this.open(global.get_current_time())) {
@@ -215,14 +215,14 @@ var AuthenticationDialog = new Lang.Class({
}
},
_emitDone(dismissed) {
_emitDone: function(dismissed) {
if (!this._doneEmitted) {
this._doneEmitted = true;
this.emit('done', dismissed);
}
},
_updateSensitivity(sensitive) {
_updateSensitivity: function(sensitive) {
this._passwordEntry.reactive = sensitive;
this._passwordEntry.clutter_text.editable = sensitive;
@@ -231,7 +231,7 @@ var AuthenticationDialog = new Lang.Class({
this._setWorking(!sensitive);
},
_onEntryActivate() {
_onEntryActivate: function() {
let response = this._passwordEntry.get_text();
this._updateSensitivity(false);
this._session.response(response);
@@ -242,11 +242,11 @@ var AuthenticationDialog = new Lang.Class({
this._nullMessageLabel.show();
},
_onAuthenticateButtonPressed() {
_onAuthenticateButtonPressed: function() {
this._onEntryActivate();
},
_onSessionCompleted(session, gainedAuthorization) {
_onSessionCompleted: function(session, gainedAuthorization) {
if (this._completed || this._doneEmitted)
return;
@@ -278,7 +278,7 @@ var AuthenticationDialog = new Lang.Class({
}
},
_onSessionRequest(session, request, echo_on) {
_onSessionRequest: function(session, request, echo_on) {
// Cheap localization trick
if (request == 'Password:' || request == 'Password: ')
this._passwordLabel.set_text(_("Password:"));
@@ -297,7 +297,7 @@ var AuthenticationDialog = new Lang.Class({
this._ensureOpen();
},
_onSessionShowError(session, text) {
_onSessionShowError: function(session, text) {
this._passwordEntry.set_text('');
this._errorMessageLabel.set_text(text);
this._errorMessageLabel.show();
@@ -306,7 +306,7 @@ var AuthenticationDialog = new Lang.Class({
this._ensureOpen();
},
_onSessionShowInfo(session, text) {
_onSessionShowInfo: function(session, text) {
this._passwordEntry.set_text('');
this._infoMessageLabel.set_text(text);
this._infoMessageLabel.show();
@@ -315,7 +315,7 @@ var AuthenticationDialog = new Lang.Class({
this._ensureOpen();
},
destroySession() {
destroySession: function() {
if (this._session) {
if (!this._completed)
this._session.cancel();
@@ -324,14 +324,14 @@ var AuthenticationDialog = new Lang.Class({
}
},
_onUserChanged() {
_onUserChanged: function() {
if (this._user.is_loaded && this._userAvatar) {
this._userAvatar.update();
this._userAvatar.actor.show();
}
},
cancel() {
cancel: function() {
this._wasDismissed = true;
this.close(global.get_current_time());
this._emitDone(true);
@@ -342,15 +342,15 @@ Signals.addSignalMethods(AuthenticationDialog.prototype);
var AuthenticationAgent = new Lang.Class({
Name: 'AuthenticationAgent',
_init() {
_init: function() {
this._currentDialog = null;
this._handle = null;
this._native = new Shell.PolkitAuthenticationAgent();
this._native.connect('initiate', this._onInitiate.bind(this));
this._native.connect('cancel', this._onCancel.bind(this));
this._native.connect('initiate', Lang.bind(this, this._onInitiate));
this._native.connect('cancel', Lang.bind(this, this._onCancel));
},
enable() {
enable: function() {
try {
this._native.register();
} catch(e) {
@@ -358,7 +358,7 @@ var AuthenticationAgent = new Lang.Class({
}
},
disable() {
disable: function() {
try {
this._native.unregister();
} catch(e) {
@@ -366,7 +366,7 @@ var AuthenticationAgent = new Lang.Class({
}
},
_onInitiate(nativeAgent, actionId, message, iconName, cookie, userNames) {
_onInitiate: function(nativeAgent, actionId, message, iconName, cookie, userNames) {
this._currentDialog = new AuthenticationDialog(actionId, message, cookie, userNames);
// We actually don't want to open the dialog until we know for
@@ -379,19 +379,19 @@ var AuthenticationAgent = new Lang.Class({
// See https://bugzilla.gnome.org/show_bug.cgi?id=643062 for more
// discussion.
this._currentDialog.connect('done', this._onDialogDone.bind(this));
this._currentDialog.connect('done', Lang.bind(this, this._onDialogDone));
this._currentDialog.performAuthentication();
},
_onCancel(nativeAgent) {
_onCancel: function(nativeAgent) {
this._completeRequest(false);
},
_onDialogDone(dialog, dismissed) {
_onDialogDone: function(dialog, dismissed) {
this._completeRequest(dismissed);
},
_completeRequest(dismissed) {
_completeRequest: function(dismissed) {
this._currentDialog.close();
this._currentDialog.destroySession();
this._currentDialog = null;

View File

@@ -47,7 +47,7 @@ var NotificationDirection = {
RECEIVED: 'chat-received'
};
var N_ = s => s;
var N_ = function(s) { return s; };
function makeMessageFromTpMessage(tpMessage, direction) {
let [text, flags] = tpMessage.to_text();
@@ -82,7 +82,7 @@ function makeMessageFromTplEvent(event) {
var TelepathyComponent = new Lang.Class({
Name: 'TelepathyComponent',
_init() {
_init: function() {
this._client = null;
if (!HAVE_TP)
@@ -91,7 +91,7 @@ var TelepathyComponent = new Lang.Class({
this._client = new TelepathyClient();
},
enable() {
enable: function() {
if (!this._client)
return;
@@ -105,7 +105,7 @@ var TelepathyComponent = new Lang.Class({
this._client.account_manager.prepare_async(null, null);
},
disable() {
disable: function() {
if (!this._client)
return;
@@ -117,7 +117,7 @@ var TelepathyClient = HAVE_TP ? new Lang.Class({
Name: 'TelepathyClient',
Extends: Tp.BaseClient,
_init() {
_init: function() {
// channel path -> ChatSource
this._chatSources = {};
this._chatState = Tp.ChannelChatState.ACTIVE;
@@ -157,10 +157,10 @@ var TelepathyClient = HAVE_TP ? new Lang.Class({
// Allow other clients (such as Empathy) to pre-empt our channels if
// needed
this.set_delegated_channels_callback(
this._delegatedChannelsCb.bind(this));
Lang.bind(this, this._delegatedChannelsCb));
},
vfunc_observe_channels(account, conn, channels,
vfunc_observe_channels: function(account, conn, channels,
dispatchOp, requests, context) {
let len = channels.length;
for (let i = 0; i < len; i++) {
@@ -181,25 +181,26 @@ var TelepathyClient = HAVE_TP ? new Lang.Class({
context.accept();
},
_createChatSource(account, conn, channel, contact) {
_createChatSource: function(account, conn, channel, contact) {
if (this._chatSources[channel.get_object_path()])
return;
let source = new ChatSource(account, conn, channel, contact, this);
this._chatSources[channel.get_object_path()] = source;
source.connect('destroy', () => {
delete this._chatSources[channel.get_object_path()];
});
source.connect('destroy', Lang.bind(this,
function() {
delete this._chatSources[channel.get_object_path()];
}));
},
vfunc_handle_channels(account, conn, channels, requests,
vfunc_handle_channels: function(account, conn, channels, requests,
user_action_time, context) {
this._handlingChannels(account, conn, channels, true);
context.accept();
},
_handlingChannels(account, conn, channels, notify) {
_handlingChannels: function(account, conn, channels, notify) {
let len = channels.length;
for (let i = 0; i < len; i++) {
let channel = channels[i];
@@ -233,7 +234,7 @@ var TelepathyClient = HAVE_TP ? new Lang.Class({
}
},
vfunc_add_dispatch_operation(account, conn, channels,
vfunc_add_dispatch_operation: function(account, conn, channels,
dispatchOp, context) {
let channel = channels[0];
let chanType = channel.get_channel_type();
@@ -251,7 +252,7 @@ var TelepathyClient = HAVE_TP ? new Lang.Class({
message: 'Unsupported channel type' }));
},
_approveTextChannel(account, conn, channel, dispatchOp, context) {
_approveTextChannel: function(account, conn, channel, dispatchOp, context) {
let [targetHandle, targetHandleType] = channel.get_handle();
if (targetHandleType != Tp.HandleType.CONTACT) {
@@ -261,19 +262,19 @@ var TelepathyClient = HAVE_TP ? new Lang.Class({
}
// Approve private text channels right away as we are going to handle it
dispatchOp.claim_with_async(this, (dispatchOp, result) => {
dispatchOp.claim_with_async(this, Lang.bind(this, function(dispatchOp, result) {
try {
dispatchOp.claim_with_finish(result);
this._handlingChannels(account, conn, [channel], false);
} catch (err) {
log('Failed to Claim channel: ' + err);
}
});
}));
context.accept();
},
_delegatedChannelsCb(client, channels) {
_delegatedChannelsCb: function(client, channels) {
// Nothing to do as we don't make a distinction between observed and
// handled channels.
},
@@ -283,7 +284,7 @@ var ChatSource = new Lang.Class({
Name: 'ChatSource',
Extends: MessageTray.Source,
_init(account, conn, channel, contact, client) {
_init: function(account, conn, channel, contact, client) {
this._account = account;
this._contact = contact;
this._client = client;
@@ -295,19 +296,19 @@ var ChatSource = new Lang.Class({
this._conn = conn;
this._channel = channel;
this._closedId = this._channel.connect('invalidated', this._channelClosed.bind(this));
this._closedId = this._channel.connect('invalidated', Lang.bind(this, this._channelClosed));
this._notifyTimeoutId = 0;
this._presence = contact.get_presence_type();
this._sentId = this._channel.connect('message-sent', this._messageSent.bind(this));
this._receivedId = this._channel.connect('message-received', this._messageReceived.bind(this));
this._pendingId = this._channel.connect('pending-message-removed', this._pendingRemoved.bind(this));
this._sentId = this._channel.connect('message-sent', Lang.bind(this, this._messageSent));
this._receivedId = this._channel.connect('message-received', Lang.bind(this, this._messageReceived));
this._pendingId = this._channel.connect('pending-message-removed', Lang.bind(this, this._pendingRemoved));
this._notifyAliasId = this._contact.connect('notify::alias', this._updateAlias.bind(this));
this._notifyAvatarId = this._contact.connect('notify::avatar-file', this._updateAvatarIcon.bind(this));
this._presenceChangedId = this._contact.connect('presence-changed', this._presenceChanged.bind(this));
this._notifyAliasId = this._contact.connect('notify::alias', Lang.bind(this, this._updateAlias));
this._notifyAvatarId = this._contact.connect('notify::avatar-file', Lang.bind(this, this._updateAvatarIcon));
this._presenceChangedId = this._contact.connect('presence-changed', Lang.bind(this, this._presenceChanged));
// Add ourselves as a source.
Main.messageTray.add(this);
@@ -315,42 +316,45 @@ var ChatSource = new Lang.Class({
this._getLogMessages();
},
_ensureNotification() {
_ensureNotification: function() {
if (this._notification)
return;
this._notification = new ChatNotification(this);
this._notification.connect('activated', this.open.bind(this));
this._notification.connect('updated', () => {
if (this._banner && this._banner.expanded)
this._ackMessages();
});
this._notification.connect('destroy', () => {
this._notification = null;
});
this._notification.connect('activated', Lang.bind(this, this.open));
this._notification.connect('updated', Lang.bind(this,
function() {
if (this._banner && this._banner.expanded)
this._ackMessages();
}));
this._notification.connect('destroy', Lang.bind(this,
function() {
this._notification = null;
}));
this.pushNotification(this._notification);
},
_createPolicy() {
_createPolicy: function() {
if (this._account.protocol_name == 'irc')
return new MessageTray.NotificationApplicationPolicy('org.gnome.Polari');
return new MessageTray.NotificationApplicationPolicy('empathy');
},
createBanner() {
createBanner: function() {
this._banner = new ChatNotificationBanner(this._notification);
// We ack messages when the user expands the new notification
let id = this._banner.connect('expanded', this._ackMessages.bind(this));
this._banner.actor.connect('destroy', () => {
this._banner.disconnect(id);
this._banner = null;
});
let id = this._banner.connect('expanded', Lang.bind(this, this._ackMessages));
this._banner.actor.connect('destroy', Lang.bind(this,
function() {
this._banner.disconnect(id);
this._banner = null;
}));
return this._banner;
},
_updateAlias() {
_updateAlias: function() {
let oldAlias = this.title;
let newAlias = this._contact.get_alias();
@@ -362,7 +366,7 @@ var ChatSource = new Lang.Class({
this._notification.appendAliasChange(oldAlias, newAlias);
},
getIcon() {
getIcon: function() {
let file = this._contact.get_avatar_file();
if (file) {
return new Gio.FileIcon({ file: file });
@@ -371,7 +375,7 @@ var ChatSource = new Lang.Class({
}
},
getSecondaryIcon() {
getSecondaryIcon: function() {
let iconName;
let presenceType = this._contact.get_presence_type();
@@ -400,7 +404,7 @@ var ChatSource = new Lang.Class({
return new Gio.ThemedIcon({ name: iconName });
},
_updateAvatarIcon() {
_updateAvatarIcon: function() {
this.iconUpdated();
if (this._notifiction)
this._notification.update(this._notification.title,
@@ -408,7 +412,7 @@ var ChatSource = new Lang.Class({
{ gicon: this.getIcon() });
},
open() {
open: function() {
Main.overview.hide();
Main.panel.closeCalendar();
@@ -433,16 +437,16 @@ var ChatSource = new Lang.Class({
}
},
_getLogMessages() {
_getLogMessages: function() {
let logManager = Tpl.LogManager.dup_singleton();
let entity = Tpl.Entity.new_from_tp_contact(this._contact, Tpl.EntityType.CONTACT);
logManager.get_filtered_events_async(this._account, entity,
Tpl.EventTypeMask.TEXT, SCROLLBACK_HISTORY_LINES,
null, this._displayPendingMessages.bind(this));
null, Lang.bind(this, this._displayPendingMessages));
},
_displayPendingMessages(logManager, result) {
_displayPendingMessages: function(logManager, result) {
let [success, events] = logManager.get_filtered_events_finish(result);
let logMessages = events.map(makeMessageFromTplEvent);
@@ -495,12 +499,12 @@ var ChatSource = new Lang.Class({
this.notify();
},
destroy(reason) {
destroy: function(reason) {
if (this._client.is_handling_channel(this._channel)) {
this._ackMessages();
// The chat box has been destroyed so it can't
// handle the channel any more.
this._channel.close_async((channel, result) => {
this._channel.close_async(function(channel, result) {
channel.close_finish(result);
});
} else {
@@ -530,7 +534,7 @@ var ChatSource = new Lang.Class({
this.parent(reason);
},
_channelClosed() {
_channelClosed: function() {
this.destroy(MessageTray.NotificationDestroyedReason.SOURCE_CLOSED);
},
@@ -547,7 +551,7 @@ var ChatSource = new Lang.Class({
return this.count > 0;
},
_messageReceived(channel, message) {
_messageReceived: function(channel, message) {
if (message.get_message_type() == Tp.ChannelTextMessageType.DELIVERY_REPORT)
return;
@@ -563,11 +567,11 @@ var ChatSource = new Lang.Class({
if (this._notifyTimeoutId != 0)
Mainloop.source_remove(this._notifyTimeoutId);
this._notifyTimeoutId = Mainloop.timeout_add(500,
this._notifyTimeout.bind(this));
Lang.bind(this, this._notifyTimeout));
GLib.Source.set_name_by_id(this._notifyTimeoutId, '[gnome-shell] this._notifyTimeout');
},
_notifyTimeout() {
_notifyTimeout: function() {
if (this._pendingMessages.length != 0)
this.notify();
@@ -578,17 +582,17 @@ var ChatSource = new Lang.Class({
// This is called for both messages we send from
// our client and other clients as well.
_messageSent(channel, message, flags, token) {
_messageSent: function(channel, message, flags, token) {
this._ensureNotification();
message = makeMessageFromTpMessage(message, NotificationDirection.SENT);
this._notification.appendMessage(message);
},
notify() {
notify: function() {
this.parent(this._notification);
},
respond(text) {
respond: function(text) {
let type;
if (text.slice(0, 4) == '/me ') {
type = Tp.ChannelTextMessageType.ACTION;
@@ -598,12 +602,12 @@ var ChatSource = new Lang.Class({
}
let msg = Tp.ClientMessage.new_text(type, text);
this._channel.send_message_async(msg, 0, (src, result) => {
this._channel.send_message_async(msg, 0, Lang.bind(this, function (src, result) {
this._channel.send_message_finish(result);
});
}));
},
setChatState(state) {
setChatState: function(state) {
// We don't want to send COMPOSING every time a letter is typed into
// the entry. We send the state only when it changes. Telepathy/Empathy
// might change it behind our back if the user is using both
@@ -616,14 +620,14 @@ var ChatSource = new Lang.Class({
}
},
_presenceChanged(contact, presence, status, message) {
_presenceChanged: function (contact, presence, status, message) {
if (this._notification)
this._notification.update(this._notification.title,
this._notification.bannerBodyText,
{ secondaryGIcon: this.getSecondaryIcon() });
},
_pendingRemoved(channel, message) {
_pendingRemoved: function(channel, message) {
let idx = this._pendingMessages.indexOf(message);
if (idx >= 0) {
@@ -636,7 +640,7 @@ var ChatSource = new Lang.Class({
this._banner.hide();
},
_ackMessages() {
_ackMessages: function() {
// Don't clear our messages here, tp-glib will send a
// 'pending-message-removed' for each one.
this._channel.ack_all_pending_messages_async(null);
@@ -647,7 +651,7 @@ var ChatNotification = new Lang.Class({
Name: 'ChatNotification',
Extends: MessageTray.Notification,
_init(source) {
_init: function(source) {
this.parent(source, source.title, null,
{ secondaryGIcon: source.getSecondaryIcon() });
this.setUrgency(MessageTray.Urgency.HIGH);
@@ -657,7 +661,7 @@ var ChatNotification = new Lang.Class({
this._timestampTimeoutId = 0;
},
destroy(reason) {
destroy: function(reason) {
if (this._timestampTimeoutId)
Mainloop.source_remove(this._timestampTimeoutId);
this._timestampTimeoutId = 0;
@@ -677,7 +681,7 @@ var ChatNotification = new Lang.Class({
* will be added, regardless of the difference since the
* last timestamp
*/
appendMessage(message, noTimestamp) {
appendMessage: function(message, noTimestamp) {
let messageBody = GLib.markup_escape_text(message.text, -1);
let styles = [message.direction];
@@ -702,7 +706,7 @@ var ChatNotification = new Lang.Class({
noTimestamp: noTimestamp });
},
_filterMessages() {
_filterMessages: function() {
if (this.messages.length < 1)
return;
@@ -718,7 +722,7 @@ var ChatNotification = new Lang.Class({
let maxLength = (lastMessageTime < currentTime - SCROLLBACK_RECENT_TIME) ?
SCROLLBACK_IDLE_LENGTH : SCROLLBACK_RECENT_LENGTH;
let filteredHistory = this.messages.filter(item => item.realMessage);
let filteredHistory = this.messages.filter(function(item) { return item.realMessage });
if (filteredHistory.length > maxLength) {
let lastMessageToKeep = filteredHistory[maxLength];
let expired = this.messages.splice(this.messages.indexOf(lastMessageToKeep));
@@ -737,7 +741,7 @@ var ChatNotification = new Lang.Class({
* timestamp: The timestamp of the message.
* noTimestamp: suppress timestamp signal?
*/
_append(props) {
_append: function(props) {
let currentTime = (Date.now() / 1000);
props = Params.parse(props, { body: null,
group: null,
@@ -767,7 +771,7 @@ var ChatNotification = new Lang.Class({
// from the timestamp of the message.
this._timestampTimeoutId = Mainloop.timeout_add_seconds(
SCROLLBACK_IMMEDIATE_TIME - (currentTime - timestamp),
this.appendTimestamp.bind(this));
Lang.bind(this, this.appendTimestamp));
GLib.Source.set_name_by_id(this._timestampTimeoutId, '[gnome-shell] this.appendTimestamp');
}
}
@@ -775,7 +779,7 @@ var ChatNotification = new Lang.Class({
this._filterMessages();
},
appendTimestamp() {
appendTimestamp: function() {
this._timestampTimeoutId = 0;
this.messages[0].showTimestamp = true;
@@ -786,7 +790,7 @@ var ChatNotification = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
appendAliasChange(oldAlias, newAlias) {
appendAliasChange: function(oldAlias, newAlias) {
oldAlias = GLib.markup_escape_text(oldAlias, -1);
newAlias = GLib.markup_escape_text(newAlias, -1);
@@ -806,7 +810,7 @@ var ChatLineBox = new Lang.Class({
Name: 'ChatLineBox',
Extends: St.BoxLayout,
vfunc_get_preferred_height(forWidth) {
vfunc_get_preferred_height: function(forWidth) {
let [, natHeight] = this.parent(forWidth);
return [natHeight, natHeight];
}
@@ -816,23 +820,23 @@ var ChatNotificationBanner = new Lang.Class({
Name: 'ChatNotificationBanner',
Extends: MessageTray.NotificationBanner,
_init(notification) {
_init: function(notification) {
this.parent(notification);
this._responseEntry = new St.Entry({ style_class: 'chat-response',
x_expand: true,
can_focus: true });
this._responseEntry.clutter_text.connect('activate', this._onEntryActivated.bind(this));
this._responseEntry.clutter_text.connect('text-changed', this._onEntryChanged.bind(this));
this._responseEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivated));
this._responseEntry.clutter_text.connect('text-changed', Lang.bind(this, this._onEntryChanged));
this.setActionArea(this._responseEntry);
this._responseEntry.clutter_text.connect('key-focus-in', () => {
this._responseEntry.clutter_text.connect('key-focus-in', Lang.bind(this, function() {
this.focused = true;
});
this._responseEntry.clutter_text.connect('key-focus-out', () => {
}));
this._responseEntry.clutter_text.connect('key-focus-out', Lang.bind(this, function() {
this.focused = false;
this.emit('unfocused');
});
}));
this._scrollArea = new St.ScrollView({ style_class: 'chat-scrollview vfade',
vscrollbar_policy: Gtk.PolicyType.AUTOMATIC,
@@ -851,11 +855,11 @@ var ChatNotificationBanner = new Lang.Class({
// force a scroll to the bottom if things change while we were at the
// bottom
this._oldMaxScrollValue = this._scrollArea.vscroll.adjustment.value;
this._scrollArea.vscroll.adjustment.connect('changed', adjustment => {
this._scrollArea.vscroll.adjustment.connect('changed', Lang.bind(this, function(adjustment) {
if (adjustment.value == this._oldMaxScrollValue)
this.scrollTo(St.Side.BOTTOM);
this._oldMaxScrollValue = Math.max(adjustment.lower, adjustment.upper - adjustment.page_size);
});
}));
this._inputHistory = new History.HistoryManager({ entry: this._responseEntry.clutter_text });
@@ -864,32 +868,32 @@ var ChatNotificationBanner = new Lang.Class({
this._messageActors = new Map();
this._messageAddedId = this.notification.connect('message-added',
(n, message) => {
Lang.bind(this, function(n, message) {
this._addMessage(message);
});
}));
this._messageRemovedId = this.notification.connect('message-removed',
(n, message) => {
Lang.bind(this, function(n, message) {
let actor = this._messageActors.get(message);
if (this._messageActors.delete(message))
actor.destroy();
});
}));
this._timestampChangedId = this.notification.connect('timestamp-changed',
(n, message) => {
Lang.bind(this, function(n, message) {
this._updateTimestamp(message);
});
}));
for (let i = this.notification.messages.length - 1; i >= 0; i--)
this._addMessage(this.notification.messages[i]);
},
_onDestroy() {
_onDestroy: function() {
this.parent();
this.notification.disconnect(this._messageAddedId);
this.notification.disconnect(this._messageRemovedId);
this.notification.disconnect(this._timestampChangedId);
},
scrollTo(side) {
scrollTo: function(side) {
let adjustment = this._scrollArea.vscroll.adjustment;
if (side == St.Side.TOP)
adjustment.value = adjustment.lower;
@@ -897,11 +901,11 @@ var ChatNotificationBanner = new Lang.Class({
adjustment.value = adjustment.upper;
},
hide() {
hide: function() {
this.emit('done-displaying');
},
_addMessage(message) {
_addMessage: function(message) {
let highlighter = new MessageList.URLHighlighter(message.body, true, true);
let body = highlighter.actor;
@@ -923,7 +927,7 @@ var ChatNotificationBanner = new Lang.Class({
this._updateTimestamp(message);
},
_updateTimestamp(message) {
_updateTimestamp: function(message) {
let actor = this._messageActors.get(message);
if (!actor)
return;
@@ -944,7 +948,7 @@ var ChatNotificationBanner = new Lang.Class({
}
},
_onEntryActivated() {
_onEntryActivated: function() {
let text = this._responseEntry.get_text();
if (text == '')
return;
@@ -957,7 +961,7 @@ var ChatNotificationBanner = new Lang.Class({
this.notification.source.respond(text);
},
_composingStopTimeout() {
_composingStopTimeout: function() {
this._composingTimeoutId = 0;
this.notification.source.setChatState(Tp.ChannelChatState.PAUSED);
@@ -965,7 +969,7 @@ var ChatNotificationBanner = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
_onEntryChanged() {
_onEntryChanged: function() {
let text = this._responseEntry.get_text();
// If we're typing, we want to send COMPOSING.
@@ -984,7 +988,7 @@ var ChatNotificationBanner = new Lang.Class({
this._composingTimeoutId = Mainloop.timeout_add_seconds(
COMPOSING_STOP_TIMEOUT,
this._composingStopTimeout.bind(this));
Lang.bind(this, this._composingStopTimeout));
GLib.Source.set_name_by_id(this._composingTimeoutId, '[gnome-shell] this._composingStopTimeout');
} else {
this.notification.source.setChatState(Tp.ChannelChatState.ACTIVE);

View File

@@ -24,14 +24,14 @@ var SortGroup = {
var CtrlAltTabManager = new Lang.Class({
Name: 'CtrlAltTabManager',
_init() {
_init: function() {
this._items = [];
this.addGroup(global.window_group, _("Windows"),
'focus-windows-symbolic', { sortGroup: SortGroup.TOP,
focusCallback: this._focusWindows.bind(this) });
focusCallback: Lang.bind(this, this._focusWindows) });
},
addGroup(root, name, icon, params) {
addGroup: function(root, name, icon, params) {
let item = Params.parse(params, { sortGroup: SortGroup.MIDDLE,
proxy: root,
focusCallback: null });
@@ -41,12 +41,12 @@ var CtrlAltTabManager = new Lang.Class({
item.iconName = icon;
this._items.push(item);
root.connect('destroy', () => { this.removeGroup(root); });
root.connect('destroy', Lang.bind(this, function() { this.removeGroup(root); }));
if (root instanceof St.Widget)
global.focus_manager.add_group(root);
},
removeGroup(root) {
removeGroup: function(root) {
if (root instanceof St.Widget)
global.focus_manager.remove_group(root);
for (let i = 0; i < this._items.length; i++) {
@@ -57,7 +57,7 @@ var CtrlAltTabManager = new Lang.Class({
}
},
focusGroup(item, timestamp) {
focusGroup: function(item, timestamp) {
if (item.focusCallback)
item.focusCallback(timestamp);
else
@@ -68,7 +68,7 @@ var CtrlAltTabManager = new Lang.Class({
// and everything else in between, sorted by X coordinate, so that
// they will have the same left-to-right ordering in the
// Ctrl-Alt-Tab dialog as they do onscreen.
_sortItems(a, b) {
_sortItems: function(a, b) {
if (a.sortGroup != b.sortGroup)
return a.sortGroup - b.sortGroup;
@@ -79,9 +79,9 @@ var CtrlAltTabManager = new Lang.Class({
return ax - bx;
},
popup(backward, binding, mask) {
popup: function(backward, binding, mask) {
// Start with the set of focus groups that are currently mapped
let items = this._items.filter(item => item.proxy.mapped);
let items = this._items.filter(function (item) { return item.proxy.mapped; });
// And add the windows metacity would show in its Ctrl-Alt-Tab list
if (Main.sessionMode.hasWindows && !Main.overview.visible) {
@@ -105,9 +105,10 @@ var CtrlAltTabManager = new Lang.Class({
items.push({ name: windows[i].title,
proxy: windows[i].get_compositor_private(),
focusCallback: function(timestamp) {
Main.activateWindow(this, timestamp);
}.bind(windows[i]),
focusCallback: Lang.bind(windows[i],
function(timestamp) {
Main.activateWindow(this, timestamp);
}),
iconActor: icon,
iconName: iconName,
sortGroup: SortGroup.MIDDLE });
@@ -117,20 +118,20 @@ var CtrlAltTabManager = new Lang.Class({
if (!items.length)
return;
items.sort(this._sortItems.bind(this));
items.sort(Lang.bind(this, this._sortItems));
if (!this._popup) {
this._popup = new CtrlAltTabPopup(items);
this._popup.show(backward, binding, mask);
this._popup.actor.connect('destroy',
() => {
Lang.bind(this, function() {
this._popup = null;
});
}));
}
},
_focusWindows(timestamp) {
_focusWindows: function(timestamp) {
global.screen.focus_default_window(timestamp);
}
});
@@ -139,13 +140,13 @@ var CtrlAltTabPopup = new Lang.Class({
Name: 'CtrlAltTabPopup',
Extends: SwitcherPopup.SwitcherPopup,
_init(items) {
_init: function(items) {
this.parent(items);
this._switcherList = new CtrlAltTabSwitcher(this._items);
},
_keyPressHandler(keysym, action) {
_keyPressHandler: function(keysym, action) {
if (action == Meta.KeyBindingAction.SWITCH_PANELS)
this._select(this._next());
else if (action == Meta.KeyBindingAction.SWITCH_PANELS_BACKWARD)
@@ -160,7 +161,7 @@ var CtrlAltTabPopup = new Lang.Class({
return Clutter.EVENT_STOP;
},
_finish(time) {
_finish : function(time) {
this.parent(time);
Main.ctrlAltTabManager.focusGroup(this._items[this._selectedIndex], time);
},
@@ -170,14 +171,14 @@ var CtrlAltTabSwitcher = new Lang.Class({
Name: 'CtrlAltTabSwitcher',
Extends: SwitcherPopup.SwitcherList,
_init(items) {
_init : function(items) {
this.parent(true);
for (let i = 0; i < items.length; i++)
this._addIcon(items[i]);
},
_addIcon(item) {
_addIcon : function(item) {
let box = new St.BoxLayout({ style_class: 'alt-tab-app',
vertical: true });

View File

@@ -37,7 +37,7 @@ var DashItemContainer = new Lang.Class({
Name: 'DashItemContainer',
Extends: St.Widget,
_init() {
_init: function() {
this.parent({ style_class: 'dash-item-container' });
this._labelText = "";
@@ -56,7 +56,7 @@ var DashItemContainer = new Lang.Class({
});
},
vfunc_allocate(box, flags) {
vfunc_allocate: function(box, flags) {
this.set_allocation(box, flags);
if (this.child == null)
@@ -80,7 +80,7 @@ var DashItemContainer = new Lang.Class({
this.child.allocate(childBox, flags);
},
vfunc_get_preferred_height(forWidth) {
vfunc_get_preferred_height: function(forWidth) {
let themeNode = this.get_theme_node();
if (this.child == null)
@@ -92,7 +92,7 @@ var DashItemContainer = new Lang.Class({
natHeight * this.child.scale_y);
},
vfunc_get_preferred_width(forHeight) {
vfunc_get_preferred_width: function(forHeight) {
let themeNode = this.get_theme_node();
if (this.child == null)
@@ -104,7 +104,7 @@ var DashItemContainer = new Lang.Class({
natWidth * this.child.scale_y);
},
showLabel() {
showLabel: function() {
if (!this._labelText)
return;
@@ -138,23 +138,23 @@ var DashItemContainer = new Lang.Class({
});
},
setLabelText(text) {
setLabelText: function(text) {
this._labelText = text;
this.child.accessible_name = text;
},
hideLabel() {
hideLabel: function () {
Tweener.addTween(this.label,
{ opacity: 0,
time: DASH_ITEM_LABEL_HIDE_TIME,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this.label.hide();
}
})
});
},
setChild(actor) {
setChild: function(actor) {
if (this.child == actor)
return;
@@ -168,7 +168,7 @@ var DashItemContainer = new Lang.Class({
this.child.set_opacity(this._childOpacity);
},
show(animate) {
show: function(animate) {
if (this.child == null)
return;
@@ -181,7 +181,7 @@ var DashItemContainer = new Lang.Class({
});
},
animateOutAndDestroy() {
animateOutAndDestroy: function() {
this.label.hide();
if (this.child == null) {
@@ -195,9 +195,9 @@ var DashItemContainer = new Lang.Class({
childOpacity: 0,
time: DASH_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this.destroy();
}
})
});
},
@@ -235,7 +235,7 @@ var ShowAppsIcon = new Lang.Class({
Name: 'ShowAppsIcon',
Extends: DashItemContainer,
_init() {
_init: function() {
this.parent();
this.toggleButton = new St.Button({ style_class: 'show-apps',
@@ -246,7 +246,7 @@ var ShowAppsIcon = new Lang.Class({
this.icon = new IconGrid.BaseIcon(_("Show Applications"),
{ setSizeManually: true,
showLabel: false,
createIcon: this._createIcon.bind(this) });
createIcon: Lang.bind(this, this._createIcon) });
this.toggleButton.add_actor(this.icon.actor);
this.toggleButton._delegate = this;
@@ -254,7 +254,7 @@ var ShowAppsIcon = new Lang.Class({
this.setDragApp(null);
},
_createIcon(size) {
_createIcon: function(size) {
this._iconActor = new St.Icon({ icon_name: 'view-app-grid-symbolic',
icon_size: size,
style_class: 'show-apps-icon',
@@ -262,7 +262,7 @@ var ShowAppsIcon = new Lang.Class({
return this._iconActor;
},
_canRemoveApp(app) {
_canRemoveApp: function(app) {
if (app == null)
return false;
@@ -274,7 +274,7 @@ var ShowAppsIcon = new Lang.Class({
return isFavorite;
},
setDragApp(app) {
setDragApp: function(app) {
let canRemove = this._canRemoveApp(app);
this.toggleButton.set_hover(canRemove);
@@ -287,24 +287,25 @@ var ShowAppsIcon = new Lang.Class({
this.setLabelText(_("Show Applications"));
},
handleDragOver(source, actor, x, y, time) {
handleDragOver: function(source, actor, x, y, time) {
if (!this._canRemoveApp(getAppFromSource(source)))
return DND.DragMotionResult.NO_DROP;
return DND.DragMotionResult.MOVE_DROP;
},
acceptDrop(source, actor, x, y, time) {
acceptDrop: function(source, actor, x, y, time) {
let app = getAppFromSource(source);
if (!this._canRemoveApp(app))
return false;
let id = app.get_id();
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
AppFavorites.getAppFavorites().removeFavorite(id);
return false;
});
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
function () {
AppFavorites.getAppFavorites().removeFavorite(id);
return false;
}));
return true;
}
@@ -314,7 +315,7 @@ var DragPlaceholderItem = new Lang.Class({
Name: 'DragPlaceholderItem',
Extends: DashItemContainer,
_init() {
_init: function() {
this.parent();
this.setChild(new St.Bin({ style_class: 'placeholder' }));
}
@@ -324,7 +325,7 @@ var EmptyDropTargetItem = new Lang.Class({
Name: 'EmptyDropTargetItem',
Extends: DashItemContainer,
_init() {
_init: function() {
this.parent();
this.setChild(new St.Bin({ style_class: 'empty-dash-drop-target' }));
}
@@ -334,14 +335,14 @@ var DashActor = new Lang.Class({
Name: 'DashActor',
Extends: St.Widget,
_init() {
_init: function() {
let layout = new Clutter.BoxLayout({ orientation: Clutter.Orientation.VERTICAL });
this.parent({ name: 'dash',
layout_manager: layout,
clip_to_allocation: true });
},
vfunc_allocate(box, flags) {
vfunc_allocate: function(box, flags) {
let contentBox = this.get_theme_node().get_content_box(box);
let availWidth = contentBox.x2 - contentBox.x1;
@@ -362,7 +363,7 @@ var DashActor = new Lang.Class({
showAppsButton.allocate(childBox, flags);
},
vfunc_get_preferred_height(forWidth) {
vfunc_get_preferred_height: function(forWidth) {
// We want to request the natural height of all our children
// as our natural height, so we chain up to StWidget (which
// then calls BoxLayout), but we only request the showApps
@@ -385,7 +386,7 @@ const baseIconSizes = [ 16, 22, 24, 32, 48, 64 ];
var Dash = new Lang.Class({
Name: 'Dash',
_init() {
_init : function() {
this._maxHeight = -1;
this.iconSize = 64;
this._shownInitially = false;
@@ -414,39 +415,40 @@ var Dash = new Lang.Class({
this._container.add_actor(this._showAppsIcon);
this.actor = new St.Bin({ child: this._container });
this.actor.connect('notify::height', () => {
if (this._maxHeight != this.actor.height)
this._queueRedisplay();
this._maxHeight = this.actor.height;
});
this.actor.connect('notify::height', Lang.bind(this,
function() {
if (this._maxHeight != this.actor.height)
this._queueRedisplay();
this._maxHeight = this.actor.height;
}));
this._workId = Main.initializeDeferredWork(this._box, this._redisplay.bind(this));
this._workId = Main.initializeDeferredWork(this._box, Lang.bind(this, this._redisplay));
this._appSystem = Shell.AppSystem.get_default();
this._appSystem.connect('installed-changed', () => {
this._appSystem.connect('installed-changed', Lang.bind(this, function() {
AppFavorites.getAppFavorites().reload();
this._queueRedisplay();
});
AppFavorites.getAppFavorites().connect('changed', this._queueRedisplay.bind(this));
this._appSystem.connect('app-state-changed', this._queueRedisplay.bind(this));
}));
AppFavorites.getAppFavorites().connect('changed', Lang.bind(this, this._queueRedisplay));
this._appSystem.connect('app-state-changed', Lang.bind(this, this._queueRedisplay));
Main.overview.connect('item-drag-begin',
this._onDragBegin.bind(this));
Lang.bind(this, this._onDragBegin));
Main.overview.connect('item-drag-end',
this._onDragEnd.bind(this));
Lang.bind(this, this._onDragEnd));
Main.overview.connect('item-drag-cancelled',
this._onDragCancelled.bind(this));
Lang.bind(this, this._onDragCancelled));
// Translators: this is the name of the dock/favorites area on
// the left of the overview
Main.ctrlAltTabManager.addGroup(this.actor, _("Dash"), 'user-bookmarks-symbolic');
},
_onDragBegin() {
_onDragBegin: function() {
this._dragCancelled = false;
this._dragMonitor = {
dragMotion: this._onDragMotion.bind(this)
dragMotion: Lang.bind(this, this._onDragMotion)
};
DND.addDragMonitor(this._dragMonitor);
@@ -457,26 +459,26 @@ var Dash = new Lang.Class({
}
},
_onDragCancelled() {
_onDragCancelled: function() {
this._dragCancelled = true;
this._endDrag();
},
_onDragEnd() {
_onDragEnd: function() {
if (this._dragCancelled)
return;
this._endDrag();
},
_endDrag() {
_endDrag: function() {
this._clearDragPlaceholder();
this._clearEmptyDropTarget();
this._showAppsIcon.setDragApp(null);
DND.removeDragMonitor(this._dragMonitor);
},
_onDragMotion(dragEvent) {
_onDragMotion: function(dragEvent) {
let app = getAppFromSource(dragEvent.source);
if (app == null)
return DND.DragMotionResult.CONTINUE;
@@ -495,56 +497,56 @@ var Dash = new Lang.Class({
return DND.DragMotionResult.CONTINUE;
},
_appIdListToHash(apps) {
_appIdListToHash: function(apps) {
let ids = {};
for (let i = 0; i < apps.length; i++)
ids[apps[i].get_id()] = apps[i];
return ids;
},
_queueRedisplay() {
_queueRedisplay: function () {
Main.queueDeferredWork(this._workId);
},
_hookUpLabel(item, appIcon) {
item.child.connect('notify::hover', () => {
_hookUpLabel: function(item, appIcon) {
item.child.connect('notify::hover', Lang.bind(this, function() {
this._syncLabel(item, appIcon);
});
}));
let id = Main.overview.connect('hiding', () => {
let id = Main.overview.connect('hiding', Lang.bind(this, function() {
this._labelShowing = false;
item.hideLabel();
});
item.child.connect('destroy', () => {
}));
item.child.connect('destroy', function() {
Main.overview.disconnect(id);
});
if (appIcon) {
appIcon.connect('sync-tooltip', () => {
appIcon.connect('sync-tooltip', Lang.bind(this, function() {
this._syncLabel(item, appIcon);
});
}));
}
},
_createAppItem(app) {
_createAppItem: function(app) {
let appIcon = new AppDisplay.AppIcon(app,
{ setSizeManually: true,
showLabel: false });
if (appIcon._draggable) {
appIcon._draggable.connect('drag-begin',
() => {
Lang.bind(this, function() {
appIcon.actor.opacity = 50;
});
}));
appIcon._draggable.connect('drag-end',
() => {
Lang.bind(this, function() {
appIcon.actor.opacity = 255;
});
}));
}
appIcon.connect('menu-state-changed',
(appIcon, opened) => {
Lang.bind(this, function(appIcon, opened) {
this._itemMenuStateChanged(item, opened);
});
}));
let item = new DashItemContainer();
item.setChild(appIcon.actor);
@@ -560,7 +562,7 @@ var Dash = new Lang.Class({
return item;
},
_itemMenuStateChanged(item, opened) {
_itemMenuStateChanged: function(item, opened) {
// When the menu closes, it calls sync_hover, which means
// that the notify::hover handler does everything we need to.
if (opened) {
@@ -573,19 +575,19 @@ var Dash = new Lang.Class({
}
},
_syncLabel(item, appIcon) {
_syncLabel: function (item, appIcon) {
let shouldShow = appIcon ? appIcon.shouldShowTooltip() : item.child.get_hover();
if (shouldShow) {
if (this._showLabelTimeoutId == 0) {
let timeout = this._labelShowing ? 0 : DASH_ITEM_HOVER_TIMEOUT;
this._showLabelTimeoutId = Mainloop.timeout_add(timeout,
() => {
Lang.bind(this, function() {
this._labelShowing = true;
item.showLabel();
this._showLabelTimeoutId = 0;
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._showLabelTimeoutId, '[gnome-shell] item.showLabel');
if (this._resetHoverTimeoutId > 0) {
Mainloop.source_remove(this._resetHoverTimeoutId);
@@ -599,22 +601,22 @@ var Dash = new Lang.Class({
item.hideLabel();
if (this._labelShowing) {
this._resetHoverTimeoutId = Mainloop.timeout_add(DASH_ITEM_HOVER_TIMEOUT,
() => {
Lang.bind(this, function() {
this._labelShowing = false;
this._resetHoverTimeoutId = 0;
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._resetHoverTimeoutId, '[gnome-shell] this._labelShowing');
}
}
},
_adjustIconSize() {
_adjustIconSize: function() {
// For the icon size, we only consider children which are "proper"
// icons (i.e. ignoring drag placeholders) and which are not
// animating out (which means they will be destroyed at the end of
// the animation)
let iconChildren = this._box.get_children().filter(actor => {
let iconChildren = this._box.get_children().filter(function(actor) {
return actor.child &&
actor.child._delegate &&
actor.child._delegate.icon &&
@@ -653,7 +655,9 @@ var Dash = new Lang.Class({
let availSize = availHeight / iconChildren.length;
let iconSizes = baseIconSizes.map(s => s * scaleFactor);
let iconSizes = baseIconSizes.map(function(s) {
return s * scaleFactor;
});
let newIconSize = baseIconSizes[0];
for (let i = 0; i < iconSizes.length; i++) {
@@ -699,18 +703,20 @@ var Dash = new Lang.Class({
}
},
_redisplay() {
_redisplay: function () {
let favorites = AppFavorites.getAppFavorites().getFavoriteMap();
let running = this._appSystem.get_running();
let children = this._box.get_children().filter(actor => {
let children = this._box.get_children().filter(function(actor) {
return actor.child &&
actor.child._delegate &&
actor.child._delegate.app;
});
// Apps currently in the dash
let oldApps = children.map(actor => actor.child._delegate.app);
let oldApps = children.map(function(actor) {
return actor.child._delegate.app;
});
// Apps supposed to be in the dash
let newApps = [];
@@ -776,7 +782,7 @@ var Dash = new Lang.Class({
let nextApp = newApps.length > newIndex + 1 ? newApps[newIndex + 1]
: null;
let insertHere = nextApp && nextApp == oldApp;
let alreadyRemoved = removedActors.reduce((result, actor) => {
let alreadyRemoved = removedActors.reduce(function(result, actor) {
let removedApp = actor.child._delegate.app;
return result || removedApp == newApp;
}, false);
@@ -828,26 +834,27 @@ var Dash = new Lang.Class({
this._box.queue_relayout();
},
_clearDragPlaceholder() {
_clearDragPlaceholder: function() {
if (this._dragPlaceholder) {
this._animatingPlaceholdersCount++;
this._dragPlaceholder.animateOutAndDestroy();
this._dragPlaceholder.connect('destroy', () => {
this._animatingPlaceholdersCount--;
});
this._dragPlaceholder.connect('destroy',
Lang.bind(this, function() {
this._animatingPlaceholdersCount--;
}));
this._dragPlaceholder = null;
}
this._dragPlaceholderPos = -1;
},
_clearEmptyDropTarget() {
_clearEmptyDropTarget: function() {
if (this._emptyDropTarget) {
this._emptyDropTarget.animateOutAndDestroy();
this._emptyDropTarget = null;
}
},
handleDragOver(source, actor, x, y, time) {
handleDragOver : function(source, actor, x, y, time) {
let app = getAppFromSource(source);
// Don't allow favoriting of transient apps
@@ -925,7 +932,7 @@ var Dash = new Lang.Class({
},
// Draggable target interface
acceptDrop(source, actor, x, y, time) {
acceptDrop : function(source, actor, x, y, time) {
let app = getAppFromSource(source);
// Don't allow favoriting of transient apps
@@ -961,14 +968,15 @@ var Dash = new Lang.Class({
if (!this._dragPlaceholder)
return true;
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
let appFavorites = AppFavorites.getAppFavorites();
if (srcIsFavorite)
appFavorites.moveFavoriteToPos(id, favPos);
else
appFavorites.addFavoriteAtPos(id, favPos);
return false;
});
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this,
function () {
let appFavorites = AppFavorites.getAppFavorites();
if (srcIsFavorite)
appFavorites.moveFavoriteToPos(id, favPos);
else
appFavorites.addFavoriteAtPos(id, favPos);
return false;
}));
return true;
}

View File

@@ -34,7 +34,7 @@ function _isToday(date) {
var TodayButton = new Lang.Class({
Name: 'TodayButton',
_init(calendar) {
_init: function(calendar) {
// Having the ability to go to the current date if the user is already
// on the current date can be confusing. So don't make the button reactive
// until the selected date changes.
@@ -43,9 +43,10 @@ var TodayButton = new Lang.Class({
can_focus: true,
reactive: false
});
this.actor.connect('clicked', () => {
this._calendar.setDate(new Date(), false);
});
this.actor.connect('clicked', Lang.bind(this,
function() {
this._calendar.setDate(new Date(), false);
}));
let hbox = new St.BoxLayout({ vertical: true });
this.actor.add_actor(hbox);
@@ -58,14 +59,15 @@ var TodayButton = new Lang.Class({
hbox.add_actor(this._dateLabel);
this._calendar = calendar;
this._calendar.connect('selected-date-changed', (calendar, date) => {
// Make the button reactive only if the selected date is not the
// current date.
this.actor.reactive = !_isToday(date)
});
this._calendar.connect('selected-date-changed', Lang.bind(this,
function(calendar, date) {
// Make the button reactive only if the selected date is not the
// current date.
this.actor.reactive = !_isToday(date)
}));
},
setDate(date) {
setDate: function(date) {
this._dayLabel.set_text(date.toLocaleFormat('%A'));
/* Translators: This is the date format to use when the calendar popup is
@@ -86,7 +88,7 @@ var TodayButton = new Lang.Class({
var WorldClocksSection = new Lang.Class({
Name: 'WorldClocksSection',
_init() {
_init: function() {
this._clock = new GnomeDesktop.WallClock();
this._clockNotifyId = 0;
@@ -95,12 +97,13 @@ var WorldClocksSection = new Lang.Class({
this.actor = new St.Button({ style_class: 'world-clocks-button',
x_fill: true,
can_focus: true });
this.actor.connect('clicked', () => {
this._clockAppMon.activateApp();
this.actor.connect('clicked', Lang.bind(this,
function() {
this._clockAppMon.activateApp();
Main.overview.hide();
Main.panel.closeCalendar();
});
Main.overview.hide();
Main.panel.closeCalendar();
}));
let layout = new Clutter.GridLayout({ orientation: Clutter.Orientation.VERTICAL });
this._grid = new St.Widget({ style_class: 'world-clocks-grid',
@@ -112,17 +115,17 @@ var WorldClocksSection = new Lang.Class({
this._clockAppMon = new Util.AppSettingsMonitor('org.gnome.clocks.desktop',
'org.gnome.clocks');
this._clockAppMon.connect('available-changed',
this._sync.bind(this));
Lang.bind(this, this._sync));
this._clockAppMon.watchSetting('world-clocks',
this._clocksChanged.bind(this));
Lang.bind(this, this._clocksChanged));
this._sync();
},
_sync() {
_sync: function() {
this.actor.visible = this._clockAppMon.available;
},
_clocksChanged(settings) {
_clocksChanged: function(settings) {
this._grid.destroy_all_children();
this._locations = [];
@@ -136,7 +139,7 @@ var WorldClocksSection = new Lang.Class({
this._locations.push({ location: l });
}
this._locations.sort((a, b) => {
this._locations.sort(function(a, b) {
return a.location.get_timezone().get_offset() -
b.location.get_timezone().get_offset();
});
@@ -176,7 +179,7 @@ var WorldClocksSection = new Lang.Class({
if (this._grid.get_n_children() > 1) {
if (!this._clockNotifyId)
this._clockNotifyId =
this._clock.connect('notify::clock', this._updateLabels.bind(this));
this._clock.connect('notify::clock', Lang.bind(this, this._updateLabels));
this._updateLabels();
} else {
if (this._clockNotifyId)
@@ -185,7 +188,7 @@ var WorldClocksSection = new Lang.Class({
}
},
_updateLabels() {
_updateLabels: function() {
for (let i = 0; i < this._locations.length; i++) {
let l = this._locations[i];
let tz = GLib.TimeZone.new(l.location.get_timezone().get_tzid());
@@ -198,7 +201,7 @@ var WorldClocksSection = new Lang.Class({
var WeatherSection = new Lang.Class({
Name: 'WeatherSection',
_init() {
_init: function() {
this._weatherClient = new Weather.WeatherClient();
this.actor = new St.Button({ style_class: 'weather-button',
@@ -230,11 +233,11 @@ var WeatherSection = new Lang.Class({
this._conditionsLabel.clutter_text.line_wrap = true;
box.add_child(this._conditionsLabel);
this._weatherClient.connect('changed', this._sync.bind(this));
this._weatherClient.connect('changed', Lang.bind(this, this._sync));
this._sync();
},
_getSummary(info, capitalize=false) {
_getSummary: function(info, capitalize=false) {
let options = capitalize ? GWeather.FormatOptions.SENTENCE_CAPITALIZATION
: GWeather.FormatOptions.NO_CAPITALIZATION;
@@ -248,7 +251,7 @@ var WeatherSection = new Lang.Class({
return GWeather.Sky.to_string_full(sky, options);
},
_sameSummary(info1, info2) {
_sameSummary: function(info1, info2) {
let [ok1, phenom1, qualifier1] = info1.get_value_conditions();
let [ok2, phenom2, qualifier2] = info2.get_value_conditions();
if (ok1 || ok2)
@@ -259,7 +262,7 @@ var WeatherSection = new Lang.Class({
return sky1 == sky2;
},
_getSummaryText() {
_getSummaryText: function() {
let info = this._weatherClient.info;
let forecasts = info.get_forecast_list();
if (forecasts.length == 0) // No forecasts, just current conditions
@@ -307,7 +310,7 @@ var WeatherSection = new Lang.Class({
return String.prototype.format.apply(fmt, summaries);
},
_getLabelText() {
_getLabelText: function() {
if (!this._weatherClient.hasLocation)
return _("Select a location…");
@@ -326,7 +329,7 @@ var WeatherSection = new Lang.Class({
return _("Weather information is currently unavailable");
},
_sync() {
_sync: function() {
this.actor.visible = this._weatherClient.available;
if (!this.actor.visible)
@@ -339,7 +342,7 @@ var WeatherSection = new Lang.Class({
var MessagesIndicator = new Lang.Class({
Name: 'MessagesIndicator',
_init() {
_init: function() {
this.actor = new St.Icon({ icon_name: 'message-indicator-symbolic',
icon_size: 16,
visible: false, y_expand: true,
@@ -347,28 +350,31 @@ var MessagesIndicator = new Lang.Class({
this._sources = [];
Main.messageTray.connect('source-added', this._onSourceAdded.bind(this));
Main.messageTray.connect('source-removed', this._onSourceRemoved.bind(this));
Main.messageTray.connect('queue-changed', this._updateCount.bind(this));
Main.messageTray.connect('source-added', Lang.bind(this, this._onSourceAdded));
Main.messageTray.connect('source-removed', Lang.bind(this, this._onSourceRemoved));
Main.messageTray.connect('queue-changed', Lang.bind(this, this._updateCount));
let sources = Main.messageTray.getSources();
sources.forEach(source => { this._onSourceAdded(null, source); });
sources.forEach(Lang.bind(this, function(source) { this._onSourceAdded(null, source); }));
},
_onSourceAdded(tray, source) {
source.connect('count-updated', this._updateCount.bind(this));
_onSourceAdded: function(tray, source) {
source.connect('count-updated', Lang.bind(this, this._updateCount));
this._sources.push(source);
this._updateCount();
},
_onSourceRemoved(tray, source) {
_onSourceRemoved: function(tray, source) {
this._sources.splice(this._sources.indexOf(source), 1);
this._updateCount();
},
_updateCount() {
_updateCount: function() {
let count = 0;
this._sources.forEach(source => { count += source.unseenCount; });
this._sources.forEach(Lang.bind(this,
function(source) {
count += source.unseenCount;
}));
count -= Main.messageTray.queueCount;
this.actor.visible = (count > 0);
@@ -379,19 +385,19 @@ var IndicatorPad = new Lang.Class({
Name: 'IndicatorPad',
Extends: St.Widget,
_init(actor) {
_init: function(actor) {
this._source = actor;
this._source.connect('notify::visible', () => { this.queue_relayout(); });
this.parent();
},
vfunc_get_preferred_width(container, forHeight) {
vfunc_get_preferred_width: function(container, forHeight) {
if (this._source.visible)
return this._source.get_preferred_width(forHeight);
return [0, 0];
},
vfunc_get_preferred_height(container, forWidth) {
vfunc_get_preferred_height: function(container, forWidth) {
if (this._source.visible)
return this._source.get_preferred_height(forWidth);
return [0, 0];
@@ -402,7 +408,7 @@ var FreezableBinLayout = new Lang.Class({
Name: 'FreezableBinLayout',
Extends: Clutter.BinLayout,
_init() {
_init: function() {
this.parent();
this._frozen = false;
@@ -419,19 +425,19 @@ var FreezableBinLayout = new Lang.Class({
this.layout_changed();
},
vfunc_get_preferred_width(container, forHeight) {
vfunc_get_preferred_width: function(container, forHeight) {
if (!this._frozen || this._savedWidth.some(isNaN))
return this.parent(container, forHeight);
return this._savedWidth;
},
vfunc_get_preferred_height(container, forWidth) {
vfunc_get_preferred_height: function(container, forWidth) {
if (!this._frozen || this._savedHeight.some(isNaN))
return this.parent(container, forWidth);
return this._savedHeight;
},
vfunc_allocate(container, allocation, flags) {
vfunc_allocate: function(container, allocation, flags) {
this.parent(container, allocation, flags);
let [width, height] = allocation.get_size();
@@ -444,12 +450,12 @@ var CalendarColumnLayout = new Lang.Class({
Name: 'CalendarColumnLayout',
Extends: Clutter.BoxLayout,
_init(actor) {
_init: function(actor) {
this.parent({ orientation: Clutter.Orientation.VERTICAL });
this._calActor = actor;
},
vfunc_get_preferred_width(container, forHeight) {
vfunc_get_preferred_width: function(container, forHeight) {
if (!this._calActor || this._calActor.get_parent() != container)
return this.parent(container, forHeight);
return this._calActor.get_preferred_width(forHeight);
@@ -460,7 +466,7 @@ var DateMenuButton = new Lang.Class({
Name: 'DateMenuButton',
Extends: PanelMenu.Button,
_init() {
_init: function() {
let item;
let hbox;
let vbox;
@@ -494,12 +500,12 @@ var DateMenuButton = new Lang.Class({
this._calendar = new Calendar.Calendar();
this._calendar.connect('selected-date-changed',
(calendar, date) => {
Lang.bind(this, function(calendar, date) {
layout.frozen = !_isToday(date);
this._messageList.setDate(date);
});
}));
this.menu.connect('open-state-changed', (menu, isOpen) => {
this.menu.connect('open-state-changed', Lang.bind(this, function(menu, isOpen) {
// Whenever the menu is opened, select today
if (isOpen) {
let now = new Date();
@@ -507,7 +513,7 @@ var DateMenuButton = new Lang.Class({
this._date.setDate(now);
this._messageList.setDate(now);
}
});
}));
// Fill up the first column
this._messageList = new Calendar.CalendarMessageList();
@@ -545,17 +551,17 @@ var DateMenuButton = new Lang.Class({
this._clock = new GnomeDesktop.WallClock();
this._clock.bind_property('clock', this._clockDisplay, 'text', GObject.BindingFlags.SYNC_CREATE);
this._clock.connect('notify::timezone', this._updateTimeZone.bind(this));
this._clock.connect('notify::timezone', Lang.bind(this, this._updateTimeZone));
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
this._sessionUpdated();
},
_getEventSource() {
_getEventSource: function() {
return new Calendar.DBusEventSource();
},
_setEventSource(eventSource) {
_setEventSource: function(eventSource) {
if (this._eventSource)
this._eventSource.destroy();
@@ -565,7 +571,7 @@ var DateMenuButton = new Lang.Class({
this._eventSource = eventSource;
},
_updateTimeZone() {
_updateTimeZone: function() {
// SpiderMonkey caches the time zone so we must explicitly clear it
// before we can update the calendar, see
// https://bugzilla.gnome.org/show_bug.cgi?id=678507
@@ -574,7 +580,7 @@ var DateMenuButton = new Lang.Class({
this._calendar.updateTimeZone();
},
_sessionUpdated() {
_sessionUpdated: function() {
let eventSource;
let showEvents = Main.sessionMode.showCalendarEvents;
if (showEvents) {

View File

@@ -11,9 +11,9 @@ var Dialog = new Lang.Class({
Name: 'Dialog',
Extends: St.Widget,
_init(parentActor, styleClass) {
_init: function (parentActor, styleClass) {
this.parent({ layout_manager: new Clutter.BinLayout() });
this.connect('destroy', this._onDestroy.bind(this));
this.connect('destroy', Lang.bind(this, this._onDestroy));
this._initialKeyFocus = null;
this._initialKeyFocusDestroyId = 0;
@@ -26,11 +26,11 @@ var Dialog = new Lang.Class({
this._dialog.add_style_class_name(styleClass);
this._parentActor = parentActor;
this._eventId = this._parentActor.connect('event', this._modalEventHandler.bind(this));
this._eventId = this._parentActor.connect('event', Lang.bind(this, this._modalEventHandler));
this._parentActor.add_child(this);
},
_createDialog() {
_createDialog: function () {
this._dialog = new St.BoxLayout({ style_class: 'modal-dialog',
x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER,
@@ -56,13 +56,13 @@ var Dialog = new Lang.Class({
y_align: St.Align.START });
},
_onDestroy() {
_onDestroy: function () {
if (this._eventId != 0)
this._parentActor.disconnect(this._eventId);
this._eventId = 0;
},
_modalEventHandler(actor, event) {
_modalEventHandler: function (actor, event) {
if (event.type() == Clutter.EventType.KEY_PRESS) {
this._pressedKey = event.get_key_symbol();
} else if (event.type() == Clutter.EventType.KEY_RELEASE) {
@@ -88,7 +88,7 @@ var Dialog = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_setInitialKeyFocus(actor) {
_setInitialKeyFocus: function(actor) {
if (this._initialKeyFocus)
this._initialKeyFocus.disconnect(this._initialKeyFocusDestroyId);
@@ -104,11 +104,11 @@ var Dialog = new Lang.Class({
return this._initialKeyFocus || this;
},
addContent(actor) {
addContent: function (actor) {
this.contentLayout.add (actor, { expand: true });
},
addButton(buttonInfo) {
addButton: function (buttonInfo) {
let { label, action, key } = buttonInfo;
let isDefault = buttonInfo['default'];
let keys;
@@ -145,7 +145,7 @@ var Dialog = new Lang.Class({
return button;
},
clearButtons() {
clearButtons: function () {
this.buttonLayout.destroy_all_children();
this._buttonKeys = {};
},
@@ -173,7 +173,7 @@ var MessageDialogContent = new Lang.Class({
null)
},
_init(params) {
_init: function(params) {
this._icon = new St.Icon({ y_align: Clutter.ActorAlign.START });
this._title = new St.Label({ style_class: 'headline' });
this._subtitle = new St.Label();
@@ -243,7 +243,7 @@ var MessageDialogContent = new Lang.Class({
this.notify(prop);
},
insertBeforeBody(actor) {
insertBeforeBody: function(actor) {
this.messageBox.insert_child_below(actor, this._body);
}
});

View File

@@ -49,9 +49,10 @@ function _getEventHandlerActor() {
Main.uiGroup.add_actor(eventHandlerActor);
// We connect to 'event' rather than 'captured-event' because the capturing phase doesn't happen
// when you've grabbed the pointer.
eventHandlerActor.connect('event', (actor, event) => {
return currentDraggable._onEvent(actor, event);
});
eventHandlerActor.connect('event',
function(actor, event) {
return currentDraggable._onEvent(actor, event);
});
}
return eventHandlerActor;
}
@@ -71,7 +72,7 @@ function removeDragMonitor(monitor) {
var _Draggable = new Lang.Class({
Name: 'Draggable',
_init(actor, params) {
_init : function(actor, params) {
params = Params.parse(params, { manualMode: false,
restoreOnSuccess: false,
dragActorMaxSize: undefined,
@@ -80,18 +81,18 @@ var _Draggable = new Lang.Class({
this.actor = actor;
if (!params.manualMode) {
this.actor.connect('button-press-event',
this._onButtonPress.bind(this));
Lang.bind(this, this._onButtonPress));
this.actor.connect('touch-event',
this._onTouchEvent.bind(this));
Lang.bind(this, this._onTouchEvent));
}
this.actor.connect('destroy', () => {
this.actor.connect('destroy', Lang.bind(this, function() {
this._actorDestroyed = true;
if (this._dragInProgress && this._dragCancellable)
this._cancelDrag(global.get_current_time());
this.disconnectAll();
});
}));
this._onEventId = null;
this._touchSequence = null;
@@ -107,7 +108,7 @@ var _Draggable = new Lang.Class({
this._eventsGrabbed = false;
},
_onButtonPress(actor, event) {
_onButtonPress : function (actor, event) {
if (event.get_button() != 1)
return Clutter.EVENT_PROPAGATE;
@@ -124,7 +125,7 @@ var _Draggable = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onTouchEvent(actor, event) {
_onTouchEvent: function (actor, event) {
if (event.type() != Clutter.EventType.TOUCH_BEGIN ||
!global.display.is_pointer_emulating_sequence(event.get_event_sequence()))
return Clutter.EVENT_PROPAGATE;
@@ -144,7 +145,7 @@ var _Draggable = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_grabDevice(actor) {
_grabDevice: function(actor) {
let manager = Clutter.DeviceManager.get_default();
let pointer = manager.get_core_device(Clutter.InputDeviceType.POINTER_DEVICE);
@@ -156,7 +157,7 @@ var _Draggable = new Lang.Class({
this._grabbedDevice = pointer;
},
_ungrabDevice() {
_ungrabDevice: function() {
if (this._touchSequence)
this._grabbedDevice.sequence_ungrab (this._touchSequence);
else
@@ -166,13 +167,13 @@ var _Draggable = new Lang.Class({
this._grabbedDevice = null;
},
_grabActor() {
_grabActor: function() {
this._grabDevice(this.actor);
this._onEventId = this.actor.connect('event',
this._onEvent.bind(this));
Lang.bind(this, this._onEvent));
},
_ungrabActor() {
_ungrabActor: function() {
if (!this._onEventId)
return;
@@ -181,7 +182,7 @@ var _Draggable = new Lang.Class({
this._onEventId = null;
},
_grabEvents() {
_grabEvents: function() {
if (!this._eventsGrabbed) {
this._eventsGrabbed = Main.pushModal(_getEventHandlerActor());
if (this._eventsGrabbed)
@@ -189,7 +190,7 @@ var _Draggable = new Lang.Class({
}
},
_ungrabEvents() {
_ungrabEvents: function() {
if (this._eventsGrabbed) {
this._ungrabDevice();
Main.popModal(_getEventHandlerActor());
@@ -197,7 +198,7 @@ var _Draggable = new Lang.Class({
}
},
_onEvent(actor, event) {
_onEvent: function(actor, event) {
// We intercept BUTTON_RELEASE event to know that the button was released in case we
// didn't start the drag, to drop the draggable in case the drag was in progress, and
// to complete the drag and ensure that whatever happens to be under the pointer does
@@ -248,7 +249,7 @@ var _Draggable = new Lang.Class({
* actors for other purposes (for example if you're using
* PopupMenu.ignoreRelease())
*/
fakeRelease() {
fakeRelease: function() {
this._buttonDown = false;
this._ungrabActor();
},
@@ -263,7 +264,7 @@ var _Draggable = new Lang.Class({
* This function is useful to call if you've specified manualMode
* for the draggable.
*/
startDrag(stageX, stageY, time, sequence) {
startDrag: function (stageX, stageY, time, sequence) {
currentDraggable = this;
this._dragInProgress = true;
@@ -370,7 +371,7 @@ var _Draggable = new Lang.Class({
scale_y: scale * origScale,
time: SCALE_ANIMATION_TIME,
transition: 'easeOutQuad',
onUpdate() {
onUpdate: function() {
let currentScale = this._dragActor.scale_x / origScale;
this._dragOffsetX = currentScale * origDragOffsetX;
this._dragOffsetY = currentScale * origDragOffsetY;
@@ -382,7 +383,7 @@ var _Draggable = new Lang.Class({
}
},
_maybeStartDrag(event) {
_maybeStartDrag: function(event) {
let [stageX, stageY] = event.get_coords();
// See if the user has moved the mouse enough to trigger a drag
@@ -396,7 +397,7 @@ var _Draggable = new Lang.Class({
return true;
},
_updateDragHover() {
_updateDragHover : function () {
this._updateHoverId = 0;
let target = this._dragActor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
this._dragX, this._dragY);
@@ -440,16 +441,16 @@ var _Draggable = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
_queueUpdateDragHover() {
_queueUpdateDragHover: function() {
if (this._updateHoverId)
return;
this._updateHoverId = GLib.idle_add(GLib.PRIORITY_DEFAULT,
this._updateDragHover.bind(this));
Lang.bind(this, this._updateDragHover));
GLib.Source.set_name_by_id(this._updateHoverId, '[gnome-shell] this._updateDragHover');
},
_updateDragPosition(event) {
_updateDragPosition : function (event) {
let [stageX, stageY] = event.get_coords();
this._dragX = stageX;
this._dragY = stageY;
@@ -460,7 +461,7 @@ var _Draggable = new Lang.Class({
return true;
},
_dragActorDropped(event) {
_dragActorDropped: function(event) {
let [dropX, dropY] = event.get_coords();
let target = this._dragActor.get_stage().get_actor_at_pos(Clutter.PickMode.ALL,
dropX, dropY);
@@ -523,7 +524,7 @@ var _Draggable = new Lang.Class({
return true;
},
_getRestoreLocation() {
_getRestoreLocation: function() {
let x, y, scale;
if (this._dragActorSource && this._dragActorSource.visible) {
@@ -555,7 +556,7 @@ var _Draggable = new Lang.Class({
return [x, y, scale];
},
_cancelDrag(eventTime) {
_cancelDrag: function(eventTime) {
this.emit('drag-cancelled', eventTime);
this._dragInProgress = false;
let [snapBackX, snapBackY, snapBackScale] = this._getRestoreLocation();
@@ -580,7 +581,7 @@ var _Draggable = new Lang.Class({
});
},
_restoreDragActor(eventTime) {
_restoreDragActor: function(eventTime) {
this._dragInProgress = false;
let [restoreX, restoreY, restoreScale] = this._getRestoreLocation();
@@ -593,14 +594,14 @@ var _Draggable = new Lang.Class({
{ time: REVERT_ANIMATION_TIME });
},
_animateDragEnd(eventTime, params) {
_animateDragEnd: function (eventTime, params) {
this._animationInProgress = true;
// finish animation if the actor gets destroyed
// during it
this._dragActorDestroyId =
this._dragActor.connect('destroy',
this._finishAnimation.bind(this));
Lang.bind(this, this._finishAnimation));
params['opacity'] = this._dragOrigOpacity;
params['transition'] = 'easeOutQuad';
@@ -612,7 +613,7 @@ var _Draggable = new Lang.Class({
Tweener.addTween(this._dragActor, params)
},
_finishAnimation() {
_finishAnimation : function () {
if (!this._animationInProgress)
return
@@ -623,7 +624,7 @@ var _Draggable = new Lang.Class({
global.screen.set_cursor(Meta.Cursor.DEFAULT);
},
_onAnimationComplete(dragActor, eventTime) {
_onAnimationComplete : function (dragActor, eventTime) {
dragActor.disconnect(this._dragActorDestroyId);
this._dragActorDestroyId = 0;
@@ -640,7 +641,7 @@ var _Draggable = new Lang.Class({
this._finishAnimation();
},
_dragComplete() {
_dragComplete: function() {
if (!this._actorDestroyed)
Shell.util_set_hidden_from_pick(this._dragActor, false);

View File

@@ -16,23 +16,25 @@ var EdgeDragAction = new Lang.Class({
Extends: Clutter.GestureAction,
Signals: { 'activated': {} },
_init(side, allowedModes) {
_init : function(side, allowedModes) {
this.parent();
this._side = side;
this._allowedModes = allowedModes;
this.set_n_touch_points(1);
global.display.connect('grab-op-begin', () => { this.cancel(); });
global.display.connect('grab-op-begin', Lang.bind(this, function() {
this.cancel();
}));
},
_getMonitorRect(x, y) {
_getMonitorRect : function (x, y) {
let rect = new Meta.Rectangle({ x: x - 1, y: y - 1, width: 1, height: 1 });
let monitorIndex = global.screen.get_monitor_index_for_rect(rect);
return global.screen.get_monitor_geometry(monitorIndex);
},
vfunc_gesture_prepare(action, actor) {
vfunc_gesture_prepare : function(action, actor) {
if (this.get_n_current_points() == 0)
return false;
@@ -48,7 +50,7 @@ var EdgeDragAction = new Lang.Class({
(this._side == St.Side.BOTTOM && y > monitorRect.y + monitorRect.height - EDGE_THRESHOLD));
},
vfunc_gesture_progress(action, actor) {
vfunc_gesture_progress : function (action, actor) {
let [startX, startY] = this.get_press_coords(0);
let [x, y] = this.get_motion_coords(0);
let offsetX = Math.abs (x - startX);
@@ -68,7 +70,7 @@ var EdgeDragAction = new Lang.Class({
return true;
},
vfunc_gesture_end(action, actor) {
vfunc_gesture_end : function (action, actor) {
let [startX, startY] = this.get_press_coords(0);
let [x, y] = this.get_motion_coords(0);
let monitorRect = this._getMonitorRect(startX, startY);

View File

@@ -63,12 +63,12 @@ const EndSessionDialogIface = '<node> \
const logoutDialogContent = {
subjectWithUser: C_("title", "Log Out %s"),
subject: C_("title", "Log Out"),
descriptionWithUser(user, seconds) {
descriptionWithUser: function(user, seconds) {
return ngettext("%s will be logged out automatically in %d second.",
"%s will be logged out automatically in %d seconds.",
seconds).format(user, seconds);
},
description(seconds) {
description: function(seconds) {
return ngettext("You will be logged out automatically in %d second.",
"You will be logged out automatically in %d seconds.",
seconds).format(seconds);
@@ -83,7 +83,7 @@ const logoutDialogContent = {
const shutdownDialogContent = {
subject: C_("title", "Power Off"),
subjectWithUpdates: C_("title", "Install Updates & Power Off"),
description(seconds) {
description: function(seconds) {
return ngettext("The system will power off automatically in %d second.",
"The system will power off automatically in %d seconds.",
seconds).format(seconds);
@@ -101,7 +101,7 @@ const shutdownDialogContent = {
const restartDialogContent = {
subject: C_("title", "Restart"),
description(seconds) {
description: function(seconds) {
return ngettext("The system will restart automatically in %d second.",
"The system will restart automatically in %d seconds.",
seconds).format(seconds);
@@ -117,7 +117,7 @@ const restartDialogContent = {
const restartUpdateDialogContent = {
subject: C_("title", "Restart & Install Updates"),
description(seconds) {
description: function(seconds) {
return ngettext("The system will automatically restart and install updates in %d second.",
"The system will automatically restart and install updates in %d seconds.",
seconds).format(seconds);
@@ -135,7 +135,7 @@ const restartUpdateDialogContent = {
const restartUpgradeDialogContent = {
subject: C_("title", "Restart & Install Upgrade"),
upgradeDescription(distroName, distroVersion) {
upgradeDescription: function(distroName, distroVersion) {
/* Translators: This is the text displayed for system upgrades in the
shut down dialog. First %s gets replaced with the distro name and
second %s with the distro version to upgrade to */
@@ -279,7 +279,7 @@ var EndSessionDialog = new Lang.Class({
Name: 'EndSessionDialog',
Extends: ModalDialog.ModalDialog,
_init() {
_init: function() {
this.parent({ styleClass: 'end-session-dialog',
destroyOnClose: false });
@@ -290,22 +290,22 @@ var EndSessionDialog = new Lang.Class({
this._pkOfflineProxy = new PkOfflineProxy(Gio.DBus.system,
'org.freedesktop.PackageKit',
'/org/freedesktop/PackageKit',
(proxy, error) => {
Lang.bind(this, function(proxy, error) {
if (error)
log(error.message);
});
}));
this._powerProxy = new UPowerProxy(Gio.DBus.system,
'org.freedesktop.UPower',
'/org/freedesktop/UPower',
(proxy, error) => {
Lang.bind(this, function(proxy, error) {
if (error) {
log(error.message);
return;
}
this._powerProxy.connect('g-properties-changed',
this._sync.bind(this));
Lang.bind(this, this._sync));
this._sync();
});
}));
this._secondsLeft = 0;
this._totalSecondsToStayOpen = 0;
@@ -313,12 +313,12 @@ var EndSessionDialog = new Lang.Class({
this._sessions = [];
this.connect('destroy',
this._onDestroy.bind(this));
Lang.bind(this, this._onDestroy));
this.connect('opened',
this._onOpened.bind(this));
Lang.bind(this, this._onOpened));
this._userLoadedId = this._user.connect('notify::is_loaded', this._sync.bind(this));
this._userChangedId = this._user.connect('changed', this._sync.bind(this));
this._userLoadedId = this._user.connect('notify::is_loaded', Lang.bind(this, this._sync));
this._userChangedId = this._user.connect('changed', Lang.bind(this, this._sync));
let mainContentLayout = new St.BoxLayout({ vertical: false });
this.contentLayout.add(mainContentLayout,
@@ -354,7 +354,7 @@ var EndSessionDialog = new Lang.Class({
y_align: St.Align.START });
this._checkBox = new CheckBox.CheckBox();
this._checkBox.actor.connect('clicked', this._sync.bind(this));
this._checkBox.actor.connect('clicked', Lang.bind(this, this._sync));
messageLayout.add(this._checkBox.actor);
this._batteryWarning = new St.Label({ style_class: 'end-session-dialog-warning',
@@ -398,12 +398,12 @@ var EndSessionDialog = new Lang.Class({
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/SessionManager/EndSessionDialog');
},
_onDestroy() {
_onDestroy: function() {
this._user.disconnect(this._userLoadedId);
this._user.disconnect(this._userChangedId);
},
_sync() {
_sync: function() {
let open = (this.state == ModalDialog.State.OPENING || this.state == ModalDialog.State.OPENED);
if (!open)
return;
@@ -476,47 +476,48 @@ var EndSessionDialog = new Lang.Class({
this._sessionHeader.visible = hasSessions;
},
_updateButtons() {
_updateButtons: function() {
let dialogContent = DialogContent[this._type];
let buttons = [{ action: this.cancel.bind(this),
let buttons = [{ action: Lang.bind(this, this.cancel),
label: _("Cancel"),
key: Clutter.Escape }];
for (let i = 0; i < dialogContent.confirmButtons.length; i++) {
let signal = dialogContent.confirmButtons[i].signal;
let label = dialogContent.confirmButtons[i].label;
buttons.push({ action: () => {
this.close(true);
let signalId = this.connect('closed', () => {
this.disconnect(signalId);
this._confirm(signal);
});
},
buttons.push({ action: Lang.bind(this, function() {
this.close(true);
let signalId = this.connect('closed',
Lang.bind(this, function() {
this.disconnect(signalId);
this._confirm(signal);
}));
}),
label: label });
}
this.setButtons(buttons);
},
close(skipSignal) {
close: function(skipSignal) {
this.parent();
if (!skipSignal)
this._dbusImpl.emit_signal('Closed', null);
},
cancel() {
cancel: function() {
this._stopTimer();
this._dbusImpl.emit_signal('Canceled', null);
this.close();
},
_confirm(signal) {
let callback = () => {
_confirm: function(signal) {
let callback = Lang.bind(this, function() {
this._fadeOutDialog();
this._stopTimer();
this._dbusImpl.emit_signal(signal, null);
};
});
// Offline update not available; just emit the signal
if (!this._checkBox.actor.visible) {
@@ -546,12 +547,13 @@ var EndSessionDialog = new Lang.Class({
}
},
_onOpened() {
_onOpened: function() {
this._sync();
},
_triggerOfflineUpdateReboot(callback) {
this._pkOfflineProxy.TriggerRemote('reboot', (result, error) => {
_triggerOfflineUpdateReboot: function(callback) {
this._pkOfflineProxy.TriggerRemote('reboot',
function (result, error) {
if (error)
log(error.message);
@@ -559,8 +561,9 @@ var EndSessionDialog = new Lang.Class({
});
},
_triggerOfflineUpdateShutdown(callback) {
this._pkOfflineProxy.TriggerRemote('power-off', (result, error) => {
_triggerOfflineUpdateShutdown: function(callback) {
this._pkOfflineProxy.TriggerRemote('power-off',
function (result, error) {
if (error)
log(error.message);
@@ -568,8 +571,8 @@ var EndSessionDialog = new Lang.Class({
});
},
_triggerOfflineUpdateCancel(callback) {
this._pkOfflineProxy.CancelRemote((result, error) => {
_triggerOfflineUpdateCancel: function(callback) {
this._pkOfflineProxy.CancelRemote(function (result, error) {
if (error)
log(error.message);
@@ -577,31 +580,32 @@ var EndSessionDialog = new Lang.Class({
});
},
_startTimer() {
_startTimer: function() {
let startTime = GLib.get_monotonic_time();
this._secondsLeft = this._totalSecondsToStayOpen;
this._timerId = Mainloop.timeout_add_seconds(1, () => {
let currentTime = GLib.get_monotonic_time();
let secondsElapsed = ((currentTime - startTime) / 1000000);
this._timerId = Mainloop.timeout_add_seconds(1, Lang.bind(this,
function() {
let currentTime = GLib.get_monotonic_time();
let secondsElapsed = ((currentTime - startTime) / 1000000);
this._secondsLeft = this._totalSecondsToStayOpen - secondsElapsed;
if (this._secondsLeft > 0) {
this._sync();
return GLib.SOURCE_CONTINUE;
}
this._secondsLeft = this._totalSecondsToStayOpen - secondsElapsed;
if (this._secondsLeft > 0) {
this._sync();
return GLib.SOURCE_CONTINUE;
}
let dialogContent = DialogContent[this._type];
let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
this._confirm(button.signal);
this._timerId = 0;
let dialogContent = DialogContent[this._type];
let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
this._confirm(button.signal);
this._timerId = 0;
return GLib.SOURCE_REMOVE;
});
return GLib.SOURCE_REMOVE;
}));
GLib.Source.set_name_by_id(this._timerId, '[gnome-shell] this._confirm');
},
_stopTimer() {
_stopTimer: function() {
if (this._timerId > 0) {
Mainloop.source_remove(this._timerId);
this._timerId = 0;
@@ -610,7 +614,7 @@ var EndSessionDialog = new Lang.Class({
this._secondsLeft = 0;
},
_constructListItemForApp(inhibitor, app) {
_constructListItemForApp: function(inhibitor, app) {
let actor = new St.BoxLayout({ style_class: 'end-session-dialog-app-list-item',
can_focus: true });
actor.add(app.create_icon_texture(_ITEM_ICON_SIZE));
@@ -635,7 +639,7 @@ var EndSessionDialog = new Lang.Class({
return actor;
},
_onInhibitorLoaded(inhibitor) {
_onInhibitorLoaded: function(inhibitor) {
if (this._applications.indexOf(inhibitor) < 0) {
// Stale inhibitor
return;
@@ -654,7 +658,7 @@ var EndSessionDialog = new Lang.Class({
this._sync();
},
_constructListItemForSession(session) {
_constructListItemForSession: function(session) {
let avatar = new UserWidget.Avatar(session.user, { iconSize: _ITEM_ICON_SIZE });
avatar.update();
@@ -684,8 +688,8 @@ var EndSessionDialog = new Lang.Class({
return actor;
},
_loadSessions() {
this._loginManager.listSessions(result => {
_loadSessions: function() {
this._loginManager.listSessions(Lang.bind(this, function(result) {
let n = 0;
for (let i = 0; i < result.length; i++) {
let[id, uid, userName, seat, sessionPath] = result[i];
@@ -716,10 +720,10 @@ var EndSessionDialog = new Lang.Class({
}
this._sync();
});
}));
},
OpenAsync(parameters, invocation) {
OpenAsync: function(parameters, invocation) {
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
this._type = type;
@@ -746,9 +750,9 @@ var EndSessionDialog = new Lang.Class({
let dialogContent = DialogContent[this._type];
for (let i = 0; i < inhibitorObjectPaths.length; i++) {
let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i], (proxy, error) => {
let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i], Lang.bind(this, function(proxy, error) {
this._onInhibitorLoaded(proxy);
});
}));
this._applications.push(inhibitor);
}
@@ -783,13 +787,14 @@ var EndSessionDialog = new Lang.Class({
this._sync();
let signalId = this.connect('opened', () => {
invocation.return_value(null);
this.disconnect(signalId);
});
let signalId = this.connect('opened',
Lang.bind(this, function() {
invocation.return_value(null);
this.disconnect(signalId);
}));
},
Close(parameters, invocation) {
Close: function(parameters, invocation) {
this.close();
}
});

View File

@@ -47,14 +47,14 @@ function _patchContainerClass(containerClass) {
function _patchLayoutClass(layoutClass, styleProps) {
if (styleProps)
layoutClass.prototype.hookup_style = function(container) {
container.connect('style-changed', () => {
container.connect('style-changed', Lang.bind(this, function() {
let node = container.get_theme_node();
for (let prop in styleProps) {
let [found, length] = node.lookup_length(styleProps[prop], false);
if (found)
this[prop] = length;
}
});
}));
};
layoutClass.prototype.child_set = function(actor, props) {
let meta = this.get_child_meta(actor.get_parent(), actor);
@@ -88,7 +88,7 @@ function init() {
window._ = Gettext.gettext;
window.C_ = Gettext.pgettext;
window.ngettext = Gettext.ngettext;
window.N_ = s => s;
window.N_ = function(s) { return s; };
// Miscellaneous monkeypatching
_patchContainerClass(St.BoxLayout);

View File

@@ -30,7 +30,7 @@ function installExtension(uuid, invocation) {
let message = Soup.form_request_new_from_hash('GET', REPOSITORY_URL_INFO, params);
_httpSession.queue_message(message, (session, message) => {
_httpSession.queue_message(message, function(session, message) {
if (message.status_code != Soup.KnownStatusCode.OK) {
ExtensionSystem.logExtensionError(uuid, 'downloading info: ' + message.status_code);
invocation.return_dbus_error('org.gnome.Shell.DownloadInfoError', message.status_code.toString());
@@ -96,7 +96,7 @@ function gotExtensionZipFile(session, message, uuid, dir, callback, errback) {
return;
}
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, (pid, status) => {
GLib.child_watch_add(GLib.PRIORITY_DEFAULT, pid, function(pid, status) {
GLib.spawn_close_pid(pid);
if (status != 0)
@@ -119,8 +119,8 @@ function updateExtension(uuid) {
let url = REPOSITORY_URL_DOWNLOAD.format(uuid);
let message = Soup.form_request_new_from_hash('GET', url, params);
_httpSession.queue_message(message, (session, message) => {
gotExtensionZipFile(session, message, uuid, newExtensionTmpDir, () => {
_httpSession.queue_message(message, Lang.bind(this, function(session, message) {
gotExtensionZipFile(session, message, uuid, newExtensionTmpDir, function() {
let oldExtension = ExtensionUtils.extensions[uuid];
let extensionDir = oldExtension.dir;
@@ -151,10 +151,10 @@ function updateExtension(uuid) {
}
FileUtils.recursivelyDeleteDir(oldExtensionTmpDir, true);
}, (code, message) => {
}, function(code, message) {
log('Error while updating extension %s: %s (%s)'.format(uuid, code, message ? message : ''));
});
});
}));
}
function checkForUpdates() {
@@ -168,7 +168,7 @@ function checkForUpdates() {
let url = REPOSITORY_URL_UPDATE;
let message = Soup.form_request_new_from_hash('GET', url, params);
_httpSession.queue_message(message, (session, message) => {
_httpSession.queue_message(message, function(session, message) {
if (message.status_code != Soup.KnownStatusCode.OK)
return;
@@ -187,7 +187,7 @@ var InstallExtensionDialog = new Lang.Class({
Name: 'InstallExtensionDialog',
Extends: ModalDialog.ModalDialog,
_init(uuid, info, invocation) {
_init: function(uuid, info, invocation) {
this.parent({ styleClass: 'extension-dialog' });
this._uuid = uuid;
@@ -195,11 +195,11 @@ var InstallExtensionDialog = new Lang.Class({
this._invocation = invocation;
this.setButtons([{ label: _("Cancel"),
action: this._onCancelButtonPressed.bind(this),
action: Lang.bind(this, this._onCancelButtonPressed),
key: Clutter.Escape
},
{ label: _("Install"),
action: this._onInstallButtonPressed.bind(this),
action: Lang.bind(this, this._onInstallButtonPressed),
default: true
}]);
@@ -218,12 +218,12 @@ var InstallExtensionDialog = new Lang.Class({
box.add(label);
},
_onCancelButtonPressed(button, event) {
_onCancelButtonPressed: function(button, event) {
this.close();
this._invocation.return_value(GLib.Variant.new('(s)', ['cancelled']));
},
_onInstallButtonPressed(button, event) {
_onInstallButtonPressed: function(button, event) {
let params = { shell_version: Config.PACKAGE_VERSION };
let url = REPOSITORY_URL_DOWNLOAD.format(this._uuid);
@@ -258,9 +258,9 @@ var InstallExtensionDialog = new Lang.Class({
invocation.return_value(GLib.Variant.new('(s)', ['successful']));
}
_httpSession.queue_message(message, (session, message) => {
_httpSession.queue_message(message, Lang.bind(this, function(session, message) {
gotExtensionZipFile(session, message, uuid, dir, callback, errback);
});
}));
this.close();
}

View File

@@ -34,8 +34,8 @@ var extensionOrder = [];
var _signals = {};
Signals.addSignalMethods(_signals);
var connect = _signals.connect.bind(_signals);
var disconnect = _signals.disconnect.bind(_signals);
var connect = Lang.bind(_signals, _signals.connect);
var disconnect = Lang.bind(_signals, _signals.disconnect);
const ENABLED_EXTENSIONS_KEY = 'enabled-extensions';
const DISABLE_USER_EXTENSIONS_KEY = 'disable-user-extensions';
@@ -273,17 +273,17 @@ function onEnabledExtensionsChanged() {
// Find and enable all the newly enabled extensions: UUIDs found in the
// new setting, but not in the old one.
newEnabledExtensions.filter(
uuid => !enabledExtensions.includes(uuid)
).forEach(uuid => {
newEnabledExtensions.filter(function(uuid) {
return enabledExtensions.indexOf(uuid) == -1;
}).forEach(function(uuid) {
enableExtension(uuid);
});
// Find and disable all the newly disabled extensions: UUIDs found in the
// old setting, but not in the new one.
enabledExtensions.filter(
item => !newEnabledExtensions.includes(item)
).forEach(uuid => {
enabledExtensions.filter(function(item) {
return newEnabledExtensions.indexOf(item) == -1;
}).forEach(function(uuid) {
disableExtension(uuid);
});
@@ -300,7 +300,7 @@ function _onVersionValidationChanged() {
enabledExtensions = getEnabledExtensions();
if (Main.sessionMode.allowExtensions) {
enabledExtensions.forEach(uuid => {
enabledExtensions.forEach(function(uuid) {
enableExtension(uuid);
});
}
@@ -314,7 +314,7 @@ function _loadExtensions() {
enabledExtensions = getEnabledExtensions();
let finder = new ExtensionUtils.ExtensionFinder();
finder.connect('extension-found', (finder, extension) => {
finder.connect('extension-found', function(finder, extension) {
loadExtension(extension);
});
finder.scanExtensions();
@@ -328,7 +328,7 @@ function enableAllExtensions() {
_loadExtensions();
initted = true;
} else {
enabledExtensions.forEach(uuid => {
enabledExtensions.forEach(function(uuid) {
enableExtension(uuid);
});
}
@@ -340,7 +340,7 @@ function disableAllExtensions() {
return;
if (initted) {
extensionOrder.slice().reverse().forEach(uuid => {
extensionOrder.slice().reverse().forEach(function(uuid) {
disableExtension(uuid);
});
}

View File

@@ -31,22 +31,22 @@ const STATECHANGED = 'object:state-changed';
var FocusCaretTracker = new Lang.Class({
Name: 'FocusCaretTracker',
_init() {
this._atspiListener = Atspi.EventListener.new(this._onChanged.bind(this));
_init: function() {
this._atspiListener = Atspi.EventListener.new(Lang.bind(this, this._onChanged));
this._atspiInited = false;
this._focusListenerRegistered = false;
this._caretListenerRegistered = false;
},
_onChanged(event) {
_onChanged: function(event) {
if (event.type.indexOf(STATECHANGED) == 0)
this.emit('focus-changed', event);
else if (event.type == CARETMOVED)
this.emit('caret-moved', event);
},
_initAtspi() {
_initAtspi: function() {
if (!this._atspiInited && Atspi.init() == 0) {
Atspi.set_timeout(250, 250);
this._atspiInited = true;
@@ -55,7 +55,7 @@ var FocusCaretTracker = new Lang.Class({
return this._atspiInited;
},
registerFocusListener() {
registerFocusListener: function() {
if (!this._initAtspi() || this._focusListenerRegistered)
return;
@@ -64,7 +64,7 @@ var FocusCaretTracker = new Lang.Class({
this._focusListenerRegistered = true;
},
registerCaretListener() {
registerCaretListener: function() {
if (!this._initAtspi() || this._caretListenerRegistered)
return;
@@ -72,7 +72,7 @@ var FocusCaretTracker = new Lang.Class({
this._caretListenerRegistered = true;
},
deregisterFocusListener() {
deregisterFocusListener: function() {
if (!this._focusListenerRegistered)
return;
@@ -81,7 +81,7 @@ var FocusCaretTracker = new Lang.Class({
this._focusListenerRegistered = false;
},
deregisterCaretListener() {
deregisterCaretListener: function() {
if (!this._caretListenerRegistered)
return;

View File

@@ -49,7 +49,7 @@ function _popGrabHelper(grabHelper) {
var GrabHelper = new Lang.Class({
Name: 'GrabHelper',
_init(owner, params) {
_init: function(owner, params) {
this._owner = owner;
this._modalParams = params;
@@ -66,10 +66,8 @@ var GrabHelper = new Lang.Class({
//
// Adds @actor to the set of actors that are allowed to process events
// during a grab.
addActor(actor) {
actor.__grabHelperDestroyId = actor.connect('destroy', () => {
this.removeActor(actor);
});
addActor: function(actor) {
actor.__grabHelperDestroyId = actor.connect('destroy', Lang.bind(this, function() { this.removeActor(actor); }));
this._actors.push(actor);
},
@@ -78,7 +76,7 @@ var GrabHelper = new Lang.Class({
//
// Removes @actor from the set of actors that are allowed to
// process events during a grab.
removeActor(actor) {
removeActor: function(actor) {
let index = this._actors.indexOf(actor);
if (index != -1)
this._actors.splice(index, 1);
@@ -88,7 +86,7 @@ var GrabHelper = new Lang.Class({
}
},
_isWithinGrabbedActor(actor) {
_isWithinGrabbedActor: function(actor) {
let currentActor = this.currentGrab.actor;
while (actor) {
if (this._actors.indexOf(actor) != -1)
@@ -112,7 +110,7 @@ var GrabHelper = new Lang.Class({
return this._grabStack;
},
_findStackIndex(actor) {
_findStackIndex: function(actor) {
if (!actor)
return -1;
@@ -123,7 +121,7 @@ var GrabHelper = new Lang.Class({
return -1;
},
_actorInGrabStack(actor) {
_actorInGrabStack: function(actor) {
while (actor) {
let idx = this._findStackIndex(actor);
if (idx >= 0)
@@ -133,7 +131,7 @@ var GrabHelper = new Lang.Class({
return -1;
},
isActorGrabbed(actor) {
isActorGrabbed: function(actor) {
return this._findStackIndex(actor) >= 0;
},
@@ -168,7 +166,7 @@ var GrabHelper = new Lang.Class({
// to that actor instead of navigating in @params.actor. This is for
// use cases like menus, where we want to grab the menu actor, but keep
// focus on the clicked on menu item.
grab(params) {
grab: function(params) {
params = Params.parse(params, { actor: null,
focus: null,
onUngrab: null });
@@ -197,7 +195,7 @@ var GrabHelper = new Lang.Class({
return true;
},
_takeModalGrab() {
_takeModalGrab: function() {
let firstGrab = (this._modalCount == 0);
if (firstGrab) {
if (!Main.pushModal(this._owner, this._modalParams))
@@ -210,7 +208,7 @@ var GrabHelper = new Lang.Class({
return true;
},
_releaseModalGrab() {
_releaseModalGrab: function() {
this._modalCount--;
if (this._modalCount > 0)
return;
@@ -229,7 +227,7 @@ var GrabHelper = new Lang.Class({
// capture event handler returns false. This is designed for things
// like the ComboBoxMenu that go away on press, but need to eat
// the next release event.
ignoreRelease() {
ignoreRelease: function() {
this._ignoreUntilRelease = true;
},
@@ -244,7 +242,7 @@ var GrabHelper = new Lang.Class({
// popped until the grabbed actor is at the top of the grab stack.
// The onUngrab callback for every grab is called for every popped
// grab with the parameter %false.
ungrab(params) {
ungrab: function(params) {
params = Params.parse(params, { actor: this.currentGrab.actor,
isUser: false });
@@ -276,7 +274,7 @@ var GrabHelper = new Lang.Class({
}
},
onCapturedEvent(event) {
onCapturedEvent: function(event) {
let type = event.type();
if (type == Clutter.EventType.KEY_PRESS &&

View File

@@ -17,7 +17,7 @@ var DEFAULT_INDEX_LABELS = [ '1', '2', '3', '4', '5', '6', '7', '8',
var CandidateArea = new Lang.Class({
Name: 'CandidateArea',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ vertical: true,
reactive: true,
visible: false });
@@ -34,13 +34,13 @@ var CandidateArea = new Lang.Class({
this.actor.add(box);
let j = i;
box.connect('button-release-event', (actor, event) => {
box.connect('button-release-event', Lang.bind(this, function(actor, event) {
this.emit('candidate-clicked', j, event.get_button(), event.get_state());
return Clutter.EVENT_PROPAGATE;
});
}));
}
this.actor.connect('scroll-event', (actor, event) => {
this.actor.connect('scroll-event', Lang.bind(this, function(actor, event) {
let direction = event.get_scroll_direction();
switch(direction) {
case Clutter.ScrollDirection.UP:
@@ -51,7 +51,7 @@ var CandidateArea = new Lang.Class({
break;
};
return Clutter.EVENT_PROPAGATE;
});
}));
this._buttonBox = new St.BoxLayout({ style_class: 'candidate-page-button-box' });
@@ -65,18 +65,18 @@ var CandidateArea = new Lang.Class({
this.actor.add(this._buttonBox);
this._previousButton.connect('clicked', () => {
this._previousButton.connect('clicked', Lang.bind(this, function() {
this.emit('previous-page');
});
this._nextButton.connect('clicked', () => {
}));
this._nextButton.connect('clicked', Lang.bind(this, function() {
this.emit('next-page');
});
}));
this._orientation = -1;
this._cursorPosition = 0;
},
setOrientation(orientation) {
setOrientation: function(orientation) {
if (this._orientation == orientation)
return;
@@ -97,7 +97,7 @@ var CandidateArea = new Lang.Class({
}
},
setCandidates(indexes, candidates, cursorPosition, cursorVisible) {
setCandidates: function(indexes, candidates, cursorPosition, cursorVisible) {
for (let i = 0; i < MAX_CANDIDATES_PER_PAGE; ++i) {
let visible = i < candidates.length;
let box = this._candidateBoxes[i];
@@ -116,7 +116,7 @@ var CandidateArea = new Lang.Class({
this._candidateBoxes[cursorPosition].add_style_pseudo_class('selected');
},
updateButtons(wrapsAround, page, nPages) {
updateButtons: function(wrapsAround, page, nPages) {
if (nPages < 2) {
this._buttonBox.hide();
return;
@@ -131,7 +131,7 @@ Signals.addSignalMethods(CandidateArea.prototype);
var CandidatePopup = new Lang.Class({
Name: 'CandidatePopup',
_init() {
_init: function() {
this._boxPointer = new BoxPointer.BoxPointer(St.Side.TOP);
this._boxPointer.actor.visible = false;
this._boxPointer.actor.style_class = 'candidate-popup-boxpointer';
@@ -152,138 +152,150 @@ var CandidatePopup = new Lang.Class({
this._candidateArea = new CandidateArea();
box.add(this._candidateArea.actor);
this._candidateArea.connect('previous-page', () => {
this._candidateArea.connect('previous-page', Lang.bind(this, function() {
this._panelService.page_up();
});
this._candidateArea.connect('next-page', () => {
}));
this._candidateArea.connect('next-page', Lang.bind(this, function() {
this._panelService.page_down();
});
}));
this._candidateArea.connect('cursor-up', () => {
this._candidateArea.connect('cursor-up', Lang.bind(this, function() {
this._panelService.cursor_up();
});
this._candidateArea.connect('cursor-down', () => {
}));
this._candidateArea.connect('cursor-down', Lang.bind(this, function() {
this._panelService.cursor_down();
});
}));
this._candidateArea.connect('candidate-clicked', () => {
this._candidateArea.connect('candidate-clicked', Lang.bind(this, function(ca, index, button, state) {
this._panelService.candidate_clicked(index, button, state);
});
}));
this._panelService = null;
},
setPanelService(panelService) {
setPanelService: function(panelService) {
this._panelService = panelService;
if (!panelService)
return;
panelService.connect('set-cursor-location', (ps, x, y, w, h) => {
this._setDummyCursorGeometry(x, y, w, h);
});
panelService.connect('set-cursor-location',
Lang.bind(this, function(ps, x, y, w, h) {
this._setDummyCursorGeometry(x, y, w, h);
}));
try {
panelService.connect('set-cursor-location-relative', (ps, x, y, w, h) => {
if (!global.display.focus_window)
return;
let window = global.display.focus_window.get_compositor_private();
this._setDummyCursorGeometry(window.x + x, window.y + y, w, h);
});
panelService.connect('set-cursor-location-relative',
Lang.bind(this, function(ps, x, y, w, h) {
if (!global.display.focus_window)
return;
let window = global.display.focus_window.get_compositor_private();
this._setDummyCursorGeometry(window.x + x, window.y + y, w, h);
}));
} catch(e) {
// Only recent IBus versions have support for this signal
// which is used for wayland clients. In order to work
// with older IBus versions we can silently ignore the
// signal's absence.
}
panelService.connect('update-preedit-text', (ps, text, cursorPosition, visible) => {
this._preeditText.visible = visible;
this._updateVisibility();
panelService.connect('update-preedit-text',
Lang.bind(this, function(ps, text, cursorPosition, visible) {
this._preeditText.visible = visible;
this._updateVisibility();
this._preeditText.text = text.get_text();
this._preeditText.text = text.get_text();
let attrs = text.get_attributes();
if (attrs)
this._setTextAttributes(this._preeditText.clutter_text,
attrs);
});
panelService.connect('show-preedit-text', ps => {
this._preeditText.show();
this._updateVisibility();
});
panelService.connect('hide-preedit-text', ps => {
this._preeditText.hide();
this._updateVisibility();
});
panelService.connect('update-auxiliary-text', (ps, text, visible) => {
this._auxText.visible = visible;
this._updateVisibility();
let attrs = text.get_attributes();
if (attrs)
this._setTextAttributes(this._preeditText.clutter_text,
attrs);
}));
panelService.connect('show-preedit-text',
Lang.bind(this, function(ps) {
this._preeditText.show();
this._updateVisibility();
}));
panelService.connect('hide-preedit-text',
Lang.bind(this, function(ps) {
this._preeditText.hide();
this._updateVisibility();
}));
panelService.connect('update-auxiliary-text',
Lang.bind(this, function(ps, text, visible) {
this._auxText.visible = visible;
this._updateVisibility();
this._auxText.text = text.get_text();
});
panelService.connect('show-auxiliary-text', ps => {
this._auxText.show();
this._updateVisibility();
});
panelService.connect('hide-auxiliary-text', ps => {
this._auxText.hide();
this._updateVisibility();
});
panelService.connect('update-lookup-table', (ps, lookupTable, visible) => {
this._candidateArea.actor.visible = visible;
this._updateVisibility();
this._auxText.text = text.get_text();
}));
panelService.connect('show-auxiliary-text',
Lang.bind(this, function(ps) {
this._auxText.show();
this._updateVisibility();
}));
panelService.connect('hide-auxiliary-text',
Lang.bind(this, function(ps) {
this._auxText.hide();
this._updateVisibility();
}));
panelService.connect('update-lookup-table',
Lang.bind(this, function(ps, lookupTable, visible) {
this._candidateArea.actor.visible = visible;
this._updateVisibility();
let nCandidates = lookupTable.get_number_of_candidates();
let cursorPos = lookupTable.get_cursor_pos();
let pageSize = lookupTable.get_page_size();
let nPages = Math.ceil(nCandidates / pageSize);
let page = ((cursorPos == 0) ? 0 : Math.floor(cursorPos / pageSize));
let startIndex = page * pageSize;
let endIndex = Math.min((page + 1) * pageSize, nCandidates);
let nCandidates = lookupTable.get_number_of_candidates();
let cursorPos = lookupTable.get_cursor_pos();
let pageSize = lookupTable.get_page_size();
let nPages = Math.ceil(nCandidates / pageSize);
let page = ((cursorPos == 0) ? 0 : Math.floor(cursorPos / pageSize));
let startIndex = page * pageSize;
let endIndex = Math.min((page + 1) * pageSize, nCandidates);
let indexes = [];
let indexLabel;
for (let i = 0; indexLabel = lookupTable.get_label(i); ++i)
indexes.push(indexLabel.get_text());
let indexes = [];
let indexLabel;
for (let i = 0; indexLabel = lookupTable.get_label(i); ++i)
indexes.push(indexLabel.get_text());
Main.keyboard.resetSuggestions();
Main.keyboard.resetSuggestions();
let candidates = [];
for (let i = startIndex; i < endIndex; ++i) {
candidates.push(lookupTable.get_candidate(i).get_text());
let candidates = [];
for (let i = startIndex; i < endIndex; ++i) {
candidates.push(lookupTable.get_candidate(i).get_text());
Main.keyboard.addSuggestion(lookupTable.get_candidate(i).get_text(), () => {
let index = i;
this._panelService.candidate_clicked(index, 1, 0);
});
}
Main.keyboard.addSuggestion(lookupTable.get_candidate(i).get_text(), Lang.bind(this, function() {
let index = i;
this._panelService.candidate_clicked(index, 1, 0);
}));
}
this._candidateArea.setCandidates(indexes,
candidates,
cursorPos % pageSize,
lookupTable.is_cursor_visible());
this._candidateArea.setOrientation(lookupTable.get_orientation());
this._candidateArea.updateButtons(lookupTable.is_round(), page, nPages);
});
panelService.connect('show-lookup-table', ps => {
this._candidateArea.actor.show();
this._updateVisibility();
});
panelService.connect('hide-lookup-table', ps => {
this._candidateArea.actor.hide();
this._updateVisibility();
});
panelService.connect('focus-out', ps => {
this._boxPointer.hide(BoxPointer.PopupAnimation.NONE);
Main.keyboard.resetSuggestions();
});
this._candidateArea.setCandidates(indexes,
candidates,
cursorPos % pageSize,
lookupTable.is_cursor_visible());
this._candidateArea.setOrientation(lookupTable.get_orientation());
this._candidateArea.updateButtons(lookupTable.is_round(), page, nPages);
}));
panelService.connect('show-lookup-table',
Lang.bind(this, function(ps) {
this._candidateArea.actor.show();
this._updateVisibility();
}));
panelService.connect('hide-lookup-table',
Lang.bind(this, function(ps) {
this._candidateArea.actor.hide();
this._updateVisibility();
}));
panelService.connect('focus-out',
Lang.bind(this, function(ps) {
this._boxPointer.hide(BoxPointer.PopupAnimation.NONE);
Main.keyboard.resetSuggestions();
}));
},
_setDummyCursorGeometry(x, y, w, h) {
_setDummyCursorGeometry: function(x, y, w, h) {
Main.layoutManager.setDummyCursorGeometry(x, y, w, h);
if (this._boxPointer.actor.visible)
this._boxPointer.setPosition(Main.layoutManager.dummyCursor, 0);
},
_updateVisibility() {
_updateVisibility: function() {
let isVisible = (!Main.keyboard.visible &&
(this._preeditText.visible ||
this._auxText.visible ||
@@ -298,7 +310,7 @@ var CandidatePopup = new Lang.Class({
}
},
_setTextAttributes(clutterText, ibusAttrList) {
_setTextAttributes: function(clutterText, ibusAttrList) {
let attr;
for (let i = 0; attr = ibusAttrList.get(i); ++i)
if (attr.get_attr_type() == IBus.AttrType.BACKGROUND)

View File

@@ -37,7 +37,7 @@ var APPICON_ANIMATION_OUT_TIME = 0.25;
var BaseIcon = new Lang.Class({
Name: 'BaseIcon',
_init(label, params) {
_init : function(label, params) {
params = Params.parse(params, { createIcon: null,
setSizeManually: false,
showLabel: true });
@@ -50,17 +50,19 @@ var BaseIcon = new Lang.Class({
x_fill: true,
y_fill: true });
this.actor._delegate = this;
this.actor.connect('style-changed', this._onStyleChanged.bind(this));
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('style-changed',
Lang.bind(this, this._onStyleChanged));
this.actor.connect('destroy',
Lang.bind(this, this._onDestroy));
this._spacing = 0;
let box = new Shell.GenericContainer();
box.connect('allocate', this._allocate.bind(this));
box.connect('allocate', Lang.bind(this, this._allocate));
box.connect('get-preferred-width',
this._getPreferredWidth.bind(this));
Lang.bind(this, this._getPreferredWidth));
box.connect('get-preferred-height',
this._getPreferredHeight.bind(this));
Lang.bind(this, this._getPreferredHeight));
this.actor.set_child(box);
this.iconSize = ICON_SIZE;
@@ -83,10 +85,10 @@ var BaseIcon = new Lang.Class({
this.icon = null;
let cache = St.TextureCache.get_default();
this._iconThemeChangedId = cache.connect('icon-theme-changed', this._onIconThemeChanged.bind(this));
this._iconThemeChangedId = cache.connect('icon-theme-changed', Lang.bind(this, this._onIconThemeChanged));
},
_allocate(actor, box, flags) {
_allocate: function(actor, box, flags) {
let availWidth = box.x2 - box.x1;
let availHeight = box.y2 - box.y1;
@@ -120,11 +122,11 @@ var BaseIcon = new Lang.Class({
this._iconBin.allocate(childBox, flags);
},
_getPreferredWidth(actor, forHeight, alloc) {
_getPreferredWidth: function(actor, forHeight, alloc) {
this._getPreferredHeight(actor, -1, alloc);
},
_getPreferredHeight(actor, forWidth, alloc) {
_getPreferredHeight: function(actor, forWidth, alloc) {
let [iconMinHeight, iconNatHeight] = this._iconBin.get_preferred_height(forWidth);
alloc.min_size = iconMinHeight;
alloc.natural_size = iconNatHeight;
@@ -138,11 +140,11 @@ var BaseIcon = new Lang.Class({
// This can be overridden by a subclass, or by the createIcon
// parameter to _init()
createIcon(size) {
createIcon: function(size) {
throw new Error('no implementation of createIcon in ' + this);
},
setIconSize(size) {
setIconSize: function(size) {
if (!this._setSizeManually)
throw new Error('setSizeManually has to be set to use setIconsize');
@@ -152,7 +154,7 @@ var BaseIcon = new Lang.Class({
this._createIconTexture(size);
},
_createIconTexture(size) {
_createIconTexture: function(size) {
if (this.icon)
this.icon.destroy();
this.iconSize = size;
@@ -161,7 +163,7 @@ var BaseIcon = new Lang.Class({
this._iconBin.child = this.icon;
},
_onStyleChanged() {
_onStyleChanged: function() {
let node = this.actor.get_theme_node();
this._spacing = node.get_length('spacing');
@@ -179,7 +181,7 @@ var BaseIcon = new Lang.Class({
this._createIconTexture(size);
},
_onDestroy() {
_onDestroy: function() {
if (this._iconThemeChangedId > 0) {
let cache = St.TextureCache.get_default();
cache.disconnect(this._iconThemeChangedId);
@@ -187,11 +189,11 @@ var BaseIcon = new Lang.Class({
}
},
_onIconThemeChanged() {
_onIconThemeChanged: function() {
this._createIconTexture(this.iconSize);
},
animateZoomOut() {
animateZoomOut: function() {
// Animate only the child instead of the entire actor, so the
// styles like hover and running are not applied while
// animating.
@@ -232,7 +234,7 @@ function zoomOutActor(actor) {
translation_y: containedY - scaledY,
opacity: 0,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
actorClone.destroy();
}
});
@@ -241,7 +243,7 @@ function zoomOutActor(actor) {
var IconGrid = new Lang.Class({
Name: 'IconGrid',
_init(params) {
_init: function(params) {
params = Params.parse(params, { rowLimit: null,
columnLimit: null,
minRows: 1,
@@ -272,7 +274,7 @@ var IconGrid = new Lang.Class({
this._fixedHItemSize = this._fixedVItemSize = undefined;
this._grid = new Shell.GenericContainer();
this.actor.add(this._grid, { expand: true, y_align: St.Align.START });
this.actor.connect('style-changed', this._onStyleChanged.bind(this));
this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
// Cancel animations when hiding the overview, to avoid icons
// swarming into the void ...
@@ -281,26 +283,26 @@ var IconGrid = new Lang.Class({
this._cancelAnimation();
});
this._grid.connect('get-preferred-width', this._getPreferredWidth.bind(this));
this._grid.connect('get-preferred-height', this._getPreferredHeight.bind(this));
this._grid.connect('allocate', this._allocate.bind(this));
this._grid.connect('actor-added', this._childAdded.bind(this));
this._grid.connect('actor-removed', this._childRemoved.bind(this));
this._grid.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this._grid.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this._grid.connect('allocate', Lang.bind(this, this._allocate));
this._grid.connect('actor-added', Lang.bind(this, this._childAdded));
this._grid.connect('actor-removed', Lang.bind(this, this._childRemoved));
},
_keyFocusIn(actor) {
_keyFocusIn: function(actor) {
this.emit('key-focus-in', actor);
},
_childAdded(grid, child) {
child._iconGridKeyFocusInId = child.connect('key-focus-in', this._keyFocusIn.bind(this));
_childAdded: function(grid, child) {
child._iconGridKeyFocusInId = child.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
},
_childRemoved(grid, child) {
_childRemoved: function(grid, child) {
child.disconnect(child._iconGridKeyFocusInId);
},
_getPreferredWidth(grid, forHeight, alloc) {
_getPreferredWidth: function (grid, forHeight, alloc) {
if (this._fillParent)
// Ignore all size requests of children and request a size of 0;
// later we'll allocate as many children as fit the parent
@@ -318,11 +320,15 @@ var IconGrid = new Lang.Class({
alloc.natural_size = nColumns * this._getHItemSize() + totalSpacing + this.leftPadding + this.rightPadding;
},
_getVisibleChildren() {
return this._grid.get_children().filter(actor => actor.visible);
_getVisibleChildren: function() {
let children = this._grid.get_children();
children = children.filter(function(actor) {
return actor.visible;
});
return children;
},
_getPreferredHeight(grid, forWidth, alloc) {
_getPreferredHeight: function (grid, forWidth, alloc) {
if (this._fillParent)
// Ignore all size requests of children and request a size of 0;
// later we'll allocate as many children as fit the parent
@@ -348,7 +354,7 @@ var IconGrid = new Lang.Class({
alloc.natural_size = height;
},
_allocate(grid, box, flags) {
_allocate: function (grid, box, flags) {
if (this._fillParent) {
// Reset the passed in box to fill the parent
let parentBox = this.actor.get_parent().allocation;
@@ -408,21 +414,21 @@ var IconGrid = new Lang.Class({
* Intended to be override by subclasses if they need a different
* set of items to be animated.
*/
_getChildrenToAnimate() {
_getChildrenToAnimate: function() {
return this._getVisibleChildren();
},
_cancelAnimation() {
_cancelAnimation: function() {
this._clonesAnimating.forEach(clone => { clone.destroy(); });
this._clonesAnimating = [];
},
_animationDone() {
_animationDone: function() {
this._clonesAnimating = [];
this.emit('animation-done');
},
animatePulse(animationDirection) {
animatePulse: function(animationDirection) {
if (animationDirection != AnimationDirection.IN)
throw new Error("Pulse animation only implements 'in' animation direction");
@@ -456,24 +462,24 @@ var IconGrid = new Lang.Class({
delay: delay,
scale_x: ANIMATION_BOUNCE_ICON_SCALE,
scale_y: ANIMATION_BOUNCE_ICON_SCALE,
onComplete: () => {
onComplete: Lang.bind(this, function() {
Tweener.addTween(actor,
{ time: ANIMATION_TIME_IN - bounceUpTime,
transition: 'easeInOutQuad',
scale_x: 1,
scale_y: 1,
onComplete: () => {
onComplete: Lang.bind(this, function() {
if (isLastItem)
this._animationDone();
actor.reactive = true;
}
})
});
}
})
});
}
},
animateSpring(animationDirection, sourceActor) {
animateSpring: function(animationDirection, sourceActor) {
this._cancelAnimation();
let actors = this._getChildrenToAnimate();
@@ -489,15 +495,15 @@ var IconGrid = new Lang.Class({
// Design decision, 1/2 of the source actor size.
let [sourceScaledWidth, sourceScaledHeight] = [sourceWidth / 2, sourceHeight / 2];
actors.forEach(actor => {
actors.forEach(function(actor) {
let [actorX, actorY] = actor._transformedPosition = actor.get_transformed_position();
let [x, y] = [actorX - sourceX, actorY - sourceY];
actor._distance = Math.sqrt(x * x + y * y);
});
let maxDist = actors.reduce((prev, cur) => {
let maxDist = actors.reduce(function(prev, cur) {
return Math.max(prev, cur._distance);
}, 0);
let minDist = actors.reduce((prev, cur) => {
let minDist = actors.reduce(function(prev, cur) {
return Math.min(prev, cur._distance);
}, Infinity);
let normalization = maxDist - minDist;
@@ -535,14 +541,14 @@ var IconGrid = new Lang.Class({
y: finalY,
scale_x: 1,
scale_y: 1,
onComplete: () => {
onComplete: Lang.bind(this, function() {
if (isLastItem)
this._animationDone();
actor.opacity = 255;
actor.reactive = true;
actorClone.destroy();
}};
})};
fadeParams = { time: ANIMATION_FADE_IN_TIME_FOR_ITEM,
transition: 'easeInOutQuad',
delay: delay,
@@ -561,14 +567,14 @@ var IconGrid = new Lang.Class({
y: adjustedSourcePositionY,
scale_x: scaleX,
scale_y: scaleY,
onComplete: () => {
onComplete: Lang.bind(this, function() {
if (isLastItem) {
this._animationDone();
this._restoreItemsOpacity();
}
actor.reactive = true;
actorClone.destroy();
}};
})};
fadeParams = { time: ANIMATION_FADE_IN_TIME_FOR_ITEM,
transition: 'easeInOutQuad',
delay: ANIMATION_TIME_OUT + delay - ANIMATION_FADE_IN_TIME_FOR_ITEM,
@@ -581,13 +587,13 @@ var IconGrid = new Lang.Class({
}
},
_restoreItemsOpacity() {
_restoreItemsOpacity: function() {
for (let index = 0; index < this._items.length; index++) {
this._items[index].actor.opacity = 255;
}
},
_getAllocatedChildSizeAndSpacing(child) {
_getAllocatedChildSizeAndSpacing: function(child) {
let [,, natWidth, natHeight] = child.get_preferred_size();
let width = Math.min(this._getHItemSize(), natWidth);
let xSpacing = Math.max(0, width - natWidth) / 2;
@@ -596,7 +602,7 @@ var IconGrid = new Lang.Class({
return [width, height, xSpacing, ySpacing];
},
_calculateChildBox(child, x, y, box) {
_calculateChildBox: function(child, x, y, box) {
/* Center the item in its allocation horizontally */
let [width, height, childXSpacing, childYSpacing] =
this._getAllocatedChildSizeAndSpacing(child);
@@ -614,15 +620,15 @@ var IconGrid = new Lang.Class({
return childBox;
},
columnsForWidth(rowWidth) {
columnsForWidth: function(rowWidth) {
return this._computeLayout(rowWidth)[0];
},
getRowLimit() {
getRowLimit: function() {
return this._rowLimit;
},
_computeLayout(forWidth) {
_computeLayout: function (forWidth) {
let nColumns = 0;
let usedWidth = this.leftPadding + this.rightPadding;
let spacing = this._getSpacing();
@@ -639,7 +645,7 @@ var IconGrid = new Lang.Class({
return [nColumns, usedWidth];
},
_onStyleChanged() {
_onStyleChanged: function() {
let themeNode = this.actor.get_theme_node();
this._spacing = themeNode.get_length('spacing');
this._hItemSize = themeNode.get_length('-shell-grid-horizontal-item-size') || ICON_SIZE;
@@ -647,7 +653,7 @@ var IconGrid = new Lang.Class({
this._grid.queue_relayout();
},
nRows(forWidth) {
nRows: function(forWidth) {
let children = this._getVisibleChildren();
let nColumns = (forWidth < 0) ? children.length : this._computeLayout(forWidth)[0];
let nRows = (nColumns > 0) ? Math.ceil(children.length / nColumns) : 0;
@@ -656,35 +662,35 @@ var IconGrid = new Lang.Class({
return nRows;
},
rowsForHeight(forHeight) {
rowsForHeight: function(forHeight) {
return Math.floor((forHeight - (this.topPadding + this.bottomPadding) + this._getSpacing()) / (this._getVItemSize() + this._getSpacing()));
},
usedHeightForNRows(nRows) {
usedHeightForNRows: function(nRows) {
return (this._getVItemSize() + this._getSpacing()) * nRows - this._getSpacing() + this.topPadding + this.bottomPadding;
},
usedWidth(forWidth) {
usedWidth: function(forWidth) {
return this.usedWidthForNColumns(this.columnsForWidth(forWidth));
},
usedWidthForNColumns(columns) {
usedWidthForNColumns: function(columns) {
let usedWidth = columns * (this._getHItemSize() + this._getSpacing());
usedWidth -= this._getSpacing();
return usedWidth + this.leftPadding + this.rightPadding;
},
removeAll() {
removeAll: function() {
this._items = [];
this._grid.remove_all_children();
},
destroyAll() {
destroyAll: function() {
this._items = [];
this._grid.destroy_all_children();
},
addItem(item, index) {
addItem: function(item, index) {
if (!item.icon instanceof BaseIcon)
throw new Error('Only items with a BaseIcon icon property can be added to IconGrid');
@@ -695,35 +701,35 @@ var IconGrid = new Lang.Class({
this._grid.add_actor(item.actor);
},
removeItem(item) {
removeItem: function(item) {
this._grid.remove_child(item.actor);
},
getItemAtIndex(index) {
getItemAtIndex: function(index) {
return this._grid.get_child_at_index(index);
},
visibleItemsCount() {
visibleItemsCount: function() {
return this._grid.get_n_children() - this._grid.get_n_skip_paint();
},
setSpacing(spacing) {
setSpacing: function(spacing) {
this._fixedSpacing = spacing;
},
_getSpacing() {
_getSpacing: function() {
return this._fixedSpacing ? this._fixedSpacing : this._spacing;
},
_getHItemSize() {
_getHItemSize: function() {
return this._fixedHItemSize ? this._fixedHItemSize : this._hItemSize;
},
_getVItemSize() {
_getVItemSize: function() {
return this._fixedVItemSize ? this._fixedVItemSize : this._vItemSize;
},
_updateSpacingForSize(availWidth, availHeight) {
_updateSpacingForSize: function(availWidth, availHeight) {
let maxEmptyVArea = availHeight - this._minRows * this._getVItemSize();
let maxEmptyHArea = availWidth - this._minColumns * this._getHItemSize();
let maxHSpacing, maxVSpacing;
@@ -760,7 +766,7 @@ var IconGrid = new Lang.Class({
* This function must to be called before iconGrid allocation,
* to know how much spacing can the grid has
*/
adaptToSize(availWidth, availHeight) {
adaptToSize: function(availWidth, availHeight) {
this._fixedHItemSize = this._hItemSize;
this._fixedVItemSize = this._vItemSize;
this._updateSpacingForSize(availWidth, availHeight);
@@ -778,11 +784,11 @@ var IconGrid = new Lang.Class({
this._updateSpacingForSize(availWidth, availHeight);
}
Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
this._updateIconSizes.bind(this));
Lang.bind(this, this._updateIconSizes));
},
// Note that this is ICON_SIZE as used by BaseIcon, not elsewhere in IconGrid; it's a bit messed up
_updateIconSizes() {
_updateIconSizes: function() {
let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize, this._vItemSize);
let newIconSize = Math.floor(ICON_SIZE * scale);
for (let i in this._items) {
@@ -796,7 +802,7 @@ var PaginatedIconGrid = new Lang.Class({
Name: 'PaginatedIconGrid',
Extends: IconGrid,
_init(params) {
_init: function(params) {
this.parent(params);
this._nPages = 0;
this.currentPage = 0;
@@ -805,12 +811,12 @@ var PaginatedIconGrid = new Lang.Class({
this._childrenPerPage = 0;
},
_getPreferredHeight(grid, forWidth, alloc) {
_getPreferredHeight: function (grid, forWidth, alloc) {
alloc.min_size = (this._availableHeightPerPageForItems() + this.bottomPadding + this.topPadding) * this._nPages + this._spaceBetweenPages * this._nPages;
alloc.natural_size = (this._availableHeightPerPageForItems() + this.bottomPadding + this.topPadding) * this._nPages + this._spaceBetweenPages * this._nPages;
},
_allocate(grid, box, flags) {
_allocate: function (grid, box, flags) {
if (this._childrenPerPage == 0)
log('computePages() must be called before allocate(); pagination will not work.');
@@ -864,7 +870,7 @@ var PaginatedIconGrid = new Lang.Class({
},
// Overriden from IconGrid
_getChildrenToAnimate() {
_getChildrenToAnimate: function() {
let children = this._getVisibleChildren();
let firstIndex = this._childrenPerPage * this.currentPage;
let lastIndex = firstIndex + this._childrenPerPage;
@@ -872,7 +878,7 @@ var PaginatedIconGrid = new Lang.Class({
return children.slice(firstIndex, lastIndex);
},
_computePages(availWidthPerPage, availHeightPerPage) {
_computePages: function (availWidthPerPage, availHeightPerPage) {
let [nColumns, usedWidth] = this._computeLayout(availWidthPerPage);
let nRows;
let children = this._getVisibleChildren();
@@ -891,24 +897,24 @@ var PaginatedIconGrid = new Lang.Class({
this._childrenPerPage = nColumns * this._rowsPerPage;
},
adaptToSize(availWidth, availHeight) {
adaptToSize: function(availWidth, availHeight) {
this.parent(availWidth, availHeight);
this._computePages(availWidth, availHeight);
},
_availableHeightPerPageForItems() {
_availableHeightPerPageForItems: function() {
return this.usedHeightForNRows(this._rowsPerPage) - (this.topPadding + this.bottomPadding);
},
nPages() {
nPages: function() {
return this._nPages;
},
getPageHeight() {
getPageHeight: function() {
return this._availableHeightPerPageForItems();
},
getPageY(pageNumber) {
getPageY: function(pageNumber) {
if (!this._nPages)
return 0;
@@ -917,7 +923,7 @@ var PaginatedIconGrid = new Lang.Class({
return childBox.y1 - this.topPadding;
},
getItemPage(item) {
getItemPage: function(item) {
let children = this._getVisibleChildren();
let index = children.indexOf(item);
if (index == -1) {
@@ -935,7 +941,7 @@ var PaginatedIconGrid = new Lang.Class({
*
* Pan view to create extra space for @nRows above or below @sourceItem.
*/
openExtraSpace(sourceItem, side, nRows) {
openExtraSpace: function(sourceItem, side, nRows) {
let children = this._getVisibleChildren();
let index = children.indexOf(sourceItem.actor);
if (index == -1) {
@@ -979,7 +985,7 @@ var PaginatedIconGrid = new Lang.Class({
}
},
_translateChildren(children, direction, nRows) {
_translateChildren: function(children, direction, nRows) {
let translationY = nRows * (this._getVItemSize() + this._getSpacing());
if (translationY == 0)
return;
@@ -994,12 +1000,15 @@ var PaginatedIconGrid = new Lang.Class({
transition: 'easeInOutQuad'
};
if (i == (children.length - 1))
params.onComplete = () => { this.emit('space-opened'); };
params.onComplete = Lang.bind(this,
function() {
this.emit('space-opened');
});
Tweener.addTween(children[i], params);
}
},
closeExtraSpace() {
closeExtraSpace: function() {
if (!this._translatedChildren || !this._translatedChildren.length) {
this.emit('space-closed');
return;
@@ -1012,7 +1021,10 @@ var PaginatedIconGrid = new Lang.Class({
{ translation_y: 0,
time: EXTRA_SPACE_ANIMATION_TIME,
transition: 'easeInOutQuad',
onComplete: () => { this.emit('space-closed'); }
onComplete: Lang.bind(this,
function() {
this.emit('space-closed');
})
});
}
}

View File

@@ -24,7 +24,7 @@ var InhibitShortcutsDialog = new Lang.Class({
'window': GObject.ParamSpec.override('window', Meta.InhibitShortcutsDialog)
},
_init(window) {
_init: function(window) {
this.parent();
this._window = window;
@@ -45,14 +45,14 @@ var InhibitShortcutsDialog = new Lang.Class({
return windowTracker.get_window_app(this._window);
},
_getRestoreAccel() {
_getRestoreAccel: function() {
let settings = new Gio.Settings({ schema_id: WAYLAND_KEYBINDINGS_SCHEMA });
let accel = settings.get_strv('restore-shortcuts')[0] || '';
return Gtk.accelerator_get_label.apply(null,
Gtk.accelerator_parse(accel));
},
_buildLayout() {
_buildLayout: function() {
let name = this._app ? this._app.get_name() : this._window.title;
/* Translators: %s is an application name like "Settings" */
@@ -84,19 +84,19 @@ var InhibitShortcutsDialog = new Lang.Class({
default: true });
},
_emitResponse(response) {
_emitResponse: function(response) {
this.emit('response', response);
this._dialog.close();
},
vfunc_show() {
vfunc_show: function() {
if (this._app && APP_WHITELIST.indexOf(this._app.get_id()) != -1)
this._emitResponse(DialogResponse.ALLOW);
else
this._dialog.open();
},
vfunc_hide() {
vfunc_hide: function() {
this._dialog.close();
}
});

View File

@@ -13,15 +13,15 @@ var KbdA11yDialog = new Lang.Class({
Name: 'KbdA11yDialog',
Extends: GObject.Object,
_init() {
_init: function() {
this._a11ySettings = new Gio.Settings({ schema_id: KEYBOARD_A11Y_SCHEMA });
let deviceManager = Clutter.DeviceManager.get_default();
deviceManager.connect('kbd-a11y-flags-changed',
this._showKbdA11yDialog.bind(this));
Lang.bind(this, this._showKbdA11yDialog));
},
_showKbdA11yDialog(deviceManager, newFlags, whatChanged) {
_showKbdA11yDialog: function(deviceManager, newFlags, whatChanged) {
let dialog = new ModalDialog.ModalDialog();
let title, body;
let key, enabled;

View File

@@ -59,7 +59,7 @@ var KeyContainer = new Lang.Class({
Name: 'KeyContainer',
Extends: St.Widget,
_init() {
_init: function() {
let gridLayout = new Clutter.GridLayout({ orientation: Clutter.Orientation.HORIZONTAL,
column_homogeneous: true,
row_homogeneous: true });
@@ -73,7 +73,7 @@ var KeyContainer = new Lang.Class({
this._rows = [];
},
appendRow(length) {
appendRow: function(length) {
this._currentRow++;
this._currentCol = 0;
@@ -83,7 +83,7 @@ var KeyContainer = new Lang.Class({
this._rows.push(row);
},
appendKey(key, width = 1, height = 1) {
appendKey: function(key, width = 1, height = 1) {
let keyInfo = {
key,
left: this._currentCol,
@@ -100,7 +100,7 @@ var KeyContainer = new Lang.Class({
this._maxCols = Math.max(this._currentCol, this._maxCols);
},
vfunc_allocate(box, flags) {
vfunc_allocate: function(box, flags) {
if (box.get_width() > 0 && box.get_height() > 0 && this._maxCols > 0) {
let keyboardRatio = this._maxCols / this._rows.length;
let sizeRatio = box.get_width() / box.get_height();
@@ -125,7 +125,7 @@ var KeyContainer = new Lang.Class({
this.parent (box, flags);
},
layoutButtons() {
layoutButtons: function() {
let nCol = 0, nRow = 0;
for (let i = 0; i < this._rows.length; i++) {
@@ -158,19 +158,19 @@ var KeyContainer = new Lang.Class({
var Suggestions = new Lang.Class({
Name: 'Suggestions',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ style_class: 'word-suggestions',
vertical: false });
this.actor.show();
},
add(word, callback) {
add: function(word, callback) {
let button = new St.Button({ label: word });
button.connect('clicked', callback);
this.actor.add(button);
},
clear() {
clear: function() {
this.actor.remove_all_children();
},
});
@@ -180,7 +180,7 @@ var LanguageSelectionPopup = new Lang.Class({
Name: 'LanguageSelectionPopup',
Extends: PopupMenu.PopupMenu,
_init(actor) {
_init: function(actor) {
this.parent(actor, 0.5, St.Side.BOTTOM);
let inputSourceManager = InputSourceManager.getInputSourceManager();
@@ -189,27 +189,27 @@ var LanguageSelectionPopup = new Lang.Class({
for (let i in inputSources) {
let is = inputSources[i];
this.addAction(is.displayName, () => {
this.addAction(is.displayName, Lang.bind(this, () => {
inputSourceManager.activateInputSource(is, true);
});
}));
}
this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this.addAction(_("Region & Language Settings"), this._launchSettings.bind(this));
this.addAction(_("Region & Language Settings"), Lang.bind(this, this._launchSettings));
this._capturedEventId = 0;
this._unmapId = actor.connect('notify::mapped', () => {
this._unmapId = actor.connect('notify::mapped', Lang.bind(this, function() {
if (!actor.is_mapped())
this.close(true);
});
}));
},
_launchSettings() {
_launchSettings: function() {
Util.spawn(['gnome-control-center', 'region']);
this.close(true);
},
_onCapturedEvent(actor, event) {
_onCapturedEvent: function(actor, event) {
if (event.get_source() == this.actor ||
this.actor.contains(event.get_source()))
return Clutter.EVENT_PROPAGATE;
@@ -220,13 +220,13 @@ var LanguageSelectionPopup = new Lang.Class({
return Clutter.EVENT_STOP;
},
open(animate) {
open: function(animate) {
this.parent(animate);
this._capturedEventId = global.stage.connect('captured-event',
this._onCapturedEvent.bind(this));
Lang.bind(this, this._onCapturedEvent));
},
close(animate) {
close: function(animate) {
this.parent(animate);
if (this._capturedEventId != 0) {
global.stage.disconnect(this._capturedEventId);
@@ -234,7 +234,7 @@ var LanguageSelectionPopup = new Lang.Class({
}
},
destroy() {
destroy: function() {
if (this._capturedEventId != 0)
global.stage.disconnect(this._capturedEventId);
if (this._unmapId != 0)
@@ -246,7 +246,7 @@ var LanguageSelectionPopup = new Lang.Class({
var Key = new Lang.Class({
Name: 'Key',
_init(key, extendedKeys) {
_init : function(key, extendedKeys) {
this.key = key || "";
this.keyButton = this._makeKey(this.key);
@@ -255,7 +255,7 @@ var Key = new Lang.Class({
*/
this.actor = new St.BoxLayout ({ style_class: 'key-container' });
this.actor.add(this.keyButton, { expand: true, x_fill: true });
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this._extended_keys = extendedKeys;
this._extended_keyboard = null;
@@ -266,14 +266,14 @@ var Key = new Lang.Class({
this._longPress = false;
},
_onDestroy() {
_onDestroy: function() {
if (this._boxPointer) {
this._boxPointer.actor.destroy();
this._boxPointer = null;
}
},
_ensureExtendedKeysPopup() {
_ensureExtendedKeysPopup: function() {
if (this._extended_keys.length == 0)
return;
@@ -291,12 +291,12 @@ var Key = new Lang.Class({
this.keyButton._extended_keys = this._extended_keyboard;
},
_getKeyval(key) {
_getKeyval: function(key) {
let unicode = String.charCodeAt(key, 0);
return Gdk.unicode_to_keyval(unicode);
},
_press(key) {
_press: function(key) {
if (key != this.key || this._extended_keys.length == 0) {
this.emit('pressed', this._getKeyval(key), key);
}
@@ -304,7 +304,7 @@ var Key = new Lang.Class({
if (key == this.key) {
this._pressTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
KEY_LONG_PRESS_TIME,
() => {
Lang.bind(this, function() {
this._longPress = true;
this._pressTimeoutId = 0;
@@ -319,11 +319,11 @@ var Key = new Lang.Class({
}
return GLib.SOURCE_REMOVE;
});
}));
}
},
_release(key) {
_release: function(key) {
if (this._pressTimeoutId != 0) {
GLib.source_remove(this._pressTimeoutId);
this._pressTimeoutId = 0;
@@ -337,7 +337,7 @@ var Key = new Lang.Class({
this._longPress = false;
},
_onCapturedEvent(actor, event) {
_onCapturedEvent: function(actor, event) {
let type = event.type();
let press = (type == Clutter.EventType.BUTTON_PRESS || type == Clutter.EventType.TOUCH_BEGIN);
let release = (type == Clutter.EventType.BUTTON_RELEASE || type == Clutter.EventType.TOUCH_END);
@@ -354,17 +354,17 @@ var Key = new Lang.Class({
return Clutter.EVENT_STOP;
},
_showSubkeys() {
_showSubkeys: function() {
this._boxPointer.show(BoxPointer.PopupAnimation.FULL);
this._capturedEventId = global.stage.connect('captured-event',
this._onCapturedEvent.bind(this));
this._unmapId = this.keyButton.connect('notify::mapped', () => {
Lang.bind(this, this._onCapturedEvent));
this._unmapId = this.keyButton.connect('notify::mapped', Lang.bind(this, function() {
if (!this.keyButton.is_mapped())
this._hideSubkeys();
});
}));
},
_hideSubkeys() {
_hideSubkeys: function() {
if (this._boxPointer)
this._boxPointer.hide(BoxPointer.PopupAnimation.FULL);
if (this._capturedEventId) {
@@ -378,53 +378,56 @@ var Key = new Lang.Class({
this._capturedPress = false;
},
_makeKey(key) {
_makeKey: function (key) {
let label = GLib.markup_escape_text(key, -1);
let button = new St.Button ({ label: label,
style_class: 'keyboard-key' });
button.keyWidth = 1;
button.connect('button-press-event', () => {
this._press(key);
return Clutter.EVENT_PROPAGATE;
});
button.connect('button-release-event', () => {
this._release(key);
return Clutter.EVENT_PROPAGATE;
});
button.connect('touch-event', (actor, event) => {
let device = event.get_device();
let sequence = event.get_event_sequence();
// We only handle touch events here on wayland. On X11
// we do get emulated pointer events, which already works
// for single-touch cases. Besides, the X11 passive touch grab
// set up by Mutter will make us see first the touch events
// and later the pointer events, so it will look like two
// unrelated series of events, we want to avoid double handling
// in these cases.
if (!Meta.is_wayland_compositor())
return Clutter.EVENT_PROPAGATE;
if (!this._touchPressed &&
event.type() == Clutter.EventType.TOUCH_BEGIN) {
device.sequence_grab(sequence, actor);
this._touchPressed = true;
button.connect('button-press-event', Lang.bind(this,
function () {
this._press(key);
} else if (this._touchPressed &&
event.type() == Clutter.EventType.TOUCH_END &&
device.sequence_get_grabbed_actor(sequence) == actor) {
device.sequence_ungrab(sequence);
this._touchPressed = false;
return Clutter.EVENT_PROPAGATE;
}));
button.connect('button-release-event', Lang.bind(this,
function () {
this._release(key);
}
return Clutter.EVENT_PROPAGATE;
});
return Clutter.EVENT_PROPAGATE;
}));
button.connect('touch-event', Lang.bind(this,
function (actor, event) {
let device = event.get_device();
let sequence = event.get_event_sequence();
// We only handle touch events here on wayland. On X11
// we do get emulated pointer events, which already works
// for single-touch cases. Besides, the X11 passive touch grab
// set up by Mutter will make us see first the touch events
// and later the pointer events, so it will look like two
// unrelated series of events, we want to avoid double handling
// in these cases.
if (!Meta.is_wayland_compositor())
return Clutter.EVENT_PROPAGATE;
if (!this._touchPressed &&
event.type() == Clutter.EventType.TOUCH_BEGIN) {
device.sequence_grab(sequence, actor);
this._touchPressed = true;
this._press(key);
} else if (this._touchPressed &&
event.type() == Clutter.EventType.TOUCH_END &&
device.sequence_get_grabbed_actor(sequence) == actor) {
device.sequence_ungrab(sequence);
this._touchPressed = false;
this._release(key);
}
return Clutter.EVENT_PROPAGATE;
}));
return button;
},
_getExtendedKeys() {
_getExtendedKeys: function () {
this._extended_keyboard = new St.BoxLayout({ style_class: 'key-container',
vertical: false });
for (let i = 0; i < this._extended_keys.length; ++i) {
@@ -444,11 +447,11 @@ var Key = new Lang.Class({
return this._boxPointer;
},
setWidth(width) {
setWidth: function (width) {
this.keyButton.keyWidth = width;
},
setLatched(latched) {
setLatched: function (latched) {
if (latched)
this.keyButton.add_style_pseudo_class('latched');
else
@@ -460,7 +463,7 @@ Signals.addSignalMethods(Key.prototype);
var KeyboardModel = new Lang.Class({
Name: 'KeyboardModel',
_init(groupName) {
_init: function (groupName) {
try {
this._model = this._loadModel(groupName);
} catch (e) {
@@ -468,18 +471,18 @@ var KeyboardModel = new Lang.Class({
}
},
_loadModel(groupName) {
_loadModel: function(groupName) {
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/osk-layouts/%s.json'.format(groupName));
let [success, contents] = file.load_contents(null);
return JSON.parse(contents);
},
getLevels() {
getLevels: function() {
return this._model.levels;
},
getKeysForLevel(levelName) {
getKeysForLevel: function(levelName) {
return this._model.levels.find(level => level == levelName);
}
});
@@ -487,13 +490,13 @@ var KeyboardModel = new Lang.Class({
var Keyboard = new Lang.Class({
Name: 'Keyboard',
_init() {
_init: function () {
this.actor = null;
this._focusInExtendedKeys = false;
this._focusCaretTracker = new FocusCaretTracker.FocusCaretTracker();
this._focusCaretTracker.connect('focus-changed', this._onFocusChanged.bind(this));
this._focusCaretTracker.connect('caret-moved', this._onCaretMoved.bind(this));
this._focusCaretTracker.connect('focus-changed', Lang.bind(this, this._onFocusChanged));
this._focusCaretTracker.connect('caret-moved', Lang.bind(this, this._onCaretMoved));
this._languagePopup = null;
this._currentAccessible = null;
this._caretTrackingEnabled = false;
@@ -506,12 +509,12 @@ var Keyboard = new Lang.Class({
this._latched = false; // current level is latched
this._a11yApplicationsSettings = new Gio.Settings({ schema_id: A11Y_APPLICATIONS_SCHEMA });
this._a11yApplicationsSettings.connect('changed', this._syncEnabled.bind(this));
this._a11yApplicationsSettings.connect('changed', Lang.bind(this, this._syncEnabled));
this._lastDeviceId = null;
this._suggestions = null;
Meta.get_backend().connect('last-device-changed',
(backend, deviceId) => {
Meta.get_backend().connect('last-device-changed', Lang.bind(this,
function (backend, deviceId) {
let manager = Clutter.DeviceManager.get_default();
let device = manager.get_device(deviceId);
@@ -519,33 +522,33 @@ var Keyboard = new Lang.Class({
this._lastDeviceId = deviceId;
this._syncEnabled();
}
});
}));
this._syncEnabled();
this._showIdleId = 0;
this._keyboardVisible = false;
Main.layoutManager.connect('keyboard-visible-changed', (o, visible) => {
Main.layoutManager.connect('keyboard-visible-changed', Lang.bind(this, function(o, visible) {
this._keyboardVisible = visible;
});
}));
this._keyboardRequested = false;
this._keyboardRestingId = 0;
Main.layoutManager.connect('monitors-changed', this._relayout.bind(this));
//Main.inputMethod.connect('cursor-location-changed', (o, rect) => {
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout));
//Main.inputMethod.connect('cursor-location-changed', Lang.bind(this, function(o, rect) {
// if (this._keyboardVisible) {
// let currentWindow = global.screen.get_display().focus_window;
// this.setCursorLocation(currentWindow, rect.get_x(), rect.get_y(),
// rect.get_width(), rect.get_height());
// }
//});
//}));
},
get visible() {
return this._keyboardVisible;
},
_setCaretTrackerEnabled(enabled) {
_setCaretTrackerEnabled: function (enabled) {
if (this._caretTrackingEnabled == enabled)
return;
@@ -560,12 +563,12 @@ var Keyboard = new Lang.Class({
}
},
_updateCaretPosition(accessible) {
_updateCaretPosition: function (accessible) {
if (this._updateCaretPositionId)
GLib.source_remove(this._updateCaretPositionId);
if (!this._keyboardRequested)
return;
this._updateCaretPositionId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
this._updateCaretPositionId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, Lang.bind(this, function() {
this._updateCaretPositionId = 0;
let currentWindow = global.screen.get_display().focus_window;
@@ -592,12 +595,12 @@ var Keyboard = new Lang.Class({
}
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._updateCaretPositionId, '[gnome-shell] this._updateCaretPosition');
},
_focusIsTextEntry(accessible) {
_focusIsTextEntry: function (accessible) {
try {
let role = accessible.get_role();
let stateSet = accessible.get_state_set();
@@ -608,7 +611,7 @@ var Keyboard = new Lang.Class({
}
},
_onFocusChanged(caretTracker, event) {
_onFocusChanged: function (caretTracker, event) {
let accessible = event.source;
if (!this._focusIsTextEntry(accessible))
return;
@@ -624,13 +627,13 @@ var Keyboard = new Lang.Class({
}
},
_onCaretMoved(caretTracker, event) {
_onCaretMoved: function (caretTracker, event) {
let accessible = event.source;
if (this._currentAccessible == accessible)
this._updateCaretPosition(accessible);
},
_lastDeviceIsTouchscreen() {
_lastDeviceIsTouchscreen: function () {
if (!this._lastDeviceId)
return false;
@@ -643,7 +646,7 @@ var Keyboard = new Lang.Class({
return device.get_device_type() == Clutter.InputDeviceType.TOUCHSCREEN_DEVICE;
},
_syncEnabled() {
_syncEnabled: function () {
let wasEnabled = this._enabled;
this._enableKeyboard = this._a11yApplicationsSettings.get_boolean(SHOW_KEYBOARD);
this._enabled = this._enableKeyboard || this._lastDeviceIsTouchscreen();
@@ -661,7 +664,7 @@ var Keyboard = new Lang.Class({
Main.layoutManager.hideKeyboard(true);
},
_destroyKeyboard() {
_destroyKeyboard: function() {
if (this._keyboardNotifyId)
this._keyboardController.disconnect(this._keyboardNotifyId);
if (this._keyboardGroupsChangedId)
@@ -680,7 +683,7 @@ var Keyboard = new Lang.Class({
}
},
_setupKeyboard() {
_setupKeyboard: function() {
this.actor = new St.BoxLayout({ name: 'keyboard', vertical: true, reactive: true });
Main.layoutManager.keyboardBox.add_actor(this.actor);
Main.layoutManager.trackChrome(this.actor);
@@ -691,9 +694,9 @@ var Keyboard = new Lang.Class({
this._current_page = null;
this._suggestions = new Suggestions();
this._suggestions.connect('suggestion-clicked', (suggestions, str) => {
this._suggestions.connect('suggestion-clicked', Lang.bind(this, function(suggestions, str) {
this._keyboardController.commitString(str);
});
}));
this.actor.add(this._suggestions.actor,
{ x_align: St.Align.MIDDLE,
x_fill: false });
@@ -706,15 +709,15 @@ var Keyboard = new Lang.Class({
// keyboard on RTL locales.
this.actor.text_direction = Clutter.TextDirection.LTR;
this._keyboardNotifyId = this._keyboardController.connect('active-group', this._onGroupChanged.bind(this));
this._keyboardGroupsChangedId = this._keyboardController.connect('groups-changed', this._onKeyboardGroupsChanged.bind(this));
this._keyboardStateId = this._keyboardController.connect('panel-state', this._onKeyboardStateChanged.bind(this));
this._focusNotifyId = global.stage.connect('notify::key-focus', this._onKeyFocusChanged.bind(this));
this._keyboardNotifyId = this._keyboardController.connect('active-group', Lang.bind(this, this._onGroupChanged));
this._keyboardGroupsChangedId = this._keyboardController.connect('groups-changed', Lang.bind(this, this._onKeyboardGroupsChanged));
this._keyboardStateId = this._keyboardController.connect('panel-state', Lang.bind(this, this._onKeyboardStateChanged));
this._focusNotifyId = global.stage.connect('notify::key-focus', Lang.bind(this, this._onKeyFocusChanged));
this._relayout();
},
_onKeyFocusChanged() {
_onKeyFocusChanged: function () {
let focus = global.stage.key_focus;
// Showing an extended key popup and clicking a key from the extended keys
@@ -731,15 +734,16 @@ var Keyboard = new Lang.Class({
}
if (!this._showIdleId) {
this._showIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
this.show(Main.layoutManager.focusIndex);
return GLib.SOURCE_REMOVE;
});
this._showIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE,
Lang.bind(this, function() {
this.show(Main.layoutManager.focusIndex);
return GLib.SOURCE_REMOVE;
}));
GLib.Source.set_name_by_id(this._showIdleId, '[gnome-shell] this.show');
}
},
_createLayersForGroup(groupName) {
_createLayersForGroup: function (groupName) {
let keyboardModel = new KeyboardModel(groupName);
let layers = {};
let levels = keyboardModel.getLevels();
@@ -764,12 +768,12 @@ var Keyboard = new Lang.Class({
return layers;
},
_ensureKeysForGroup(group) {
_ensureKeysForGroup: function(group) {
if (!this._groups[group])
this._groups[group] = this._createLayersForGroup(group);
},
_addRowKeys(keys, layout) {
_addRowKeys : function (keys, layout) {
for (let i = 0; i < keys.length; ++i) {
let key = keys[i];
let button = new Key(key.shift(), key);
@@ -778,7 +782,7 @@ var Keyboard = new Lang.Class({
if (button.key == ' ')
button.setWidth(keys.length <= 3 ? 5 : 3);
button.connect('pressed', (actor, keyval, str) => {
button.connect('pressed', Lang.bind(this, function(actor, keyval, str) {
if (!Main.inputMethod.currentFocus ||
!this._keyboardController.commitString(str, true)) {
if (keyval != 0) {
@@ -786,8 +790,8 @@ var Keyboard = new Lang.Class({
button._keyvalPress = true;
}
}
});
button.connect('released', (actor, keyval, str) => {
}));
button.connect('released', Lang.bind(this, function(actor, keyval, str) {
if (keyval != 0) {
if (button._keyvalPress)
this._keyboardController.keyvalRelease(keyval);
@@ -796,13 +800,13 @@ var Keyboard = new Lang.Class({
if (!this._latched)
this._setActiveLayer(0);
});
}));
layout.appendKey(button.actor, button.keyButton.keyWidth);
}
},
_popupLanguageMenu(keyActor) {
_popupLanguageMenu: function(keyActor) {
if (this._languagePopup)
this._languagePopup.destroy();
@@ -811,7 +815,7 @@ var Keyboard = new Lang.Class({
this._languagePopup.open(true);
},
_loadDefaultKeys(keys, layout, numLevels, numKeys) {
_loadDefaultKeys: function(keys, layout, numLevels, numKeys) {
let extraButton;
for (let i = 0; i < keys.length; i++) {
let key = keys[i];
@@ -829,7 +833,7 @@ var Keyboard = new Lang.Class({
let actor = extraButton.keyButton;
extraButton.connect('pressed', () => {
extraButton.connect('pressed', Lang.bind(this, function() {
if (switchToLevel != null) {
this._setActiveLayer(switchToLevel);
// Shift only gets latched on long press
@@ -837,23 +841,23 @@ var Keyboard = new Lang.Class({
} else if (keyval != null) {
this._keyboardController.keyvalPress(keyval);
}
});
extraButton.connect('released', () => {
}));
extraButton.connect('released', Lang.bind(this, function() {
if (keyval != null)
this._keyboardController.keyvalRelease(keyval);
else if (action == 'hide')
this.hide();
else if (action == 'languageMenu')
this._popupLanguageMenu(actor);
});
}));
if (switchToLevel == 0) {
layout.shiftKeys.push(extraButton);
} else if (switchToLevel == 1) {
extraButton.connect('long-press', () => {
extraButton.connect('long-press', Lang.bind(this, function() {
this._latched = true;
this._setCurrentLevelLatched(this._current_page, this._latched);
});
}));
}
/* Fixup default keys based on the number of levels/keys */
@@ -876,14 +880,14 @@ var Keyboard = new Lang.Class({
}
},
_setCurrentLevelLatched(layout, latched) {
_setCurrentLevelLatched: function(layout, latched) {
for (let i = 0; layout.shiftKeys[i]; i++) {
let key = layout.shiftKeys[i];
key.setLatched(latched);
}
},
_getDefaultKeysForRow(row, numRows, level) {
_getDefaultKeysForRow: function(row, numRows, level) {
let pre, post;
/* The first 2 rows in defaultKeysPre/Post belong together with
@@ -901,7 +905,7 @@ var Keyboard = new Lang.Class({
}
},
_mergeRowKeys(layout, pre, row, post, numLevels) {
_mergeRowKeys: function (layout, pre, row, post, numLevels) {
if (pre != null)
this._loadDefaultKeys(pre, layout, numLevels, row.length);
@@ -911,7 +915,7 @@ var Keyboard = new Lang.Class({
this._loadDefaultKeys(post, layout, numLevels, row.length);
},
_loadRows(model, level, numLevels, layout) {
_loadRows : function (model, level, numLevels, layout) {
let rows = model.rows;
for (let i = 0; i < rows.length; ++i) {
layout.appendRow();
@@ -920,7 +924,7 @@ var Keyboard = new Lang.Class({
}
},
_getGridSlots() {
_getGridSlots: function() {
let numOfHorizSlots = 0, numOfVertSlots;
let rows = this._current_page.get_children();
numOfVertSlots = rows.length;
@@ -935,7 +939,7 @@ var Keyboard = new Lang.Class({
return [numOfHorizSlots, numOfVertSlots];
},
_relayout() {
_relayout: function () {
if (this.actor == null)
return;
let monitor = Main.layoutManager.keyboardMonitor;
@@ -944,17 +948,17 @@ var Keyboard = new Lang.Class({
this.actor.height = maxHeight;
},
_onGroupChanged() {
_onGroupChanged: function () {
this._ensureKeysForGroup(this._keyboardController.getCurrentGroup());
this._setActiveLayer(0);
},
_onKeyboardGroupsChanged(keyboard) {
_onKeyboardGroupsChanged: function(keyboard) {
this._groups = [];
this._onGroupChanged();
},
_onKeyboardStateChanged(controller, state) {
_onKeyboardStateChanged: function(controller, state) {
let enabled;
if (state == Clutter.InputPanelState.OFF)
enabled = false;
@@ -971,7 +975,7 @@ var Keyboard = new Lang.Class({
this.hide();
},
_setActiveLayer(activeLevel) {
_setActiveLayer: function (activeLevel) {
let activeGroupName = this._keyboardController.getCurrentGroup();
let layers = this._groups[activeGroupName];
@@ -984,20 +988,20 @@ var Keyboard = new Lang.Class({
this._current_page.show();
},
shouldTakeEvent(event) {
shouldTakeEvent: function(event) {
let actor = event.get_source();
return Main.layoutManager.keyboardBox.contains(actor) ||
!!actor._extended_keys || !!actor.extended_key;
},
_clearKeyboardRestTimer() {
_clearKeyboardRestTimer: function() {
if (!this._keyboardRestingId)
return;
GLib.source_remove(this._keyboardRestingId);
this._keyboardRestingId = 0;
},
show(monitor) {
show: function (monitor) {
if (!this._enabled)
return;
@@ -1015,15 +1019,15 @@ var Keyboard = new Lang.Class({
this._clearKeyboardRestTimer();
this._keyboardRestingId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
KEYBOARD_REST_TIME,
() => {
Lang.bind(this, function() {
this._clearKeyboardRestTimer();
this._show(monitor);
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._keyboardRestingId, '[gnome-shell] this._clearKeyboardRestTimer');
},
_show(monitor) {
_show: function(monitor) {
if (!this._keyboardRequested)
return;
@@ -1034,7 +1038,7 @@ var Keyboard = new Lang.Class({
Main.layoutManager.showKeyboard();
},
hide() {
hide: function () {
if (!this._enabled)
return;
@@ -1047,15 +1051,15 @@ var Keyboard = new Lang.Class({
this._clearKeyboardRestTimer();
this._keyboardRestingId = GLib.timeout_add(GLib.PRIORITY_DEFAULT,
KEYBOARD_REST_TIME,
() => {
Lang.bind(this, function() {
this._clearKeyboardRestTimer();
this._hide();
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._keyboardRestingId, '[gnome-shell] this._clearKeyboardRestTimer');
},
_hide() {
_hide: function() {
if (this._keyboardRequested)
return;
@@ -1063,7 +1067,7 @@ var Keyboard = new Lang.Class({
this.setCursorLocation(null);
},
_hideSubkeys() {
_hideSubkeys: function() {
if (this._subkeysBoxPointer) {
this._subkeysBoxPointer.hide(BoxPointer.PopupAnimation.FULL);
this._subkeysBoxPointer = null;
@@ -1075,26 +1079,26 @@ var Keyboard = new Lang.Class({
this._capturedPress = false;
},
resetSuggestions() {
resetSuggestions: function() {
if (this._suggestions)
this._suggestions.clear();
},
addSuggestion(text, callback) {
addSuggestion: function(text, callback) {
if (!this._suggestions)
return;
this._suggestions.add(text, callback);
this._suggestions.actor.show();
},
_clearShowIdle() {
_clearShowIdle: function() {
if (!this._showIdleId)
return;
GLib.source_remove(this._showIdleId);
this._showIdleId = 0;
},
_windowSlideAnimationComplete(window, delta) {
_windowSlideAnimationComplete: function(window, delta) {
// Synchronize window and actor positions again.
let windowActor = window.get_compositor_private();
let frameRect = window.get_frame_rect();
@@ -1102,7 +1106,7 @@ var Keyboard = new Lang.Class({
window.move_frame(true, frameRect.x, frameRect.y);
},
_animateWindow(window, show, deltaY) {
_animateWindow: function(window, show, deltaY) {
let windowActor = window.get_compositor_private();
if (!windowActor)
return;
@@ -1124,7 +1128,7 @@ var Keyboard = new Lang.Class({
}
},
setCursorLocation(window, x, y , w, h) {
setCursorLocation: function(window, x, y , w, h) {
if (window == this._oskFocusWindow)
return;
@@ -1159,45 +1163,41 @@ var Keyboard = new Lang.Class({
var KeyboardController = new Lang.Class({
Name: 'KeyboardController',
_init() {
_init: function () {
this.parent();
let deviceManager = Clutter.DeviceManager.get_default();
this._virtualDevice = deviceManager.create_virtual_device(Clutter.InputDeviceType.KEYBOARD_DEVICE);
this._inputSourceManager = InputSourceManager.getInputSourceManager();
this._sourceChangedId = this._inputSourceManager.connect('current-source-changed',
this._onSourceChanged.bind(this));
Lang.bind(this, this._onSourceChanged));
this._sourcesModifiedId = this._inputSourceManager.connect ('sources-changed',
this._onSourcesModified.bind(this));
Lang.bind(this, this._onSourcesModified));
this._currentSource = this._inputSourceManager.currentSource;
Main.inputMethod.connect('notify::content-purpose',
this._onContentPurposeHintsChanged.bind(this));
Main.inputMethod.connect('notify::content-hints',
this._onContentPurposeHintsChanged.bind(this));
Main.inputMethod.connect('input-panel-state', (o, state) => {
this.emit('panel-state', state);
});
Main.inputMethod.connect('notify::content-purpose', Lang.bind(this, this._onContentPurposeHintsChanged));
Main.inputMethod.connect('notify::content-hints', Lang.bind(this, this._onContentPurposeHintsChanged));
Main.inputMethod.connect('input-panel-state', Lang.bind(this, function(o, state) { this.emit('panel-state', state); }));
},
_onSourcesModified() {
_onSourcesModified: function () {
this.emit('groups-changed');
},
_onSourceChanged(inputSourceManager, oldSource) {
_onSourceChanged: function (inputSourceManager, oldSource) {
let source = inputSourceManager.currentSource;
this._currentSource = source;
this.emit('active-group', source.id);
},
_onContentPurposeHintsChanged(method) {
_onContentPurposeHintsChanged: function(method) {
let hints = method.content_hints;
let purpose = method.content_purpose;
// XXX: hook numeric/emoji/etc special keyboards
},
getGroups() {
getGroups: function () {
let inputSources = this._inputSourceManager.inputSources;
let groups = []
@@ -1209,11 +1209,11 @@ var KeyboardController = new Lang.Class({
return groups;
},
getCurrentGroup() {
getCurrentGroup: function () {
return this._currentSource.xkbId;
},
commitString(string, fromKey) {
commitString: function(string, fromKey) {
if (string == null)
return false;
/* Let ibus methods fall through keyval emission */
@@ -1224,12 +1224,12 @@ var KeyboardController = new Lang.Class({
return true;
},
keyvalPress(keyval) {
keyvalPress: function(keyval) {
this._virtualDevice.notify_keyval(Clutter.get_current_event_time(),
keyval, Clutter.KeyState.PRESSED);
},
keyvalRelease(keyval) {
keyvalRelease: function(keyval) {
this._virtualDevice.notify_keyval(Clutter.get_current_event_time(),
keyval, Clutter.KeyState.RELEASED);
},

View File

@@ -52,7 +52,7 @@ var MonitorConstraint = new Lang.Class({
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
false)},
_init(props) {
_init: function(props) {
this._primary = false;
this._index = -1;
this._workArea = false;
@@ -98,21 +98,19 @@ var MonitorConstraint = new Lang.Class({
this.notify('work-area');
},
vfunc_set_actor(actor) {
vfunc_set_actor: function(actor) {
if (actor) {
if (!this._monitorsChangedId) {
this._monitorsChangedId =
Main.layoutManager.connect('monitors-changed', () => {
this.actor.queue_relayout();
});
this._monitorsChangedId = Main.layoutManager.connect('monitors-changed', Lang.bind(this, function() {
this.actor.queue_relayout();
}));
}
if (!this._workareasChangedId) {
this._workareasChangedId =
global.screen.connect('workareas-changed', () => {
if (this._workArea)
this.actor.queue_relayout();
});
this._workareasChangedId = global.screen.connect('workareas-changed', Lang.bind(this, function() {
if (this._workArea)
this.actor.queue_relayout();
}));
}
} else {
if (this._monitorsChangedId)
@@ -127,7 +125,7 @@ var MonitorConstraint = new Lang.Class({
this.parent(actor);
},
vfunc_update_allocation(actor, actorBox) {
vfunc_update_allocation: function(actor, actorBox) {
if (!this._primary && this._index < 0)
return;
@@ -155,7 +153,7 @@ var MonitorConstraint = new Lang.Class({
var Monitor = new Lang.Class({
Name: 'Monitor',
_init(index, geometry) {
_init: function(index, geometry) {
this.index = index;
this.x = geometry.x;
this.y = geometry.y;
@@ -177,7 +175,7 @@ const defaultParams = {
var LayoutManager = new Lang.Class({
Name: 'LayoutManager',
_init() {
_init: function () {
this._rtl = (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL);
this.monitors = [];
this.primaryMonitor = null;
@@ -203,19 +201,22 @@ var LayoutManager = new Lang.Class({
// Set up stage hierarchy to group all UI actors under one container.
this.uiGroup = new Shell.GenericContainer({ name: 'uiGroup' });
this.uiGroup.connect('allocate', (actor, box, flags) => {
let children = actor.get_children();
for (let i = 0; i < children.length; i++)
children[i].allocate_preferred_size(flags);
});
this.uiGroup.connect('get-preferred-width', (actor, forHeight, alloc) => {
let width = global.stage.width;
[alloc.min_size, alloc.natural_size] = [width, width];
});
this.uiGroup.connect('get-preferred-height', (actor, forWidth, alloc) => {
let height = global.stage.height;
[alloc.min_size, alloc.natural_size] = [height, height];
});
this.uiGroup.connect('allocate',
function (actor, box, flags) {
let children = actor.get_children();
for (let i = 0; i < children.length; i++)
children[i].allocate_preferred_size(flags);
});
this.uiGroup.connect('get-preferred-width',
function(actor, forHeight, alloc) {
let width = global.stage.width;
[alloc.min_size, alloc.natural_size] = [width, width];
});
this.uiGroup.connect('get-preferred-height',
function(actor, forWidth, alloc) {
let height = global.stage.height;
[alloc.min_size, alloc.natural_size] = [height, height];
});
global.stage.remove_actor(global.window_group);
this.uiGroup.add_actor(global.window_group);
@@ -239,7 +240,7 @@ var LayoutManager = new Lang.Class({
this.addChrome(this.panelBox, { affectsStruts: true,
trackFullscreen: true });
this.panelBox.connect('allocation-changed',
this._panelBoxChanged.bind(this));
Lang.bind(this, this._panelBoxChanged));
this.modalDialogGroup = new St.Widget({ name: 'modalDialogGroup',
layout_manager: new Clutter.BinLayout() });
@@ -270,13 +271,13 @@ var LayoutManager = new Lang.Class({
// Need to update struts on new workspaces when they are added
global.screen.connect('notify::n-workspaces',
this._queueUpdateRegions.bind(this));
Lang.bind(this, this._queueUpdateRegions));
global.screen.connect('restacked',
this._windowsRestacked.bind(this));
Lang.bind(this, this._windowsRestacked));
global.screen.connect('monitors-changed',
this._monitorsChanged.bind(this));
Lang.bind(this, this._monitorsChanged));
global.screen.connect('in-fullscreen-changed',
this._updateFullscreen.bind(this));
Lang.bind(this, this._updateFullscreen));
this._monitorsChanged();
// NVIDIA drivers don't preserve FBO contents across
@@ -284,41 +285,41 @@ var LayoutManager = new Lang.Class({
// https://bugzilla.gnome.org/show_bug.cgi?id=739178
if (Shell.util_need_background_refresh()) {
LoginManager.getLoginManager().connect('prepare-for-sleep',
(lm, suspending) => {
if (suspending)
return;
Meta.Background.refresh_all();
});
function(lm, suspending) {
if (suspending)
return;
Meta.Background.refresh_all();
});
}
},
// This is called by Main after everything else is constructed
init() {
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
init: function() {
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
this._loadBackground();
},
showOverview() {
showOverview: function() {
this.overviewGroup.show();
this._inOverview = true;
this._updateVisibility();
},
hideOverview() {
hideOverview: function() {
this.overviewGroup.hide();
this._inOverview = false;
this._updateVisibility();
},
_sessionUpdated() {
_sessionUpdated: function() {
this._updateVisibility();
this._queueUpdateRegions();
},
_updateMonitors() {
_updateMonitors: function() {
let screen = global.screen;
this.monitors = [];
@@ -356,9 +357,9 @@ var LayoutManager = new Lang.Class({
}
},
_updateHotCorners() {
_updateHotCorners: function() {
// destroy old hot corners
this.hotCorners.forEach(corner => {
this.hotCorners.forEach(function(corner) {
if (corner)
corner.destroy();
});
@@ -415,22 +416,22 @@ var LayoutManager = new Lang.Class({
this.emit('hot-corners-changed');
},
_addBackgroundMenu(bgManager) {
_addBackgroundMenu: function(bgManager) {
BackgroundMenu.addBackgroundMenu(bgManager.backgroundActor, this);
},
_createBackgroundManager(monitorIndex) {
_createBackgroundManager: function(monitorIndex) {
let bgManager = new Background.BackgroundManager({ container: this._backgroundGroup,
layoutManager: this,
monitorIndex: monitorIndex });
bgManager.connect('changed', this._addBackgroundMenu.bind(this));
bgManager.connect('changed', Lang.bind(this, this._addBackgroundMenu));
this._addBackgroundMenu(bgManager);
return bgManager;
},
_showSecondaryBackgrounds() {
_showSecondaryBackgrounds: function() {
for (let i = 0; i < this.monitors.length; i++) {
if (i != this.primaryIndex) {
let backgroundActor = this._bgManagers[i].backgroundActor;
@@ -444,7 +445,7 @@ var LayoutManager = new Lang.Class({
}
},
_updateBackgrounds() {
_updateBackgrounds: function() {
let i;
for (i = 0; i < this._bgManagers.length; i++)
this._bgManagers[i].destroy();
@@ -463,13 +464,13 @@ var LayoutManager = new Lang.Class({
}
},
_updateKeyboardBox() {
_updateKeyboardBox: function() {
this.keyboardBox.set_position(this.keyboardMonitor.x,
this.keyboardMonitor.y + this.keyboardMonitor.height);
this.keyboardBox.set_size(this.keyboardMonitor.width, -1);
},
_updateBoxes() {
_updateBoxes: function() {
this.screenShieldGroup.set_position(0, 0);
this.screenShieldGroup.set_size(global.screen_width, global.screen_height);
@@ -482,17 +483,17 @@ var LayoutManager = new Lang.Class({
this.keyboardIndex = this.primaryIndex;
},
_panelBoxChanged() {
_panelBoxChanged: function() {
this._updatePanelBarrier();
let size = this.panelBox.height;
this.hotCorners.forEach(corner => {
this.hotCorners.forEach(function(corner) {
if (corner)
corner.setBarrierSize(size);
});
},
_updatePanelBarrier() {
_updatePanelBarrier: function() {
if (this._rightPanelBarrier) {
this._rightPanelBarrier.destroy();
this._rightPanelBarrier = null;
@@ -511,7 +512,7 @@ var LayoutManager = new Lang.Class({
}
},
_monitorsChanged() {
_monitorsChanged: function() {
this._updateMonitors();
this._updateBoxes();
this._updateHotCorners();
@@ -523,7 +524,7 @@ var LayoutManager = new Lang.Class({
this.emit('monitors-changed');
},
_isAboveOrBelowPrimary(monitor) {
_isAboveOrBelowPrimary: function(monitor) {
let primary = this.monitors[this.primaryIndex];
let monitorLeft = monitor.x, monitorRight = monitor.x + monitor.width;
let primaryLeft = primary.x, primaryRight = primary.x + primary.width;
@@ -569,7 +570,7 @@ var LayoutManager = new Lang.Class({
return this._keyboardIndex;
},
_loadBackground() {
_loadBackground: function() {
if (!this.primaryMonitor) {
this._pendingLoadBackground = true;
return;
@@ -583,13 +584,13 @@ var LayoutManager = new Lang.Class({
coordinate: Clutter.BindCoordinate.ALL });
this._systemBackground.actor.add_constraint(constraint);
let signalId = this._systemBackground.connect('loaded', () => {
let signalId = this._systemBackground.connect('loaded', Lang.bind(this, function() {
this._systemBackground.disconnect(signalId);
this._systemBackground.actor.show();
global.stage.show();
this._prepareStartupAnimation();
});
}));
},
// Startup Animations
@@ -607,7 +608,7 @@ var LayoutManager = new Lang.Class({
// When starting a normal user session, we want to grow it out of the middle
// of the screen.
_prepareStartupAnimation() {
_prepareStartupAnimation: function() {
// During the initial transition, add a simple actor to block all events,
// so they don't get delivered to X11 windows that have been transformed.
this._coverPane = new Clutter.Actor({ opacity: 0,
@@ -651,14 +652,14 @@ var LayoutManager = new Lang.Class({
// until the event loop is uncontended and idle.
// This helps to prevent us from running the animation
// when the system is bogged down
let id = GLib.idle_add(GLib.PRIORITY_LOW, () => {
let id = GLib.idle_add(GLib.PRIORITY_LOW, Lang.bind(this, function() {
this._startupAnimation();
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(id, '[gnome-shell] this._startupAnimation');
},
_startupAnimation() {
_startupAnimation: function() {
if (Meta.is_restart())
this._startupAnimationComplete();
else if (Main.sessionMode.isGreeter)
@@ -667,7 +668,7 @@ var LayoutManager = new Lang.Class({
this._startupAnimationSession();
},
_startupAnimationGreeter() {
_startupAnimationGreeter: function() {
Tweener.addTween(this.panelBox,
{ translation_y: 0,
time: STARTUP_ANIMATION_TIME,
@@ -676,7 +677,7 @@ var LayoutManager = new Lang.Class({
onCompleteScope: this });
},
_startupAnimationSession() {
_startupAnimationSession: function() {
Tweener.addTween(this.uiGroup,
{ scale_x: 1,
scale_y: 1,
@@ -687,7 +688,7 @@ var LayoutManager = new Lang.Class({
onCompleteScope: this });
},
_startupAnimationComplete() {
_startupAnimationComplete: function() {
this._coverPane.destroy();
this._coverPane = null;
@@ -708,7 +709,7 @@ var LayoutManager = new Lang.Class({
this.emit('startup-complete');
},
showKeyboard() {
showKeyboard: function () {
this.keyboardBox.show();
Tweener.addTween(this.keyboardBox,
{ anchor_y: this.keyboardBox.height,
@@ -721,17 +722,17 @@ var LayoutManager = new Lang.Class({
this.emit('keyboard-visible-changed', true);
},
_showKeyboardComplete() {
_showKeyboardComplete: function() {
// Poke Chrome to update the input shape; it doesn't notice
// anchor point changes
this._updateRegions();
this._keyboardHeightNotifyId = this.keyboardBox.connect('notify::height', () => {
this._keyboardHeightNotifyId = this.keyboardBox.connect('notify::height', Lang.bind(this, function () {
this.keyboardBox.anchor_y = this.keyboardBox.height;
});
}));
},
hideKeyboard(immediate) {
hideKeyboard: function (immediate) {
if (this._keyboardHeightNotifyId) {
this.keyboardBox.disconnect(this._keyboardHeightNotifyId);
this._keyboardHeightNotifyId = 0;
@@ -748,7 +749,7 @@ var LayoutManager = new Lang.Class({
this.emit('keyboard-visible-changed', false);
},
_hideKeyboardComplete() {
_hideKeyboardComplete: function() {
this.keyboardBox.hide();
this._updateRegions();
},
@@ -763,7 +764,7 @@ var LayoutManager = new Lang.Class({
// the actual mouse pointer as it moves, you need to call this
// function before you show the menu to ensure it is at the right
// position and has the right size.
setDummyCursorGeometry(x, y, w, h) {
setDummyCursorGeometry: function(x, y, w, h) {
this.dummyCursor.set_position(Math.round(x), Math.round(y));
this.dummyCursor.set_size(Math.round(w), Math.round(h));
},
@@ -787,7 +788,7 @@ var LayoutManager = new Lang.Class({
// will be bound to the presence of fullscreen windows on the same
// monitor (it will be hidden whenever a fullscreen window is visible,
// and shown otherwise)
addChrome(actor, params) {
addChrome: function(actor, params) {
this.uiGroup.add_actor(actor);
if (this.uiGroup.contains(global.top_window_group))
this.uiGroup.set_child_below_sibling(actor, global.top_window_group);
@@ -804,7 +805,7 @@ var LayoutManager = new Lang.Class({
// @params can have any of the same values as in addChrome(),
// though some possibilities don't make sense. By default, @actor has
// the same params as its chrome ancestor.
trackChrome(actor, params) {
trackChrome: function(actor, params) {
let ancestor = actor.get_parent();
let index = this._findActor(ancestor);
while (ancestor && index == -1) {
@@ -830,7 +831,7 @@ var LayoutManager = new Lang.Class({
// @actor: an actor previously tracked via trackChrome()
//
// Undoes the effect of trackChrome()
untrackChrome(actor) {
untrackChrome: function(actor) {
this._untrackActor(actor);
},
@@ -838,12 +839,12 @@ var LayoutManager = new Lang.Class({
// @actor: a chrome actor
//
// Removes @actor from the chrome
removeChrome(actor) {
removeChrome: function(actor) {
this.uiGroup.remove_actor(actor);
this._untrackActor(actor);
},
_findActor(actor) {
_findActor: function(actor) {
for (let i = 0; i < this._trackedActors.length; i++) {
let actorData = this._trackedActors[i];
if (actorData.actor == actor)
@@ -852,18 +853,18 @@ var LayoutManager = new Lang.Class({
return -1;
},
_trackActor(actor, params) {
_trackActor: function(actor, params) {
if (this._findActor(actor) != -1)
throw new Error('trying to re-track existing chrome actor');
let actorData = Params.parse(params, defaultParams);
actorData.actor = actor;
actorData.visibleId = actor.connect('notify::visible',
this._queueUpdateRegions.bind(this));
Lang.bind(this, this._queueUpdateRegions));
actorData.allocationId = actor.connect('notify::allocation',
this._queueUpdateRegions.bind(this));
Lang.bind(this, this._queueUpdateRegions));
actorData.destroyId = actor.connect('destroy',
this._untrackActor.bind(this));
Lang.bind(this, this._untrackActor));
// Note that destroying actor will unset its parent, so we don't
// need to connect to 'destroy' too.
@@ -872,7 +873,7 @@ var LayoutManager = new Lang.Class({
this._queueUpdateRegions();
},
_untrackActor(actor) {
_untrackActor: function(actor) {
let i = this._findActor(actor);
if (i == -1)
@@ -887,7 +888,7 @@ var LayoutManager = new Lang.Class({
this._queueUpdateRegions();
},
_updateActorVisibility(actorData) {
_updateActorVisibility: function(actorData) {
if (!actorData.trackFullscreen)
return;
@@ -897,16 +898,16 @@ var LayoutManager = new Lang.Class({
monitor.inFullscreen);
},
_updateVisibility() {
_updateVisibility: function() {
let windowsVisible = Main.sessionMode.hasWindows && !this._inOverview;
global.window_group.visible = windowsVisible;
global.top_window_group.visible = windowsVisible;
this._trackedActors.forEach(this._updateActorVisibility.bind(this));
this._trackedActors.forEach(Lang.bind(this, this._updateActorVisibility));
},
getWorkAreaForMonitor(monitorIndex) {
getWorkAreaForMonitor: function(monitorIndex) {
// Assume that all workspaces will have the same
// struts and pick the first one.
let ws = global.screen.get_workspace_by_index(0);
@@ -915,42 +916,42 @@ var LayoutManager = new Lang.Class({
// This call guarantees that we return some monitor to simplify usage of it
// In practice all tracked actors should be visible on some monitor anyway
findIndexForActor(actor) {
findIndexForActor: function(actor) {
let [x, y] = actor.get_transformed_position();
let [w, h] = actor.get_transformed_size();
let rect = new Meta.Rectangle({ x: x, y: y, width: w, height: h });
return global.screen.get_monitor_index_for_rect(rect);
},
findMonitorForActor(actor) {
findMonitorForActor: function(actor) {
let index = this.findIndexForActor(actor);
if (index >= 0 && index < this.monitors.length)
return this.monitors[index];
return null;
},
_queueUpdateRegions() {
_queueUpdateRegions: function() {
if (this._startingUp)
return;
if (!this._updateRegionIdle)
this._updateRegionIdle = Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
this._updateRegions.bind(this));
Lang.bind(this, this._updateRegions));
},
_getWindowActorsForWorkspace(workspace) {
return global.get_window_actors().filter(actor => {
_getWindowActorsForWorkspace: function(workspace) {
return global.get_window_actors().filter(function (actor) {
let win = actor.meta_window;
return win.located_on_workspace(workspace);
});
},
_updateFullscreen() {
_updateFullscreen: function() {
this._updateVisibility();
this._queueUpdateRegions();
},
_windowsRestacked() {
_windowsRestacked: function() {
let changed = false;
if (this._isPopupWindowVisible != global.top_window_group.get_children().some(isPopupMetaWindow))
@@ -962,7 +963,7 @@ var LayoutManager = new Lang.Class({
}
},
_updateRegions() {
_updateRegions: function() {
if (this._updateRegionIdle) {
Meta.later_remove(this._updateRegionIdle);
delete this._updateRegionIdle;
@@ -1061,7 +1062,7 @@ var LayoutManager = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
modalEnded() {
modalEnded: function() {
// We don't update the stage input region while in a modal,
// so queue an update now.
this._queueUpdateRegions();
@@ -1077,7 +1078,7 @@ Signals.addSignalMethods(LayoutManager.prototype);
var HotCorner = new Lang.Class({
Name: 'HotCorner',
_init(layoutManager, monitor, x, y) {
_init : function(layoutManager, monitor, x, y) {
// We use this flag to mark the case where the user has entered the
// hot corner and has not left both the hot corner and a surrounding
// guard area (the "environs"). This avoids triggering the hot corner
@@ -1095,7 +1096,7 @@ var HotCorner = new Lang.Class({
HOT_CORNER_PRESSURE_TIMEOUT,
Shell.ActionMode.NORMAL |
Shell.ActionMode.OVERVIEW);
this._pressureBarrier.connect('trigger', this._toggleOverview.bind(this));
this._pressureBarrier.connect('trigger', Lang.bind(this, this._toggleOverview));
// Cache the three ripples instead of dynamically creating and destroying them.
this._ripple1 = new St.BoxLayout({ style_class: 'ripple-box', opacity: 0, visible: false });
@@ -1107,7 +1108,7 @@ var HotCorner = new Lang.Class({
layoutManager.uiGroup.add_actor(this._ripple3);
},
setBarrierSize(size) {
setBarrierSize: function(size) {
if (this._verticalBarrier) {
this._pressureBarrier.removeBarrier(this._verticalBarrier);
this._verticalBarrier.destroy();
@@ -1142,7 +1143,7 @@ var HotCorner = new Lang.Class({
}
},
_setupFallbackCornerIfNeeded(layoutManager) {
_setupFallbackCornerIfNeeded: function(layoutManager) {
if (!global.display.supports_extended_barriers()) {
this.actor = new Clutter.Actor({ name: 'hot-corner-environs',
x: this._x, y: this._y,
@@ -1168,16 +1169,16 @@ var HotCorner = new Lang.Class({
}
this.actor.connect('leave-event',
this._onEnvironsLeft.bind(this));
Lang.bind(this, this._onEnvironsLeft));
this._corner.connect('enter-event',
this._onCornerEntered.bind(this));
Lang.bind(this, this._onCornerEntered));
this._corner.connect('leave-event',
this._onCornerLeft.bind(this));
Lang.bind(this, this._onCornerLeft));
}
},
destroy() {
destroy: function() {
this.setBarrierSize(0);
this._pressureBarrier.destroy();
this._pressureBarrier = null;
@@ -1186,7 +1187,7 @@ var HotCorner = new Lang.Class({
this.actor.destroy();
},
_animRipple(ripple, delay, time, startScale, startOpacity, finalScale) {
_animRipple : function(ripple, delay, time, startScale, startOpacity, finalScale) {
// We draw a ripple by using a source image and animating it scaling
// outwards and fading away. We want the ripples to move linearly
// or it looks unrealistic, but if the opacity of the ripple goes
@@ -1212,11 +1213,11 @@ var HotCorner = new Lang.Class({
delay: delay,
time: time,
transition: 'linear',
onUpdate() { ripple.opacity = 255 * Math.sqrt(ripple._opacity); },
onComplete() { ripple.visible = false; } });
onUpdate: function() { ripple.opacity = 255 * Math.sqrt(ripple._opacity); },
onComplete: function() { ripple.visible = false; } });
},
_rippleAnimation() {
_rippleAnimation: function() {
// Show three concentric ripples expanding outwards; the exact
// parameters were found by trial and error, so don't look
// for them to make perfect sense mathematically
@@ -1227,7 +1228,7 @@ var HotCorner = new Lang.Class({
this._animRipple(this._ripple3, 0.35, 1.0, 0.0, 0.3, 1);
},
_toggleOverview() {
_toggleOverview: function() {
if (this._monitor.inFullscreen)
return;
@@ -1237,7 +1238,7 @@ var HotCorner = new Lang.Class({
}
},
handleDragOver(source, actor, x, y, time) {
handleDragOver: function(source, actor, x, y, time) {
if (source != Main.xdndHandler)
return DND.DragMotionResult.CONTINUE;
@@ -1246,7 +1247,7 @@ var HotCorner = new Lang.Class({
return DND.DragMotionResult.CONTINUE;
},
_onCornerEntered() {
_onCornerEntered : function() {
if (!this._entered) {
this._entered = true;
this._toggleOverview();
@@ -1254,14 +1255,14 @@ var HotCorner = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onCornerLeft(actor, event) {
_onCornerLeft : function(actor, event) {
if (event.get_related() != this.actor)
this._entered = false;
// Consume event, otherwise this will confuse onEnvironsLeft
return Clutter.EVENT_STOP;
},
_onEnvironsLeft(actor, event) {
_onEnvironsLeft : function(actor, event) {
if (event.get_related() != this._corner)
this._entered = false;
return Clutter.EVENT_PROPAGATE;
@@ -1271,7 +1272,7 @@ var HotCorner = new Lang.Class({
var PressureBarrier = new Lang.Class({
Name: 'PressureBarrier',
_init(threshold, timeout, actionMode) {
_init: function(threshold, timeout, actionMode) {
this._threshold = threshold;
this._timeout = timeout;
this._actionMode = actionMode;
@@ -1282,57 +1283,57 @@ var PressureBarrier = new Lang.Class({
this._reset();
},
addBarrier(barrier) {
barrier._pressureHitId = barrier.connect('hit', this._onBarrierHit.bind(this));
barrier._pressureLeftId = barrier.connect('left', this._onBarrierLeft.bind(this));
addBarrier: function(barrier) {
barrier._pressureHitId = barrier.connect('hit', Lang.bind(this, this._onBarrierHit));
barrier._pressureLeftId = barrier.connect('left', Lang.bind(this, this._onBarrierLeft));
this._barriers.push(barrier);
},
_disconnectBarrier(barrier) {
_disconnectBarrier: function(barrier) {
barrier.disconnect(barrier._pressureHitId);
barrier.disconnect(barrier._pressureLeftId);
},
removeBarrier(barrier) {
removeBarrier: function(barrier) {
this._disconnectBarrier(barrier);
this._barriers.splice(this._barriers.indexOf(barrier), 1);
},
destroy() {
this._barriers.forEach(this._disconnectBarrier.bind(this));
destroy: function() {
this._barriers.forEach(Lang.bind(this, this._disconnectBarrier));
this._barriers = [];
},
setEventFilter(filter) {
setEventFilter: function(filter) {
this._eventFilter = filter;
},
_reset() {
_reset: function() {
this._barrierEvents = [];
this._currentPressure = 0;
this._lastTime = 0;
},
_isHorizontal(barrier) {
_isHorizontal: function(barrier) {
return barrier.y1 == barrier.y2;
},
_getDistanceAcrossBarrier(barrier, event) {
_getDistanceAcrossBarrier: function(barrier, event) {
if (this._isHorizontal(barrier))
return Math.abs(event.dy);
else
return Math.abs(event.dx);
},
_getDistanceAlongBarrier(barrier, event) {
_getDistanceAlongBarrier: function(barrier, event) {
if (this._isHorizontal(barrier))
return Math.abs(event.dx);
else
return Math.abs(event.dy);
},
_trimBarrierEvents() {
_trimBarrierEvents: function() {
// Events are guaranteed to be sorted in time order from
// oldest to newest, so just look for the first old event,
// and then chop events after that off.
@@ -1356,21 +1357,21 @@ var PressureBarrier = new Lang.Class({
this._barrierEvents = this._barrierEvents.slice(firstNewEvent);
},
_onBarrierLeft(barrier, event) {
_onBarrierLeft: function(barrier, event) {
barrier._isHit = false;
if (this._barriers.every(b => !b._isHit)) {
if (this._barriers.every(function(b) { return !b._isHit; })) {
this._reset();
this._isTriggered = false;
}
},
_trigger() {
_trigger: function() {
this._isTriggered = true;
this.emit('trigger');
this._reset();
},
_onBarrierHit(barrier, event) {
_onBarrierHit: function(barrier, event) {
barrier._isHit = true;
// If we've triggered the barrier, wait until the pointer has the

View File

@@ -31,7 +31,7 @@ var RadialShaderQuad = new Lang.Class({
Name: 'RadialShaderQuad',
Extends: Shell.GLSLQuad,
_init(params) {
_init: function(params) {
this.parent(params);
this._brightnessLocation = this.get_uniform_location('brightness');
@@ -41,7 +41,7 @@ var RadialShaderQuad = new Lang.Class({
this.vignetteSharpness = 0.0;
},
vfunc_build_pipeline() {
vfunc_build_pipeline: function() {
this.add_glsl_snippet(Shell.SnippetHook.FRAGMENT,
VIGNETTE_DECLARATIONS, VIGNETTE_CODE, true);
},
@@ -94,7 +94,7 @@ var RadialShaderQuad = new Lang.Class({
var Lightbox = new Lang.Class({
Name: 'Lightbox',
_init(container, params) {
_init : function(container, params) {
params = Params.parse(params, { inhibitEvents: false,
width: null,
height: null,
@@ -122,7 +122,7 @@ var Lightbox = new Lang.Class({
this.actor.hide();
this.shown = false;
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
if (params.width && params.height) {
this.actor.width = params.width;
@@ -133,13 +133,13 @@ var Lightbox = new Lang.Class({
this.actor.add_constraint(constraint);
}
this._actorAddedSignalId = container.connect('actor-added', this._actorAdded.bind(this));
this._actorRemovedSignalId = container.connect('actor-removed', this._actorRemoved.bind(this));
this._actorAddedSignalId = container.connect('actor-added', Lang.bind(this, this._actorAdded));
this._actorRemovedSignalId = container.connect('actor-removed', Lang.bind(this, this._actorRemoved));
this._highlighted = null;
},
_actorAdded(container, newChild) {
_actorAdded : function(container, newChild) {
let children = this._container.get_children();
let myIndex = children.indexOf(this.actor);
let newChildIndex = children.indexOf(newChild);
@@ -161,7 +161,7 @@ var Lightbox = new Lang.Class({
}
},
show(fadeInTime) {
show: function(fadeInTime) {
fadeInTime = fadeInTime || 0;
Tweener.removeTweens(this.actor);
@@ -171,27 +171,27 @@ var Lightbox = new Lang.Class({
vignetteSharpness: VIGNETTE_SHARPNESS,
time: fadeInTime,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this.shown = true;
this.emit('shown');
}
})
});
} else {
Tweener.addTween(this.actor,
{ opacity: 255 * this._fadeFactor,
time: fadeInTime,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this.shown = true;
this.emit('shown');
}
})
});
}
this.actor.show();
},
hide(fadeOutTime) {
hide: function(fadeOutTime) {
fadeOutTime = fadeOutTime || 0;
this.shown = false;
@@ -203,23 +203,23 @@ var Lightbox = new Lang.Class({
opacity: 0,
time: fadeOutTime,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this.actor.hide();
}
})
});
} else {
Tweener.addTween(this.actor,
{ opacity: 0,
time: fadeOutTime,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this.actor.hide();
}
})
});
}
},
_actorRemoved(container, child) {
_actorRemoved : function(container, child) {
let index = this._children.indexOf(child);
if (index != -1) // paranoia
this._children.splice(index, 1);
@@ -236,7 +236,7 @@ var Lightbox = new Lang.Class({
* currently-highlighted actor. With no arguments or a false/null
* argument, all actors will be unhighlighted.
*/
highlight(window) {
highlight : function(window) {
if (this._highlighted == window)
return;
@@ -264,7 +264,7 @@ var Lightbox = new Lang.Class({
*
* Destroys the lightbox.
*/
destroy() {
destroy : function() {
this.actor.destroy();
},
@@ -274,7 +274,7 @@ var Lightbox = new Lang.Class({
* This is called when the lightbox' actor is destroyed, either
* by destroying its container or by explicitly calling this.destroy().
*/
_onDestroy() {
_onDestroy: function() {
this._container.disconnect(this._actorAddedSignalId);
this._container.disconnect(this._actorRemovedSignalId);

View File

@@ -40,9 +40,9 @@ var commandHeader = 'const Clutter = imports.gi.Clutter; ' +
* in the shell core code too. */
'const stage = global.stage; ' +
/* Special lookingGlass functions */
'const inspect = Main.lookingGlass.inspect.bind(Main.lookingGlass); ' +
'const inspect = Lang.bind(Main.lookingGlass, Main.lookingGlass.inspect); ' +
'const it = Main.lookingGlass.getIt(); ' +
'const r = Main.lookingGlass.getResult.bind(Main.lookingGlass); ';
'const r = Lang.bind(Main.lookingGlass, Main.lookingGlass.getResult); ';
const HISTORY_KEY = 'looking-glass-history';
// Time between tabs for them to count as a double-tab event
@@ -53,9 +53,7 @@ var AUTO_COMPLETE_GLOBAL_KEYWORDS = _getAutoCompleteGlobalKeywords();
function _getAutoCompleteGlobalKeywords() {
const keywords = ['true', 'false', 'null', 'new'];
// Don't add the private properties of window (i.e., ones starting with '_')
const windowProperties = Object.getOwnPropertyNames(window).filter(
a => a.charAt(0) != '_'
);
const windowProperties = Object.getOwnPropertyNames(window).filter(function(a){ return a.charAt(0) != '_' });
const headerProperties = JsParse.getDeclaredConstants(commandHeader);
return keywords.concat(windowProperties).concat(headerProperties);
@@ -64,13 +62,13 @@ function _getAutoCompleteGlobalKeywords() {
var AutoComplete = new Lang.Class({
Name: 'AutoComplete',
_init(entry) {
_init: function(entry) {
this._entry = entry;
this._entry.connect('key-press-event', this._entryKeyPressEvent.bind(this));
this._entry.connect('key-press-event', Lang.bind(this, this._entryKeyPressEvent));
this._lastTabTime = global.get_current_time();
},
_processCompletionRequest(event) {
_processCompletionRequest: function(event) {
if (event.completions.length == 0) {
return;
}
@@ -92,7 +90,7 @@ var AutoComplete = new Lang.Class({
}
},
_entryKeyPressEvent(actor, event) {
_entryKeyPressEvent: function(actor, event) {
let cursorPos = this._entry.clutter_text.get_cursor_position();
let text = this._entry.get_text();
if (cursorPos != -1) {
@@ -117,7 +115,7 @@ var AutoComplete = new Lang.Class({
// Insert characters of text not already included in head at cursor position. i.e., if text="abc" and head="a",
// the string "bc" will be appended to this._entry
additionalCompletionText(text, head) {
additionalCompletionText: function(text, head) {
let additionalCompletionText = text.slice(head.length);
let cursorPos = this._entry.clutter_text.get_cursor_position();
@@ -130,7 +128,7 @@ Signals.addSignalMethods(AutoComplete.prototype);
var Notebook = new Lang.Class({
Name: 'Notebook',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ vertical: true });
this.tabControls = new St.BoxLayout({ style_class: 'labels' });
@@ -139,15 +137,15 @@ var Notebook = new Lang.Class({
this._tabs = [];
},
appendPage(name, child) {
appendPage: function(name, child) {
let labelBox = new St.BoxLayout({ style_class: 'notebook-tab',
reactive: true,
track_hover: true });
let label = new St.Button({ label: name });
label.connect('clicked', () => {
label.connect('clicked', Lang.bind(this, function () {
this.selectChild(child);
return true;
});
}));
labelBox.add(label, { expand: true });
this.tabControls.add(labelBox);
@@ -165,14 +163,14 @@ var Notebook = new Lang.Class({
this.actor.add(scrollview, { expand: true });
let vAdjust = scrollview.vscroll.adjustment;
vAdjust.connect('changed', () => { this._onAdjustScopeChanged(tabData); });
vAdjust.connect('notify::value', () => { this._onAdjustValueChanged(tabData); });
vAdjust.connect('changed', Lang.bind(this, function () { this._onAdjustScopeChanged(tabData); }));
vAdjust.connect('notify::value', Lang.bind(this, function() { this._onAdjustValueChanged(tabData); }));
if (this._selectedIndex == -1)
this.selectIndex(0);
},
_unselect() {
_unselect: function() {
if (this._selectedIndex < 0)
return;
let tabData = this._tabs[this._selectedIndex];
@@ -181,7 +179,7 @@ var Notebook = new Lang.Class({
this._selectedIndex = -1;
},
selectIndex(index) {
selectIndex: function(index) {
if (index == this._selectedIndex)
return;
if (index < 0) {
@@ -203,7 +201,7 @@ var Notebook = new Lang.Class({
this.emit('selection', tabData.child);
},
selectChild(child) {
selectChild: function(child) {
if (child == null)
this.selectIndex(-1);
else {
@@ -217,26 +215,26 @@ var Notebook = new Lang.Class({
}
},
scrollToBottom(index) {
scrollToBottom: function(index) {
let tabData = this._tabs[index];
tabData._scrollToBottom = true;
},
_onAdjustValueChanged(tabData) {
_onAdjustValueChanged: function (tabData) {
let vAdjust = tabData.scrollView.vscroll.adjustment;
if (vAdjust.value < (vAdjust.upper - vAdjust.lower - 0.5))
tabData._scrolltoBottom = false;
},
_onAdjustScopeChanged(tabData) {
_onAdjustScopeChanged: function (tabData) {
if (!tabData._scrollToBottom)
return;
let vAdjust = tabData.scrollView.vscroll.adjustment;
vAdjust.value = vAdjust.upper - vAdjust.page_size;
},
nextTab() {
nextTab: function() {
let nextIndex = this._selectedIndex;
if (nextIndex < this._tabs.length - 1) {
++nextIndex;
@@ -245,7 +243,7 @@ var Notebook = new Lang.Class({
this.selectIndex(nextIndex);
},
prevTab() {
prevTab: function() {
let prevIndex = this._selectedIndex;
if (prevIndex > 0) {
--prevIndex;
@@ -268,7 +266,7 @@ function objectToString(o) {
var ObjLink = new Lang.Class({
Name: 'ObjLink',
_init(lookingGlass, o, title) {
_init: function(lookingGlass, o, title) {
let text;
if (title)
text = title;
@@ -282,12 +280,12 @@ var ObjLink = new Lang.Class({
style_class: 'shell-link',
label: text });
this.actor.get_child().single_line_mode = true;
this.actor.connect('clicked', this._onClicked.bind(this));
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
this._lookingGlass = lookingGlass;
},
_onClicked(link) {
_onClicked: function (link) {
this._lookingGlass.inspectObject(this._obj, this.actor);
}
});
@@ -295,7 +293,7 @@ var ObjLink = new Lang.Class({
var Result = new Lang.Class({
Name: 'Result',
_init(lookingGlass, command, o, index) {
_init: function(lookingGlass, command, o, index) {
this.index = index;
this.o = o;
@@ -318,17 +316,17 @@ var Result = new Lang.Class({
var WindowList = new Lang.Class({
Name: 'WindowList',
_init(lookingGlass) {
_init: function(lookingGlass) {
this.actor = new St.BoxLayout({ name: 'Windows', vertical: true, style: 'spacing: 8px' });
let tracker = Shell.WindowTracker.get_default();
this._updateId = Main.initializeDeferredWork(this.actor, this._updateWindowList.bind(this));
global.display.connect('window-created', this._updateWindowList.bind(this));
tracker.connect('tracked-windows-changed', this._updateWindowList.bind(this));
this._updateId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._updateWindowList));
global.display.connect('window-created', Lang.bind(this, this._updateWindowList));
tracker.connect('tracked-windows-changed', Lang.bind(this, this._updateWindowList));
this._lookingGlass = lookingGlass;
},
_updateWindowList() {
_updateWindowList: function() {
this.actor.destroy_all_children();
let windows = global.get_window_actors();
let tracker = Shell.WindowTracker.get_default();
@@ -336,7 +334,7 @@ var WindowList = new Lang.Class({
let metaWindow = windows[i].metaWindow;
// Avoid multiple connections
if (!metaWindow._lookingGlassManaged) {
metaWindow.connect('unmanaged', this._updateWindowList.bind(this));
metaWindow.connect('unmanaged', Lang.bind(this, this._updateWindowList));
metaWindow._lookingGlassManaged = true;
}
let box = new St.BoxLayout({ vertical: true });
@@ -366,7 +364,7 @@ Signals.addSignalMethods(WindowList.prototype);
var ObjInspector = new Lang.Class({
Name: 'ObjInspector',
_init(lookingGlass) {
_init: function(lookingGlass) {
this._obj = null;
this._previousObj = null;
@@ -383,7 +381,7 @@ var ObjInspector = new Lang.Class({
this._lookingGlass = lookingGlass;
},
selectObject(obj, skipPrevious) {
selectObject: function(obj, skipPrevious) {
if (!skipPrevious)
this._previousObj = this._obj;
else
@@ -399,17 +397,17 @@ var ObjInspector = new Lang.Class({
label.single_line_mode = true;
hbox.add(label, { expand: true, y_fill: false });
let button = new St.Button({ label: 'Insert', style_class: 'lg-obj-inspector-button' });
button.connect('clicked', this._onInsert.bind(this));
button.connect('clicked', Lang.bind(this, this._onInsert));
hbox.add(button);
if (this._previousObj != null) {
button = new St.Button({ label: 'Back', style_class: 'lg-obj-inspector-button' });
button.connect('clicked', this._onBack.bind(this));
button.connect('clicked', Lang.bind(this, this._onBack));
hbox.add(button);
}
button = new St.Button({ style_class: 'window-close' });
button.connect('clicked', this.close.bind(this));
button.connect('clicked', Lang.bind(this, this.close));
hbox.add(button);
if (typeof(obj) == typeof({})) {
let properties = [];
@@ -437,7 +435,7 @@ var ObjInspector = new Lang.Class({
}
},
open(sourceActor) {
open: function(sourceActor) {
if (this._open)
return;
this._previousObj = null;
@@ -453,7 +451,7 @@ var ObjInspector = new Lang.Class({
}
},
close() {
close: function() {
if (!this._open)
return;
this._open = false;
@@ -462,13 +460,13 @@ var ObjInspector = new Lang.Class({
this._obj = null;
},
_onInsert() {
_onInsert: function() {
let obj = this._obj;
this.close();
this._lookingGlass.insertObject(obj);
},
_onBack() {
_onBack: function() {
this.selectObject(this._previousObj, true);
}
});
@@ -477,7 +475,7 @@ var RedBorderEffect = new Lang.Class({
Name: 'RedBorderEffect',
Extends: Clutter.Effect,
vfunc_paint() {
vfunc_paint: function() {
let actor = this.get_actor();
actor.continue_paint();
@@ -502,10 +500,10 @@ var RedBorderEffect = new Lang.Class({
var Inspector = new Lang.Class({
Name: 'Inspector',
_init(lookingGlass) {
_init: function(lookingGlass) {
let container = new Shell.GenericContainer({ width: 0,
height: 0 });
container.connect('allocate', this._allocate.bind(this));
container.connect('allocate', Lang.bind(this, this._allocate));
Main.uiGroup.add_actor(container);
let eventHandler = new St.BoxLayout({ name: 'LookingGlassDialog',
@@ -516,10 +514,10 @@ var Inspector = new Lang.Class({
this._displayText = new St.Label();
eventHandler.add(this._displayText, { expand: true });
eventHandler.connect('key-press-event', this._onKeyPressEvent.bind(this));
eventHandler.connect('button-press-event', this._onButtonPressEvent.bind(this));
eventHandler.connect('scroll-event', this._onScrollEvent.bind(this));
eventHandler.connect('motion-event', this._onMotionEvent.bind(this));
eventHandler.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
eventHandler.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
eventHandler.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
eventHandler.connect('motion-event', Lang.bind(this, this._onMotionEvent));
Clutter.grab_pointer(eventHandler);
Clutter.grab_keyboard(eventHandler);
@@ -534,7 +532,7 @@ var Inspector = new Lang.Class({
this._lookingGlass = lookingGlass;
},
_allocate(actor, box, flags) {
_allocate: function(actor, box, flags) {
if (!this._eventHandler)
return;
@@ -551,7 +549,7 @@ var Inspector = new Lang.Class({
this._eventHandler.allocate(childBox, flags);
},
_close() {
_close: function() {
Clutter.ungrab_pointer();
Clutter.ungrab_keyboard();
this._eventHandler.destroy();
@@ -559,13 +557,13 @@ var Inspector = new Lang.Class({
this.emit('closed');
},
_onKeyPressEvent(actor, event) {
_onKeyPressEvent: function (actor, event) {
if (event.get_key_symbol() == Clutter.Escape)
this._close();
return Clutter.EVENT_STOP;
},
_onButtonPressEvent(actor, event) {
_onButtonPressEvent: function (actor, event) {
if (this._target) {
let [stageX, stageY] = event.get_coords();
this.emit('target', this._target, stageX, stageY);
@@ -574,7 +572,7 @@ var Inspector = new Lang.Class({
return Clutter.EVENT_STOP;
},
_onScrollEvent(actor, event) {
_onScrollEvent: function (actor, event) {
switch (event.get_scroll_direction()) {
case Clutter.ScrollDirection.UP:
// select parent
@@ -608,12 +606,12 @@ var Inspector = new Lang.Class({
return Clutter.EVENT_STOP;
},
_onMotionEvent(actor, event) {
_onMotionEvent: function (actor, event) {
this._update(event);
return Clutter.EVENT_STOP;
},
_update(event) {
_update: function(event) {
let [stageX, stageY] = event.get_coords();
let target = global.stage.get_actor_at_pos(Clutter.PickMode.ALL,
stageX,
@@ -636,7 +634,7 @@ Signals.addSignalMethods(Inspector.prototype);
var Extensions = new Lang.Class({
Name: 'Extensions',
_init(lookingGlass) {
_init: function(lookingGlass) {
this._lookingGlass = lookingGlass;
this.actor = new St.BoxLayout({ vertical: true,
name: 'lookingGlassExtensions' });
@@ -652,10 +650,10 @@ var Extensions = new Lang.Class({
this._loadExtension(null, uuid);
ExtensionSystem.connect('extension-loaded',
this._loadExtension.bind(this));
Lang.bind(this, this._loadExtension));
},
_loadExtension(o, uuid) {
_loadExtension: function(o, uuid) {
let extension = ExtensionUtils.extensions[uuid];
// There can be cases where we create dummy extension metadata
// that's not really a proper extension. Don't bother with these.
@@ -670,20 +668,20 @@ var Extensions = new Lang.Class({
this._extensionsList.add(extensionDisplay);
},
_onViewSource(actor) {
_onViewSource: function (actor) {
let extension = actor._extension;
let uri = extension.dir.get_uri();
Gio.app_info_launch_default_for_uri(uri, global.create_app_launch_context(0, -1));
this._lookingGlass.close();
},
_onWebPage(actor) {
_onWebPage: function (actor) {
let extension = actor._extension;
Gio.app_info_launch_default_for_uri(extension.metadata.url, global.create_app_launch_context(0, -1));
this._lookingGlass.close();
},
_onViewErrors(actor) {
_onViewErrors: function (actor) {
let extension = actor._extension;
let shouldShow = !actor._isShowing;
@@ -711,7 +709,7 @@ var Extensions = new Lang.Class({
actor._isShowing = shouldShow;
},
_stateToString(extensionState) {
_stateToString: function(extensionState) {
switch (extensionState) {
case ExtensionSystem.ExtensionState.ENABLED:
return _("Enabled");
@@ -728,7 +726,7 @@ var Extensions = new Lang.Class({
return 'Unknown'; // Not translated, shouldn't appear
},
_createExtensionDisplay(extension) {
_createExtensionDisplay: function(extension) {
let box = new St.BoxLayout({ style_class: 'lg-extension', vertical: true });
let name = new St.Label({ style_class: 'lg-extension-name',
text: extension.metadata.name });
@@ -749,7 +747,7 @@ var Extensions = new Lang.Class({
style_class: 'shell-link',
label: _("View Source") });
viewsource._extension = extension;
viewsource.connect('clicked', this._onViewSource.bind(this));
viewsource.connect('clicked', Lang.bind(this, this._onViewSource));
metaBox.add(viewsource);
if (extension.metadata.url) {
@@ -758,7 +756,7 @@ var Extensions = new Lang.Class({
style_class: 'shell-link',
label: _("Web Page") });
webpage._extension = extension;
webpage.connect('clicked', this._onWebPage.bind(this));
webpage.connect('clicked', Lang.bind(this, this._onWebPage));
metaBox.add(webpage);
}
@@ -769,7 +767,7 @@ var Extensions = new Lang.Class({
viewerrors._extension = extension;
viewerrors._parentBox = box;
viewerrors._isShowing = false;
viewerrors.connect('clicked', this._onViewErrors.bind(this));
viewerrors.connect('clicked', Lang.bind(this, this._onViewErrors));
metaBox.add(viewerrors);
return box;
@@ -779,7 +777,7 @@ var Extensions = new Lang.Class({
var LookingGlass = new Lang.Class({
Name: 'LookingGlass',
_init() {
_init : function() {
this._borderPaintTarget = null;
this._redBorderEffect = new RedBorderEffect();
@@ -797,11 +795,11 @@ var LookingGlass = new Lang.Class({
vertical: true,
visible: false,
reactive: true });
this.actor.connect('key-press-event', this._globalKeyPressEvent.bind(this));
this.actor.connect('key-press-event', Lang.bind(this, this._globalKeyPressEvent));
this._interfaceSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.interface' });
this._interfaceSettings.connect('changed::monospace-font-name',
this._updateFont.bind(this));
Lang.bind(this, this._updateFont));
this._updateFont();
// We want it to appear to slide out from underneath the panel
@@ -809,9 +807,9 @@ var LookingGlass = new Lang.Class({
Main.uiGroup.set_child_below_sibling(this.actor,
Main.layoutManager.panelBox);
Main.layoutManager.panelBox.connect('allocation-changed',
this._queueResize.bind(this));
Lang.bind(this, this._queueResize));
Main.layoutManager.keyboardBox.connect('allocation-changed',
this._queueResize.bind(this));
Lang.bind(this, this._queueResize));
this._objInspector = new ObjInspector(this);
Main.uiGroup.add_actor(this._objInspector.actor);
@@ -823,34 +821,34 @@ var LookingGlass = new Lang.Class({
icon_size: 24 });
toolbar.add_actor(inspectIcon);
inspectIcon.reactive = true;
inspectIcon.connect('button-press-event', () => {
inspectIcon.connect('button-press-event', Lang.bind(this, function () {
let inspector = new Inspector(this);
inspector.connect('target', (i, target, stageX, stageY) => {
inspector.connect('target', Lang.bind(this, function(i, target, stageX, stageY) {
this._pushResult('inspect(' + Math.round(stageX) + ', ' + Math.round(stageY) + ')', target);
});
inspector.connect('closed', () => {
}));
inspector.connect('closed', Lang.bind(this, function() {
this.actor.show();
global.stage.set_key_focus(this._entry);
});
}));
this.actor.hide();
return Clutter.EVENT_STOP;
});
}));
let gcIcon = new St.Icon({ icon_name: 'user-trash-full',
icon_size: 24 });
toolbar.add_actor(gcIcon);
gcIcon.reactive = true;
gcIcon.connect('button-press-event', () => {
gcIcon.connect('button-press-event', Lang.bind(this, function () {
gcIcon.icon_name = 'user-trash';
System.gc();
this._timeoutId = Mainloop.timeout_add(500, () => {
this._timeoutId = Mainloop.timeout_add(500, Lang.bind(this, function () {
gcIcon.icon_name = 'user-trash-full';
this._timeoutId = 0;
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] gcIcon.icon_name = \'user-trash-full\'');
return Clutter.EVENT_PROPAGATE;
});
}));
let notebook = new Notebook();
this._notebook = notebook;
@@ -882,7 +880,7 @@ var LookingGlass = new Lang.Class({
this._extensions = new Extensions(this);
notebook.appendPage('Extensions', this._extensions.actor);
this._entry.clutter_text.connect('activate', (o, e) => {
this._entry.clutter_text.connect('activate', Lang.bind(this, function (o, e) {
// Hide any completions we are currently showing
this._hideCompletions();
@@ -896,26 +894,26 @@ var LookingGlass = new Lang.Class({
return true;
this._evaluate(text);
return true;
});
}));
this._history = new History.HistoryManager({ gsettingsKey: HISTORY_KEY,
entry: this._entry.clutter_text });
this._autoComplete = new AutoComplete(this._entry);
this._autoComplete.connect('suggest', (a, e) => {
this._autoComplete.connect('suggest', Lang.bind(this, function(a,e) {
this._showCompletions(e.completions);
});
}));
// If a completion is completed unambiguously, the currently-displayed completion
// suggestions become irrelevant.
this._autoComplete.connect('completion', (a, e) => {
this._autoComplete.connect('completion', Lang.bind(this, function(a,e) {
if (e.type == 'whole-word')
this._hideCompletions();
});
}));
this._resize();
},
_updateFont() {
_updateFont: function() {
let fontName = this._interfaceSettings.get_string('monospace-font-name');
let fontDesc = Pango.FontDescription.from_string(fontName);
// We ignore everything but size and style; you'd be crazy to set your system-wide
@@ -925,7 +923,7 @@ var LookingGlass = new Lang.Class({
+ 'font-family: "' + fontDesc.get_family() + '";';
},
setBorderPaintTarget(obj) {
setBorderPaintTarget: function(obj) {
if (this._borderPaintTarget != null)
this._borderPaintTarget.remove_effect(this._redBorderEffect);
this._borderPaintTarget = obj;
@@ -933,7 +931,7 @@ var LookingGlass = new Lang.Class({
this._borderPaintTarget.add_effect(this._redBorderEffect);
},
_pushResult(command, obj) {
_pushResult: function(command, obj) {
let index = this._results.length + this._offset;
let result = new Result(this, CHEVRON + command, obj, index);
this._results.push(result);
@@ -953,7 +951,7 @@ var LookingGlass = new Lang.Class({
this._notebook.scrollToBottom(0);
},
_showCompletions(completions) {
_showCompletions: function(completions) {
if (!this._completionActor) {
this._completionActor = new St.Label({ name: 'LookingGlassAutoCompletionText', style_class: 'lg-completions-text' });
this._completionActor.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
@@ -982,21 +980,21 @@ var LookingGlass = new Lang.Class({
}
},
_hideCompletions() {
_hideCompletions: function() {
if (this._completionActor) {
Tweener.removeTweens(this._completionActor);
Tweener.addTween(this._completionActor, { time: AUTO_COMPLETE_SHOW_COMPLETION_ANIMATION_DURATION / St.get_slow_down_factor(),
transition: 'easeOutQuad',
height: 0,
opacity: 0,
onComplete: () => {
onComplete: Lang.bind(this, function () {
this._completionActor.hide();
}
})
});
}
},
_evaluate(command) {
_evaluate : function(command) {
this._history.addItem(command);
let fullCmd = commandHeader + command;
@@ -1012,30 +1010,31 @@ var LookingGlass = new Lang.Class({
this._entry.text = '';
},
inspect(x, y) {
inspect: function(x, y) {
return global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
},
getIt() {
getIt: function () {
return this._it;
},
getResult(idx) {
getResult: function(idx) {
return this._results[idx - this._offset].o;
},
toggle() {
toggle: function() {
if (this._open)
this.close();
else
this.open();
},
_queueResize() {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => { this._resize(); });
_queueResize: function() {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
Lang.bind(this, function () { this._resize(); }));
},
_resize() {
_resize: function() {
let primary = Main.layoutManager.primaryMonitor;
let myWidth = primary.width * 0.7;
let availableHeight = primary.height - Main.layoutManager.keyboardBox.height;
@@ -1051,17 +1050,17 @@ var LookingGlass = new Lang.Class({
this._targetY + Math.floor(myHeight * 0.1));
},
insertObject(obj) {
insertObject: function(obj) {
this._pushResult('<insert>', obj);
},
inspectObject(obj, sourceActor) {
inspectObject: function(obj, sourceActor) {
this._objInspector.open(sourceActor);
this._objInspector.selectObject(obj);
},
// Handle key events which are relevant for all tabs of the LookingGlass
_globalKeyPressEvent(actor, event) {
_globalKeyPressEvent : function(actor, event) {
let symbol = event.get_key_symbol();
let modifierState = event.get_state();
if (symbol == Clutter.Escape) {
@@ -1083,7 +1082,7 @@ var LookingGlass = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
open() {
open : function() {
if (this._open)
return;
@@ -1105,7 +1104,7 @@ var LookingGlass = new Lang.Class({
});
},
close() {
close : function() {
if (!this._open)
return;
@@ -1121,9 +1120,9 @@ var LookingGlass = new Lang.Class({
Tweener.addTween(this.actor, { time: Math.min(0.5 / St.get_slow_down_factor(), 0.5),
transition: 'easeOutQuad',
y: this._hiddenY,
onComplete: () => {
onComplete: Lang.bind(this, function () {
this.actor.hide();
}
})
});
}
});

File diff suppressed because it is too large Load Diff

View File

@@ -101,7 +101,7 @@ let _zoomRegionInstanceCount = 0;
var ShellMagnifier = new Lang.Class({
Name: 'ShellMagnifier',
_init() {
_init: function() {
this._zoomers = {};
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(MagnifierIface, this);
@@ -112,7 +112,7 @@ var ShellMagnifier = new Lang.Class({
* setActive:
* @activate: Boolean to activate or de-activate the magnifier.
*/
setActive(activate) {
setActive: function(activate) {
Main.magnifier.setActive(activate);
},
@@ -120,7 +120,7 @@ var ShellMagnifier = new Lang.Class({
* isActive:
* @return Whether the magnifier is active (boolean).
*/
isActive() {
isActive: function() {
return Main.magnifier.isActive();
},
@@ -128,7 +128,7 @@ var ShellMagnifier = new Lang.Class({
* showCursor:
* Show the system mouse pointer.
*/
showCursor() {
showCursor: function() {
Main.magnifier.showSystemCursor();
},
@@ -136,7 +136,7 @@ var ShellMagnifier = new Lang.Class({
* hideCursor:
* Hide the system mouse pointer.
*/
hideCursor() {
hideCursor: function() {
Main.magnifier.hideSystemCursor();
},
@@ -160,7 +160,7 @@ var ShellMagnifier = new Lang.Class({
*
* @return The newly created ZoomRegion.
*/
createZoomRegion(xMagFactor, yMagFactor, roi, viewPort) {
createZoomRegion: function(xMagFactor, yMagFactor, roi, viewPort) {
let ROI = { x: roi[0], y: roi[1], width: roi[2] - roi[0], height: roi[3] - roi[1] };
let viewBox = { x: viewPort[0], y: viewPort[1], width: viewPort[2] - viewPort[0], height: viewPort[3] - viewPort[1] };
let realZoomRegion = Main.magnifier.createZoomRegion(xMagFactor, yMagFactor, ROI, viewBox);
@@ -180,7 +180,7 @@ var ShellMagnifier = new Lang.Class({
* Append the given ZoomRegion to the magnifier's list of ZoomRegions.
* @zoomerObjectPath: The object path for the zoom region proxy.
*/
addZoomRegion(zoomerObjectPath) {
addZoomRegion: function(zoomerObjectPath) {
let proxyAndZoomRegion = this._zoomers[zoomerObjectPath];
if (proxyAndZoomRegion && proxyAndZoomRegion.zoomRegion) {
Main.magnifier.addZoomRegion(proxyAndZoomRegion.zoomRegion);
@@ -196,14 +196,14 @@ var ShellMagnifier = new Lang.Class({
* @return: The Magnifier's zoom region list as an array of DBus object
* paths.
*/
getZoomRegions() {
getZoomRegions: function() {
// There may be more ZoomRegions in the magnifier itself than have
// been added through dbus. Make sure all of them are associated with
// an object path and proxy.
let zoomRegions = Main.magnifier.getZoomRegions();
let objectPaths = [];
let thoseZoomers = this._zoomers;
zoomRegions.forEach ((aZoomRegion, index, array) => {
zoomRegions.forEach (function(aZoomRegion, index, array) {
let found = false;
for (let objectPath in thoseZoomers) {
let proxyAndZoomRegion = thoseZoomers[objectPath];
@@ -232,7 +232,7 @@ var ShellMagnifier = new Lang.Class({
* clearAllZoomRegions:
* Remove all the zoom regions from this Magnfier's ZoomRegion list.
*/
clearAllZoomRegions() {
clearAllZoomRegions: function() {
Main.magnifier.clearAllZoomRegions();
for (let objectPath in this._zoomers) {
let proxyAndZoomer = this._zoomers[objectPath];
@@ -249,7 +249,7 @@ var ShellMagnifier = new Lang.Class({
* Consult if the Magnifier can magnify in full-screen mode.
* @return Always return true.
*/
fullScreenCapable() {
fullScreenCapable: function() {
return true;
},
@@ -258,7 +258,7 @@ var ShellMagnifier = new Lang.Class({
* Set the crosswire size of all ZoomRegions.
* @size: The thickness of each line in the cross wire.
*/
setCrosswireSize(size) {
setCrosswireSize: function(size) {
Main.magnifier.setCrosshairsThickness(size);
},
@@ -267,7 +267,7 @@ var ShellMagnifier = new Lang.Class({
* Get the crosswire size of all ZoomRegions.
* @return: The thickness of each line in the cross wire.
*/
getCrosswireSize() {
getCrosswireSize: function() {
return Main.magnifier.getCrosshairsThickness();
},
@@ -276,7 +276,7 @@ var ShellMagnifier = new Lang.Class({
* Set the crosswire length of all zoom-regions..
* @size: The length of each line in the cross wire.
*/
setCrosswireLength(length) {
setCrosswireLength: function(length) {
Main.magnifier.setCrosshairsLength(length);
},
@@ -285,7 +285,7 @@ var ShellMagnifier = new Lang.Class({
* Set the crosswire size of all zoom-regions.
* @size: The thickness of each line in the cross wire.
*/
getCrosswireLength() {
getCrosswireLength: function() {
return Main.magnifier.getCrosshairsLength();
},
@@ -294,7 +294,7 @@ var ShellMagnifier = new Lang.Class({
* Set if the crosswire will be clipped by the cursor image..
* @clip: Flag to indicate whether to clip the crosswire.
*/
setCrosswireClip(clip) {
setCrosswireClip: function(clip) {
Main.magnifier.setCrosshairsClip(clip);
},
@@ -303,7 +303,7 @@ var ShellMagnifier = new Lang.Class({
* Get the crosswire clip value.
* @return: Whether the crosswire is clipped by the cursor image.
*/
getCrosswireClip() {
getCrosswireClip: function() {
return Main.magnifier.getCrosshairsClip();
},
@@ -312,7 +312,7 @@ var ShellMagnifier = new Lang.Class({
* Set the crosswire color of all ZoomRegions.
* @color: Unsigned int of the form rrggbbaa.
*/
setCrosswireColor(color) {
setCrosswireColor: function(color) {
Main.magnifier.setCrosshairsColor('#%08x'.format(color));
},
@@ -321,7 +321,7 @@ var ShellMagnifier = new Lang.Class({
* Get the crosswire color of all ZoomRegions.
* @return: The crosswire color as an unsigned int in the form rrggbbaa.
*/
getCrosswireColor() {
getCrosswireColor: function() {
let colorString = Main.magnifier.getCrosshairsColor();
// Drop the leading '#'.
return parseInt(colorString.slice(1), 16);
@@ -337,7 +337,7 @@ var ShellMagnifier = new Lang.Class({
var ShellMagnifierZoomRegion = new Lang.Class({
Name: 'ShellMagnifierZoomRegion',
_init(zoomerObjectPath, zoomRegion) {
_init: function(zoomerObjectPath, zoomRegion) {
this._zoomRegion = zoomRegion;
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ZoomRegionIface, this);
@@ -352,7 +352,7 @@ var ShellMagnifierZoomRegion = new Lang.Class({
* @yMagFactor: The power to set the vertical magnification factor to
* of the magnified view.
*/
setMagFactor(xMagFactor, yMagFactor) {
setMagFactor: function(xMagFactor, yMagFactor) {
this._zoomRegion.setMagFactor(xMagFactor, yMagFactor);
},
@@ -363,7 +363,7 @@ var ShellMagnifierZoomRegion = new Lang.Class({
* magnification. A value of 2.0 means the contents are doubled
* in size, and so on.
*/
getMagFactor() {
getMagFactor: function() {
return this._zoomRegion.getMagFactor();
},
@@ -374,7 +374,7 @@ var ShellMagnifierZoomRegion = new Lang.Class({
* screen to magnify. The values are in screen (unmagnified)
* coordinate space.
*/
setRoi(roi) {
setRoi: function(roi) {
let roiObject = { x: roi[0], y: roi[1], width: roi[2] - roi[0], height: roi[3] - roi[1] };
this._zoomRegion.setROI(roiObject);
},
@@ -387,7 +387,7 @@ var ShellMagnifierZoomRegion = new Lang.Class({
* @return an array, [left, top, right, bottom], representing the bounding
* rectangle of what is shown in the magnified view.
*/
getRoi() {
getRoi: function() {
let roi = this._zoomRegion.getROI();
roi[2] += roi[0];
roi[3] += roi[1];
@@ -402,7 +402,7 @@ var ShellMagnifierZoomRegion = new Lang.Class({
* @return Whether the shift was successful (for GS-mag, this is always
* true).
*/
shiftContentsTo(x, y) {
shiftContentsTo: function(x, y) {
this._zoomRegion.scrollContentsTo(x, y);
return true;
},
@@ -413,12 +413,12 @@ var ShellMagnifierZoomRegion = new Lang.Class({
* @viewPort Array, [left, top, right, bottom], defining the position and
* size on screen to place the zoom region.
*/
moveResize(viewPort) {
moveResize: function(viewPort) {
let viewRect = { x: viewPort[0], y: viewPort[1], width: viewPort[2] - viewPort[0], height: viewPort[3] - viewPort[1] };
this._zoomRegion.setViewPort(viewRect);
},
destroy() {
destroy: function() {
this._dbusImpl.unexport();
}
});

View File

@@ -96,7 +96,7 @@ function _sessionUpdated() {
wm.setCustomKeybindingHandler('panel-main-menu',
Shell.ActionMode.NORMAL |
Shell.ActionMode.OVERVIEW,
sessionMode.hasOverview ? overview.toggle.bind(overview) : null);
sessionMode.hasOverview ? Lang.bind(overview, overview.toggle) : null);
wm.allowKeybinding('overlay-key', Shell.ActionMode.NORMAL |
Shell.ActionMode.OVERVIEW);
@@ -119,9 +119,7 @@ function start() {
global.log = window.log;
// Chain up async errors reported from C
global.connect('notify-error', (global, msg, detail) => {
notifyError(msg, detail);
});
global.connect('notify-error', function (global, msg, detail) { notifyError(msg, detail); });
Gio.DesktopAppInfo.set_desktop_env('GNOME');
@@ -192,17 +190,17 @@ function _initializeUI() {
_a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
global.display.connect('overlay-key', () => {
global.display.connect('overlay-key', Lang.bind(overview, function () {
if (!_a11ySettings.get_boolean (STICKY_KEYS_ENABLE))
overview.toggle();
});
}));
global.display.connect('show-restart-message', (display, message) => {
global.display.connect('show-restart-message', function(display, message) {
showRestartMessage(message);
return true;
});
global.display.connect('restart', () => {
global.display.connect('restart', function() {
global.reexec_self();
return true;
});
@@ -229,12 +227,12 @@ function _initializeUI() {
ExtensionSystem.init();
if (sessionMode.isGreeter && screenShield) {
layoutManager.connect('startup-prepared', () => {
layoutManager.connect('startup-prepared', function() {
screenShield.showDialog();
});
}
layoutManager.connect('startup-complete', () => {
layoutManager.connect('startup-complete', function() {
if (actionMode == Shell.ActionMode.NONE) {
actionMode = Shell.ActionMode.NORMAL;
}
@@ -425,7 +423,7 @@ function pushModal(actor, params) {
}
modalCount += 1;
let actorDestroyId = actor.connect('destroy', () => {
let actorDestroyId = actor.connect('destroy', function() {
let index = _findModal(actor);
if (index >= 0)
popModal(actor);
@@ -434,7 +432,7 @@ function pushModal(actor, params) {
let prevFocus = global.stage.get_key_focus();
let prevFocusDestroyId;
if (prevFocus != null) {
prevFocusDestroyId = prevFocus.connect('destroy', () => {
prevFocusDestroyId = prevFocus.connect('destroy', function() {
let index = _findModal(actor);
if (index >= 0)
modalActorFocusStack[index].prevFocus = null;
@@ -608,7 +606,7 @@ function _runBeforeRedrawQueue() {
function _queueBeforeRedraw(workId) {
_beforeRedrawQueue.push(workId);
if (_beforeRedrawQueue.length == 1) {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, function () {
_runBeforeRedrawQueue();
return false;
});
@@ -638,12 +636,12 @@ function initializeDeferredWork(actor, callback, props) {
let workId = '' + (++_deferredWorkSequence);
_deferredWorkData[workId] = { 'actor': actor,
'callback': callback };
actor.connect('notify::mapped', () => {
actor.connect('notify::mapped', function () {
if (!(actor.mapped && _deferredWorkQueue.indexOf(workId) >= 0))
return;
_queueBeforeRedraw(workId);
});
actor.connect('destroy', () => {
actor.connect('destroy', function() {
let index = _deferredWorkQueue.indexOf(workId);
if (index >= 0)
_deferredWorkQueue.splice(index, 1);
@@ -675,7 +673,7 @@ function queueDeferredWork(workId) {
_queueBeforeRedraw(workId);
return;
} else if (_deferredTimeoutId == 0) {
_deferredTimeoutId = Mainloop.timeout_add_seconds(DEFERRED_TIMEOUT_SECONDS, () => {
_deferredTimeoutId = Mainloop.timeout_add_seconds(DEFERRED_TIMEOUT_SECONDS, function () {
_runAllDeferredWork();
_deferredTimeoutId = 0;
return GLib.SOURCE_REMOVE;
@@ -688,7 +686,7 @@ var RestartMessage = new Lang.Class({
Name: 'RestartMessage',
Extends: ModalDialog.ModalDialog,
_init(message) {
_init : function(message) {
this.parent({ shellReactive: true,
styleClass: 'restart-message headline',
shouldFadeIn: false,

View File

@@ -42,13 +42,13 @@ function _fixMarkup(text, allowMarkup) {
var URLHighlighter = new Lang.Class({
Name: 'URLHighlighter',
_init(text, lineWrap, allowMarkup) {
_init: function(text, lineWrap, allowMarkup) {
if (!text)
text = '';
this.actor = new St.Label({ reactive: true, style_class: 'url-highlighter',
x_expand: true, x_align: Clutter.ActorAlign.START });
this._linkColor = '#ccccff';
this.actor.connect('style-changed', () => {
this.actor.connect('style-changed', Lang.bind(this, function() {
let [hasColor, color] = this.actor.get_theme_node().lookup_color('link-color', false);
if (hasColor) {
let linkColor = color.to_string().substr(0, 7);
@@ -57,12 +57,12 @@ var URLHighlighter = new Lang.Class({
this._highlightUrls();
}
}
});
}));
this.actor.clutter_text.line_wrap = lineWrap;
this.actor.clutter_text.line_wrap_mode = Pango.WrapMode.WORD_CHAR;
this.setMarkup(text, allowMarkup);
this.actor.connect('button-press-event', (actor, event) => {
this.actor.connect('button-press-event', Lang.bind(this, function(actor, event) {
// Don't try to URL highlight when invisible.
// The MessageTray doesn't actually hide us, so
// we need to check for paint opacities as well.
@@ -73,8 +73,8 @@ var URLHighlighter = new Lang.Class({
// a pointer grab, which would block our button-release-event
// handler, if an URL is clicked
return this._findUrlAtPos(event) != -1;
});
this.actor.connect('button-release-event', (actor, event) => {
}));
this.actor.connect('button-release-event', Lang.bind(this, function (actor, event) {
if (!actor.visible || actor.get_paint_opacity() == 0)
return Clutter.EVENT_PROPAGATE;
@@ -88,8 +88,8 @@ var URLHighlighter = new Lang.Class({
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
});
this.actor.connect('motion-event', (actor, event) => {
}));
this.actor.connect('motion-event', Lang.bind(this, function(actor, event) {
if (!actor.visible || actor.get_paint_opacity() == 0)
return Clutter.EVENT_PROPAGATE;
@@ -102,8 +102,8 @@ var URLHighlighter = new Lang.Class({
this._cursorChanged = false;
}
return Clutter.EVENT_PROPAGATE;
});
this.actor.connect('leave-event', () => {
}));
this.actor.connect('leave-event', Lang.bind(this, function() {
if (!this.actor.visible || this.actor.get_paint_opacity() == 0)
return Clutter.EVENT_PROPAGATE;
@@ -112,10 +112,10 @@ var URLHighlighter = new Lang.Class({
global.screen.set_cursor(Meta.Cursor.DEFAULT);
}
return Clutter.EVENT_PROPAGATE;
});
}));
},
setMarkup(text, allowMarkup) {
setMarkup: function(text, allowMarkup) {
text = text ? _fixMarkup(text, allowMarkup) : '';
this._text = text;
@@ -125,7 +125,7 @@ var URLHighlighter = new Lang.Class({
this._highlightUrls();
},
_highlightUrls() {
_highlightUrls: function() {
// text here contain markup
let urls = Util.findUrls(this._text);
let markup = '';
@@ -140,7 +140,7 @@ var URLHighlighter = new Lang.Class({
this.actor.clutter_text.set_markup(markup);
},
_findUrlAtPos(event) {
_findUrlAtPos: function(event) {
let success;
let [x, y] = event.get_coords();
[success, x, y] = this.actor.transform_stage_point(x, y);
@@ -165,12 +165,12 @@ var ScaleLayout = new Lang.Class({
Name: 'ScaleLayout',
Extends: Clutter.BinLayout,
_init(params) {
_init: function(params) {
this._container = null;
this.parent(params);
},
_connectContainer(container) {
_connectContainer: function(container) {
if (this._container == container)
return;
@@ -183,14 +183,15 @@ var ScaleLayout = new Lang.Class({
if (this._container)
for (let signal of ['notify::scale-x', 'notify::scale-y']) {
let id = this._container.connect(signal, () => {
this.layout_changed();
});
let id = this._container.connect(signal, Lang.bind(this,
function() {
this.layout_changed();
}));
this._signals.push(id);
}
},
vfunc_get_preferred_width(container, forHeight) {
vfunc_get_preferred_width: function(container, forHeight) {
this._connectContainer(container);
let [min, nat] = this.parent(container, forHeight);
@@ -198,7 +199,7 @@ var ScaleLayout = new Lang.Class({
Math.floor(nat * container.scale_x)];
},
vfunc_get_preferred_height(container, forWidth) {
vfunc_get_preferred_height: function(container, forWidth) {
this._connectContainer(container);
let [min, nat] = this.parent(container, forWidth);
@@ -217,7 +218,7 @@ var LabelExpanderLayout = new Lang.Class({
GObject.ParamFlags.READABLE | GObject.ParamFlags.WRITABLE,
0, 1, 0)},
_init(params) {
_init: function(params) {
this._expansion = 0;
this._expandLines = DEFAULT_EXPAND_LINES;
@@ -249,11 +250,11 @@ var LabelExpanderLayout = new Lang.Class({
this.layout_changed();
},
vfunc_set_container(container) {
vfunc_set_container: function(container) {
this._container = container;
},
vfunc_get_preferred_width(container, forHeight) {
vfunc_get_preferred_width: function(container, forHeight) {
let [min, nat] = [0, 0];
for (let i = 0; i < container.get_n_children(); i++) {
@@ -268,7 +269,7 @@ var LabelExpanderLayout = new Lang.Class({
return [min, nat];
},
vfunc_get_preferred_height(container, forWidth) {
vfunc_get_preferred_height: function(container, forWidth) {
let [min, nat] = [0, 0];
let children = container.get_children();
@@ -286,7 +287,7 @@ var LabelExpanderLayout = new Lang.Class({
return [min, nat];
},
vfunc_allocate(container, box, flags) {
vfunc_allocate: function(container, box, flags) {
for (let i = 0; i < container.get_n_children(); i++) {
let child = container.get_child_at_index(i);
@@ -300,7 +301,7 @@ var LabelExpanderLayout = new Lang.Class({
var Message = new Lang.Class({
Name: 'Message',
_init(title, body) {
_init: function(title, body) {
this.expanded = false;
this._useBodyMarkup = false;
@@ -310,7 +311,7 @@ var Message = new Lang.Class({
can_focus: true,
x_expand: true, x_fill: true });
this.actor.connect('key-press-event',
this._onKeyPressed.bind(this));
Lang.bind(this, this._onKeyPressed));
let vbox = new St.BoxLayout({ vertical: true });
this.actor.set_child(vbox);
@@ -361,32 +362,32 @@ var Message = new Lang.Class({
this._bodyStack.add_actor(this.bodyLabel.actor);
this.setBody(body);
this._closeButton.connect('clicked', this.close.bind(this));
this.actor.connect('notify::hover', this._sync.bind(this));
this.actor.connect('clicked', this._onClicked.bind(this));
this.actor.connect('destroy', this._onDestroy.bind(this));
this._closeButton.connect('clicked', Lang.bind(this, this.close));
this.actor.connect('notify::hover', Lang.bind(this, this._sync));
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this._sync();
},
close() {
close: function() {
this.emit('close');
},
setIcon(actor) {
setIcon: function(actor) {
this._iconBin.child = actor;
this._iconBin.visible = (actor != null);
},
setSecondaryActor(actor) {
setSecondaryActor: function(actor) {
this._secondaryBin.child = actor;
},
setTitle(text) {
setTitle: function(text) {
let title = text ? _fixMarkup(text.replace(/\n/g, ' '), false) : '';
this.titleLabel.clutter_text.set_markup(title);
},
setBody(text) {
setBody: function(text) {
this._bodyText = text;
this.bodyLabel.setMarkup(text ? text.replace(/\n/g, ' ') : '',
this._useBodyMarkup);
@@ -394,7 +395,7 @@ var Message = new Lang.Class({
this._expandedLabel.setMarkup(text, this._useBodyMarkup);
},
setUseBodyMarkup(enable) {
setUseBodyMarkup: function(enable) {
if (this._useBodyMarkup === enable)
return;
this._useBodyMarkup = enable;
@@ -402,7 +403,7 @@ var Message = new Lang.Class({
this.setBody(this._bodyText);
},
setActionArea(actor) {
setActionArea: function(actor) {
if (actor == null) {
if (this._actionBin.get_n_children() > 0)
this._actionBin.get_child_at_index(0).destroy();
@@ -416,7 +417,7 @@ var Message = new Lang.Class({
this._actionBin.visible = this.expanded;
},
addMediaControl(iconName, callback) {
addMediaControl: function(iconName, callback) {
let icon = new St.Icon({ icon_name: iconName, icon_size: 16 });
let button = new St.Button({ style_class: 'message-media-control',
child: icon });
@@ -425,7 +426,7 @@ var Message = new Lang.Class({
return button;
},
setExpandedBody(actor) {
setExpandedBody: function(actor) {
if (actor == null) {
if (this._bodyStack.get_n_children() > 1)
this._bodyStack.get_child_at_index(1).destroy();
@@ -438,11 +439,11 @@ var Message = new Lang.Class({
this._bodyStack.insert_child_at_index(actor, 1);
},
setExpandedLines(nLines) {
setExpandedLines: function(nLines) {
this._bodyStack.layout_manager.expandLines = nLines;
},
expand(animate) {
expand: function(animate) {
this.expanded = true;
this._actionBin.visible = (this._actionBin.get_n_children() > 0);
@@ -471,7 +472,7 @@ var Message = new Lang.Class({
this.emit('expanded');
},
unexpand(animate) {
unexpand: function(animate) {
if (animate) {
Tweener.addTween(this._bodyStack.layout_manager,
{ expansion: 0,
@@ -482,7 +483,7 @@ var Message = new Lang.Class({
time: MessageTray.ANIMATION_TIME,
transition: 'easeOutQuad',
onCompleteScope: this,
onComplete() {
onComplete: function() {
this._actionBin.hide();
this.expanded = false;
}});
@@ -495,22 +496,22 @@ var Message = new Lang.Class({
this.emit('unexpanded');
},
canClose() {
canClose: function() {
return this._mediaControls.get_n_children() == 0;
},
_sync() {
_sync: function() {
let visible = this.actor.hover && this.canClose();
this._closeButton.opacity = visible ? 255 : 0;
},
_onClicked() {
_onClicked: function() {
},
_onDestroy() {
_onDestroy: function() {
},
_onKeyPressed(a, event) {
_onKeyPressed: function(a, event) {
let keysym = event.get_key_symbol();
if (keysym == Clutter.KEY_Delete ||
@@ -526,7 +527,7 @@ Signals.addSignalMethods(Message.prototype);
var MessageListSection = new Lang.Class({
Name: 'MessageListSection',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ style_class: 'message-list-section',
clip_to_allocation: true,
x_expand: true, vertical: true });
@@ -535,12 +536,12 @@ var MessageListSection = new Lang.Class({
vertical: true });
this.actor.add_actor(this._list);
this._list.connect('actor-added', this._sync.bind(this));
this._list.connect('actor-removed', this._sync.bind(this));
this._list.connect('actor-added', Lang.bind(this, this._sync));
this._list.connect('actor-removed', Lang.bind(this, this._sync));
let id = Main.sessionMode.connect('updated',
this._sync.bind(this));
this.actor.connect('destroy', () => {
Lang.bind(this, this._sync));
this.actor.connect('destroy', function() {
Main.sessionMode.disconnect(id);
});
@@ -551,7 +552,7 @@ var MessageListSection = new Lang.Class({
this._sync();
},
_onKeyFocusIn(actor) {
_onKeyFocusIn: function(actor) {
this.emit('key-focus-in', actor);
},
@@ -559,18 +560,18 @@ var MessageListSection = new Lang.Class({
return true;
},
setDate(date) {
setDate: function(date) {
if (Calendar.sameDay(date, this._date))
return;
this._date = date;
this._sync();
},
addMessage(message, animate) {
addMessage: function(message, animate) {
this.addMessageAtIndex(message, -1, animate);
},
addMessageAtIndex(message, index, animate) {
addMessageAtIndex: function(message, index, animate) {
let obj = {
container: null,
destroyId: 0,
@@ -583,13 +584,15 @@ var MessageListSection = new Lang.Class({
pivot_point: pivot,
scale_x: scale, scale_y: scale });
obj.keyFocusId = message.actor.connect('key-focus-in',
this._onKeyFocusIn.bind(this));
obj.destroyId = message.actor.connect('destroy', () => {
this.removeMessage(message, false);
});
obj.closeId = message.connect('close', () => {
this.removeMessage(message, true);
});
Lang.bind(this, this._onKeyFocusIn));
obj.destroyId = message.actor.connect('destroy',
Lang.bind(this, function() {
this.removeMessage(message, false);
}));
obj.closeId = message.connect('close',
Lang.bind(this, function() {
this.removeMessage(message, true);
}));
this._messages.set(message, obj);
obj.container.add_actor(message.actor);
@@ -603,7 +606,7 @@ var MessageListSection = new Lang.Class({
transition: 'easeOutQuad' });
},
moveMessage(message, index, animate) {
moveMessage: function(message, index, animate) {
let obj = this._messages.get(message);
if (!animate) {
@@ -611,13 +614,13 @@ var MessageListSection = new Lang.Class({
return;
}
let onComplete = () => {
let onComplete = Lang.bind(this, function() {
this._list.set_child_at_index(obj.container, index);
Tweener.addTween(obj.container, { scale_x: 1,
scale_y: 1,
time: MESSAGE_ANIMATION_TIME,
transition: 'easeOutQuad' });
};
});
Tweener.addTween(obj.container, { scale_x: 0,
scale_y: 0,
time: MESSAGE_ANIMATION_TIME,
@@ -625,7 +628,7 @@ var MessageListSection = new Lang.Class({
onComplete: onComplete });
},
removeMessage(message, animate) {
removeMessage: function(message, animate) {
let obj = this._messages.get(message);
message.actor.disconnect(obj.destroyId);
@@ -638,7 +641,7 @@ var MessageListSection = new Lang.Class({
Tweener.addTween(obj.container, { scale_x: 0, scale_y: 0,
time: MESSAGE_ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
obj.container.destroy();
global.sync_pointer();
}});
@@ -648,12 +651,14 @@ var MessageListSection = new Lang.Class({
}
},
clear() {
let messages = [...this._messages.keys()].filter(msg => msg.canClose());
clear: function() {
let messages = [...this._messages.keys()].filter(function(message) {
return message.canClose();
});
// If there are few messages, letting them all zoom out looks OK
if (messages.length < 2) {
messages.forEach(message => {
messages.forEach(function(message) {
message.close();
});
} else {
@@ -669,25 +674,25 @@ var MessageListSection = new Lang.Class({
time: MESSAGE_ANIMATION_TIME,
delay: i * delay,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
message.close();
}});
}
}
},
_canClear() {
_canClear: function() {
for (let message of this._messages.keys())
if (message.canClose())
return true;
return false;
},
_shouldShow() {
_shouldShow: function() {
return !this.empty;
},
_sync() {
_sync: function() {
let empty = this._list.get_n_children() == 0;
let changed = this.empty !== empty;
this.empty = empty;

View File

@@ -72,20 +72,20 @@ var Urgency = {
var FocusGrabber = new Lang.Class({
Name: 'FocusGrabber',
_init(actor) {
_init: function(actor) {
this._actor = actor;
this._prevKeyFocusActor = null;
this._focusActorChangedId = 0;
this._focused = false;
},
grabFocus() {
grabFocus: function() {
if (this._focused)
return;
this._prevKeyFocusActor = global.stage.get_key_focus();
this._focusActorChangedId = global.stage.connect('notify::key-focus', this._focusActorChanged.bind(this));
this._focusActorChangedId = global.stage.connect('notify::key-focus', Lang.bind(this, this._focusActorChanged));
if (!this._actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false))
this._actor.grab_key_focus();
@@ -93,7 +93,7 @@ var FocusGrabber = new Lang.Class({
this._focused = true;
},
_focusUngrabbed() {
_focusUngrabbed: function() {
if (!this._focused)
return false;
@@ -106,13 +106,13 @@ var FocusGrabber = new Lang.Class({
return true;
},
_focusActorChanged() {
_focusActorChanged: function() {
let focusedActor = global.stage.get_key_focus();
if (!focusedActor || !this._actor.contains(focusedActor))
this._focusUngrabbed();
},
ungrabFocus() {
ungrabFocus: function() {
if (!this._focusUngrabbed())
return;
@@ -135,7 +135,7 @@ var FocusGrabber = new Lang.Class({
var NotificationPolicy = new Lang.Class({
Name: 'NotificationPolicy',
_init(params) {
_init: function(params) {
params = Params.parse(params, { enable: true,
enableSound: true,
showBanners: true,
@@ -148,8 +148,8 @@ var NotificationPolicy = new Lang.Class({
// Do nothing for the default policy. These methods are only useful for the
// GSettings policy.
store() { },
destroy() { }
store: function() { },
destroy: function() { }
});
Signals.addSignalMethods(NotificationPolicy.prototype);
@@ -157,23 +157,23 @@ var NotificationGenericPolicy = new Lang.Class({
Name: 'NotificationGenericPolicy',
Extends: NotificationPolicy,
_init() {
_init: function() {
// Don't chain to parent, it would try setting
// our properties to the defaults
this.id = 'generic';
this._masterSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.notifications' });
this._masterSettings.connect('changed', this._changed.bind(this));
this._masterSettings.connect('changed', Lang.bind(this, this._changed));
},
store() { },
store: function() { },
destroy() {
destroy: function() {
this._masterSettings.run_dispose();
},
_changed(settings, key) {
_changed: function(settings, key) {
this.emit('policy-changed', key);
},
@@ -206,7 +206,7 @@ var NotificationApplicationPolicy = new Lang.Class({
Name: 'NotificationApplicationPolicy',
Extends: NotificationPolicy,
_init(id) {
_init: function(id) {
// Don't chain to parent, it would try setting
// our properties to the defaults
@@ -217,11 +217,11 @@ var NotificationApplicationPolicy = new Lang.Class({
this._settings = new Gio.Settings({ schema_id: 'org.gnome.desktop.notifications.application',
path: '/org/gnome/desktop/notifications/application/' + this._canonicalId + '/' });
this._masterSettings.connect('changed', this._changed.bind(this));
this._settings.connect('changed', this._changed.bind(this));
this._masterSettings.connect('changed', Lang.bind(this, this._changed));
this._settings.connect('changed', Lang.bind(this, this._changed));
},
store() {
store: function() {
this._settings.set_string('application-id', this.id + '.desktop');
let apps = this._masterSettings.get_strv('application-children');
@@ -231,18 +231,18 @@ var NotificationApplicationPolicy = new Lang.Class({
}
},
destroy() {
destroy: function() {
this._masterSettings.run_dispose();
this._settings.run_dispose();
},
_changed(settings, key) {
_changed: function(settings, key) {
this.emit('policy-changed', key);
if (key == 'enable')
this.emit('enable-changed');
},
_canonicalizeId(id) {
_canonicalizeId: function(id) {
// Keys are restricted to lowercase alphanumeric characters and dash,
// and two dashes cannot be in succession
return id.toLowerCase().replace(/[^a-z0-9\-]/g, '-').replace(/--+/g, '-');
@@ -331,7 +331,7 @@ var NotificationApplicationPolicy = new Lang.Class({
var Notification = new Lang.Class({
Name: 'Notification',
_init(source, title, banner, params) {
_init: function(source, title, banner, params) {
this.source = source;
this.title = title;
this.urgency = Urgency.NORMAL;
@@ -363,7 +363,7 @@ var Notification = new Lang.Class({
// Updates the notification by regenerating its icon and updating
// the title/banner. If @params.clear is %true, it will also
// remove any additional actors/action buttons previously added.
update(title, banner, params) {
update: function(title, banner, params) {
params = Params.parse(params, { gicon: null,
secondaryGIcon: null,
bannerMarkup: false,
@@ -403,7 +403,7 @@ var Notification = new Lang.Class({
// addAction:
// @label: the label for the action's button
// @callback: the callback for the action
addAction(label, callback) {
addAction: function(label, callback) {
this.actions.push({ label: label, callback: callback });
},
@@ -418,23 +418,23 @@ var Notification = new Lang.Class({
this.emit('acknowledged-changed');
},
setUrgency(urgency) {
setUrgency: function(urgency) {
this.urgency = urgency;
},
setResident(resident) {
setResident: function(resident) {
this.resident = resident;
},
setTransient(isTransient) {
setTransient: function(isTransient) {
this.isTransient = isTransient;
},
setForFeedback(forFeedback) {
setForFeedback: function(forFeedback) {
this.forFeedback = forFeedback;
},
playSound() {
playSound: function() {
if (this._soundPlayed)
return;
@@ -471,17 +471,17 @@ var Notification = new Lang.Class({
// the source (which will create a NotificationBanner),
// so customization can be done by subclassing either
// Notification or Source
createBanner() {
createBanner: function() {
return this.source.createBanner(this);
},
activate() {
activate: function() {
this.emit('activated');
if (!this.resident)
this.destroy();
},
destroy(reason) {
destroy: function(reason) {
if (!reason)
reason = NotificationDestroyedReason.DISMISSED;
this.emit('destroy', reason);
@@ -493,7 +493,7 @@ var NotificationBanner = new Lang.Class({
Name: 'NotificationBanner',
Extends: Calendar.NotificationMessage,
_init(notification) {
_init: function(notification) {
this.parent(notification);
this.actor.can_focus = false;
@@ -504,21 +504,22 @@ var NotificationBanner = new Lang.Class({
this._addActions();
this._addSecondaryIcon();
this._activatedId = this.notification.connect('activated', () => {
// We hide all types of notifications once the user clicks on
// them because the common outcome of clicking should be the
// relevant window being brought forward and the user's
// attention switching to the window.
this.emit('done-displaying');
});
this._activatedId = this.notification.connect('activated',
Lang.bind(this, function() {
// We hide all types of notifications once the user clicks on
// them because the common outcome of clicking should be the
// relevant window being brought forward and the user's
// attention switching to the window.
this.emit('done-displaying');
}));
},
_onDestroy() {
_onDestroy: function() {
this.parent();
this.notification.disconnect(this._activatedId);
},
_onUpdated(n, clear) {
_onUpdated: function(n, clear) {
this.parent(n, clear);
if (clear) {
@@ -531,13 +532,14 @@ var NotificationBanner = new Lang.Class({
this._addSecondaryIcon();
},
_addActions() {
this.notification.actions.forEach(action => {
this.addAction(action.label, action.callback);
});
_addActions: function() {
this.notification.actions.forEach(Lang.bind(this,
function(action) {
this.addAction(action.label, action.callback);
}));
},
_addSecondaryIcon() {
_addSecondaryIcon: function() {
if (this.notification.secondaryGIcon) {
let icon = new St.Icon({ gicon: this.notification.secondaryGIcon,
x_align: Clutter.ActorAlign.END });
@@ -545,7 +547,7 @@ var NotificationBanner = new Lang.Class({
}
},
addButton(button, callback) {
addButton: function(button, callback) {
if (!this._buttonBox) {
this._buttonBox = new St.BoxLayout({ style_class: 'notification-actions',
x_expand: true });
@@ -557,7 +559,7 @@ var NotificationBanner = new Lang.Class({
return null;
this._buttonBox.add(button);
button.connect('clicked', () => {
button.connect('clicked', Lang.bind(this, function() {
callback();
if (!this.notification.resident) {
@@ -568,12 +570,12 @@ var NotificationBanner = new Lang.Class({
this.emit('done-displaying');
this.notification.destroy();
}
});
}));
return button;
},
addAction(label, callback) {
addAction: function(label, callback) {
let button = new St.Button({ style_class: 'notification-button',
label: label,
x_expand: true,
@@ -586,18 +588,18 @@ var NotificationBanner = new Lang.Class({
var SourceActor = new Lang.Class({
Name: 'SourceActor',
_init(source, size) {
_init: function(source, size) {
this._source = source;
this._size = size;
this.actor = new Shell.GenericContainer();
this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
this.actor.connect('allocate', this._allocate.bind(this));
this.actor.connect('destroy', () => {
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('destroy', Lang.bind(this, function() {
this._source.disconnect(this._iconUpdatedId);
this._actorDestroyed = true;
});
}));
this._actorDestroyed = false;
let scale_factor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
@@ -607,31 +609,31 @@ var SourceActor = new Lang.Class({
this.actor.add_actor(this._iconBin);
this._iconUpdatedId = this._source.connect('icon-updated', this._updateIcon.bind(this));
this._iconUpdatedId = this._source.connect('icon-updated', Lang.bind(this, this._updateIcon));
this._updateIcon();
},
setIcon(icon) {
setIcon: function(icon) {
this._iconBin.child = icon;
this._iconSet = true;
},
_getPreferredWidth(actor, forHeight, alloc) {
_getPreferredWidth: function (actor, forHeight, alloc) {
let [min, nat] = this._iconBin.get_preferred_width(forHeight);
alloc.min_size = min; alloc.nat_size = nat;
},
_getPreferredHeight(actor, forWidth, alloc) {
_getPreferredHeight: function (actor, forWidth, alloc) {
let [min, nat] = this._iconBin.get_preferred_height(forWidth);
alloc.min_size = min; alloc.nat_size = nat;
},
_allocate(actor, box, flags) {
_allocate: function(actor, box, flags) {
// the iconBin should fill our entire box
this._iconBin.allocate(box, flags);
},
_updateIcon() {
_updateIcon: function() {
if (this._actorDestroyed)
return;
@@ -644,7 +646,7 @@ var SourceActorWithLabel = new Lang.Class({
Name: 'SourceActorWithLabel',
Extends: SourceActor,
_init(source, size) {
_init: function(source, size) {
this.parent(source, size);
this._counterLabel = new St.Label({ x_align: Clutter.ActorAlign.CENTER,
@@ -657,23 +659,23 @@ var SourceActorWithLabel = new Lang.Class({
layout_manager: new Clutter.BinLayout() });
this._counterBin.hide();
this._counterBin.connect('style-changed', () => {
this._counterBin.connect('style-changed', Lang.bind(this, function() {
let themeNode = this._counterBin.get_theme_node();
this._counterBin.translation_x = themeNode.get_length('-shell-counter-overlap-x');
this._counterBin.translation_y = themeNode.get_length('-shell-counter-overlap-y');
});
}));
this.actor.add_actor(this._counterBin);
this._countUpdatedId = this._source.connect('count-updated', this._updateCount.bind(this));
this._countUpdatedId = this._source.connect('count-updated', Lang.bind(this, this._updateCount));
this._updateCount();
this.actor.connect('destroy', () => {
this.actor.connect('destroy', function() {
this._source.disconnect(this._countUpdatedId);
});
},
_allocate(actor, box, flags) {
_allocate: function(actor, box, flags) {
this.parent(actor, box, flags);
let childBox = new Clutter.ActorBox();
@@ -697,7 +699,7 @@ var SourceActorWithLabel = new Lang.Class({
this._counterBin.allocate(childBox, flags);
},
_updateCount() {
_updateCount: function() {
if (this._actorDestroyed)
return;
@@ -718,7 +720,7 @@ var Source = new Lang.Class({
SOURCE_ICON_SIZE: 48,
_init(title, iconName) {
_init: function(title, iconName) {
this.title = title;
this.iconName = iconName;
@@ -734,43 +736,43 @@ var Source = new Lang.Class({
},
get unseenCount() {
return this.notifications.filter(n => !n.acknowledged).length;
return this.notifications.filter(function(n) { return !n.acknowledged; }).length;
},
get countVisible() {
return this.count > 1;
},
countUpdated() {
countUpdated: function() {
this.emit('count-updated');
},
_createPolicy() {
_createPolicy: function() {
return new NotificationPolicy();
},
setTitle(newTitle) {
setTitle: function(newTitle) {
this.title = newTitle;
this.emit('title-changed');
},
createBanner(notification) {
createBanner: function(notification) {
return new NotificationBanner(notification);
},
// Called to create a new icon actor.
// Provides a sane default implementation, override if you need
// something more fancy.
createIcon(size) {
createIcon: function(size) {
return new St.Icon({ gicon: this.getIcon(),
icon_size: size });
},
getIcon() {
getIcon: function() {
return new Gio.ThemedIcon({ name: this.iconName });
},
_onNotificationDestroy(notification) {
_onNotificationDestroy: function(notification) {
let index = this.notifications.indexOf(notification);
if (index < 0)
return;
@@ -782,22 +784,22 @@ var Source = new Lang.Class({
this.countUpdated();
},
pushNotification(notification) {
pushNotification: function(notification) {
if (this.notifications.indexOf(notification) >= 0)
return;
while (this.notifications.length >= MAX_NOTIFICATIONS_PER_SOURCE)
this.notifications.shift().destroy(NotificationDestroyedReason.EXPIRED);
notification.connect('destroy', this._onNotificationDestroy.bind(this));
notification.connect('acknowledged-changed', this.countUpdated.bind(this));
notification.connect('destroy', Lang.bind(this, this._onNotificationDestroy));
notification.connect('acknowledged-changed', Lang.bind(this, this.countUpdated));
this.notifications.push(notification);
this.emit('notification-added', notification);
this.countUpdated();
},
notify(notification) {
notify: function(notification) {
notification.acknowledged = false;
this.pushNotification(notification);
@@ -808,7 +810,7 @@ var Source = new Lang.Class({
}
},
destroy(reason) {
destroy: function(reason) {
this.policy.destroy();
let notifications = this.notifications;
@@ -820,15 +822,15 @@ var Source = new Lang.Class({
this.emit('destroy', reason);
},
iconUpdated() {
iconUpdated: function() {
this.emit('icon-updated');
},
// To be overridden by subclasses
open() {
open: function() {
},
destroyNonResidentNotifications() {
destroyNonResidentNotifications: function() {
for (let i = this.notifications.length - 1; i >= 0; i--)
if (!this.notifications[i].resident)
this.notifications[i].destroy();
@@ -841,26 +843,27 @@ Signals.addSignalMethods(Source.prototype);
var MessageTray = new Lang.Class({
Name: 'MessageTray',
_init() {
this._presence = new GnomeSession.Presence((proxy, error) => {
_init: function() {
this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) {
this._onStatusChanged(proxy.status);
});
}));
this._busy = false;
this._bannerBlocked = false;
this._presence.connectSignal('StatusChanged', (proxy, senderName, [status]) => {
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
this._onStatusChanged(status);
});
}));
global.stage.connect('enter-event', (a, ev) => {
// HACK: St uses ClutterInputDevice for hover tracking, which
// misses relevant X11 events when untracked actors are
// involved (read: the notification banner in normal mode),
// so fix up Clutter's view of the pointer position in
// that case.
let related = ev.get_related();
if (!related || this.actor.contains(related))
global.sync_pointer();
});
global.stage.connect('enter-event', Lang.bind(this,
function(a, ev) {
// HACK: St uses ClutterInputDevice for hover tracking, which
// misses relevant X11 events when untracked actors are
// involved (read: the notification banner in normal mode),
// so fix up Clutter's view of the pointer position in
// that case.
let related = ev.get_related();
if (!related || this.actor.contains(related))
global.sync_pointer();
}));
this.actor = new St.Widget({ visible: false,
clip_to_allocation: true,
@@ -880,9 +883,9 @@ var MessageTray = new Lang.Class({
x_expand: true,
layout_manager: new Clutter.BinLayout() });
this._bannerBin.connect('key-release-event',
this._onNotificationKeyRelease.bind(this));
Lang.bind(this, this._onNotificationKeyRelease));
this._bannerBin.connect('notify::hover',
this._onNotificationHoverChanged.bind(this));
Lang.bind(this, this._onNotificationHoverChanged));
this.actor.add_actor(this._bannerBin);
this._notificationFocusGrabber = new FocusGrabber(this._bannerBin);
@@ -915,50 +918,50 @@ var MessageTray = new Lang.Class({
Main.layoutManager.addChrome(this.actor, { affectsInputRegion: false });
Main.layoutManager.trackChrome(this._bannerBin, { affectsInputRegion: true });
global.screen.connect('in-fullscreen-changed', this._updateState.bind(this));
global.screen.connect('in-fullscreen-changed', Lang.bind(this, this._updateState));
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
Main.overview.connect('window-drag-begin',
this._onDragBegin.bind(this));
Lang.bind(this, this._onDragBegin));
Main.overview.connect('window-drag-cancelled',
this._onDragEnd.bind(this));
Lang.bind(this, this._onDragEnd));
Main.overview.connect('window-drag-end',
this._onDragEnd.bind(this));
Lang.bind(this, this._onDragEnd));
Main.overview.connect('item-drag-begin',
this._onDragBegin.bind(this));
Lang.bind(this, this._onDragBegin));
Main.overview.connect('item-drag-cancelled',
this._onDragEnd.bind(this));
Lang.bind(this, this._onDragEnd));
Main.overview.connect('item-drag-end',
this._onDragEnd.bind(this));
Lang.bind(this, this._onDragEnd));
Main.xdndHandler.connect('drag-begin',
this._onDragBegin.bind(this));
Lang.bind(this, this._onDragBegin));
Main.xdndHandler.connect('drag-end',
this._onDragEnd.bind(this));
Lang.bind(this, this._onDragEnd));
Main.wm.addKeybinding('focus-active-notification',
new Gio.Settings({ schema_id: SHELL_KEYBINDINGS_SCHEMA }),
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.NORMAL |
Shell.ActionMode.OVERVIEW,
this._expandActiveNotification.bind(this));
Lang.bind(this, this._expandActiveNotification));
this._sources = new Map();
this._sessionUpdated();
},
_sessionUpdated() {
_sessionUpdated: function() {
this._updateState();
},
_onDragBegin() {
_onDragBegin: function() {
Shell.util_set_hidden_from_pick(this.actor, true);
},
_onDragEnd() {
_onDragEnd: function() {
Shell.util_set_hidden_from_pick(this.actor, false);
},
@@ -970,7 +973,7 @@ var MessageTray = new Lang.Class({
this._bannerBin.set_x_align(align);
},
_onNotificationKeyRelease(actor, event) {
_onNotificationKeyRelease: function(actor, event) {
if (event.get_key_symbol() == Clutter.KEY_Escape && event.get_state() == 0) {
this._expireNotification();
return Clutter.EVENT_STOP;
@@ -979,7 +982,7 @@ var MessageTray = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_expireNotification() {
_expireNotification: function() {
this._notificationExpired = true;
this._updateState();
},
@@ -995,11 +998,11 @@ var MessageTray = new Lang.Class({
this._updateState();
},
contains(source) {
contains: function(source) {
return this._sources.has(source);
},
add(source) {
add: function(source) {
if (this.contains(source)) {
log('Trying to re-add source ' + source.title);
return;
@@ -1008,14 +1011,12 @@ var MessageTray = new Lang.Class({
// Register that we got a notification for this source
source.policy.store();
source.policy.connect('enable-changed', () => {
this._onSourceEnableChanged(source.policy, source);
});
source.policy.connect('policy-changed', this._updateState.bind(this));
source.policy.connect('enable-changed', Lang.bind(this, this._onSourceEnableChanged, source));
source.policy.connect('policy-changed', Lang.bind(this, this._updateState));
this._onSourceEnableChanged(source.policy, source);
},
_addSource(source) {
_addSource: function(source) {
let obj = {
source: source,
notifyId: 0,
@@ -1024,13 +1025,13 @@ var MessageTray = new Lang.Class({
this._sources.set(source, obj);
obj.notifyId = source.connect('notify', this._onNotify.bind(this));
obj.destroyId = source.connect('destroy', this._onSourceDestroy.bind(this));
obj.notifyId = source.connect('notify', Lang.bind(this, this._onNotify));
obj.destroyId = source.connect('destroy', Lang.bind(this, this._onSourceDestroy));
this.emit('source-added', source);
},
_removeSource(source) {
_removeSource: function(source) {
let obj = this._sources.get(source);
this._sources.delete(source);
@@ -1040,11 +1041,11 @@ var MessageTray = new Lang.Class({
this.emit('source-removed', source);
},
getSources() {
getSources: function() {
return [...this._sources.keys()];
},
_onSourceEnableChanged(policy, source) {
_onSourceEnableChanged: function(policy, source) {
let wasEnabled = this.contains(source);
let shouldBeEnabled = policy.enable;
@@ -1056,11 +1057,11 @@ var MessageTray = new Lang.Class({
}
},
_onSourceDestroy(source) {
_onSourceDestroy: function(source) {
this._removeSource(source);
},
_onNotificationDestroy(notification) {
_onNotificationDestroy: function(notification) {
if (this._notification == notification && (this._notificationState == State.SHOWN || this._notificationState == State.SHOWING)) {
this._updateNotificationTimeout(0);
this._notificationRemoved = true;
@@ -1075,7 +1076,7 @@ var MessageTray = new Lang.Class({
}
},
_onNotify(source, notification) {
_onNotify: function(source, notification) {
if (this._notification == notification) {
// If a notification that is being shown is updated, we update
// how it is shown and extend the time until it auto-hides.
@@ -1090,18 +1091,18 @@ var MessageTray = new Lang.Class({
let full = (this.queueCount + bannerCount >= MAX_NOTIFICATIONS_IN_QUEUE);
if (!full || notification.urgency == Urgency.CRITICAL) {
notification.connect('destroy',
this._onNotificationDestroy.bind(this));
Lang.bind(this, this._onNotificationDestroy));
this._notificationQueue.push(notification);
this._notificationQueue.sort(
(n1, n2) => n2.urgency - n1.urgency
);
this._notificationQueue.sort(function(notification1, notification2) {
return (notification2.urgency - notification1.urgency);
});
this.emit('queue-changed');
}
}
this._updateState();
},
_resetNotificationLeftTimeout() {
_resetNotificationLeftTimeout: function() {
this._useLongerNotificationLeftTimeout = false;
if (this._notificationLeftTimeoutId) {
Mainloop.source_remove(this._notificationLeftTimeoutId);
@@ -1111,7 +1112,7 @@ var MessageTray = new Lang.Class({
}
},
_onNotificationHoverChanged() {
_onNotificationHoverChanged: function() {
if (this._bannerBin.hover == this._notificationHovered)
return;
@@ -1150,12 +1151,12 @@ var MessageTray = new Lang.Class({
// We wait for a longer period if the notification popped up where the mouse pointer was already positioned.
// That gives the user more time to mouse away from the notification and mouse back in in order to expand it.
let timeout = this._useLongerNotificationLeftTimeout ? LONGER_HIDE_TIMEOUT * 1000 : HIDE_TIMEOUT * 1000;
this._notificationLeftTimeoutId = Mainloop.timeout_add(timeout, this._onNotificationLeftTimeout.bind(this));
this._notificationLeftTimeoutId = Mainloop.timeout_add(timeout, Lang.bind(this, this._onNotificationLeftTimeout));
GLib.Source.set_name_by_id(this._notificationLeftTimeoutId, '[gnome-shell] this._onNotificationLeftTimeout');
}
},
_onStatusChanged(status) {
_onStatusChanged: function(status) {
if (status == GnomeSession.PresenceStatus.BUSY) {
// remove notification and allow the summary to be closed now
this._updateNotificationTimeout(0);
@@ -1170,7 +1171,7 @@ var MessageTray = new Lang.Class({
this._updateState();
},
_onNotificationLeftTimeout() {
_onNotificationLeftTimeout: function() {
let [x, y, mods] = global.get_pointer();
// We extend the timeout once if the mouse moved no further than MOUSE_LEFT_ACTOR_THRESHOLD to either side.
if (this._notificationLeftMouseX > -1 &&
@@ -1180,7 +1181,7 @@ var MessageTray = new Lang.Class({
x > this._notificationLeftMouseX - MOUSE_LEFT_ACTOR_THRESHOLD) {
this._notificationLeftMouseX = -1;
this._notificationLeftTimeoutId = Mainloop.timeout_add(LONGER_HIDE_TIMEOUT * 1000,
this._onNotificationLeftTimeout.bind(this));
Lang.bind(this, this._onNotificationLeftTimeout));
GLib.Source.set_name_by_id(this._notificationLeftTimeoutId, '[gnome-shell] this._onNotificationLeftTimeout');
} else {
this._notificationLeftTimeoutId = 0;
@@ -1192,7 +1193,7 @@ var MessageTray = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
_escapeTray() {
_escapeTray: function() {
this._pointerInNotification = false;
this._updateNotificationTimeout(0);
this._updateState();
@@ -1203,7 +1204,7 @@ var MessageTray = new Lang.Class({
// 'this._pointerInNotification', 'this._traySummoned', etc, and
// _updateState() figures out what (if anything) needs to be done
// at the present time.
_updateState() {
_updateState: function() {
let hasMonitor = Main.layoutManager.primaryMonitor != null;
this.actor.visible = !this._bannerBlocked && hasMonitor && this._banner != null;
if (this._bannerBlocked || !hasMonitor)
@@ -1218,7 +1219,7 @@ var MessageTray = new Lang.Class({
// Filter out acknowledged notifications.
let changed = false;
this._notificationQueue = this._notificationQueue.filter(n => {
this._notificationQueue = this._notificationQueue.filter(function(n) {
changed = changed || n.acknowledged;
return !n.acknowledged;
});
@@ -1261,7 +1262,7 @@ var MessageTray = new Lang.Class({
this._notificationExpired = false;
},
_tween(actor, statevar, value, params) {
_tween: function(actor, statevar, value, params) {
let onComplete = params.onComplete;
let onCompleteScope = params.onCompleteScope;
let onCompleteParams = params.onCompleteParams;
@@ -1278,24 +1279,24 @@ var MessageTray = new Lang.Class({
this[statevar] = valuing;
},
_tweenComplete(statevar, value, onComplete, onCompleteScope, onCompleteParams) {
_tweenComplete: function(statevar, value, onComplete, onCompleteScope, onCompleteParams) {
this[statevar] = value;
if (onComplete)
onComplete.apply(onCompleteScope, onCompleteParams);
this._updateState();
},
_clampOpacity() {
_clampOpacity: function() {
this._bannerBin.opacity = Math.max(0, Math.min(this._bannerBin._opacity, 255));
},
_onIdleMonitorBecameActive() {
_onIdleMonitorBecameActive: function() {
this._userActiveWhileNotificationShown = true;
this._updateNotificationTimeout(2000);
this._updateState();
},
_showNotification() {
_showNotification: function() {
this._notification = this._notificationQueue.shift();
this.emit('queue-changed');
@@ -1303,15 +1304,15 @@ var MessageTray = new Lang.Class({
if (!this._userActiveWhileNotificationShown) {
// If the user isn't active, set up a watch to let us know
// when the user becomes active.
this.idleMonitor.add_user_active_watch(this._onIdleMonitorBecameActive.bind(this));
this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
}
this._banner = this._notification.createBanner();
this._bannerClickedId = this._banner.connect('done-displaying',
this._escapeTray.bind(this));
this._bannerUnfocusedId = this._banner.connect('unfocused', () => {
Lang.bind(this, this._escapeTray));
this._bannerUnfocusedId = this._banner.connect('unfocused', Lang.bind(this, function() {
this._updateState();
});
}));
this._bannerBin.add_actor(this._banner.actor);
@@ -1339,7 +1340,7 @@ var MessageTray = new Lang.Class({
this._resetNotificationLeftTimeout();
},
_updateShowingNotification() {
_updateShowingNotification: function() {
this._notification.acknowledged = true;
this._notification.playSound();
@@ -1373,12 +1374,12 @@ var MessageTray = new Lang.Class({
this._tween(this._bannerBin, '_notificationState', State.SHOWN, tweenParams);
},
_showNotificationCompleted() {
_showNotificationCompleted: function() {
if (this._notification.urgency != Urgency.CRITICAL)
this._updateNotificationTimeout(NOTIFICATION_TIMEOUT * 1000);
},
_updateNotificationTimeout(timeout) {
_updateNotificationTimeout: function(timeout) {
if (this._notificationTimeoutId) {
Mainloop.source_remove(this._notificationTimeoutId);
this._notificationTimeoutId = 0;
@@ -1386,12 +1387,12 @@ var MessageTray = new Lang.Class({
if (timeout > 0) {
this._notificationTimeoutId =
Mainloop.timeout_add(timeout,
this._notificationTimeout.bind(this));
Lang.bind(this, this._notificationTimeout));
GLib.Source.set_name_by_id(this._notificationTimeoutId, '[gnome-shell] this._notificationTimeout');
}
},
_notificationTimeout() {
_notificationTimeout: function() {
let [x, y, mods] = global.get_pointer();
if (y < this._lastSeenMouseY - 10 && !this._notificationHovered) {
// The mouse is moving towards the notification, so don't
@@ -1415,7 +1416,7 @@ var MessageTray = new Lang.Class({
return GLib.SOURCE_REMOVE;
},
_hideNotification(animate) {
_hideNotification: function(animate) {
this._notificationFocusGrabber.ungrabFocus();
if (this._bannerClickedId) {
@@ -1449,7 +1450,7 @@ var MessageTray = new Lang.Class({
}
},
_hideNotificationCompleted() {
_hideNotificationCompleted: function() {
let notification = this._notification;
this._notification = null;
if (notification.isTransient)
@@ -1463,14 +1464,14 @@ var MessageTray = new Lang.Class({
this.actor.hide();
},
_expandActiveNotification() {
_expandActiveNotification: function() {
if (!this._banner)
return;
this._expandBanner(false);
},
_expandBanner(autoExpanding) {
_expandBanner: function(autoExpanding) {
// Don't animate changes in notifications that are auto-expanding.
this._banner.expand(!autoExpanding);
@@ -1479,7 +1480,7 @@ var MessageTray = new Lang.Class({
this._ensureBannerFocused();
},
_ensureBannerFocused() {
_ensureBannerFocused: function() {
this._notificationFocusGrabber.grabFocus();
}
});
@@ -1489,11 +1490,11 @@ var SystemNotificationSource = new Lang.Class({
Name: 'SystemNotificationSource',
Extends: Source,
_init() {
_init: function() {
this.parent(_("System Information"), 'dialog-information-symbolic');
},
open() {
open: function() {
this.destroy();
}
});

View File

@@ -34,7 +34,7 @@ var State = {
var ModalDialog = new Lang.Class({
Name: 'ModalDialog',
_init(params) {
_init: function(params) {
params = Params.parse(params, { shellReactive: false,
styleClass: null,
actionMode: Shell.ActionMode.SYSTEM_MODAL,
@@ -60,7 +60,7 @@ var ModalDialog = new Lang.Class({
coordinate: Clutter.BindCoordinate.ALL });
this._group.add_constraint(constraint);
this._group.connect('destroy', this._onGroupDestroy.bind(this));
this._group.connect('destroy', Lang.bind(this, this._onGroupDestroy));
this.backgroundStack = new St.Widget({ layout_manager: new Clutter.BinLayout() });
this._backgroundBin = new St.Bin({ child: this.backgroundStack,
@@ -89,15 +89,15 @@ var ModalDialog = new Lang.Class({
this._savedKeyFocus = null;
},
destroy() {
destroy: function() {
this._group.destroy();
},
clearButtons() {
clearButtons: function() {
this.dialogLayout.clearButtons();
},
setButtons(buttons) {
setButtons: function(buttons) {
this.clearButtons();
for (let i = 0; i < buttons.length; i++) {
@@ -117,15 +117,15 @@ var ModalDialog = new Lang.Class({
}
},
addButton(buttonInfo) {
addButton: function (buttonInfo) {
return this.dialogLayout.addButton(buttonInfo);
},
_onGroupDestroy() {
_onGroupDestroy: function() {
this.emit('destroy');
},
_fadeOpen(onPrimary) {
_fadeOpen: function(onPrimary) {
if (onPrimary)
this._monitorConstraint.primary = true;
else
@@ -142,26 +142,27 @@ var ModalDialog = new Lang.Class({
{ opacity: 255,
time: this._shouldFadeIn ? OPEN_AND_CLOSE_TIME : 0,
transition: 'easeOutQuad',
onComplete: () => {
this.state = State.OPENED;
this.emit('opened');
}
onComplete: Lang.bind(this,
function() {
this.state = State.OPENED;
this.emit('opened');
})
});
},
setInitialKeyFocus(actor) {
setInitialKeyFocus: function(actor) {
if (this._initialKeyFocusDestroyId)
this._initialKeyFocus.disconnect(this._initialKeyFocusDestroyId);
this._initialKeyFocus = actor;
this._initialKeyFocusDestroyId = actor.connect('destroy', () => {
this._initialKeyFocusDestroyId = actor.connect('destroy', Lang.bind(this, function() {
this._initialKeyFocus = null;
this._initialKeyFocusDestroyId = 0;
});
}));
},
open(timestamp, onPrimary) {
open: function(timestamp, onPrimary) {
if (this.state == State.OPENED || this.state == State.OPENING)
return true;
@@ -172,7 +173,7 @@ var ModalDialog = new Lang.Class({
return true;
},
_closeComplete() {
_closeComplete: function() {
this.state = State.CLOSED;
this._group.hide();
this.emit('closed');
@@ -181,7 +182,7 @@ var ModalDialog = new Lang.Class({
this.destroy();
},
close(timestamp) {
close: function(timestamp) {
if (this.state == State.CLOSED || this.state == State.CLOSING)
return;
@@ -194,7 +195,8 @@ var ModalDialog = new Lang.Class({
{ opacity: 0,
time: OPEN_AND_CLOSE_TIME,
transition: 'easeOutQuad',
onComplete: this._closeComplete.bind(this)
onComplete: Lang.bind(this,
this._closeComplete)
})
else
this._closeComplete();
@@ -203,7 +205,7 @@ var ModalDialog = new Lang.Class({
// Drop modal status without closing the dialog; this makes the
// dialog insensitive as well, so it needs to be followed shortly
// by either a close() or a pushModal()
popModal(timestamp) {
popModal: function(timestamp) {
if (!this._hasModal)
return;
@@ -220,7 +222,7 @@ var ModalDialog = new Lang.Class({
this._eventBlocker.raise_top();
},
pushModal(timestamp) {
pushModal: function (timestamp) {
if (this._hasModal)
return true;
@@ -255,7 +257,7 @@ var ModalDialog = new Lang.Class({
// e.g., if a user clicked "Log Out" then the dialog should go away
// imediately, but the lightbox should remain until the logout is
// complete.
_fadeOutDialog(timestamp) {
_fadeOutDialog: function(timestamp) {
if (this.state == State.CLOSED || this.state == State.CLOSING)
return;
@@ -267,9 +269,10 @@ var ModalDialog = new Lang.Class({
{ opacity: 0,
time: FADE_OUT_DIALOG_TIME,
transition: 'easeOutQuad',
onComplete: () => {
this.state = State.FADED_OUT;
}
onComplete: Lang.bind(this,
function() {
this.state = State.FADED_OUT;
})
});
}
});

View File

@@ -51,7 +51,7 @@ var MediaMessage = new Lang.Class({
Name: 'MediaMessage',
Extends: MessageList.Message,
_init(player) {
_init: function(player) {
this._player = player;
this.parent('', '');
@@ -60,35 +60,35 @@ var MediaMessage = new Lang.Class({
this.setIcon(this._icon);
this._prevButton = this.addMediaControl('media-skip-backward-symbolic',
() => {
Lang.bind(this, function() {
this._player.previous();
});
}));
this._playPauseButton = this.addMediaControl(null,
() => {
Lang.bind(this, function() {
this._player.playPause();
});
}));
this._nextButton = this.addMediaControl('media-skip-forward-symbolic',
() => {
Lang.bind(this, function() {
this._player.next();
});
}));
this._player.connect('changed', this._update.bind(this));
this._player.connect('closed', this.close.bind(this));
this._player.connect('changed', Lang.bind(this, this._update));
this._player.connect('closed', Lang.bind(this, this.close));
this._update();
},
_onClicked() {
_onClicked: function() {
this._player.raise();
Main.panel.closeCalendar();
},
_updateNavButton(button, sensitive) {
_updateNavButton: function(button, sensitive) {
button.reactive = sensitive;
},
_update() {
_update: function() {
this.setTitle(this._player.trackArtists.join(', '));
this.setBody(this._player.trackTitle);
@@ -114,13 +114,13 @@ var MediaMessage = new Lang.Class({
var MprisPlayer = new Lang.Class({
Name: 'MprisPlayer',
_init(busName) {
_init: function(busName) {
this._mprisProxy = new MprisProxy(Gio.DBus.session, busName,
'/org/mpris/MediaPlayer2',
this._onMprisProxyReady.bind(this));
Lang.bind(this, this._onMprisProxyReady));
this._playerProxy = new MprisPlayerProxy(Gio.DBus.session, busName,
'/org/mpris/MediaPlayer2',
this._onPlayerProxyReady.bind(this));
Lang.bind(this, this._onPlayerProxyReady));
this._visible = false;
this._trackArtists = [];
@@ -144,7 +144,7 @@ var MprisPlayer = new Lang.Class({
return this._trackCoverUrl;
},
playPause() {
playPause: function() {
this._playerProxy.PlayPauseRemote();
},
@@ -152,7 +152,7 @@ var MprisPlayer = new Lang.Class({
return this._playerProxy.CanGoNext;
},
next() {
next: function() {
this._playerProxy.NextRemote();
},
@@ -160,11 +160,11 @@ var MprisPlayer = new Lang.Class({
return this._playerProxy.CanGoPrevious;
},
previous() {
previous: function() {
this._playerProxy.PreviousRemote();
},
raise() {
raise: function() {
// The remote Raise() method may run into focus stealing prevention,
// so prefer activating the app via .desktop file if possible
let app = null;
@@ -179,7 +179,7 @@ var MprisPlayer = new Lang.Class({
this._mprisProxy.RaiseRemote();
},
_close() {
_close: function() {
this._mprisProxy.disconnect(this._ownerNotifyId);
this._mprisProxy = null;
@@ -189,21 +189,21 @@ var MprisPlayer = new Lang.Class({
this.emit('closed');
},
_onMprisProxyReady() {
_onMprisProxyReady: function() {
this._ownerNotifyId = this._mprisProxy.connect('notify::g-name-owner',
() => {
Lang.bind(this, function() {
if (!this._mprisProxy.g_name_owner)
this._close();
});
}));
},
_onPlayerProxyReady() {
_onPlayerProxyReady: function() {
this._propsChangedId = this._playerProxy.connect('g-properties-changed',
this._updateState.bind(this));
Lang.bind(this, this._updateState));
this._updateState();
},
_updateState() {
_updateState: function() {
let metadata = {};
for (let prop in this._playerProxy.Metadata)
metadata[prop] = this._playerProxy.Metadata[prop].deep_unpack();
@@ -230,7 +230,7 @@ var MediaSection = new Lang.Class({
Name: 'MediaSection',
Extends: MessageList.MessageListSection,
_init() {
_init: function() {
this.parent();
this._players = new Map();
@@ -238,44 +238,46 @@ var MediaSection = new Lang.Class({
this._proxy = new DBusProxy(Gio.DBus.session,
'org.freedesktop.DBus',
'/org/freedesktop/DBus',
this._onProxyReady.bind(this));
Lang.bind(this, this._onProxyReady));
},
_shouldShow() {
_shouldShow: function() {
return !this.empty && Calendar.isToday(this._date);
},
_addPlayer(busName) {
_addPlayer: function(busName) {
if (this._players.get(busName))
return;
let player = new MprisPlayer(busName);
player.connect('closed',
() => {
player.connect('closed', Lang.bind(this,
function() {
this._players.delete(busName);
});
player.connect('show',
() => {
}));
player.connect('show', Lang.bind(this,
function() {
let message = new MediaMessage(player);
this.addMessage(message, true);
});
}));
this._players.set(busName, player);
},
_onProxyReady() {
this._proxy.ListNamesRemote(([names]) => {
names.forEach(name => {
if (!name.startsWith(MPRIS_PLAYER_PREFIX))
return;
_onProxyReady: function() {
this._proxy.ListNamesRemote(Lang.bind(this,
function([names]) {
names.forEach(Lang.bind(this,
function(name) {
if (!name.startsWith(MPRIS_PLAYER_PREFIX))
return;
this._addPlayer(name);
});
});
this._addPlayer(name);
}));
}));
this._proxy.connectSignal('NameOwnerChanged',
this._onNameOwnerChanged.bind(this));
Lang.bind(this, this._onNameOwnerChanged));
},
_onNameOwnerChanged(proxy, sender, [name, oldOwner, newOwner]) {
_onNameOwnerChanged: function(proxy, sender, [name, oldOwner, newOwner]) {
if (!name.startsWith(MPRIS_PLAYER_PREFIX))
return;

View File

@@ -94,7 +94,7 @@ const rewriteRules = {
var FdoNotificationDaemon = new Lang.Class({
Name: 'FdoNotificationDaemon',
_init() {
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(FdoNotificationsIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/freedesktop/Notifications');
@@ -106,12 +106,12 @@ var FdoNotificationDaemon = new Lang.Class({
this._nextNotificationId = 1;
Shell.WindowTracker.get_default().connect('notify::focus-app',
this._onFocusAppChanged.bind(this));
Lang.bind(this, this._onFocusAppChanged));
Main.overview.connect('hidden',
this._onFocusAppChanged.bind(this));
Lang.bind(this, this._onFocusAppChanged));
},
_imageForNotificationData(hints) {
_imageForNotificationData: function(hints) {
if (hints['image-data']) {
let [width, height, rowStride, hasAlpha,
bitsPerSample, nChannels, data] = hints['image-data'];
@@ -123,7 +123,7 @@ var FdoNotificationDaemon = new Lang.Class({
return null;
},
_fallbackIconForNotificationData(hints) {
_fallbackIconForNotificationData: function(hints) {
let stockIcon;
switch (hints.urgency) {
case Urgency.LOW:
@@ -137,7 +137,7 @@ var FdoNotificationDaemon = new Lang.Class({
return new Gio.ThemedIcon({ name: stockIcon });
},
_iconForNotificationData(icon) {
_iconForNotificationData: function(icon) {
if (icon) {
if (icon.substr(0, 7) == 'file://')
return new Gio.FileIcon({ file: Gio.File.new_for_uri(icon) });
@@ -149,7 +149,7 @@ var FdoNotificationDaemon = new Lang.Class({
return null;
},
_lookupSource(title, pid) {
_lookupSource: function(title, pid) {
for (let i = 0; i < this._sources.length; i++) {
let source = this._sources[i];
if (source.pid == pid && source.initialTitle == title)
@@ -169,7 +169,7 @@ var FdoNotificationDaemon = new Lang.Class({
//
// Either a pid or ndata.notification is needed to retrieve or
// create a source.
_getSource(title, pid, ndata, sender) {
_getSource: function(title, pid, ndata, sender) {
if (!pid && !(ndata && ndata.notification))
return null;
@@ -190,17 +190,17 @@ var FdoNotificationDaemon = new Lang.Class({
source = new FdoNotificationDaemonSource(title, pid, sender, appId);
this._sources.push(source);
source.connect('destroy', () => {
source.connect('destroy', Lang.bind(this, function() {
let index = this._sources.indexOf(source);
if (index >= 0)
this._sources.splice(index, 1);
});
}));
Main.messageTray.add(source);
return source;
},
NotifyAsync(params, invocation) {
NotifyAsync: function(params, invocation) {
let [appName, replacesId, icon, summary, body, actions, hints, timeout] = params;
let id;
@@ -220,10 +220,11 @@ var FdoNotificationDaemon = new Lang.Class({
// Ignore replacesId since we already sent back a
// NotificationClosed for that id.
id = this._nextNotificationId++;
let idle_id = Mainloop.idle_add(() => {
this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
return GLib.SOURCE_REMOVE;
});
let idle_id = Mainloop.idle_add(Lang.bind(this,
function () {
this._emitNotificationClosed(id, NotificationClosedReason.DISMISSED);
return GLib.SOURCE_REMOVE;
}));
GLib.Source.set_name_by_id(idle_id, '[gnome-shell] this._emitNotificationClosed');
return invocation.return_value(GLib.Variant.new('(u)', [id]));
}
@@ -284,7 +285,7 @@ var FdoNotificationDaemon = new Lang.Class({
return invocation.return_value(GLib.Variant.new('(u)', [id]));;
}
this._busProxy.GetConnectionUnixProcessIDRemote(sender, (result, excp) => {
this._busProxy.GetConnectionUnixProcessIDRemote(sender, Lang.bind(this, function (result, excp) {
// The app may have updated or removed the notification
ndata = this._notifications[id];
if (!ndata)
@@ -299,16 +300,16 @@ var FdoNotificationDaemon = new Lang.Class({
source = this._getSource(appName, pid, ndata, sender, null);
this._senderToPid[sender] = pid;
source.connect('destroy', () => {
source.connect('destroy', Lang.bind(this, function() {
delete this._senderToPid[sender];
});
}));
this._notifyForSource(source, ndata);
});
}));
return invocation.return_value(GLib.Variant.new('(u)', [id]));
},
_notifyForSource(source, ndata) {
_notifyForSource: function(source, ndata) {
let [id, icon, summary, body, actions, hints, notification] =
[ndata.id, ndata.icon, ndata.summary, ndata.body,
ndata.actions, ndata.hints, ndata.notification];
@@ -316,22 +317,23 @@ var FdoNotificationDaemon = new Lang.Class({
if (notification == null) {
notification = new MessageTray.Notification(source);
ndata.notification = notification;
notification.connect('destroy', (n, reason) => {
delete this._notifications[ndata.id];
let notificationClosedReason;
switch (reason) {
case MessageTray.NotificationDestroyedReason.EXPIRED:
notificationClosedReason = NotificationClosedReason.EXPIRED;
break;
case MessageTray.NotificationDestroyedReason.DISMISSED:
notificationClosedReason = NotificationClosedReason.DISMISSED;
break;
case MessageTray.NotificationDestroyedReason.SOURCE_CLOSED:
notificationClosedReason = NotificationClosedReason.APP_CLOSED;
break;
}
this._emitNotificationClosed(ndata.id, notificationClosedReason);
});
notification.connect('destroy', Lang.bind(this,
function(n, reason) {
delete this._notifications[ndata.id];
let notificationClosedReason;
switch (reason) {
case MessageTray.NotificationDestroyedReason.EXPIRED:
notificationClosedReason = NotificationClosedReason.EXPIRED;
break;
case MessageTray.NotificationDestroyedReason.DISMISSED:
notificationClosedReason = NotificationClosedReason.DISMISSED;
break;
case MessageTray.NotificationDestroyedReason.SOURCE_CLOSED:
notificationClosedReason = NotificationClosedReason.APP_CLOSED;
break;
}
this._emitNotificationClosed(ndata.id, notificationClosedReason);
}));
}
let gicon = this._iconForNotificationData(icon, hints);
@@ -363,20 +365,20 @@ var FdoNotificationDaemon = new Lang.Class({
if (actionId == 'default')
hasDefaultAction = true;
else
notification.addAction(label, () => {
notification.addAction(label, Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, actionId);
});
}));
}
}
if (hasDefaultAction) {
notification.connect('activated', () => {
notification.connect('activated', Lang.bind(this, function() {
this._emitActionInvoked(ndata.id, 'default');
});
}));
} else {
notification.connect('activated', () => {
notification.connect('activated', Lang.bind(this, function() {
source.open();
});
}));
}
switch (hints.urgency) {
@@ -399,7 +401,7 @@ var FdoNotificationDaemon = new Lang.Class({
source.processNotification(notification, sourceGIcon);
},
CloseNotification(id) {
CloseNotification: function(id) {
let ndata = this._notifications[id];
if (ndata) {
if (ndata.notification)
@@ -408,7 +410,7 @@ var FdoNotificationDaemon = new Lang.Class({
}
},
GetCapabilities() {
GetCapabilities: function() {
return [
'actions',
// 'action-icons',
@@ -423,7 +425,7 @@ var FdoNotificationDaemon = new Lang.Class({
];
},
GetServerInformation() {
GetServerInformation: function() {
return [
Config.PACKAGE_NAME,
'GNOME',
@@ -432,7 +434,7 @@ var FdoNotificationDaemon = new Lang.Class({
];
},
_onFocusAppChanged() {
_onFocusAppChanged: function() {
let tracker = Shell.WindowTracker.get_default();
if (!tracker.focus_app)
return;
@@ -446,12 +448,12 @@ var FdoNotificationDaemon = new Lang.Class({
}
},
_emitNotificationClosed(id, reason) {
_emitNotificationClosed: function(id, reason) {
this._dbusImpl.emit_signal('NotificationClosed',
GLib.Variant.new('(uu)', [id, reason]));
},
_emitActionInvoked(id, action) {
_emitActionInvoked: function(id, action) {
this._dbusImpl.emit_signal('ActionInvoked',
GLib.Variant.new('(us)', [id, action]));
}
@@ -461,7 +463,7 @@ var FdoNotificationDaemonSource = new Lang.Class({
Name: 'FdoNotificationDaemonSource',
Extends: MessageTray.Source,
_init(title, pid, sender, appId) {
_init: function(title, pid, sender, appId) {
// Need to set the app before chaining up, so
// methods called from the parent constructor can find it
this.pid = pid;
@@ -480,12 +482,12 @@ var FdoNotificationDaemonSource = new Lang.Class({
this._nameWatcherId = Gio.DBus.session.watch_name(sender,
Gio.BusNameWatcherFlags.NONE,
null,
this._onNameVanished.bind(this));
Lang.bind(this, this._onNameVanished));
else
this._nameWatcherId = 0;
},
_createPolicy() {
_createPolicy: function() {
if (this.app && this.app.get_app_info()) {
let id = this.app.get_id().replace(/\.desktop$/,'');
return new MessageTray.NotificationApplicationPolicy(id);
@@ -494,7 +496,7 @@ var FdoNotificationDaemonSource = new Lang.Class({
}
},
_onNameVanished() {
_onNameVanished: function() {
// Destroy the notification source when its sender is removed from DBus.
// Only do so if this.app is set to avoid removing "notify-send" sources, senders
// of which аre removed from DBus immediately.
@@ -504,7 +506,7 @@ var FdoNotificationDaemonSource = new Lang.Class({
this.destroy();
},
processNotification(notification, gicon) {
processNotification: function(notification, gicon) {
if (gicon)
this._gicon = gicon;
this.iconUpdated();
@@ -516,7 +518,7 @@ var FdoNotificationDaemonSource = new Lang.Class({
this.notify(notification);
},
_getApp(appId) {
_getApp: function(appId) {
let app;
app = Shell.WindowTracker.get_default().get_app_from_pid(this.pid);
@@ -532,7 +534,7 @@ var FdoNotificationDaemonSource = new Lang.Class({
return null;
},
setTitle(title) {
setTitle: function(title) {
// Do nothing if .app is set, we don't want to override the
// app name with whatever is provided through libnotify (usually
// garbage)
@@ -542,12 +544,12 @@ var FdoNotificationDaemonSource = new Lang.Class({
this.parent(title);
},
open() {
open: function() {
this.openApp();
this.destroyNonResidentNotifications();
},
openApp() {
openApp: function() {
if (this.app == null)
return;
@@ -556,7 +558,7 @@ var FdoNotificationDaemonSource = new Lang.Class({
Main.panel.closeCalendar();
},
destroy() {
destroy: function() {
if (this._nameWatcherId) {
Gio.DBus.session.unwatch_name(this._nameWatcherId);
this._nameWatcherId = 0;
@@ -565,7 +567,7 @@ var FdoNotificationDaemonSource = new Lang.Class({
this.parent();
},
createIcon(size) {
createIcon: function(size) {
if (this.app) {
return this.app.create_icon_texture(size);
} else if (this._gicon) {
@@ -588,7 +590,7 @@ var GtkNotificationDaemonNotification = new Lang.Class({
Name: 'GtkNotificationDaemonNotification',
Extends: MessageTray.Notification,
_init(source, notification) {
_init: function(source, notification) {
this.parent(source);
this._serialized = GLib.Variant.new('a{sv}', notification);
@@ -613,11 +615,10 @@ var GtkNotificationDaemonNotification = new Lang.Class({
}
if (buttons) {
buttons.deep_unpack().forEach(button => {
this.addAction(button.label.unpack(), () => {
this._onButtonClicked(button);
});
});
buttons.deep_unpack().forEach(Lang.bind(this, function(button) {
this.addAction(button.label.unpack(),
Lang.bind(this, this._onButtonClicked, button));
}));
}
this._defaultAction = defaultAction ? defaultAction.unpack() : null;
@@ -628,7 +629,7 @@ var GtkNotificationDaemonNotification = new Lang.Class({
datetime : time ? GLib.DateTime.new_from_unix_local(time.unpack()) : null });
},
_activateAction(namespacedActionId, target) {
_activateAction: function(namespacedActionId, target) {
if (namespacedActionId) {
if (namespacedActionId.startsWith('app.')) {
let actionId = namespacedActionId.slice('app.'.length);
@@ -639,17 +640,17 @@ var GtkNotificationDaemonNotification = new Lang.Class({
}
},
_onButtonClicked(button) {
_onButtonClicked: function(button) {
let { 'action': action, 'target': actionTarget } = button;
this._activateAction(action.unpack(), actionTarget);
},
activate() {
activate: function() {
this._activateAction(this._defaultAction, this._defaultActionTarget);
this.parent();
},
serialize() {
serialize: function() {
return this._serialized;
},
});
@@ -683,7 +684,7 @@ var GtkNotificationDaemonAppSource = new Lang.Class({
Name: 'GtkNotificationDaemonAppSource',
Extends: MessageTray.Source,
_init(appId) {
_init: function(appId) {
this._appId = appId;
this._objectPath = objectPathFromAppId(appId);
if (!GLib.Variant.is_object_path(this._objectPath))
@@ -699,20 +700,20 @@ var GtkNotificationDaemonAppSource = new Lang.Class({
this.parent(this._app.get_name());
},
createIcon(size) {
createIcon: function(size) {
return this._app.create_icon_texture(size);
},
_createPolicy() {
_createPolicy: function() {
return new MessageTray.NotificationApplicationPolicy(this._appId);
},
_createApp(callback) {
_createApp: function(callback) {
return new FdoApplicationProxy(Gio.DBus.session, this._appId, this._objectPath, callback);
},
activateAction(actionId, target) {
this._createApp((app, error) => {
activateAction: function(actionId, target) {
this._createApp(function (app, error) {
if (error == null)
app.ActivateActionRemote(actionId, target ? [target] : [], getPlatformData());
else
@@ -722,8 +723,8 @@ var GtkNotificationDaemonAppSource = new Lang.Class({
Main.panel.closeCalendar();
},
open() {
this._createApp((app, error) => {
open: function() {
this._createApp(function (app, error) {
if (error == null)
app.ActivateRemote(getPlatformData());
else
@@ -733,16 +734,16 @@ var GtkNotificationDaemonAppSource = new Lang.Class({
Main.panel.closeCalendar();
},
addNotification(notificationId, notificationParams, showBanner) {
addNotification: function(notificationId, notificationParams, showBanner) {
this._notificationPending = true;
if (this._notifications[notificationId])
this._notifications[notificationId].destroy();
let notification = new GtkNotificationDaemonNotification(this, notificationParams);
notification.connect('destroy', () => {
notification.connect('destroy', Lang.bind(this, function() {
delete this._notifications[notificationId];
});
}));
this._notifications[notificationId] = notification;
if (showBanner)
@@ -753,18 +754,18 @@ var GtkNotificationDaemonAppSource = new Lang.Class({
this._notificationPending = false;
},
destroy(reason) {
destroy: function(reason) {
if (this._notificationPending)
return;
this.parent(reason);
},
removeNotification(notificationId) {
removeNotification: function(notificationId) {
if (this._notifications[notificationId])
this._notifications[notificationId].destroy(MessageTray.NotificationDestroyedReason.SOURCE_CLOSED);
},
serialize() {
serialize: function() {
let notifications = [];
for (let notificationId in this._notifications) {
let notification = this._notifications[notificationId];
@@ -791,7 +792,7 @@ const GtkNotificationsIface = '<node> \
var GtkNotificationDaemon = new Lang.Class({
Name: 'GtkNotificationDaemon',
_init() {
_init: function() {
this._sources = {};
this._loadNotifications();
@@ -802,29 +803,29 @@ var GtkNotificationDaemon = new Lang.Class({
Gio.DBus.session.own_name('org.gtk.Notifications', Gio.BusNameOwnerFlags.REPLACE, null, null);
},
_ensureAppSource(appId) {
_ensureAppSource: function(appId) {
if (this._sources[appId])
return this._sources[appId];
let source = new GtkNotificationDaemonAppSource(appId);
source.connect('destroy', () => {
source.connect('destroy', Lang.bind(this, function() {
delete this._sources[appId];
this._saveNotifications();
});
source.connect('count-updated', this._saveNotifications.bind(this));
}));
source.connect('count-updated', Lang.bind(this, this._saveNotifications));
Main.messageTray.add(source);
this._sources[appId] = source;
return source;
},
_loadNotifications() {
_loadNotifications: function() {
this._isLoading = true;
let value = global.get_persistent_state('a(sa(sv))', 'notifications');
if (value) {
let sources = value.deep_unpack();
sources.forEach(([appId, notifications]) => {
sources.forEach(Lang.bind(this, function([appId, notifications]) {
if (notifications.length == 0)
return;
@@ -835,16 +836,16 @@ var GtkNotificationDaemon = new Lang.Class({
return;
}
notifications.forEach(([notificationId, notification]) => {
notifications.forEach(function([notificationId, notification]) {
source.addNotification(notificationId, notification.deep_unpack(), false);
});
});
}));
}
this._isLoading = false;
},
_saveNotifications() {
_saveNotifications: function() {
if (this._isLoading)
return;
@@ -857,7 +858,7 @@ var GtkNotificationDaemon = new Lang.Class({
global.set_persistent_state('notifications', new GLib.Variant('a(sa(sv))', sources));
},
AddNotificationAsync(params, invocation) {
AddNotificationAsync: function(params, invocation) {
let [appId, notificationId, notification] = params;
let source;
@@ -876,7 +877,7 @@ var GtkNotificationDaemon = new Lang.Class({
invocation.return_value(null);
},
RemoveNotificationAsync(params, invocation) {
RemoveNotificationAsync: function(params, invocation) {
let [appId, notificationId] = params;
let source = this._sources[appId];
if (source)
@@ -889,7 +890,7 @@ var GtkNotificationDaemon = new Lang.Class({
var NotificationDaemon = new Lang.Class({
Name: 'NotificationDaemon',
_init() {
_init: function() {
this._fdoNotificationDaemon = new FdoNotificationDaemon();
this._gtkNotificationDaemon = new GtkNotificationDaemon();
},

View File

@@ -14,7 +14,7 @@ var FADE_TIME = 0.1;
var OsdMonitorLabel = new Lang.Class({
Name: 'OsdMonitorLabel',
_init(monitor, label) {
_init: function(monitor, label) {
this._actor = new St.Widget({ x_expand: true,
y_expand: true });
@@ -35,7 +35,7 @@ var OsdMonitorLabel = new Lang.Class({
Meta.disable_unredirect_for_screen(global.screen);
},
_position() {
_position: function() {
let workArea = Main.layoutManager.getWorkAreaForMonitor(this._monitor);
if (Clutter.get_default_text_direction() == Clutter.TextDirection.RTL)
@@ -46,7 +46,7 @@ var OsdMonitorLabel = new Lang.Class({
this._box.y = workArea.y;
},
destroy() {
destroy: function() {
this._actor.destroy();
Meta.enable_unredirect_for_screen(global.screen);
}
@@ -55,18 +55,18 @@ var OsdMonitorLabel = new Lang.Class({
var OsdMonitorLabeler = new Lang.Class({
Name: 'OsdMonitorLabeler',
_init() {
_init: function() {
this._monitorManager = Meta.MonitorManager.get();
this._client = null;
this._clientWatchId = 0;
this._osdLabels = [];
this._monitorLabels = null;
Main.layoutManager.connect('monitors-changed',
this._reset.bind(this));
Lang.bind(this, this._reset));
this._reset();
},
_reset() {
_reset: function() {
for (let i in this._osdLabels)
this._osdLabels[i].destroy();
this._osdLabels = [];
@@ -76,19 +76,19 @@ var OsdMonitorLabeler = new Lang.Class({
this._monitorLabels.set(monitors[i].index, []);
},
_trackClient(client) {
_trackClient: function(client) {
if (this._client)
return (this._client == client);
this._client = client;
this._clientWatchId = Gio.bus_watch_name(Gio.BusType.SESSION, client, 0, null,
(c, name) => {
Lang.bind(this, function(c, name) {
this.hide(name);
});
}));
return true;
},
_untrackClient(client) {
_untrackClient: function(client) {
if (!this._client || this._client != client)
return false;
@@ -98,7 +98,7 @@ var OsdMonitorLabeler = new Lang.Class({
return true;
},
show(client, params) {
show: function(client, params) {
if (!this._trackClient(client))
return;
@@ -120,7 +120,7 @@ var OsdMonitorLabeler = new Lang.Class({
}
},
show2(client, params) {
show2: function(client, params) {
if (!this._trackClient(client))
return;
@@ -139,7 +139,7 @@ var OsdMonitorLabeler = new Lang.Class({
}
},
hide(client) {
hide: function(client) {
if (!this._untrackClient(client))
return;

View File

@@ -18,7 +18,7 @@ var LEVEL_ANIMATION_TIME = 0.1;
var LevelBar = new Lang.Class({
Name: 'LevelBar',
_init() {
_init: function() {
this._level = 0;
this.actor = new St.Bin({ style_class: 'level',
@@ -49,7 +49,7 @@ var OsdWindowConstraint = new Lang.Class({
Name: 'OsdWindowConstraint',
Extends: Clutter.Constraint,
_init(props) {
_init: function(props) {
this._minSize = 0;
this.parent(props);
},
@@ -60,7 +60,7 @@ var OsdWindowConstraint = new Lang.Class({
this.actor.queue_relayout();
},
vfunc_update_allocation(actor, actorBox) {
vfunc_update_allocation: function(actor, actorBox) {
// Clutter will adjust the allocation for margins,
// so add it to our minimum size
let minSize = this._minSize + actor.margin_top + actor.margin_bottom;
@@ -80,7 +80,7 @@ var OsdWindowConstraint = new Lang.Class({
var OsdWindow = new Lang.Class({
Name: 'OsdWindow',
_init(monitorIndex) {
_init: function(monitorIndex) {
this.actor = new St.Widget({ x_expand: true,
y_expand: true,
x_align: Clutter.ActorAlign.CENTER,
@@ -109,25 +109,25 @@ var OsdWindow = new Lang.Class({
this._reset();
Main.layoutManager.connect('monitors-changed',
this._relayout.bind(this));
Lang.bind(this, this._relayout));
let themeContext = St.ThemeContext.get_for_stage(global.stage);
themeContext.connect('notify::scale-factor',
this._relayout.bind(this));
Lang.bind(this, this._relayout));
this._relayout();
Main.uiGroup.add_child(this.actor);
},
setIcon(icon) {
setIcon: function(icon) {
this._icon.gicon = icon;
},
setLabel(label) {
setLabel: function(label) {
this._label.visible = (label != undefined);
if (label)
this._label.text = label;
},
setLevel(level) {
setLevel: function(level) {
this._level.actor.visible = (level != undefined);
if (level != undefined) {
if (this.actor.visible)
@@ -140,7 +140,7 @@ var OsdWindow = new Lang.Class({
}
},
show() {
show: function() {
if (!this._icon.gicon)
return;
@@ -159,11 +159,11 @@ var OsdWindow = new Lang.Class({
if (this._hideTimeoutId)
Mainloop.source_remove(this._hideTimeoutId);
this._hideTimeoutId = Mainloop.timeout_add(HIDE_TIMEOUT,
this._hide.bind(this));
Lang.bind(this, this._hide));
GLib.Source.set_name_by_id(this._hideTimeoutId, '[gnome-shell] this._hide');
},
cancel() {
cancel: function() {
if (!this._hideTimeoutId)
return;
@@ -171,27 +171,27 @@ var OsdWindow = new Lang.Class({
this._hide();
},
_hide() {
_hide: function() {
this._hideTimeoutId = 0;
Tweener.addTween(this.actor,
{ opacity: 0,
time: FADE_TIME,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
this._reset();
Meta.enable_unredirect_for_screen(global.screen);
}
})
});
return GLib.SOURCE_REMOVE;
},
_reset() {
_reset: function() {
this.actor.hide();
this.setLabel(null);
this.setLevel(null);
},
_relayout() {
_relayout: function() {
/* assume 110x110 on a 640x480 display and scale from there */
let monitor = Main.layoutManager.monitors[this._monitorIndex];
if (!monitor)
@@ -212,14 +212,14 @@ var OsdWindow = new Lang.Class({
var OsdWindowManager = new Lang.Class({
Name: 'OsdWindowManager',
_init() {
_init: function() {
this._osdWindows = [];
Main.layoutManager.connect('monitors-changed',
this._monitorsChanged.bind(this));
Lang.bind(this, this._monitorsChanged));
this._monitorsChanged();
},
_monitorsChanged() {
_monitorsChanged: function() {
for (let i = 0; i < Main.layoutManager.monitors.length; i++) {
if (this._osdWindows[i] == undefined)
this._osdWindows[i] = new OsdWindow(i);
@@ -233,14 +233,14 @@ var OsdWindowManager = new Lang.Class({
this._osdWindows.length = Main.layoutManager.monitors.length;
},
_showOsdWindow(monitorIndex, icon, label, level) {
_showOsdWindow: function(monitorIndex, icon, label, level) {
this._osdWindows[monitorIndex].setIcon(icon);
this._osdWindows[monitorIndex].setLabel(label);
this._osdWindows[monitorIndex].setLevel(level);
this._osdWindows[monitorIndex].show();
},
show(monitorIndex, icon, label, level) {
show: function(monitorIndex, icon, label, level) {
if (monitorIndex != -1) {
for (let i = 0; i < this._osdWindows.length; i++) {
if (i == monitorIndex)
@@ -254,7 +254,7 @@ var OsdWindowManager = new Lang.Class({
}
},
hideAll() {
hideAll: function() {
for (let i = 0; i < this._osdWindows.length; i++)
this._osdWindows[i].cancel();
}

View File

@@ -38,12 +38,12 @@ var OVERVIEW_ACTIVATION_TIMEOUT = 0.5;
var ShellInfo = new Lang.Class({
Name: 'ShellInfo',
_init() {
_init: function() {
this._source = null;
this._undoCallback = null;
},
_onUndoClicked() {
_onUndoClicked: function() {
if (this._undoCallback)
this._undoCallback();
this._undoCallback = null;
@@ -52,7 +52,7 @@ var ShellInfo = new Lang.Class({
this._source.destroy();
},
setMessage(text, options) {
setMessage: function(text, options) {
options = Params.parse(options, { undoCallback: null,
forFeedback: false
});
@@ -62,9 +62,10 @@ var ShellInfo = new Lang.Class({
if (this._source == null) {
this._source = new MessageTray.SystemNotificationSource();
this._source.connect('destroy', () => {
this._source = null;
});
this._source.connect('destroy', Lang.bind(this,
function() {
this._source = null;
}));
Main.messageTray.add(this._source);
}
@@ -80,7 +81,7 @@ var ShellInfo = new Lang.Class({
this._undoCallback = undoCallback;
if (undoCallback)
notification.addAction(_("Undo"), this._onUndoClicked.bind(this));
notification.addAction(_("Undo"), Lang.bind(this, this._onUndoClicked));
this._source.notify(notification);
}
@@ -89,15 +90,15 @@ var ShellInfo = new Lang.Class({
var Overview = new Lang.Class({
Name: 'Overview',
_init() {
_init: function() {
this._overviewCreated = false;
this._initCalled = false;
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
this._sessionUpdated();
},
_createOverview() {
_createOverview: function() {
if (this._overviewCreated)
return;
@@ -140,7 +141,7 @@ var Overview = new Lang.Class({
this._coverPane = new Clutter.Actor({ opacity: 0,
reactive: true });
Main.layoutManager.overviewGroup.add_child(this._coverPane);
this._coverPane.connect('event', () => Clutter.EVENT_STOP);
this._coverPane.connect('event', Lang.bind(this, function (actor, event) { return Clutter.EVENT_STOP; }));
Main.layoutManager.overviewGroup.add_child(this._overview);
@@ -148,16 +149,16 @@ var Overview = new Lang.Class({
// XDND
this._dragMonitor = {
dragMotion: this._onDragMotion.bind(this)
dragMotion: Lang.bind(this, this._onDragMotion)
};
Main.layoutManager.overviewGroup.connect('scroll-event',
this._onScrollEvent.bind(this));
Main.xdndHandler.connect('drag-begin', this._onDragBegin.bind(this));
Main.xdndHandler.connect('drag-end', this._onDragEnd.bind(this));
Lang.bind(this, this._onScrollEvent));
Main.xdndHandler.connect('drag-begin', Lang.bind(this, this._onDragBegin));
Main.xdndHandler.connect('drag-end', Lang.bind(this, this._onDragEnd));
global.screen.connect('restacked', this._onRestacked.bind(this));
global.screen.connect('restacked', Lang.bind(this, this._onRestacked));
this._windowSwitchTimeoutId = 0;
this._windowSwitchTimestamp = 0;
@@ -169,7 +170,7 @@ var Overview = new Lang.Class({
this.init();
},
_updateBackgrounds() {
_updateBackgrounds: function() {
for (let i = 0; i < this._bgManagers.length; i++)
this._bgManagers[i].destroy();
@@ -183,7 +184,7 @@ var Overview = new Lang.Class({
}
},
_unshadeBackgrounds() {
_unshadeBackgrounds: function() {
let backgrounds = this._backgroundGroup.get_children();
for (let i = 0; i < backgrounds.length; i++) {
Tweener.addTween(backgrounds[i],
@@ -195,7 +196,7 @@ var Overview = new Lang.Class({
}
},
_shadeBackgrounds() {
_shadeBackgrounds: function() {
let backgrounds = this._backgroundGroup.get_children();
for (let i = 0; i < backgrounds.length; i++) {
Tweener.addTween(backgrounds[i],
@@ -207,7 +208,7 @@ var Overview = new Lang.Class({
}
},
_sessionUpdated() {
_sessionUpdated: function() {
this.isDummy = !Main.sessionMode.hasOverview;
this._createOverview();
},
@@ -216,7 +217,7 @@ var Overview = new Lang.Class({
// want to access the overview as Main.overview to connect
// signal handlers and so forth. So we create them after
// construction in this init() method.
init() {
init: function() {
this._initCalled = true;
if (this.isDummy)
@@ -253,19 +254,20 @@ var Overview = new Lang.Class({
// TODO - recalculate everything when desktop size changes
this.dashIconSize = this._dash.iconSize;
this._dash.connect('icon-size-changed', () => {
this.dashIconSize = this._dash.iconSize;
});
this._dash.connect('icon-size-changed',
Lang.bind(this, function() {
this.dashIconSize = this._dash.iconSize;
}));
Main.layoutManager.connect('monitors-changed', this._relayout.bind(this));
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._relayout));
this._relayout();
},
addSearchProvider(provider) {
addSearchProvider: function(provider) {
this.viewSelector.addSearchProvider(provider);
},
removeSearchProvider(provider) {
removeSearchProvider: function(provider) {
this.viewSelector.removeSearchProvider(provider);
},
@@ -274,14 +276,14 @@ var Overview = new Lang.Class({
// - undoCallback (function): the callback to be called if undo support is needed
// - forFeedback (boolean): whether the message is for direct feedback of a user action
//
setMessage(text, options) {
setMessage: function(text, options) {
if (this.isDummy)
return;
this._shellInfo.setMessage(text, options);
},
_onDragBegin() {
_onDragBegin: function() {
this._inXdndDrag = true;
DND.addDragMonitor(this._dragMonitor);
@@ -289,7 +291,7 @@ var Overview = new Lang.Class({
this._lastActiveWorkspaceIndex = global.screen.get_active_workspace_index();
},
_onDragEnd(time) {
_onDragEnd: function(time) {
this._inXdndDrag = false;
// In case the drag was canceled while in the overview
@@ -305,7 +307,7 @@ var Overview = new Lang.Class({
this.endItemDrag();
},
_resetWindowSwitchTimeout() {
_resetWindowSwitchTimeout: function() {
if (this._windowSwitchTimeoutId != 0) {
Mainloop.source_remove(this._windowSwitchTimeoutId);
this._windowSwitchTimeoutId = 0;
@@ -313,7 +315,7 @@ var Overview = new Lang.Class({
}
},
_fakePointerEvent() {
_fakePointerEvent: function() {
let display = Gdk.Display.get_default();
let deviceManager = display.get_device_manager();
let pointer = deviceManager.get_client_pointer();
@@ -322,7 +324,7 @@ var Overview = new Lang.Class({
pointer.warp(screen, pointerX, pointerY);
},
_onDragMotion(dragEvent) {
_onDragMotion: function(dragEvent) {
let targetIsWindow = dragEvent.targetActor &&
dragEvent.targetActor._delegate &&
dragEvent.targetActor._delegate.metaWindow &&
@@ -341,50 +343,50 @@ var Overview = new Lang.Class({
if (targetIsWindow) {
this._lastHoveredWindow = dragEvent.targetActor._delegate.metaWindow;
this._windowSwitchTimeoutId = Mainloop.timeout_add(DND_WINDOW_SWITCH_TIMEOUT,
() => {
this._windowSwitchTimeoutId = 0;
this._needsFakePointerEvent = true;
Main.activateWindow(dragEvent.targetActor._delegate.metaWindow,
this._windowSwitchTimestamp);
this.hide();
this._lastHoveredWindow = null;
return GLib.SOURCE_REMOVE;
});
Lang.bind(this, function() {
this._windowSwitchTimeoutId = 0;
this._needsFakePointerEvent = true;
Main.activateWindow(dragEvent.targetActor._delegate.metaWindow,
this._windowSwitchTimestamp);
this.hide();
this._lastHoveredWindow = null;
return GLib.SOURCE_REMOVE;
}));
GLib.Source.set_name_by_id(this._windowSwitchTimeoutId, '[gnome-shell] Main.activateWindow');
}
return DND.DragMotionResult.CONTINUE;
},
_onScrollEvent(actor, event) {
_onScrollEvent: function(actor, event) {
this.emit('scroll-event', event);
return Clutter.EVENT_PROPAGATE;
},
addAction(action) {
addAction: function(action) {
if (this.isDummy)
return;
this._backgroundGroup.add_action(action);
},
_getDesktopClone() {
let windows = global.get_window_actors().filter(
w => w.meta_window.get_window_type() == Meta.WindowType.DESKTOP
);
_getDesktopClone: function() {
let windows = global.get_window_actors().filter(function(w) {
return w.meta_window.get_window_type() == Meta.WindowType.DESKTOP;
});
if (windows.length == 0)
return null;
let window = windows[0];
let clone = new Clutter.Clone({ source: window,
x: window.x, y: window.y });
clone.source.connect('destroy', () => {
clone.source.connect('destroy', Lang.bind(this, function() {
clone.destroy();
});
}));
return clone;
},
_relayout() {
_relayout: function () {
// To avoid updating the position and size of the workspaces
// we just hide the overview. The positions will be updated
// when it is next shown.
@@ -401,7 +403,7 @@ var Overview = new Lang.Class({
this._updateBackgrounds();
},
_onRestacked() {
_onRestacked: function() {
let stack = global.get_window_actors();
let stackIndices = {};
@@ -413,44 +415,44 @@ var Overview = new Lang.Class({
this.emit('windows-restacked', stackIndices);
},
beginItemDrag(source) {
beginItemDrag: function(source) {
this.emit('item-drag-begin');
this._inItemDrag = true;
},
cancelledItemDrag(source) {
cancelledItemDrag: function(source) {
this.emit('item-drag-cancelled');
},
endItemDrag(source) {
endItemDrag: function(source) {
if (!this._inItemDrag)
return;
this.emit('item-drag-end');
this._inItemDrag = false;
},
beginWindowDrag(window) {
beginWindowDrag: function(window) {
this.emit('window-drag-begin', window);
this._inWindowDrag = true;
},
cancelledWindowDrag(window) {
cancelledWindowDrag: function(window) {
this.emit('window-drag-cancelled', window);
},
endWindowDrag(window) {
endWindowDrag: function(window) {
if (!this._inWindowDrag)
return;
this.emit('window-drag-end', window);
this._inWindowDrag = false;
},
focusSearch() {
focusSearch: function() {
this.show();
this._searchEntry.grab_key_focus();
},
fadeInDesktop() {
fadeInDesktop: function() {
this._desktopFade.opacity = 0;
this._desktopFade.show();
Tweener.addTween(this._desktopFade,
@@ -459,7 +461,7 @@ var Overview = new Lang.Class({
transition: 'easeOutQuad' });
},
fadeOutDesktop() {
fadeOutDesktop: function() {
if (!this._desktopFade.get_n_children()) {
let clone = this._getDesktopClone();
if (!clone)
@@ -483,7 +485,7 @@ var Overview = new Lang.Class({
// triggered will return false. This avoids opening and closing
// the overview if the user both triggered the hot corner and
// clicked the Activities button.
shouldToggleByCornerOrButton() {
shouldToggleByCornerOrButton: function() {
if (this.animationInProgress)
return false;
if (this._inItemDrag || this._inWindowDrag)
@@ -493,7 +495,7 @@ var Overview = new Lang.Class({
return false;
},
_syncGrab() {
_syncGrab: function() {
// We delay grab changes during animation so that when removing the
// overview we don't have a problem with the release of a press/release
// going to an application.
@@ -525,7 +527,7 @@ var Overview = new Lang.Class({
// show:
//
// Animates the overview visible and grabs mouse and keyboard input
show() {
show: function() {
if (this.isDummy)
return;
if (this._shown)
@@ -540,7 +542,7 @@ var Overview = new Lang.Class({
},
_animateVisible() {
_animateVisible: function() {
if (this.visible || this.animationInProgress)
return;
@@ -567,7 +569,7 @@ var Overview = new Lang.Class({
this.emit('showing');
},
_showDone() {
_showDone: function() {
this.animationInProgress = false;
this._desktopFade.hide();
this._coverPane.hide();
@@ -584,7 +586,7 @@ var Overview = new Lang.Class({
// hide:
//
// Reverses the effect of show()
hide() {
hide: function() {
if (this.isDummy)
return;
@@ -608,7 +610,7 @@ var Overview = new Lang.Class({
},
_animateNotVisible() {
_animateNotVisible: function() {
if (!this.visible || this.animationInProgress)
return;
@@ -632,7 +634,7 @@ var Overview = new Lang.Class({
this.emit('hiding');
},
_hideDone() {
_hideDone: function() {
// Re-enable unredirection
Meta.enable_unredirect_for_screen(global.screen);
@@ -659,7 +661,7 @@ var Overview = new Lang.Class({
}
},
toggle() {
toggle: function() {
if (this.isDummy)
return;
@@ -669,7 +671,7 @@ var Overview = new Lang.Class({
this.show();
},
getShowAppsButton() {
getShowAppsButton: function() {
return this._dash.showAppsButton;
}
});

View File

@@ -34,7 +34,7 @@ var SlideLayout = new Lang.Class({
Name: 'SlideLayout',
Extends: Clutter.FixedLayout,
_init(params) {
_init: function(params) {
this._slideX = 1;
this._translationX = undefined;
this._direction = SlideDirection.LEFT;
@@ -42,7 +42,7 @@ var SlideLayout = new Lang.Class({
this.parent(params);
},
vfunc_get_preferred_width(container, forHeight) {
vfunc_get_preferred_width: function(container, forHeight) {
let child = container.get_first_child();
let [minWidth, natWidth] = child.get_preferred_width(forHeight);
@@ -53,7 +53,7 @@ var SlideLayout = new Lang.Class({
return [minWidth, natWidth];
},
vfunc_allocate(container, box, flags) {
vfunc_allocate: function(container, box, flags) {
let child = container.get_first_child();
let availWidth = Math.round(box.x2 - box.x1);
@@ -107,7 +107,7 @@ var SlideLayout = new Lang.Class({
var SlidingControl = new Lang.Class({
Name: 'SlidingControl',
_init(params) {
_init: function(params) {
params = Params.parse(params, { slideDirection: SlideDirection.LEFT });
this._visible = true;
@@ -119,34 +119,34 @@ var SlidingControl = new Lang.Class({
style_class: 'overview-controls',
clip_to_allocation: true });
Main.overview.connect('hiding', this._onOverviewHiding.bind(this));
Main.overview.connect('hiding', Lang.bind(this, this._onOverviewHiding));
Main.overview.connect('item-drag-begin', this._onDragBegin.bind(this));
Main.overview.connect('item-drag-end', this._onDragEnd.bind(this));
Main.overview.connect('item-drag-cancelled', this._onDragEnd.bind(this));
Main.overview.connect('item-drag-begin', Lang.bind(this, this._onDragBegin));
Main.overview.connect('item-drag-end', Lang.bind(this, this._onDragEnd));
Main.overview.connect('item-drag-cancelled', Lang.bind(this, this._onDragEnd));
Main.overview.connect('window-drag-begin', this._onWindowDragBegin.bind(this));
Main.overview.connect('window-drag-cancelled', this._onWindowDragEnd.bind(this));
Main.overview.connect('window-drag-end', this._onWindowDragEnd.bind(this));
Main.overview.connect('window-drag-begin', Lang.bind(this, this._onWindowDragBegin));
Main.overview.connect('window-drag-cancelled', Lang.bind(this, this._onWindowDragEnd));
Main.overview.connect('window-drag-end', Lang.bind(this, this._onWindowDragEnd));
},
_getSlide() {
_getSlide: function() {
throw new Error('getSlide() must be overridden');
},
_updateSlide() {
_updateSlide: function() {
Tweener.addTween(this.layout, { slideX: this._getSlide(),
time: SIDE_CONTROLS_ANIMATION_TIME,
transition: 'easeOutQuad' });
},
getVisibleWidth() {
getVisibleWidth: function() {
let child = this.actor.get_first_child();
let [, , natWidth, ] = child.get_preferred_size();
return natWidth;
},
_getTranslation() {
_getTranslation: function() {
let child = this.actor.get_first_child();
let direction = getRtlSlideDirection(this.layout.slideDirection, child);
let visibleWidth = this.getVisibleWidth();
@@ -157,7 +157,7 @@ var SlidingControl = new Lang.Class({
return visibleWidth;
},
_updateTranslation() {
_updateTranslation: function() {
let translationStart = 0;
let translationEnd = 0;
let translation = this._getTranslation();
@@ -178,57 +178,57 @@ var SlidingControl = new Lang.Class({
transition: 'easeOutQuad' });
},
_onOverviewHiding() {
_onOverviewHiding: function() {
// We need to explicitly slideOut since showing pages
// doesn't imply sliding out, instead, hiding the overview does.
this.slideOut();
},
_onWindowDragBegin() {
_onWindowDragBegin: function() {
this._onDragBegin();
},
_onWindowDragEnd() {
_onWindowDragEnd: function() {
this._onDragEnd();
},
_onDragBegin() {
_onDragBegin: function() {
this._inDrag = true;
this._updateTranslation();
this._updateSlide();
},
_onDragEnd() {
_onDragEnd: function() {
this._inDrag = false;
this._updateSlide();
},
fadeIn() {
fadeIn: function() {
Tweener.addTween(this.actor, { opacity: 255,
time: SIDE_CONTROLS_ANIMATION_TIME / 2,
transition: 'easeInQuad'
});
},
fadeHalf() {
fadeHalf: function() {
Tweener.addTween(this.actor, { opacity: 128,
time: SIDE_CONTROLS_ANIMATION_TIME / 2,
transition: 'easeOutQuad'
});
},
slideIn() {
slideIn: function() {
this._visible = true;
// we will update slideX and the translation from pageEmpty
},
slideOut() {
slideOut: function() {
this._visible = false;
this._updateTranslation();
// we will update slideX from pageEmpty
},
pageEmpty() {
pageEmpty: function() {
// When pageEmpty is received, there's no visible view in the
// selector; this means we can now safely set the full slide for
// the next page, since slideIn or slideOut might have been called,
@@ -242,7 +242,7 @@ var ThumbnailsSlider = new Lang.Class({
Name: 'ThumbnailsSlider',
Extends: SlidingControl,
_init(thumbnailsBox) {
_init: function(thumbnailsBox) {
this.parent({ slideDirection: SlideDirection.RIGHT });
this._thumbnailsBox = thumbnailsBox;
@@ -252,12 +252,12 @@ var ThumbnailsSlider = new Lang.Class({
this.actor.track_hover = true;
this.actor.add_actor(this._thumbnailsBox.actor);
Main.layoutManager.connect('monitors-changed', this._updateSlide.bind(this));
this.actor.connect('notify::hover', this._updateSlide.bind(this));
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._updateSlide));
this.actor.connect('notify::hover', Lang.bind(this, this._updateSlide));
this._thumbnailsBox.actor.bind_property('visible', this.actor, 'visible', GObject.BindingFlags.SYNC_CREATE);
},
_getAlwaysZoomOut() {
_getAlwaysZoomOut: function() {
// Always show the pager on hover or during a drag
let alwaysZoomOut = this.actor.hover || this._inDrag;
@@ -279,12 +279,12 @@ var ThumbnailsSlider = new Lang.Class({
return alwaysZoomOut;
},
getNonExpandedWidth() {
getNonExpandedWidth: function() {
let child = this.actor.get_first_child();
return child.get_theme_node().get_length('visible-width');
},
_getSlide() {
_getSlide: function() {
if (!this._visible)
return 0;
@@ -299,7 +299,7 @@ var ThumbnailsSlider = new Lang.Class({
return this.getNonExpandedWidth() / expandedWidth;
},
getVisibleWidth() {
getVisibleWidth: function() {
let alwaysZoomOut = this._getAlwaysZoomOut();
if (alwaysZoomOut)
return this.parent();
@@ -312,7 +312,7 @@ var DashSlider = new Lang.Class({
Name: 'DashSlider',
Extends: SlidingControl,
_init(dash) {
_init: function(dash) {
this.parent({ slideDirection: SlideDirection.LEFT });
this._dash = dash;
@@ -328,21 +328,21 @@ var DashSlider = new Lang.Class({
this.actor.add_actor(this._dash.actor);
this._dash.connect('icon-size-changed', this._updateSlide.bind(this));
this._dash.connect('icon-size-changed', Lang.bind(this, this._updateSlide));
},
_getSlide() {
_getSlide: function() {
if (this._visible || this._inDrag)
return 1;
else
return 0;
},
_onWindowDragBegin() {
_onWindowDragBegin: function() {
this.fadeHalf();
},
_onWindowDragEnd() {
_onWindowDragEnd: function() {
this.fadeIn();
}
});
@@ -351,13 +351,13 @@ var DashSpacer = new Lang.Class({
Name: 'DashSpacer',
Extends: St.Widget,
_init(params) {
_init: function(params) {
this.parent(params);
this._bindConstraint = null;
},
setDashActor(dashActor) {
setDashActor: function(dashActor) {
if (this._bindConstraint) {
this.remove_constraint(this._bindConstraint);
this._bindConstraint = null;
@@ -370,14 +370,14 @@ var DashSpacer = new Lang.Class({
}
},
vfunc_get_preferred_width(forHeight) {
vfunc_get_preferred_width: function(forHeight) {
let box = this.get_allocation_box();
let minWidth = this.parent(forHeight)[0];
let natWidth = box.x2 - box.x1;
return [minWidth, natWidth];
},
vfunc_get_preferred_height(forWidth) {
vfunc_get_preferred_height: function(forWidth) {
let box = this.get_allocation_box();
let minHeight = this.parent(forWidth)[0];
let natHeight = box.y2 - box.y1;
@@ -390,7 +390,7 @@ var ControlsLayout = new Lang.Class({
Extends: Clutter.BinLayout,
Signals: { 'allocation-changed': { flags: GObject.SignalFlags.RUN_LAST } },
vfunc_allocate(container, box, flags) {
vfunc_allocate: function(container, box, flags) {
this.parent(container, box, flags);
this.emit('allocation-changed');
}
@@ -399,7 +399,7 @@ var ControlsLayout = new Lang.Class({
var ControlsManager = new Lang.Class({
Name: 'ControlsManager',
_init(searchEntry) {
_init: function(searchEntry) {
this.dash = new Dash.Dash();
this._dashSlider = new DashSlider(this.dash);
this._dashSpacer = new DashSpacer();
@@ -410,8 +410,8 @@ var ControlsManager = new Lang.Class({
this.viewSelector = new ViewSelector.ViewSelector(searchEntry,
this.dash.showAppsButton);
this.viewSelector.connect('page-changed', this._setVisibility.bind(this));
this.viewSelector.connect('page-empty', this._onPageEmpty.bind(this));
this.viewSelector.connect('page-changed', Lang.bind(this, this._setVisibility));
this.viewSelector.connect('page-empty', Lang.bind(this, this._onPageEmpty));
let layout = new ControlsLayout();
this.actor = new St.Widget({ layout_manager: layout,
@@ -428,23 +428,26 @@ var ControlsManager = new Lang.Class({
expand: true });
this._group.add_actor(this._thumbnailsSlider.actor);
layout.connect('allocation-changed', this._updateWorkspacesGeometry.bind(this));
layout.connect('allocation-changed', Lang.bind(this, this._updateWorkspacesGeometry));
Main.overview.connect('showing', this._updateSpacerVisibility.bind(this));
Main.overview.connect('item-drag-begin', () => {
let activePage = this.viewSelector.getActivePage();
if (activePage != ViewSelector.ViewPage.WINDOWS)
this.viewSelector.fadeHalf();
});
Main.overview.connect('item-drag-end', () => {
this.viewSelector.fadeIn();
});
Main.overview.connect('item-drag-cancelled', () => {
this.viewSelector.fadeIn();
});
Main.overview.connect('showing', Lang.bind(this, this._updateSpacerVisibility));
Main.overview.connect('item-drag-begin', Lang.bind(this,
function() {
let activePage = this.viewSelector.getActivePage();
if (activePage != ViewSelector.ViewPage.WINDOWS)
this.viewSelector.fadeHalf();
}));
Main.overview.connect('item-drag-end', Lang.bind(this,
function() {
this.viewSelector.fadeIn();
}));
Main.overview.connect('item-drag-cancelled', Lang.bind(this,
function() {
this.viewSelector.fadeIn();
}));
},
_updateWorkspacesGeometry() {
_updateWorkspacesGeometry: function() {
let [x, y] = this.actor.get_transformed_position();
let [width, height] = this.actor.get_transformed_size();
let geometry = { x: x, y: y, width: width, height: height };
@@ -464,7 +467,7 @@ var ControlsManager = new Lang.Class({
this.viewSelector.setWorkspacesFullGeometry(geometry);
},
_setVisibility() {
_setVisibility: function() {
// Ignore the case when we're leaving the overview, since
// actors will be made visible again when entering the overview
// next time, and animating them while doing so is just
@@ -489,7 +492,7 @@ var ControlsManager = new Lang.Class({
this._thumbnailsSlider.slideOut();
},
_updateSpacerVisibility() {
_updateSpacerVisibility: function() {
if (Main.overview.animationInProgress && !Main.overview.visibleTarget)
return;
@@ -497,7 +500,7 @@ var ControlsManager = new Lang.Class({
this._dashSpacer.visible = (activePage == ViewSelector.ViewPage.WINDOWS);
},
_onPageEmpty() {
_onPageEmpty: function() {
this._dashSlider.pageEmpty();
this._thumbnailsSlider.pageEmpty();

View File

@@ -33,7 +33,7 @@ const DOWN = 1;
var PadChooser = new Lang.Class({
Name: 'PadChooser',
_init(device, groupDevices) {
_init: function (device, groupDevices) {
this.actor = new St.Button({ style_class: 'pad-chooser-button',
toggle_mode: true,
x_fill: false,
@@ -49,8 +49,8 @@ var PadChooser = new Lang.Class({
this.actor.set_child(arrow);
this._ensureMenu(groupDevices);
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('clicked', actor => {
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this.actor.connect('clicked', Lang.bind(this, function (actor) {
if (actor.get_checked()) {
if (this._padChooserMenu != null)
this._padChooserMenu.open(true);
@@ -59,14 +59,12 @@ var PadChooser = new Lang.Class({
} else {
this._padChooserMenu.close(true);
}
});
}));
},
_ensureMenu(devices) {
_ensureMenu: function (devices) {
this._padChooserMenu = new PopupMenu.PopupMenu(this.actor, 0.5, St.Side.TOP);
this._padChooserMenu.connect('menu-closed', () => {
this.actor.set_checked(false);
});
this._padChooserMenu.connect('menu-closed', Lang.bind(this, function() { this.actor.set_checked(false); }));
this._padChooserMenu.actor.hide();
Main.uiGroup.add_actor(this._padChooserMenu.actor);
@@ -81,18 +79,18 @@ var PadChooser = new Lang.Class({
}
},
_onDestroy() {
_onDestroy: function () {
this._padChooserMenu.destroy();
},
update(devices) {
update: function (devices) {
if (this._padChooserMenu)
this._padChooserMenu.actor.destroy();
this.actor.set_checked(false);
this._ensureMenu(devices);
},
destroy() {
destroy: function () {
this.actor.destroy();
},
});
@@ -101,13 +99,13 @@ Signals.addSignalMethods(PadChooser.prototype);
var KeybindingEntry = new Lang.Class({
Name: 'KeybindingEntry',
_init() {
_init: function () {
this.actor = new St.Entry({ hint_text: _("New shortcut…"),
style: 'width: 10em' });
this.actor.connect('captured-event', this._onCapturedEvent.bind(this));
this.actor.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
},
_onCapturedEvent(actor, event) {
_onCapturedEvent: function (actor, event) {
if (event.type() != Clutter.EventType.KEY_PRESS)
return Clutter.EVENT_PROPAGATE;
@@ -125,9 +123,9 @@ Signals.addSignalMethods(KeybindingEntry.prototype);
var ActionComboBox = new Lang.Class({
Name: 'ActionComboBox',
_init() {
_init: function () {
this.actor = new St.Button({ style_class: 'button' });
this.actor.connect('clicked', this._onButtonClicked.bind(this));
this.actor.connect('clicked', Lang.bind(this, this._onButtonClicked));
this.actor.set_toggle_mode(true);
let boxLayout = new Clutter.BoxLayout({ orientation: Clutter.Orientation.HORIZONTAL,
@@ -146,9 +144,7 @@ var ActionComboBox = new Lang.Class({
box.add_child(arrow);
this._editMenu = new PopupMenu.PopupMenu(this.actor, 0, St.Side.TOP);
this._editMenu.connect('menu-closed', () => {
this.actor.set_checked(false);
});
this._editMenu.connect('menu-closed', Lang.bind(this, function() { this.actor.set_checked(false); }));
this._editMenu.actor.hide();
Main.uiGroup.add_actor(this._editMenu.actor);
@@ -162,9 +158,7 @@ var ActionComboBox = new Lang.Class({
for (let [action, label] of this._actionLabels.entries()) {
let selectedAction = action;
let item = this._editMenu.addAction(label, () => {
this._onActionSelected(selectedAction);
});
let item = this._editMenu.addAction(label, Lang.bind(this, function() { this._onActionSelected(selectedAction) }));
/* These actions only apply to pad buttons */
if (selectedAction == GDesktopEnums.PadButtonAction.HELP ||
@@ -175,32 +169,32 @@ var ActionComboBox = new Lang.Class({
this.setAction(GDesktopEnums.PadButtonAction.NONE);
},
_onActionSelected(action) {
_onActionSelected: function (action) {
this.setAction(action);
this.popdown();
this.emit('action-selected', action);
},
setAction(action) {
setAction: function (action) {
this._label.set_text(this._actionLabels.get(action));
},
popup() {
popup: function () {
this._editMenu.open(true);
},
popdown() {
popdown: function () {
this._editMenu.close(true);
},
_onButtonClicked() {
_onButtonClicked: function () {
if (this.actor.get_checked())
this.popup();
else
this.popdown();
},
setButtonActionsActive(active) {
setButtonActionsActive: function (active) {
this._buttonItems.forEach(item => { item.setSensitive(active); });
}
});
@@ -209,28 +203,28 @@ Signals.addSignalMethods(ActionComboBox.prototype);
var ActionEditor = new Lang.Class({
Name: 'ActionEditor',
_init() {
_init: function () {
let boxLayout = new Clutter.BoxLayout({ orientation: Clutter.Orientation.HORIZONTAL,
spacing: 12 });
this.actor = new St.Widget({ layout_manager: boxLayout });
this._actionComboBox = new ActionComboBox();
this._actionComboBox.connect('action-selected', this._onActionSelected.bind(this));
this._actionComboBox.connect('action-selected', Lang.bind(this, this._onActionSelected));
this.actor.add_actor(this._actionComboBox.actor);
this._keybindingEdit = new KeybindingEntry();
this._keybindingEdit.connect('keybinding-edited', this._onKeybindingEdited.bind(this));
this._keybindingEdit.connect('keybinding-edited', Lang.bind(this, this._onKeybindingEdited));
this.actor.add_actor(this._keybindingEdit.actor);
this._doneButton = new St.Button({ label: _("Done"),
style_class: 'button',
x_expand: false});
this._doneButton.connect('clicked', this._onEditingDone.bind(this));
this._doneButton.connect('clicked', Lang.bind(this, this._onEditingDone));
this.actor.add_actor(this._doneButton);
},
_updateKeybindingEntryState() {
_updateKeybindingEntryState: function () {
if (this._currentAction == GDesktopEnums.PadButtonAction.KEYBINDING) {
this._keybindingEdit.actor.set_text(this._currentKeybinding);
this._keybindingEdit.actor.show();
@@ -240,7 +234,7 @@ var ActionEditor = new Lang.Class({
}
},
setSettings(settings, action) {
setSettings: function (settings, action) {
this._buttonSettings = settings;
this._currentAction = this._buttonSettings.get_enum('action');
@@ -252,21 +246,21 @@ var ActionEditor = new Lang.Class({
this._actionComboBox.setButtonActionsActive(isButton);
},
close() {
close: function() {
this._actionComboBox.popdown();
this.actor.hide();
},
_onKeybindingEdited(entry, keybinding) {
_onKeybindingEdited: function (entry, keybinding) {
this._currentKeybinding = keybinding;
},
_onActionSelected(menu, action) {
_onActionSelected: function (menu, action) {
this._currentAction = action;
this._updateKeybindingEntryState();
},
_storeSettings() {
_storeSettings: function () {
if (!this._buttonSettings)
return;
@@ -283,7 +277,7 @@ var ActionEditor = new Lang.Class({
this._buttonSettings.reset('keybinding');
},
_onEditingDone() {
_onEditingDone: function () {
this._storeSettings();
this.close();
this.emit('done');
@@ -310,7 +304,7 @@ var PadDiagram = new Lang.Class({
GObject.ParamFlags.CONSTRUCT_ONLY,
Clutter.Actor.$gtype) },
_init(params) {
_init: function (params) {
let file = Gio.File.new_for_uri('resource:///org/gnome/shell/theme/pad-osd.css');
let [success, css, etag] = file.load_contents(null);
this._curEdited = null;
@@ -353,7 +347,7 @@ var PadDiagram = new Lang.Class({
this.add_actor(actor);
},
_wrappingSvgHeader() {
_wrappingSvgHeader: function () {
return ('<?xml version="1.0" encoding="UTF-8" standalone="no"?>' +
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg" ' +
'xmlns:xi="http://www.w3.org/2001/XInclude" ' +
@@ -361,13 +355,13 @@ var PadDiagram = new Lang.Class({
'<style type="text/css">');
},
_wrappingSvgFooter() {
_wrappingSvgFooter: function () {
return ('</style>' +
'<xi:include href="' + this._imagePath + '" />' +
'</svg>');
},
_cssString() {
_cssString: function () {
let css = this._css;
for (let i = 0; i < this._activeButtons.length; i++) {
@@ -381,7 +375,7 @@ var PadDiagram = new Lang.Class({
return css;
},
_composeStyledDiagram() {
_composeStyledDiagram: function () {
let svgData = '';
if (!GLib.file_test(this._imagePath, GLib.FileTest.EXISTS))
@@ -399,7 +393,7 @@ var PadDiagram = new Lang.Class({
return handle;
},
_updateDiagramScale() {
_updateDiagramScale: function () {
if (this._handle == null)
return;
@@ -410,7 +404,7 @@ var PadDiagram = new Lang.Class({
this._scale = Math.min(scaleX, scaleY);
},
_allocateChild(child, x, y, direction) {
_allocateChild: function (child, x, y, direction) {
let [prefHeight, natHeight] = child.get_preferred_height(-1);
let [prefWidth, natWidth] = child.get_preferred_width(natHeight);
let childBox = new Clutter.ActorBox();
@@ -428,7 +422,7 @@ var PadDiagram = new Lang.Class({
child.allocate(childBox, 0);
},
vfunc_allocate(box, flags) {
vfunc_allocate: function (box, flags) {
this.parent(box, flags);
this._updateDiagramScale();
@@ -445,7 +439,7 @@ var PadDiagram = new Lang.Class({
}
},
vfunc_repaint() {
vfunc_repaint: function () {
if (this._handle == null)
return;
@@ -467,7 +461,7 @@ var PadDiagram = new Lang.Class({
cr.$dispose();
},
_transformPoint(x, y) {
_transformPoint: function (x, y) {
if (this._handle == null || this._scale == null)
return [x, y];
@@ -478,7 +472,7 @@ var PadDiagram = new Lang.Class({
return [Math.round(x), Math.round(y)];
},
_getItemLabelCoords(labelName, leaderName) {
_getItemLabelCoords: function (labelName, leaderName) {
if (this._handle == null)
return [false];
@@ -510,7 +504,7 @@ var PadDiagram = new Lang.Class({
return [true, x, y, direction];
},
getButtonLabelCoords(button) {
getButtonLabelCoords: function (button) {
let ch = String.fromCharCode('A'.charCodeAt() + button);
let labelName = 'Label' + ch;
let leaderName = 'Leader' + ch;
@@ -518,7 +512,7 @@ var PadDiagram = new Lang.Class({
return this._getItemLabelCoords(labelName, leaderName);
},
getRingLabelCoords(number, dir) {
getRingLabelCoords: function (number, dir) {
let numStr = number > 0 ? (number + 1).toString() : '';
let dirStr = dir == CW ? 'CW' : 'CCW';
let labelName = 'LabelRing' + numStr + dirStr;
@@ -527,7 +521,7 @@ var PadDiagram = new Lang.Class({
return this._getItemLabelCoords(labelName, leaderName);
},
getStripLabelCoords(number, dir) {
getStripLabelCoords: function (number, dir) {
let numStr = number > 0 ? (number + 1).toString() : '';
let dirStr = dir == UP ? 'Up' : 'Down';
let labelName = 'LabelStrip' + numStr + dirStr;
@@ -536,7 +530,7 @@ var PadDiagram = new Lang.Class({
return this._getItemLabelCoords(labelName, leaderName);
},
getLabelCoords(action, idx, dir) {
getLabelCoords: function (action, idx, dir) {
if (action == Meta.PadActionType.BUTTON)
return this.getButtonLabelCoords(idx);
else if (action == Meta.PadActionType.RING)
@@ -547,19 +541,19 @@ var PadDiagram = new Lang.Class({
return [false];
},
_invalidateSvg() {
_invalidateSvg: function () {
if (this._handle == null)
return;
this._handle = this._composeStyledDiagram();
this.queue_repaint();
},
activateButton(button) {
activateButton: function (button) {
this._activeButtons.push(button);
this._invalidateSvg();
},
deactivateButton(button) {
deactivateButton: function (button) {
for (let i = 0; i < this._activeButtons.length; i++) {
if (this._activeButtons[i] == button)
this._activeButtons.splice(i, 1);
@@ -567,12 +561,12 @@ var PadDiagram = new Lang.Class({
this._invalidateSvg();
},
addLabel(label, type, idx, dir) {
addLabel: function (label, type, idx, dir) {
this._labels.push([label, type, idx, dir]);
this.add_actor(label);
},
_applyLabel(label, action, idx, dir, str) {
_applyLabel: function(label, action, idx, dir, str) {
if (str != null) {
label.set_text(str);
@@ -582,7 +576,7 @@ var PadDiagram = new Lang.Class({
label.show();
},
stopEdition(continues, str) {
stopEdition: function (continues, str) {
this._editorActor.hide();
if (this._prevEdited) {
@@ -600,7 +594,7 @@ var PadDiagram = new Lang.Class({
}
},
startEdition(action, idx, dir) {
startEdition: function(action, idx, dir) {
let editedLabel;
if (this._curEdited)
@@ -628,24 +622,24 @@ var PadDiagram = new Lang.Class({
var PadOsd = new Lang.Class({
Name: 'PadOsd',
_init(padDevice, settings, imagePath, editionMode, monitorIndex) {
_init: function (padDevice, settings, imagePath, editionMode, monitorIndex) {
this.padDevice = padDevice;
this._groupPads = [ padDevice ];
this._settings = settings;
this._imagePath = imagePath;
this._editionMode = editionMode;
this._capturedEventId = global.stage.connect('captured-event', this._onCapturedEvent.bind(this));
this._capturedEventId = global.stage.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
this._padChooser = null;
let deviceManager = Clutter.DeviceManager.get_default();
this._deviceAddedId = deviceManager.connect('device-added', (manager, device) => {
this._deviceAddedId = deviceManager.connect('device-added', Lang.bind(this, function (manager, device) {
if (device.get_device_type() == Clutter.InputDeviceType.PAD_DEVICE &&
this.padDevice.is_grouped(device)) {
this._groupPads.push(device);
this._updatePadChooser();
}
});
this._deviceRemovedId = deviceManager.connect('device-removed', (manager, device) => {
}));
this._deviceRemovedId = deviceManager.connect('device-removed', Lang.bind(this, function (manager, device) {
// If the device is being removed, destroy the padOsd.
if (device == this.padDevice) {
this.destroy();
@@ -656,21 +650,21 @@ var PadOsd = new Lang.Class({
this._updatePadChooser();
}
});
}));
deviceManager.list_devices().forEach(device => {
deviceManager.list_devices().forEach(Lang.bind(this, function(device) {
if (device != this.padDevice &&
device.get_device_type() == Clutter.InputDeviceType.PAD_DEVICE &&
this.padDevice.is_grouped(device))
this._groupPads.push(device);
});
}));
this.actor = new St.BoxLayout({ style_class: 'pad-osd-window',
x_expand: true,
y_expand: true,
vertical: true,
reactive: true });
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
Main.uiGroup.add_actor(this.actor);
this._monitorIndex = monitorIndex;
@@ -698,7 +692,7 @@ var PadOsd = new Lang.Class({
this._updatePadChooser();
this._actionEditor = new ActionEditor();
this._actionEditor.connect('done', this._endActionEdition.bind(this));
this._actionEditor.connect('done', Lang.bind(this, this._endActionEdition));
this._padDiagram = new PadDiagram({ image: this._imagePath,
left_handed: settings.get_boolean('left-handed'),
@@ -741,22 +735,20 @@ var PadOsd = new Lang.Class({
style_class: 'button',
x_align: Clutter.ActorAlign.CENTER,
can_focus: true });
this._editButton.connect('clicked', () => {
this.setEditionMode(true);
});
this._editButton.connect('clicked', Lang.bind(this, function () { this.setEditionMode(true) }));
buttonBox.add_actor(this._editButton);
this._syncEditionMode();
Main.pushModal(this.actor);
},
_updatePadChooser() {
_updatePadChooser: function () {
if (this._groupPads.length > 1) {
if (this._padChooser == null) {
this._padChooser = new PadChooser(this.padDevice, this._groupPads)
this._padChooser.connect('pad-selected', (chooser, pad) => {
this._padChooser.connect('pad-selected', Lang.bind(this, function (chooser, pad) {
this._requestForOtherPad(pad);
});
}));
this._titleBox.add_child(this._padChooser.actor);
} else {
this._padChooser.update(this._groupPads);
@@ -767,7 +759,7 @@ var PadOsd = new Lang.Class({
}
},
_requestForOtherPad(pad) {
_requestForOtherPad: function (pad) {
if (pad == this.padDevice ||
this._groupPads.indexOf(pad) == -1)
return;
@@ -777,13 +769,13 @@ var PadOsd = new Lang.Class({
global.display.request_pad_osd(pad, editionMode);
},
_createLabel(type, number, dir) {
_createLabel: function (type, number, dir) {
let str = global.display.get_pad_action_label(this.padDevice, type, number);
let label = new St.Label({ text: str ? str : _("None") });
this._padDiagram.addLabel(label, type, number, dir);
},
_onCapturedEvent(actor, event) {
_onCapturedEvent : function (actor, event) {
if (event.type() == Clutter.EventType.PAD_BUTTON_PRESS &&
event.get_source_device() == this.padDevice) {
this._padDiagram.activateButton(event.get_button());
@@ -828,7 +820,7 @@ var PadOsd = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_syncEditionMode() {
_syncEditionMode: function () {
this._editButton.set_reactive(!this._editionMode);
this._editButton.save_easing_state();
this._editButton.set_easing_duration(200);
@@ -848,7 +840,7 @@ var PadOsd = new Lang.Class({
this._titleLabel.clutter_text.set_markup('<span size="larger"><b>' + title + '</b></span>');
},
_isEditedAction(type, number, dir) {
_isEditedAction: function (type, number, dir) {
if (!this._editedAction)
return false;
@@ -857,7 +849,7 @@ var PadOsd = new Lang.Class({
this._editedAction.dir == dir);
},
_followUpActionEdition(str) {
_followUpActionEdition: function (str) {
let { type, dir, number, mode } = this._editedAction;
let hasNextAction = (type == Meta.PadActionType.RING && dir == CCW ||
type == Meta.PadActionType.STRIP && dir == UP);
@@ -874,7 +866,7 @@ var PadOsd = new Lang.Class({
return true;
},
_endActionEdition() {
_endActionEdition: function () {
this._actionEditor.close();
if (this._editedAction != null) {
@@ -891,7 +883,7 @@ var PadOsd = new Lang.Class({
this._editedActionSettings = null;
},
_startActionEdition(key, type, number, dir, mode) {
_startActionEdition: function (key, type, number, dir, mode) {
if (this._isEditedAction(type, number, dir))
return;
@@ -905,25 +897,25 @@ var PadOsd = new Lang.Class({
this._padDiagram.startEdition(type, number, dir);
},
_startButtonActionEdition(button) {
_startButtonActionEdition: function (button) {
let ch = String.fromCharCode('A'.charCodeAt() + button);
let key = 'button' + ch;
this._startActionEdition(key, Meta.PadActionType.BUTTON, button);
},
_startRingActionEdition(ring, dir, mode) {
_startRingActionEdition: function (ring, dir, mode) {
let ch = String.fromCharCode('A'.charCodeAt() + ring);
let key = 'ring%s-%s-mode-%d'.format(ch, dir == CCW ? 'ccw' : 'cw', mode);
this._startActionEdition(key, Meta.PadActionType.RING, ring, dir, mode);
},
_startStripActionEdition(strip, dir, mode) {
_startStripActionEdition: function (strip, dir, mode) {
let ch = String.fromCharCode('A'.charCodeAt() + strip);
let key = 'strip%s-%s-mode-%d'.format(ch, dir == UP ? 'up' : 'down', mode);
this._startActionEdition(key, Meta.PadActionType.STRIP, strip, dir, mode);
},
setEditionMode(editionMode) {
setEditionMode: function (editionMode) {
if (this._editionMode == editionMode)
return;
@@ -931,11 +923,11 @@ var PadOsd = new Lang.Class({
this._syncEditionMode();
},
destroy() {
destroy: function () {
this.actor.destroy();
},
_onDestroy() {
_onDestroy: function () {
Main.popModal(this.actor);
this._actionEditor.close();
@@ -972,23 +964,23 @@ const PadOsdIface = '<node> \
var PadOsdService = new Lang.Class({
Name: 'PadOsdService',
_init() {
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(PadOsdIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/Wacom');
Gio.DBus.session.own_name('org.gnome.Shell.Wacom.PadOsd', Gio.BusNameOwnerFlags.REPLACE, null, null);
},
ShowAsync(params, invocation) {
ShowAsync: function(params, invocation) {
let [deviceNode, editionMode] = params;
let deviceManager = Clutter.DeviceManager.get_default();
let devices = deviceManager.list_devices();
let padDevice = null;
devices.forEach(device => {
devices.forEach(Lang.bind(this, function(device) {
if (deviceNode == device.get_device_node() &&
device.get_device_type() == Clutter.InputDeviceType.PAD_DEVICE)
padDevice = device;
});
}));
if (padDevice == null) {
invocation.return_error_literal(Gio.IOErrorEnum,

View File

@@ -87,7 +87,7 @@ var AppMenuButton = new Lang.Class({
Name: 'AppMenuButton',
Extends: PanelMenu.Button,
_init(panel) {
_init: function(panel) {
this.parent(0.0, null, true);
this.actor.accessible_role = Atk.Role.MENU;
@@ -102,7 +102,7 @@ var AppMenuButton = new Lang.Class({
this._busyNotifyId = 0;
let bin = new St.Bin({ name: 'appMenu' });
bin.connect('style-changed', this._onStyleChanged.bind(this));
bin.connect('style-changed', Lang.bind(this, this._onStyleChanged));
this.actor.add_actor(bin);
this.actor.bind_property("reactive", this.actor, "can-focus", 0);
@@ -113,7 +113,7 @@ var AppMenuButton = new Lang.Class({
let textureCache = St.TextureCache.get_default();
textureCache.connect('icon-theme-changed',
this._onIconThemeChanged.bind(this));
Lang.bind(this, this._onIconThemeChanged));
this._iconBox = new St.Bin({ style_class: 'app-menu-icon' });
this._container.add_actor(this._iconBox);
@@ -128,10 +128,10 @@ var AppMenuButton = new Lang.Class({
!Main.overview.visible;
if (!this._visible)
this.actor.hide();
this._overviewHidingId = Main.overview.connect('hiding', this._sync.bind(this));
this._overviewShowingId = Main.overview.connect('showing', this._sync.bind(this));
this._overviewHidingId = Main.overview.connect('hiding', Lang.bind(this, this._sync));
this._overviewShowingId = Main.overview.connect('showing', Lang.bind(this, this._sync));
this._showsAppMenuId = this._gtkSettings.connect('notify::gtk-shell-shows-app-menu',
this._sync.bind(this));
Lang.bind(this, this._sync));
this._stop = true;
@@ -140,16 +140,16 @@ var AppMenuButton = new Lang.Class({
let tracker = Shell.WindowTracker.get_default();
let appSys = Shell.AppSystem.get_default();
this._focusAppNotifyId =
tracker.connect('notify::focus-app', this._focusAppChanged.bind(this));
tracker.connect('notify::focus-app', Lang.bind(this, this._focusAppChanged));
this._appStateChangedSignalId =
appSys.connect('app-state-changed', this._onAppStateChanged.bind(this));
appSys.connect('app-state-changed', Lang.bind(this, this._onAppStateChanged));
this._switchWorkspaceNotifyId =
global.window_manager.connect('switch-workspace', this._sync.bind(this));
global.window_manager.connect('switch-workspace', Lang.bind(this, this._sync));
this._sync();
},
show() {
show: function() {
if (this._visible)
return;
@@ -163,7 +163,7 @@ var AppMenuButton = new Lang.Class({
transition: 'easeOutQuad' });
},
hide() {
hide: function() {
if (!this._visible)
return;
@@ -174,13 +174,13 @@ var AppMenuButton = new Lang.Class({
{ opacity: 0,
time: Overview.ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
this.actor.hide();
},
onCompleteScope: this });
},
_onStyleChanged(actor) {
_onStyleChanged: function(actor) {
let node = actor.get_theme_node();
let [success, icon] = node.lookup_url('spinner-image', false);
if (!success || (this._spinnerIcon && this._spinnerIcon.equal(icon)))
@@ -191,7 +191,7 @@ var AppMenuButton = new Lang.Class({
this._spinner.actor.hide();
},
_syncIcon() {
_syncIcon: function() {
if (!this._targetApp)
return;
@@ -199,14 +199,14 @@ var AppMenuButton = new Lang.Class({
this._iconBox.set_child(icon);
},
_onIconThemeChanged() {
_onIconThemeChanged: function() {
if (this._iconBox.child == null)
return;
this._syncIcon();
},
stopAnimation() {
stopAnimation: function() {
if (this._stop)
return;
@@ -220,7 +220,7 @@ var AppMenuButton = new Lang.Class({
time: SPINNER_ANIMATION_TIME,
transition: "easeOutQuad",
onCompleteScope: this,
onComplete() {
onComplete: function() {
this._spinner.stop();
this._spinner.actor.opacity = 255;
this._spinner.actor.hide();
@@ -228,7 +228,7 @@ var AppMenuButton = new Lang.Class({
});
},
startAnimation() {
startAnimation: function() {
this._stop = false;
if (this._spinner == null)
@@ -238,12 +238,15 @@ var AppMenuButton = new Lang.Class({
this._spinner.actor.show();
},
_onAppStateChanged(appSys, app) {
_onAppStateChanged: function(appSys, app) {
let state = app.state;
if (state != Shell.AppState.STARTING)
this._startingApps = this._startingApps.filter(a => a != app);
else if (state == Shell.AppState.STARTING)
if (state != Shell.AppState.STARTING) {
this._startingApps = this._startingApps.filter(function(a) {
return a != app;
});
} else if (state == Shell.AppState.STARTING) {
this._startingApps.push(app);
}
// For now just resync on all running state changes; this is mainly to handle
// cases where the focused window's application changes without the focus
// changing. An example case is how we map OpenOffice.org based on the window
@@ -251,7 +254,7 @@ var AppMenuButton = new Lang.Class({
this._sync();
},
_focusAppChanged() {
_focusAppChanged: function() {
let tracker = Shell.WindowTracker.get_default();
let focusedApp = tracker.focus_app;
if (!focusedApp) {
@@ -264,7 +267,7 @@ var AppMenuButton = new Lang.Class({
this._sync();
},
_findTargetApp() {
_findTargetApp: function() {
let workspace = global.screen.get_active_workspace();
let tracker = Shell.WindowTracker.get_default();
let focusedApp = tracker.focus_app;
@@ -278,7 +281,7 @@ var AppMenuButton = new Lang.Class({
return null;
},
_sync() {
_sync: function() {
let targetApp = this._findTargetApp();
if (this._targetApp != targetApp) {
@@ -298,9 +301,9 @@ var AppMenuButton = new Lang.Class({
this._targetApp = targetApp;
if (this._targetApp) {
this._appMenuNotifyId = this._targetApp.connect('notify::menu', this._sync.bind(this));
this._actionGroupNotifyId = this._targetApp.connect('notify::action-group', this._sync.bind(this));
this._busyNotifyId = this._targetApp.connect('notify::busy', this._sync.bind(this));
this._appMenuNotifyId = this._targetApp.connect('notify::menu', Lang.bind(this, this._sync));
this._actionGroupNotifyId = this._targetApp.connect('notify::action-group', Lang.bind(this, this._sync));
this._busyNotifyId = this._targetApp.connect('notify::busy', Lang.bind(this, this._sync));
this._label.set_text(this._targetApp.get_name());
this.actor.set_accessible_name(this._targetApp.get_name());
}
@@ -329,7 +332,7 @@ var AppMenuButton = new Lang.Class({
this.emit('changed');
},
_maybeSetMenu() {
_maybeSetMenu: function() {
let menu;
if (this._targetApp == null) {
@@ -340,10 +343,10 @@ var AppMenuButton = new Lang.Class({
return;
menu = new RemoteMenu.RemoteMenu(this.actor, this._targetApp.menu, this._targetApp.action_group);
menu.connect('activate', () => {
menu.connect('activate', Lang.bind(this, function() {
let win = this._targetApp.get_windows()[0];
win.check_alive(global.get_current_time());
});
}));
} else {
if (this.menu && this.menu.isDummyQuitMenu)
@@ -352,9 +355,9 @@ var AppMenuButton = new Lang.Class({
// fallback to older menu
menu = new PopupMenu.PopupMenu(this.actor, 0.0, St.Side.TOP, 0);
menu.isDummyQuitMenu = true;
menu.addAction(_("Quit"), () => {
menu.addAction(_("Quit"), Lang.bind(this, function() {
this._targetApp.request_quit();
});
}));
}
this.setMenu(menu);
@@ -362,7 +365,7 @@ var AppMenuButton = new Lang.Class({
this._menuManager.addMenu(menu);
},
destroy() {
destroy: function() {
if (this._appStateChangedSignalId > 0) {
let appSys = Shell.AppSystem.get_default();
appSys.disconnect(this._appStateChangedSignalId);
@@ -400,7 +403,7 @@ var ActivitiesButton = new Lang.Class({
Name: 'ActivitiesButton',
Extends: PanelMenu.Button,
_init() {
_init: function() {
this.parent(0.0, null, true);
this.actor.accessible_role = Atk.Role.TOGGLE_BUTTON;
@@ -414,36 +417,35 @@ var ActivitiesButton = new Lang.Class({
this.actor.label_actor = this._label;
this.actor.connect('captured-event', this._onCapturedEvent.bind(this));
this.actor.connect_after('key-release-event', this._onKeyRelease.bind(this));
this.actor.connect('captured-event', Lang.bind(this, this._onCapturedEvent));
this.actor.connect_after('key-release-event', Lang.bind(this, this._onKeyRelease));
Main.overview.connect('showing', () => {
Main.overview.connect('showing', Lang.bind(this, function() {
this.actor.add_style_pseudo_class('overview');
this.actor.add_accessible_state (Atk.StateType.CHECKED);
});
Main.overview.connect('hiding', () => {
}));
Main.overview.connect('hiding', Lang.bind(this, function() {
this.actor.remove_style_pseudo_class('overview');
this.actor.remove_accessible_state (Atk.StateType.CHECKED);
});
}));
this._xdndTimeOut = 0;
},
handleDragOver(source, actor, x, y, time) {
handleDragOver: function(source, actor, x, y, time) {
if (source != Main.xdndHandler)
return DND.DragMotionResult.CONTINUE;
if (this._xdndTimeOut != 0)
Mainloop.source_remove(this._xdndTimeOut);
this._xdndTimeOut = Mainloop.timeout_add(BUTTON_DND_ACTIVATION_TIMEOUT, () => {
this._xdndToggleOverview(actor);
});
this._xdndTimeOut = Mainloop.timeout_add(BUTTON_DND_ACTIVATION_TIMEOUT,
Lang.bind(this, this._xdndToggleOverview, actor));
GLib.Source.set_name_by_id(this._xdndTimeOut, '[gnome-shell] this._xdndToggleOverview');
return DND.DragMotionResult.CONTINUE;
},
_onCapturedEvent(actor, event) {
_onCapturedEvent: function(actor, event) {
if (event.type() == Clutter.EventType.BUTTON_PRESS ||
event.type() == Clutter.EventType.TOUCH_BEGIN) {
if (!Main.overview.shouldToggleByCornerOrButton())
@@ -452,7 +454,7 @@ var ActivitiesButton = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onEvent(actor, event) {
_onEvent: function(actor, event) {
this.parent(actor, event);
if (event.type() == Clutter.EventType.TOUCH_END ||
@@ -463,7 +465,7 @@ var ActivitiesButton = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onKeyRelease(actor, event) {
_onKeyRelease: function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Return || symbol == Clutter.KEY_space) {
if (Main.overview.shouldToggleByCornerOrButton())
@@ -472,7 +474,7 @@ var ActivitiesButton = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_xdndToggleOverview(actor) {
_xdndToggleOverview: function(actor) {
let [x, y, mask] = global.get_pointer();
let pickedActor = global.stage.get_actor_at_pos(Clutter.PickMode.REACTIVE, x, y);
@@ -488,15 +490,15 @@ var ActivitiesButton = new Lang.Class({
var PanelCorner = new Lang.Class({
Name: 'PanelCorner',
_init(side) {
_init: function(side) {
this._side = side;
this.actor = new St.DrawingArea({ style_class: 'panel-corner' });
this.actor.connect('style-changed', this._styleChanged.bind(this));
this.actor.connect('repaint', this._repaint.bind(this));
this.actor.connect('style-changed', Lang.bind(this, this._styleChanged));
this.actor.connect('repaint', Lang.bind(this, this._repaint));
},
_findRightmostButton(container) {
_findRightmostButton: function(container) {
if (!container.get_children)
return null;
@@ -521,7 +523,7 @@ var PanelCorner = new Lang.Class({
return children[index];
},
_findLeftmostButton(container) {
_findLeftmostButton: function(container) {
if (!container.get_children)
return null;
@@ -546,7 +548,7 @@ var PanelCorner = new Lang.Class({
return children[index];
},
setStyleParent(box) {
setStyleParent: function(box) {
let side = this._side;
let rtlAwareContainer = box instanceof St.BoxLayout;
@@ -572,19 +574,20 @@ var PanelCorner = new Lang.Class({
this._button = button;
button.connect('destroy', () => {
if (this._button == button) {
this._button = null;
this._buttonStyleChangedSignalId = 0;
}
});
button.connect('destroy', Lang.bind(this,
function() {
if (this._button == button) {
this._button = null;
this._buttonStyleChangedSignalId = 0;
}
}));
// Synchronize the locate button's pseudo classes with this corner
this._buttonStyleChangedSignalId = button.connect('style-changed',
actor => {
this._buttonStyleChangedSignalId = button.connect('style-changed', Lang.bind(this,
function(actor) {
let pseudoClass = button.get_style_pseudo_class();
this.actor.set_style_pseudo_class(pseudoClass);
});
}));
// The corner doesn't support theme transitions, so override
// the .panel-button default
@@ -592,7 +595,7 @@ var PanelCorner = new Lang.Class({
}
},
_repaint() {
_repaint: function() {
let node = this.actor.get_theme_node();
let cornerRadius = node.get_length("-panel-corner-radius");
@@ -640,7 +643,7 @@ var PanelCorner = new Lang.Class({
cr.$dispose();
},
_styleChanged() {
_styleChanged: function() {
let node = this.actor.get_theme_node();
let cornerRadius = node.get_length("-panel-corner-radius");
@@ -655,7 +658,7 @@ var AggregateLayout = new Lang.Class({
Name: 'AggregateLayout',
Extends: Clutter.BoxLayout,
_init(params) {
_init: function(params) {
if (!params)
params = {};
params['orientation'] = Clutter.Orientation.VERTICAL;
@@ -664,12 +667,12 @@ var AggregateLayout = new Lang.Class({
this._sizeChildren = [];
},
addSizeChild(actor) {
addSizeChild: function(actor) {
this._sizeChildren.push(actor);
this.layout_changed();
},
vfunc_get_preferred_width(container, forHeight) {
vfunc_get_preferred_width: function(container, forHeight) {
let themeNode = container.get_theme_node();
let minWidth = themeNode.get_min_width();
let natWidth = minWidth;
@@ -688,7 +691,7 @@ var AggregateMenu = new Lang.Class({
Name: 'AggregateMenu',
Extends: PanelMenu.Button,
_init() {
_init: function() {
this.parent(0.0, C_("System menu in the top bar", "System"), false);
this.menu.actor.add_style_class_name('aggregate-menu');
@@ -768,7 +771,7 @@ const PANEL_ITEM_IMPLEMENTATIONS = {
var Panel = new Lang.Class({
Name: 'Panel',
_init() {
_init : function() {
this.actor = new Shell.GenericContainer({ name: 'panel',
reactive: true });
this.actor._delegate = this;
@@ -792,45 +795,45 @@ var Panel = new Lang.Class({
this._rightCorner = new PanelCorner(St.Side.RIGHT);
this.actor.add_actor(this._rightCorner.actor);
this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
this.actor.connect('allocate', this._allocate.bind(this));
this.actor.connect('button-press-event', this._onButtonPress.bind(this));
this.actor.connect('key-press-event', this._onKeyPress.bind(this));
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPress));
Main.overview.connect('showing', () => {
Main.overview.connect('showing', Lang.bind(this, function () {
this.actor.add_style_pseudo_class('overview');
this._updateSolidStyle();
});
Main.overview.connect('hiding', () => {
}));
Main.overview.connect('hiding', Lang.bind(this, function () {
this.actor.remove_style_pseudo_class('overview');
this._updateSolidStyle();
});
}));
Main.layoutManager.panelBox.add(this.actor);
Main.ctrlAltTabManager.addGroup(this.actor, _("Top Bar"), 'focus-top-bar-symbolic',
{ sortGroup: CtrlAltTab.SortGroup.TOP });
Main.sessionMode.connect('updated', this._updatePanel.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._updatePanel));
this._trackedWindows = new Map();
global.window_group.connect('actor-added', this._onWindowActorAdded.bind(this));
global.window_group.connect('actor-removed', this._onWindowActorRemoved.bind(this));
global.window_manager.connect('switch-workspace', this._updateSolidStyle.bind(this));
global.window_group.connect('actor-added', Lang.bind(this, this._onWindowActorAdded));
global.window_group.connect('actor-removed', Lang.bind(this, this._onWindowActorRemoved));
global.window_manager.connect('switch-workspace', Lang.bind(this, this._updateSolidStyle));
global.screen.connect('workareas-changed', () => { this.actor.queue_relayout(); });
this._updatePanel();
},
_onWindowActorAdded(container, metaWindowActor) {
_onWindowActorAdded: function(container, metaWindowActor) {
let signalIds = [];
['allocation-changed', 'notify::visible'].forEach(s => {
signalIds.push(metaWindowActor.connect(s, this._updateSolidStyle.bind(this)));
signalIds.push(metaWindowActor.connect(s, Lang.bind(this, this._updateSolidStyle)));
});
this._trackedWindows.set(metaWindowActor, signalIds);
},
_onWindowActorRemoved(container, metaWindowActor) {
_onWindowActorRemoved: function(container, metaWindowActor) {
this._trackedWindows.get(metaWindowActor).forEach(id => {
metaWindowActor.disconnect(id);
});
@@ -838,7 +841,7 @@ var Panel = new Lang.Class({
this._updateSolidStyle();
},
_getPreferredWidth(actor, forHeight, alloc) {
_getPreferredWidth: function(actor, forHeight, alloc) {
let primaryMonitor = Main.layoutManager.primaryMonitor;
alloc.min_size = -1;
@@ -849,13 +852,13 @@ var Panel = new Lang.Class({
alloc.natural_size = -1;
},
_getPreferredHeight(actor, forWidth, alloc) {
_getPreferredHeight: function(actor, forWidth, alloc) {
// We don't need to implement this; it's forced by the CSS
alloc.min_size = -1;
alloc.natural_size = -1;
},
_allocate(actor, box, flags) {
_allocate: function(actor, box, flags) {
let allocWidth = box.x2 - box.x1;
let allocHeight = box.y2 - box.y1;
@@ -932,7 +935,7 @@ var Panel = new Lang.Class({
this._rightCorner.actor.allocate(childBox, flags);
},
_onButtonPress(actor, event) {
_onButtonPress: function(actor, event) {
if (Main.modalCount > 0)
return Clutter.EVENT_PROPAGATE;
@@ -974,7 +977,7 @@ var Panel = new Lang.Class({
return Clutter.EVENT_STOP;
},
_onKeyPress(actor, event) {
_onKeyPress: function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Escape) {
global.screen.focus_default_window(event.get_time());
@@ -984,7 +987,7 @@ var Panel = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_toggleMenu(indicator) {
_toggleMenu: function(indicator) {
if (!indicator) // menu not supported by current session mode
return;
@@ -997,15 +1000,15 @@ var Panel = new Lang.Class({
menu.actor.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
},
toggleAppMenu() {
toggleAppMenu: function() {
this._toggleMenu(this.statusArea.appMenu);
},
toggleCalendar() {
toggleCalendar: function() {
this._toggleMenu(this.statusArea.dateMenu);
},
closeCalendar() {
closeCalendar: function() {
let indicator = this.statusArea.dateMenu;
if (!indicator) // calendar not supported by current session mode
return;
@@ -1032,7 +1035,7 @@ var Panel = new Lang.Class({
return this._leftBox.opacity;
},
_updatePanel() {
_updatePanel: function() {
let panel = Main.sessionMode.panel;
this._hideIndicators();
this._updateBox(panel.left, this._leftBox);
@@ -1065,7 +1068,7 @@ var Panel = new Lang.Class({
}
},
_updateSolidStyle() {
_updateSolidStyle: function() {
if (this.actor.has_style_pseudo_class('overview') || !Main.sessionMode.hasWindows) {
this._removeStyleClassName('solid');
return;
@@ -1076,7 +1079,7 @@ var Panel = new Lang.Class({
/* Get all the windows in the active workspace that are in the primary monitor and visible */
let activeWorkspace = global.screen.get_active_workspace();
let windows = activeWorkspace.list_windows().filter(metaWindow => {
let windows = activeWorkspace.list_windows().filter(function(metaWindow) {
return metaWindow.is_on_primary_monitor() &&
metaWindow.showing_on_its_workspace() &&
metaWindow.get_window_type() != Meta.WindowType.DESKTOP;
@@ -1086,10 +1089,10 @@ var Panel = new Lang.Class({
let [, panelTop] = this.actor.get_transformed_position();
let panelBottom = panelTop + this.actor.get_height();
let scale = St.ThemeContext.get_for_stage(global.stage).scale_factor;
let isNearEnough = windows.some(metaWindow => {
let isNearEnough = windows.some(Lang.bind(this, function(metaWindow) {
let verticalPosition = metaWindow.get_frame_rect().y;
return verticalPosition < panelBottom + 5 * scale;
});
}));
if (isNearEnough)
this._addStyleClassName('solid');
@@ -1098,7 +1101,7 @@ var Panel = new Lang.Class({
},
_hideIndicators() {
_hideIndicators: function() {
for (let role in PANEL_ITEM_IMPLEMENTATIONS) {
let indicator = this.statusArea[role];
if (!indicator)
@@ -1107,7 +1110,7 @@ var Panel = new Lang.Class({
}
},
_ensureIndicator(role) {
_ensureIndicator: function(role) {
let indicator = this.statusArea[role];
if (!indicator) {
let constructor = PANEL_ITEM_IMPLEMENTATIONS[role];
@@ -1121,7 +1124,7 @@ var Panel = new Lang.Class({
return indicator;
},
_updateBox(elements, box) {
_updateBox: function(elements, box) {
let nChildren = box.get_n_children();
for (let i = 0; i < elements.length; i++) {
@@ -1134,7 +1137,7 @@ var Panel = new Lang.Class({
}
},
_addToPanelBox(role, indicator, position, box) {
_addToPanelBox: function(role, indicator, position, box) {
let container = indicator.container;
container.show();
@@ -1147,16 +1150,16 @@ var Panel = new Lang.Class({
if (indicator.menu)
this.menuManager.addMenu(indicator.menu);
this.statusArea[role] = indicator;
let destroyId = indicator.connect('destroy', emitter => {
let destroyId = indicator.connect('destroy', Lang.bind(this, function(emitter) {
delete this.statusArea[role];
emitter.disconnect(destroyId);
container.destroy();
});
indicator.connect('menu-set', this._onMenuSet.bind(this));
}));
indicator.connect('menu-set', Lang.bind(this, this._onMenuSet));
this._onMenuSet(indicator);
},
addToStatusArea(role, indicator, position, box) {
addToStatusArea: function(role, indicator, position, box) {
if (this.statusArea[role])
throw new Error('Extension point conflict: there is already a status indicator for role ' + role);
@@ -1175,24 +1178,24 @@ var Panel = new Lang.Class({
return indicator;
},
_addStyleClassName(className) {
_addStyleClassName: function(className) {
this.actor.add_style_class_name(className);
this._rightCorner.actor.add_style_class_name(className);
this._leftCorner.actor.add_style_class_name(className);
},
_removeStyleClassName(className) {
_removeStyleClassName: function(className) {
this.actor.remove_style_class_name(className);
this._rightCorner.actor.remove_style_class_name(className);
this._leftCorner.actor.remove_style_class_name(className);
},
_onMenuSet(indicator) {
_onMenuSet: function(indicator) {
if (!indicator.menu || indicator.menu.hasOwnProperty('_openChangedId'))
return;
indicator.menu._openChangedId = indicator.menu.connect('open-state-changed',
(menu, isOpen) => {
Lang.bind(this, function(menu, isOpen) {
let boxAlignment;
if (this._leftBox.contains(indicator.container))
boxAlignment = Clutter.ActorAlign.START;
@@ -1203,6 +1206,6 @@ var Panel = new Lang.Class({
if (boxAlignment == Main.messageTray.bannerAlignment)
Main.messageTray.bannerBlocked = isOpen;
});
}));
}
});

View File

@@ -16,7 +16,7 @@ const PopupMenu = imports.ui.popupMenu;
var ButtonBox = new Lang.Class({
Name: 'ButtonBox',
_init(params) {
_init: function(params) {
params = Params.parse(params, { style_class: 'panel-button' }, true);
this.actor = new Shell.GenericContainer(params);
this.actor._delegate = this;
@@ -25,22 +25,22 @@ var ButtonBox = new Lang.Class({
x_fill: true,
child: this.actor });
this.actor.connect('get-preferred-width', this._getPreferredWidth.bind(this));
this.actor.connect('get-preferred-height', this._getPreferredHeight.bind(this));
this.actor.connect('allocate', this._allocate.bind(this));
this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));
this.actor.connect('style-changed', this._onStyleChanged.bind(this));
this.actor.connect('style-changed', Lang.bind(this, this._onStyleChanged));
this._minHPadding = this._natHPadding = 0.0;
},
_onStyleChanged(actor) {
_onStyleChanged: function(actor) {
let themeNode = actor.get_theme_node();
this._minHPadding = themeNode.get_length('-minimum-hpadding');
this._natHPadding = themeNode.get_length('-natural-hpadding');
},
_getPreferredWidth(actor, forHeight, alloc) {
_getPreferredWidth: function(actor, forHeight, alloc) {
let child = actor.get_first_child();
if (child) {
@@ -53,7 +53,7 @@ var ButtonBox = new Lang.Class({
alloc.natural_size += 2 * this._natHPadding;
},
_getPreferredHeight(actor, forWidth, alloc) {
_getPreferredHeight: function(actor, forWidth, alloc) {
let child = actor.get_first_child();
if (child) {
@@ -63,7 +63,7 @@ var ButtonBox = new Lang.Class({
}
},
_allocate(actor, box, flags) {
_allocate: function(actor, box, flags) {
let child = actor.get_first_child();
if (!child)
return;
@@ -93,15 +93,15 @@ var Button = new Lang.Class({
Name: 'PanelMenuButton',
Extends: ButtonBox,
_init(menuAlignment, nameText, dontCreateMenu) {
_init: function(menuAlignment, nameText, dontCreateMenu) {
this.parent({ reactive: true,
can_focus: true,
track_hover: true,
accessible_name: nameText ? nameText : "",
accessible_role: Atk.Role.MENU });
this.actor.connect('event', this._onEvent.bind(this));
this.actor.connect('notify::visible', this._onVisibilityChanged.bind(this));
this.actor.connect('event', Lang.bind(this, this._onEvent));
this.actor.connect('notify::visible', Lang.bind(this, this._onVisibilityChanged));
if (dontCreateMenu)
this.menu = new PopupMenu.PopupDummyMenu(this.actor);
@@ -109,21 +109,21 @@ var Button = new Lang.Class({
this.setMenu(new PopupMenu.PopupMenu(this.actor, menuAlignment, St.Side.TOP, 0));
},
setSensitive(sensitive) {
setSensitive: function(sensitive) {
this.actor.reactive = sensitive;
this.actor.can_focus = sensitive;
this.actor.track_hover = sensitive;
},
setMenu(menu) {
setMenu: function(menu) {
if (this.menu)
this.menu.destroy();
this.menu = menu;
if (this.menu) {
this.menu.actor.add_style_class_name('panel-menu');
this.menu.connect('open-state-changed', this._onOpenStateChanged.bind(this));
this.menu.actor.connect('key-press-event', this._onMenuKeyPress.bind(this));
this.menu.connect('open-state-changed', Lang.bind(this, this._onOpenStateChanged));
this.menu.actor.connect('key-press-event', Lang.bind(this, this._onMenuKeyPress));
Main.uiGroup.add_actor(this.menu.actor);
this.menu.actor.hide();
@@ -131,7 +131,7 @@ var Button = new Lang.Class({
this.emit('menu-set');
},
_onEvent(actor, event) {
_onEvent: function(actor, event) {
if (this.menu &&
(event.type() == Clutter.EventType.TOUCH_BEGIN ||
event.type() == Clutter.EventType.BUTTON_PRESS))
@@ -140,7 +140,7 @@ var Button = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onVisibilityChanged() {
_onVisibilityChanged: function() {
if (!this.menu)
return;
@@ -148,7 +148,7 @@ var Button = new Lang.Class({
this.menu.close();
},
_onMenuKeyPress(actor, event) {
_onMenuKeyPress: function(actor, event) {
if (global.focus_manager.navigate_from_event(event))
return Clutter.EVENT_STOP;
@@ -164,7 +164,7 @@ var Button = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onOpenStateChanged(menu, open) {
_onOpenStateChanged: function(menu, open) {
if (open)
this.actor.add_style_pseudo_class('active');
else
@@ -184,7 +184,7 @@ var Button = new Lang.Class({
this.menu.actor.style = ('max-height: %spx;').format(maxHeight);
},
destroy() {
destroy: function() {
this.actor._delegate = null;
if (this.menu)
@@ -206,21 +206,23 @@ Signals.addSignalMethods(Button.prototype);
var SystemIndicator = new Lang.Class({
Name: 'SystemIndicator',
_init() {
_init: function() {
this.indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box',
reactive: true });
this.indicators.hide();
this.menu = new PopupMenu.PopupMenuSection();
},
_syncIndicatorsVisible() {
this.indicators.visible = this.indicators.get_children().some(a => a.visible);
_syncIndicatorsVisible: function() {
this.indicators.visible = this.indicators.get_children().some(function(actor) {
return actor.visible;
});
},
_addIndicator() {
_addIndicator: function() {
let icon = new St.Icon({ style_class: 'system-status-icon' });
this.indicators.add_actor(icon);
icon.connect('notify::visible', this._syncIndicatorsVisible.bind(this));
icon.connect('notify::visible', Lang.bind(this, this._syncIndicatorsVisible));
this._syncIndicatorsVisible();
return icon;
}

View File

@@ -25,7 +25,7 @@ function getPointerWatcher() {
var PointerWatch = new Lang.Class({
Name: 'PointerWatch',
_init(watcher, interval, callback) {
_init: function(watcher, interval, callback) {
this.watcher = watcher;
this.interval = interval;
this.callback = callback;
@@ -34,7 +34,7 @@ var PointerWatch = new Lang.Class({
// remove:
// remove this watch. This function may safely be called
// while the callback is executing.
remove() {
remove: function() {
this.watcher._removeWatch(this);
}
});
@@ -42,9 +42,9 @@ var PointerWatch = new Lang.Class({
var PointerWatcher = new Lang.Class({
Name: 'PointerWatcher',
_init() {
_init: function() {
this._idleMonitor = Meta.IdleMonitor.get_core();
this._idleMonitor.add_idle_watch(IDLE_TIME, this._onIdleMonitorBecameIdle.bind(this));
this._idleMonitor.add_idle_watch(IDLE_TIME, Lang.bind(this, this._onIdleMonitorBecameIdle));
this._idle = this._idleMonitor.get_idletime() > IDLE_TIME;
this._watches = [];
this.pointerX = null;
@@ -55,12 +55,12 @@ var PointerWatcher = new Lang.Class({
// @interval: hint as to the time resolution needed. When the user is
// not idle, the position of the pointer will be queried at least
// once every this many milliseconds.
// @callback to call when the pointer position changes - takes
// @callback: function to call when the pointer position changes - takes
// two arguments, X and Y.
//
// Set up a watch on the position of the mouse pointer. Returns a
// PointerWatch object which has a remove() method to remove the watch.
addWatch(interval, callback) {
addWatch: function(interval, callback) {
// Avoid unreliably calling the watch for the current position
this._updatePointer();
@@ -70,7 +70,7 @@ var PointerWatcher = new Lang.Class({
return watch;
},
_removeWatch(watch) {
_removeWatch: function(watch) {
for (let i = 0; i < this._watches.length; i++) {
if (this._watches[i] == watch) {
this._watches.splice(i, 1);
@@ -80,19 +80,19 @@ var PointerWatcher = new Lang.Class({
}
},
_onIdleMonitorBecameActive(monitor) {
_onIdleMonitorBecameActive: function(monitor) {
this._idle = false;
this._updatePointer();
this._updateTimeout();
},
_onIdleMonitorBecameIdle(monitor) {
_onIdleMonitorBecameIdle: function(monitor) {
this._idle = true;
this._idleMonitor.add_user_active_watch(this._onIdleMonitorBecameActive.bind(this));
this._idleMonitor.add_user_active_watch(Lang.bind(this, this._onIdleMonitorBecameActive));
this._updateTimeout();
},
_updateTimeout() {
_updateTimeout: function() {
if (this._timeoutId) {
Mainloop.source_remove(this._timeoutId);
this._timeoutId = 0;
@@ -106,16 +106,16 @@ var PointerWatcher = new Lang.Class({
minInterval = Math.min(this._watches[i].interval, minInterval);
this._timeoutId = Mainloop.timeout_add(minInterval,
this._onTimeout.bind(this));
Lang.bind(this, this._onTimeout));
GLib.Source.set_name_by_id(this._timeoutId, '[gnome-shell] this._onTimeout');
},
_onTimeout() {
_onTimeout: function() {
this._updatePointer();
return GLib.SOURCE_CONTINUE;
},
_updatePointer() {
_updatePointer: function() {
let [x, y, mods] = global.get_pointer();
if (this.pointerX == x && this.pointerY == y)
return;

View File

@@ -61,7 +61,7 @@ function arrowIcon(side) {
var PopupBaseMenuItem = new Lang.Class({
Name: 'PopupBaseMenuItem',
_init(params) {
_init: function (params) {
params = Params.parse (params, { reactive: true,
activate: true,
hover: true,
@@ -92,43 +92,43 @@ var PopupBaseMenuItem = new Lang.Class({
this.actor.add_style_class_name(params.style_class);
if (this._activatable) {
this.actor.connect('button-press-event', this._onButtonPressEvent.bind(this));
this.actor.connect('button-release-event', this._onButtonReleaseEvent.bind(this));
this.actor.connect('touch-event', this._onTouchEvent.bind(this));
this.actor.connect('key-press-event', this._onKeyPressEvent.bind(this));
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPressEvent));
this.actor.connect('button-release-event', Lang.bind(this, this._onButtonReleaseEvent));
this.actor.connect('touch-event', Lang.bind(this, this._onTouchEvent));
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
}
if (params.reactive && params.hover)
this.actor.connect('notify::hover', this._onHoverChanged.bind(this));
this.actor.connect('notify::hover', Lang.bind(this, this._onHoverChanged));
this.actor.connect('key-focus-in', this._onKeyFocusIn.bind(this));
this.actor.connect('key-focus-out', this._onKeyFocusOut.bind(this));
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('key-focus-in', Lang.bind(this, this._onKeyFocusIn));
this.actor.connect('key-focus-out', Lang.bind(this, this._onKeyFocusOut));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
},
_getTopMenu() {
_getTopMenu: function() {
if (this._parent)
return this._parent._getTopMenu();
else
return this;
},
_setParent(parent) {
_setParent: function(parent) {
this._parent = parent;
},
_onButtonPressEvent(actor, event) {
_onButtonPressEvent: function (actor, event) {
// This is the CSS active state
this.actor.add_style_pseudo_class ('active');
return Clutter.EVENT_PROPAGATE;
},
_onButtonReleaseEvent(actor, event) {
_onButtonReleaseEvent: function (actor, event) {
this.actor.remove_style_pseudo_class ('active');
this.activate(event);
return Clutter.EVENT_STOP;
},
_onTouchEvent(actor, event) {
_onTouchEvent: function (actor, event) {
if (event.type() == Clutter.EventType.TOUCH_END) {
this.actor.remove_style_pseudo_class ('active');
this.activate(event);
@@ -140,7 +140,7 @@ var PopupBaseMenuItem = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onKeyPressEvent(actor, event) {
_onKeyPressEvent: function (actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_space || symbol == Clutter.KEY_Return) {
@@ -150,23 +150,23 @@ var PopupBaseMenuItem = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onKeyFocusIn(actor) {
_onKeyFocusIn: function (actor) {
this.setActive(true);
},
_onKeyFocusOut(actor) {
_onKeyFocusOut: function (actor) {
this.setActive(false);
},
_onHoverChanged(actor) {
_onHoverChanged: function (actor) {
this.setActive(actor.hover);
},
activate(event) {
activate: function (event) {
this.emit('activate', event);
},
setActive(active) {
setActive: function (active) {
let activeChanged = active != this.active;
if (activeChanged) {
this.active = active;
@@ -187,7 +187,7 @@ var PopupBaseMenuItem = new Lang.Class({
}
},
syncSensitive() {
syncSensitive: function() {
let sensitive = this.getSensitive();
this.actor.reactive = sensitive;
this.actor.can_focus = sensitive;
@@ -195,12 +195,12 @@ var PopupBaseMenuItem = new Lang.Class({
return sensitive;
},
getSensitive() {
getSensitive: function() {
let parentSensitive = this._parent ? this._parent.getSensitive() : true;
return this._activatable && this._sensitive && parentSensitive;
},
setSensitive(sensitive) {
setSensitive: function(sensitive) {
if (this._sensitive == sensitive)
return;
@@ -208,15 +208,15 @@ var PopupBaseMenuItem = new Lang.Class({
this.syncSensitive();
},
destroy() {
destroy: function() {
this.actor.destroy();
},
_onDestroy() {
_onDestroy: function() {
this.emit('destroy');
},
setOrnament(ornament) {
setOrnament: function(ornament) {
if (ornament == this._ornament)
return;
@@ -240,7 +240,7 @@ var PopupMenuItem = new Lang.Class({
Name: 'PopupMenuItem',
Extends: PopupBaseMenuItem,
_init(text, params) {
_init: function (text, params) {
this.parent(params);
this.label = new St.Label({ text: text });
@@ -253,7 +253,7 @@ var PopupSeparatorMenuItem = new Lang.Class({
Name: 'PopupSeparatorMenuItem',
Extends: PopupBaseMenuItem,
_init(text) {
_init: function (text) {
this.parent({ reactive: false,
can_focus: false});
@@ -262,7 +262,7 @@ var PopupSeparatorMenuItem = new Lang.Class({
this.actor.label_actor = this.label;
this.label.connect('notify::text',
this._syncVisibility.bind(this));
Lang.bind(this, this._syncVisibility));
this._syncVisibility();
this._separator = new St.Widget({ style_class: 'popup-separator-menu-item',
@@ -271,7 +271,7 @@ var PopupSeparatorMenuItem = new Lang.Class({
this.actor.add(this._separator, { expand: true });
},
_syncVisibility() {
_syncVisibility: function() {
this.label.visible = this.label.text != '';
}
});
@@ -279,7 +279,7 @@ var PopupSeparatorMenuItem = new Lang.Class({
var Switch = new Lang.Class({
Name: 'Switch',
_init(state) {
_init: function(state) {
this.actor = new St.Bin({ style_class: 'toggle-switch',
accessible_role: Atk.Role.CHECK_BOX,
can_focus: true });
@@ -292,7 +292,7 @@ var Switch = new Lang.Class({
this.setToggleState(state);
},
setToggleState(state) {
setToggleState: function(state) {
if (state)
this.actor.add_style_pseudo_class('checked');
else
@@ -300,7 +300,7 @@ var Switch = new Lang.Class({
this.state = state;
},
toggle() {
toggle: function() {
this.setToggleState(!this.state);
}
});
@@ -309,7 +309,7 @@ var PopupSwitchMenuItem = new Lang.Class({
Name: 'PopupSwitchMenuItem',
Extends: PopupBaseMenuItem,
_init(text, active, params) {
_init: function(text, active, params) {
this.parent(params);
this.label = new St.Label({ text: text });
@@ -330,7 +330,7 @@ var PopupSwitchMenuItem = new Lang.Class({
this._statusBin.child = this._switch.actor;
},
setStatus(text) {
setStatus: function(text) {
if (text != null) {
this._statusLabel.text = text;
this._statusBin.child = this._statusLabel;
@@ -344,7 +344,7 @@ var PopupSwitchMenuItem = new Lang.Class({
this.checkAccessibleState();
},
activate(event) {
activate: function(event) {
if (this._switch.actor.mapped) {
this.toggle();
}
@@ -358,7 +358,7 @@ var PopupSwitchMenuItem = new Lang.Class({
this.parent(event);
},
toggle() {
toggle: function() {
this._switch.toggle();
this.emit('toggled', this._switch.state);
this.checkAccessibleState();
@@ -368,12 +368,12 @@ var PopupSwitchMenuItem = new Lang.Class({
return this._switch.state;
},
setToggleState(state) {
setToggleState: function(state) {
this._switch.setToggleState(state);
this.checkAccessibleState();
},
checkAccessibleState() {
checkAccessibleState: function() {
switch (this.actor.accessible_role) {
case Atk.Role.CHECK_MENU_ITEM:
if (this._switch.state)
@@ -391,7 +391,7 @@ var PopupImageMenuItem = new Lang.Class({
Name: 'PopupImageMenuItem',
Extends: PopupBaseMenuItem,
_init(text, icon, params) {
_init: function (text, icon, params) {
this.parent(params);
this._icon = new St.Icon({ style_class: 'popup-menu-icon' });
@@ -403,7 +403,7 @@ var PopupImageMenuItem = new Lang.Class({
this.setIcon(icon);
},
setIcon(icon) {
setIcon: function(icon) {
// The 'icon' parameter can be either a Gio.Icon or a string.
if (icon instanceof GObject.Object && GObject.type_is_a(icon, Gio.Icon))
this._icon.gicon = icon;
@@ -416,7 +416,7 @@ var PopupMenuBase = new Lang.Class({
Name: 'PopupMenuBase',
Abstract: true,
_init(sourceActor, styleClass) {
_init: function(sourceActor, styleClass) {
this.sourceActor = sourceActor;
this._parent = null;
@@ -439,36 +439,36 @@ var PopupMenuBase = new Lang.Class({
this._sensitive = true;
this._sessionUpdatedId = Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
this._sessionUpdatedId = Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
},
_getTopMenu() {
_getTopMenu: function() {
if (this._parent)
return this._parent._getTopMenu();
else
return this;
},
_setParent(parent) {
_setParent: function(parent) {
this._parent = parent;
},
getSensitive() {
getSensitive: function() {
let parentSensitive = this._parent ? this._parent.getSensitive() : true;
return this._sensitive && parentSensitive;
},
setSensitive(sensitive) {
setSensitive: function(sensitive) {
this._sensitive = sensitive;
this.emit('sensitive-changed');
},
_sessionUpdated() {
_sessionUpdated: function() {
this._setSettingsVisibility(Main.sessionMode.allowSettings);
this.close();
},
addAction(title, callback, icon) {
addAction: function(title, callback, icon) {
let menuItem;
if (icon != undefined)
menuItem = new PopupImageMenuItem(title, icon);
@@ -476,25 +476,25 @@ var PopupMenuBase = new Lang.Class({
menuItem = new PopupMenuItem(title);
this.addMenuItem(menuItem);
menuItem.connect('activate', (menuItem, event) => {
menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
callback(event);
});
}));
return menuItem;
},
addSettingsAction(title, desktopFile) {
let menuItem = this.addAction(title, () => {
let app = Shell.AppSystem.get_default().lookup_app(desktopFile);
addSettingsAction: function(title, desktopFile) {
let menuItem = this.addAction(title, function() {
let app = Shell.AppSystem.get_default().lookup_app(desktopFile);
if (!app) {
log('Settings panel for desktop file ' + desktopFile + ' could not be loaded!');
return;
}
if (!app) {
log('Settings panel for desktop file ' + desktopFile + ' could not be loaded!');
return;
}
Main.overview.hide();
app.activate();
});
Main.overview.hide();
app.activate();
});
menuItem.actor.visible = Main.sessionMode.allowSettings;
this._settingsActions[desktopFile] = menuItem;
@@ -502,15 +502,15 @@ var PopupMenuBase = new Lang.Class({
return menuItem;
},
_setSettingsVisibility(visible) {
_setSettingsVisibility: function(visible) {
for (let id in this._settingsActions) {
let item = this._settingsActions[id];
item.actor.visible = visible;
}
},
isEmpty() {
let hasVisibleChildren = this.box.get_children().some(child => {
isEmpty: function() {
let hasVisibleChildren = this.box.get_children().some(function(child) {
if (child._delegate instanceof PopupSeparatorMenuItem)
return false;
return isPopupMenuItemVisible(child);
@@ -519,22 +519,22 @@ var PopupMenuBase = new Lang.Class({
return !hasVisibleChildren;
},
itemActivated(animate) {
itemActivated: function(animate) {
if (animate == undefined)
animate = BoxPointer.PopupAnimation.FULL;
this._getTopMenu().close(animate);
},
_subMenuActiveChanged(submenu, submenuItem) {
_subMenuActiveChanged: function(submenu, submenuItem) {
if (this._activeMenuItem && this._activeMenuItem != submenuItem)
this._activeMenuItem.setActive(false);
this._activeMenuItem = submenuItem;
this.emit('active-changed', submenuItem);
},
_connectItemSignals(menuItem) {
menuItem._activeChangeId = menuItem.connect('active-changed', (menuItem, active) => {
_connectItemSignals: function(menuItem) {
menuItem._activeChangeId = menuItem.connect('active-changed', Lang.bind(this, function (menuItem, active) {
if (active && this._activeMenuItem != menuItem) {
if (this._activeMenuItem)
this._activeMenuItem.setActive(false);
@@ -544,8 +544,8 @@ var PopupMenuBase = new Lang.Class({
this._activeMenuItem = null;
this.emit('active-changed', null);
}
});
menuItem._sensitiveChangeId = menuItem.connect('sensitive-changed', () => {
}));
menuItem._sensitiveChangeId = menuItem.connect('sensitive-changed', Lang.bind(this, function() {
let sensitive = menuItem.getSensitive();
if (!sensitive && this._activeMenuItem == menuItem) {
if (!this.actor.navigate_focus(menuItem.actor,
@@ -556,21 +556,21 @@ var PopupMenuBase = new Lang.Class({
if (global.stage.get_key_focus() == this.actor)
menuItem.actor.grab_key_focus();
}
});
menuItem._activateId = menuItem.connect('activate', (menuItem, event) => {
}));
menuItem._activateId = menuItem.connect('activate', Lang.bind(this, function (menuItem, event) {
this.emit('activate', menuItem);
this.itemActivated(BoxPointer.PopupAnimation.FULL);
});
}));
menuItem._parentSensitiveChangeId = this.connect('sensitive-changed', () => {
menuItem._parentSensitiveChangeId = this.connect('sensitive-changed', Lang.bind(this, function() {
menuItem.syncSensitive();
});
}));
// the weird name is to avoid a conflict with some random property
// the menuItem may have, called destroyId
// (FIXME: in the future it may make sense to have container objects
// like PopupMenuManager does)
menuItem._popupMenuDestroyId = menuItem.connect('destroy', menuItem => {
menuItem._popupMenuDestroyId = menuItem.connect('destroy', Lang.bind(this, function(menuItem) {
menuItem.disconnect(menuItem._popupMenuDestroyId);
menuItem.disconnect(menuItem._activateId);
menuItem.disconnect(menuItem._activeChangeId);
@@ -578,10 +578,10 @@ var PopupMenuBase = new Lang.Class({
this.disconnect(menuItem._parentSensitiveChangeId);
if (menuItem == this._activeMenuItem)
this._activeMenuItem = null;
});
}));
},
_updateSeparatorVisibility(menuItem) {
_updateSeparatorVisibility: function(menuItem) {
if (menuItem.label.text)
return;
@@ -617,7 +617,7 @@ var PopupMenuBase = new Lang.Class({
menuItem.actor.show();
},
moveMenuItem(menuItem, position) {
moveMenuItem: function(menuItem, position) {
let items = this._getMenuItems();
let i = 0;
@@ -635,7 +635,7 @@ var PopupMenuBase = new Lang.Class({
}
},
addMenuItem(menuItem, position) {
addMenuItem: function(menuItem, position) {
let before_item = null;
if (position == undefined) {
this.box.add(menuItem.actor);
@@ -650,28 +650,28 @@ var PopupMenuBase = new Lang.Class({
}
if (menuItem instanceof PopupMenuSection) {
let activeChangeId = menuItem.connect('active-changed', this._subMenuActiveChanged.bind(this));
let activeChangeId = menuItem.connect('active-changed', Lang.bind(this, this._subMenuActiveChanged));
let parentOpenStateChangedId = this.connect('open-state-changed', (self, open) => {
let parentOpenStateChangedId = this.connect('open-state-changed', function(self, open) {
if (open)
menuItem.open();
else
menuItem.close();
});
let parentClosingId = this.connect('menu-closed', () => {
let parentClosingId = this.connect('menu-closed', function() {
menuItem.emit('menu-closed');
});
let subMenuSensitiveChangedId = this.connect('sensitive-changed', () => {
let subMenuSensitiveChangedId = this.connect('sensitive-changed', Lang.bind(this, function() {
menuItem.emit('sensitive-changed');
});
}));
menuItem.connect('destroy', () => {
menuItem.connect('destroy', Lang.bind(this, function() {
menuItem.disconnect(activeChangeId);
this.disconnect(subMenuSensitiveChangedId);
this.disconnect(parentOpenStateChangedId);
this.disconnect(parentClosingId);
this.length--;
});
}));
} else if (menuItem instanceof PopupSubMenuMenuItem) {
if (before_item == null)
this.box.add(menuItem.menu.actor);
@@ -679,15 +679,15 @@ var PopupMenuBase = new Lang.Class({
this.box.insert_child_below(menuItem.menu.actor, before_item);
this._connectItemSignals(menuItem);
let subMenuActiveChangeId = menuItem.menu.connect('active-changed', this._subMenuActiveChanged.bind(this));
let closingId = this.connect('menu-closed', () => {
let subMenuActiveChangeId = menuItem.menu.connect('active-changed', Lang.bind(this, this._subMenuActiveChanged));
let closingId = this.connect('menu-closed', function() {
menuItem.menu.close(BoxPointer.PopupAnimation.NONE);
});
menuItem.connect('destroy', () => {
menuItem.connect('destroy', Lang.bind(this, function() {
menuItem.menu.disconnect(subMenuActiveChangeId);
this.disconnect(closingId);
});
}));
} else if (menuItem instanceof PopupSeparatorMenuItem) {
this._connectItemSignals(menuItem);
@@ -695,13 +695,11 @@ var PopupMenuBase = new Lang.Class({
// separator's adjacent siblings change visibility or position.
// open-state-changed isn't exactly that, but doing it in more
// precise ways would require a lot more bookkeeping.
let openStateChangeId = this.connect('open-state-changed', () => {
this._updateSeparatorVisibility(menuItem);
});
let destroyId = menuItem.connect('destroy', () => {
let openStateChangeId = this.connect('open-state-changed', Lang.bind(this, function() { this._updateSeparatorVisibility(menuItem); }));
let destroyId = menuItem.connect('destroy', Lang.bind(this, function() {
this.disconnect(openStateChangeId);
menuItem.disconnect(destroyId);
});
}));
} else if (menuItem instanceof PopupBaseMenuItem)
this._connectItemSignals(menuItem);
else
@@ -712,8 +710,10 @@ var PopupMenuBase = new Lang.Class({
this.length++;
},
_getMenuItems() {
return this.box.get_children().map(a => a._delegate).filter(item => {
_getMenuItems: function() {
return this.box.get_children().map(function (actor) {
return actor._delegate;
}).filter(function(item) {
return item instanceof PopupBaseMenuItem || item instanceof PopupMenuSection;
});
},
@@ -730,7 +730,7 @@ var PopupMenuBase = new Lang.Class({
return this._getMenuItems().length;
},
removeAll() {
removeAll: function() {
let children = this._getMenuItems();
for (let i = 0; i < children.length; i++) {
let item = children[i];
@@ -738,14 +738,14 @@ var PopupMenuBase = new Lang.Class({
}
},
toggle() {
toggle: function() {
if (this.isOpen)
this.close(BoxPointer.PopupAnimation.FULL);
else
this.open(BoxPointer.PopupAnimation.FULL);
},
destroy() {
destroy: function() {
this.close();
this.removeAll();
this.actor.destroy();
@@ -762,7 +762,7 @@ var PopupMenu = new Lang.Class({
Name: 'PopupMenu',
Extends: PopupMenuBase,
_init(sourceActor, arrowAlignment, arrowSide) {
_init: function(sourceActor, arrowAlignment, arrowSide) {
this.parent(sourceActor, 'popup-menu-content');
this._arrowAlignment = arrowAlignment;
@@ -784,19 +784,19 @@ var PopupMenu = new Lang.Class({
if (this.sourceActor)
this._keyPressId = this.sourceActor.connect('key-press-event',
this._onKeyPress.bind(this));
Lang.bind(this, this._onKeyPress));
this._openedSubMenu = null;
},
_setOpenedSubMenu(submenu) {
_setOpenedSubMenu: function(submenu) {
if (this._openedSubMenu)
this._openedSubMenu.close(true);
this._openedSubMenu = submenu;
},
_onKeyPress(actor, event) {
_onKeyPress: function(actor, event) {
// Disable toggling the menu by keyboard
// when it cannot be toggled by pointer
if (!actor.reactive)
@@ -845,15 +845,15 @@ var PopupMenu = new Lang.Class({
},
setArrowOrigin(origin) {
setArrowOrigin: function(origin) {
this._boxPointer.setArrowOrigin(origin);
},
setSourceAlignment(alignment) {
setSourceAlignment: function(alignment) {
this._boxPointer.setSourceAlignment(alignment);
},
open(animate) {
open: function(animate) {
if (this.isOpen)
return;
@@ -870,14 +870,14 @@ var PopupMenu = new Lang.Class({
this.emit('open-state-changed', true);
},
close(animate) {
close: function(animate) {
if (this._activeMenuItem)
this._activeMenuItem.setActive(false);
if (this._boxPointer.actor.visible) {
this._boxPointer.hide(animate, () => {
this._boxPointer.hide(animate, Lang.bind(this, function() {
this.emit('menu-closed');
});
}));
}
if (!this.isOpen)
@@ -887,7 +887,7 @@ var PopupMenu = new Lang.Class({
this.emit('open-state-changed', false);
},
destroy() {
destroy: function() {
if (this._keyPressId)
this.sourceActor.disconnect(this._keyPressId);
this.parent();
@@ -897,20 +897,20 @@ var PopupMenu = new Lang.Class({
var PopupDummyMenu = new Lang.Class({
Name: 'PopupDummyMenu',
_init(sourceActor) {
_init: function(sourceActor) {
this.sourceActor = sourceActor;
this.actor = sourceActor;
this.actor._delegate = this;
},
getSensitive() {
getSensitive: function() {
return true;
},
open() { this.emit('open-state-changed', true); },
close() { this.emit('open-state-changed', false); },
toggle() {},
destroy() {
open: function() { this.emit('open-state-changed', true); },
close: function() { this.emit('open-state-changed', false); },
toggle: function() {},
destroy: function() {
this.emit('destroy');
},
});
@@ -920,7 +920,7 @@ var PopupSubMenu = new Lang.Class({
Name: 'PopupSubMenu',
Extends: PopupMenuBase,
_init(sourceActor, sourceArrow) {
_init: function(sourceActor, sourceArrow) {
this.parent(sourceActor);
this._arrow = sourceArrow;
@@ -935,11 +935,11 @@ var PopupSubMenu = new Lang.Class({
this.actor.add_actor(this.box);
this.actor._delegate = this;
this.actor.clip_to_allocation = true;
this.actor.connect('key-press-event', this._onKeyPressEvent.bind(this));
this.actor.connect('key-press-event', Lang.bind(this, this._onKeyPressEvent));
this.actor.hide();
},
_needsScrollbar() {
_needsScrollbar: function() {
let topMenu = this._getTopMenu();
let [topMinHeight, topNaturalHeight] = topMenu.actor.get_preferred_height(-1);
let topThemeNode = topMenu.actor.get_theme_node();
@@ -948,11 +948,11 @@ var PopupSubMenu = new Lang.Class({
return topMaxHeight >= 0 && topNaturalHeight >= topMaxHeight;
},
getSensitive() {
getSensitive: function() {
return this._sensitive && this.sourceActor._delegate.getSensitive();
},
open(animate) {
open: function(animate) {
if (this.isOpen)
return;
@@ -995,11 +995,11 @@ var PopupSubMenu = new Lang.Class({
height: naturalHeight,
time: 0.25,
onUpdateScope: this,
onUpdate() {
onUpdate: function() {
this._arrow.rotation_angle_z = this.actor._arrowRotation;
},
onCompleteScope: this,
onComplete() {
onComplete: function() {
this.actor.set_height(-1);
}
});
@@ -1008,7 +1008,7 @@ var PopupSubMenu = new Lang.Class({
}
},
close(animate) {
close: function(animate) {
if (!this.isOpen)
return;
@@ -1028,11 +1028,11 @@ var PopupSubMenu = new Lang.Class({
height: 0,
time: 0.25,
onUpdateScope: this,
onUpdate() {
onUpdate: function() {
this._arrow.rotation_angle_z = this.actor._arrowRotation;
},
onCompleteScope: this,
onComplete() {
onComplete: function() {
this.actor.hide();
this.actor.set_height(-1);
},
@@ -1043,7 +1043,7 @@ var PopupSubMenu = new Lang.Class({
}
},
_onKeyPressEvent(actor, event) {
_onKeyPressEvent: function(actor, event) {
// Move focus back to parent menu if the user types Left.
if (this.isOpen && event.get_key_symbol() == Clutter.KEY_Left) {
@@ -1068,7 +1068,7 @@ var PopupMenuSection = new Lang.Class({
Name: 'PopupMenuSection',
Extends: PopupMenuBase,
_init() {
_init: function() {
this.parent();
this.actor = this.box;
@@ -1078,15 +1078,15 @@ var PopupMenuSection = new Lang.Class({
// deliberately ignore any attempt to open() or close(), but emit the
// corresponding signal so children can still pick it up
open() { this.emit('open-state-changed', true); },
close() { this.emit('open-state-changed', false); },
open: function() { this.emit('open-state-changed', true); },
close: function() { this.emit('open-state-changed', false); },
});
var PopupSubMenuMenuItem = new Lang.Class({
Name: 'PopupSubMenuMenuItem',
Extends: PopupBaseMenuItem,
_init(text, wantIcon) {
_init: function(text, wantIcon) {
this.parent();
this.actor.add_style_class_name('popup-submenu-menu-item');
@@ -1116,22 +1116,22 @@ var PopupSubMenuMenuItem = new Lang.Class({
this.actor.add_accessible_state (Atk.StateType.EXPANDABLE);
this.menu = new PopupSubMenu(this.actor, this._triangle);
this.menu.connect('open-state-changed', this._subMenuOpenStateChanged.bind(this));
this.menu.connect('open-state-changed', Lang.bind(this, this._subMenuOpenStateChanged));
},
_setParent(parent) {
_setParent: function(parent) {
this.parent(parent);
this.menu._setParent(parent);
},
syncSensitive() {
syncSensitive: function() {
let sensitive = this.parent();
this._triangle.visible = sensitive;
if (!sensitive)
this.menu.close(false);
},
_subMenuOpenStateChanged(menu, open) {
_subMenuOpenStateChanged: function(menu, open) {
if (open) {
this.actor.add_style_pseudo_class('open');
this._getTopMenu()._setOpenedSubMenu(this.menu);
@@ -1145,28 +1145,28 @@ var PopupSubMenuMenuItem = new Lang.Class({
}
},
destroy() {
destroy: function() {
this.menu.destroy();
this.parent();
},
setSubmenuShown(open) {
setSubmenuShown: function(open) {
if (open)
this.menu.open(BoxPointer.PopupAnimation.FULL);
else
this.menu.close(BoxPointer.PopupAnimation.FULL);
},
_setOpenState(open) {
_setOpenState: function(open) {
this.setSubmenuShown(open);
},
_getOpenState() {
_getOpenState: function() {
return this.menu.isOpen;
},
_onKeyPressEvent(actor, event) {
_onKeyPressEvent: function(actor, event) {
let symbol = event.get_key_symbol();
if (symbol == Clutter.KEY_Right) {
@@ -1181,11 +1181,11 @@ var PopupSubMenuMenuItem = new Lang.Class({
return this.parent(actor, event);
},
activate(event) {
activate: function(event) {
this._setOpenState(true);
},
_onButtonReleaseEvent(actor) {
_onButtonReleaseEvent: function(actor) {
// Since we override the parent, we need to manage what the parent does
// with the active style class
this.actor.remove_style_pseudo_class ('active');
@@ -1193,7 +1193,7 @@ var PopupSubMenuMenuItem = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onTouchEvent(actor, event) {
_onTouchEvent: function(actor, event) {
if (event.type() == Clutter.EventType.TOUCH_END) {
// Since we override the parent, we need to manage what the parent does
// with the active style class
@@ -1210,7 +1210,7 @@ var PopupSubMenuMenuItem = new Lang.Class({
var PopupMenuManager = new Lang.Class({
Name: 'PopupMenuManager',
_init(owner, grabParams) {
_init: function(owner, grabParams) {
grabParams = Params.parse(grabParams,
{ actionMode: Shell.ActionMode.POPUP });
this._owner = owner;
@@ -1218,14 +1218,14 @@ var PopupMenuManager = new Lang.Class({
this._menus = [];
},
addMenu(menu, position) {
addMenu: function(menu, position) {
if (this._findMenu(menu) > -1)
return;
let menudata = {
menu: menu,
openStateChangeId: menu.connect('open-state-changed', this._onMenuOpenState.bind(this)),
destroyId: menu.connect('destroy', this._onMenuDestroy.bind(this)),
openStateChangeId: menu.connect('open-state-changed', Lang.bind(this, this._onMenuOpenState)),
destroyId: menu.connect('destroy', Lang.bind(this, this._onMenuDestroy)),
enterId: 0,
focusInId: 0
};
@@ -1234,11 +1234,8 @@ var PopupMenuManager = new Lang.Class({
if (source) {
if (!menu.blockSourceEvents)
this._grabHelper.addActor(source);
menudata.enterId = source.connect('enter-event',
() => this._onMenuSourceEnter(menu));
menudata.focusInId = source.connect('key-focus-in', () => {
this._onMenuSourceEnter(menu);
});
menudata.enterId = source.connect('enter-event', Lang.bind(this, function() { return this._onMenuSourceEnter(menu); }));
menudata.focusInId = source.connect('key-focus-in', Lang.bind(this, function() { this._onMenuSourceEnter(menu); }));
}
if (position == undefined)
@@ -1247,7 +1244,7 @@ var PopupMenuManager = new Lang.Class({
this._menus.splice(position, 0, menudata);
},
removeMenu(menu) {
removeMenu: function(menu) {
if (menu == this.activeMenu)
this._closeMenu(false, menu);
@@ -1277,29 +1274,27 @@ var PopupMenuManager = new Lang.Class({
return null;
},
ignoreRelease() {
ignoreRelease: function() {
return this._grabHelper.ignoreRelease();
},
_onMenuOpenState(menu, open) {
_onMenuOpenState: function(menu, open) {
if (open) {
if (this.activeMenu)
this.activeMenu.close(BoxPointer.PopupAnimation.FADE);
this._grabHelper.grab({ actor: menu.actor, focus: menu.sourceActor,
onUngrab: isUser => {
this._closeMenu(isUser, menu);
} });
onUngrab: Lang.bind(this, this._closeMenu, menu) });
} else {
this._grabHelper.ungrab({ actor: menu.actor });
}
},
_changeMenu(newMenu) {
_changeMenu: function(newMenu) {
newMenu.open(this.activeMenu ? BoxPointer.PopupAnimation.FADE
: BoxPointer.PopupAnimation.FULL);
},
_onMenuSourceEnter(menu) {
_onMenuSourceEnter: function(menu) {
if (!this._grabHelper.grabbed)
return Clutter.EVENT_PROPAGATE;
@@ -1310,11 +1305,11 @@ var PopupMenuManager = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onMenuDestroy(menu) {
_onMenuDestroy: function(menu) {
this.removeMenu(menu);
},
_findMenu(item) {
_findMenu: function(item) {
for (let i = 0; i < this._menus.length; i++) {
let menudata = this._menus[i];
if (item == menudata.menu)
@@ -1323,7 +1318,7 @@ var PopupMenuManager = new Lang.Class({
return -1;
},
_closeMenu(isUser, menu) {
_closeMenu: function(isUser, menu) {
// If this isn't a user action, we called close()
// on the BoxPointer ourselves, so we shouldn't
// reanimate.

View File

@@ -41,18 +41,18 @@ function _removeItem(menu, position) {
var RemoteMenuSeparatorItemMapper = new Lang.Class({
Name: 'RemoteMenuSeparatorItemMapper',
_init(trackerItem) {
_init: function(trackerItem) {
this._trackerItem = trackerItem;
this.menuItem = new PopupMenu.PopupSeparatorMenuItem();
this._trackerItem.connect('notify::label', this._updateLabel.bind(this));
this._trackerItem.connect('notify::label', Lang.bind(this, this._updateLabel));
this._updateLabel();
this.menuItem.connect('destroy', () => {
this.menuItem.connect('destroy', function() {
trackerItem.run_dispose();
});
},
_updateLabel() {
_updateLabel: function() {
this.menuItem.label.text = stripMnemonics(this._trackerItem.label);
},
});
@@ -61,17 +61,17 @@ var RequestSubMenu = new Lang.Class({
Name: 'RequestSubMenu',
Extends: PopupMenu.PopupSubMenuMenuItem,
_init() {
_init: function() {
this.parent('');
this._requestOpen = false;
},
_setOpenState(open) {
_setOpenState: function(open) {
this.emit('request-open', open);
this._requestOpen = open;
},
_getOpenState() {
_getOpenState: function() {
return this._requestOpen;
},
});
@@ -79,35 +79,35 @@ var RequestSubMenu = new Lang.Class({
var RemoteMenuSubmenuItemMapper = new Lang.Class({
Name: 'RemoteMenuSubmenuItemMapper',
_init(trackerItem) {
_init: function(trackerItem) {
this._trackerItem = trackerItem;
this.menuItem = new RequestSubMenu();
this._trackerItem.connect('notify::label', this._updateLabel.bind(this));
this._trackerItem.connect('notify::label', Lang.bind(this, this._updateLabel));
this._updateLabel();
this._tracker = Shell.MenuTracker.new_for_item_submenu(this._trackerItem,
_insertItem.bind(null, this.menuItem.menu),
_removeItem.bind(null, this.menuItem.menu));
this.menuItem.connect('request-open', (menu, open) => {
this.menuItem.connect('request-open', Lang.bind(this, function(menu, open) {
this._trackerItem.request_submenu_shown(open);
});
}));
this._trackerItem.connect('notify::submenu-shown', () => {
this._trackerItem.connect('notify::submenu-shown', Lang.bind(this, function() {
this.menuItem.setSubmenuShown(this._trackerItem.get_submenu_shown());
});
}));
this.menuItem.connect('destroy', () => {
this.menuItem.connect('destroy', function() {
trackerItem.run_dispose();
});
},
destroy() {
destroy: function() {
this._tracker.destroy();
this.parent();
},
_updateLabel() {
_updateLabel: function() {
this.menuItem.label.text = stripMnemonics(this._trackerItem.label);
},
});
@@ -115,7 +115,7 @@ var RemoteMenuSubmenuItemMapper = new Lang.Class({
var RemoteMenuItemMapper = new Lang.Class({
Name: 'RemoteMenuItemMapper',
_init(trackerItem) {
_init: function(trackerItem) {
this._trackerItem = trackerItem;
this.menuItem = new PopupMenu.PopupBaseMenuItem();
@@ -123,35 +123,35 @@ var RemoteMenuItemMapper = new Lang.Class({
this.menuItem.actor.add_child(this._label);
this.menuItem.actor.label_actor = this._label;
this.menuItem.connect('activate', () => {
this.menuItem.connect('activate', Lang.bind(this, function() {
this._trackerItem.activated();
});
}));
this._trackerItem.bind_property('visible', this.menuItem.actor, 'visible', GObject.BindingFlags.SYNC_CREATE);
this._trackerItem.connect('notify::label', this._updateLabel.bind(this));
this._trackerItem.connect('notify::sensitive', this._updateSensitivity.bind(this));
this._trackerItem.connect('notify::role', this._updateRole.bind(this));
this._trackerItem.connect('notify::toggled', this._updateDecoration.bind(this));
this._trackerItem.connect('notify::label', Lang.bind(this, this._updateLabel));
this._trackerItem.connect('notify::sensitive', Lang.bind(this, this._updateSensitivity));
this._trackerItem.connect('notify::role', Lang.bind(this, this._updateRole));
this._trackerItem.connect('notify::toggled', Lang.bind(this, this._updateDecoration));
this._updateLabel();
this._updateSensitivity();
this._updateRole();
this.menuItem.connect('destroy', () => {
this.menuItem.connect('destroy', function() {
trackerItem.run_dispose();
});
},
_updateLabel() {
_updateLabel: function() {
this._label.text = stripMnemonics(this._trackerItem.label);
},
_updateSensitivity() {
_updateSensitivity: function() {
this.menuItem.setSensitive(this._trackerItem.sensitive);
},
_updateDecoration() {
_updateDecoration: function() {
let ornamentForRole = {};
ornamentForRole[ShellMenu.MenuTrackerItemRole.RADIO] = PopupMenu.Ornament.DOT;
ornamentForRole[ShellMenu.MenuTrackerItemRole.CHECK] = PopupMenu.Ornament.CHECK;
@@ -163,7 +163,7 @@ var RemoteMenuItemMapper = new Lang.Class({
this.menuItem.setOrnament(ornament);
},
_updateRole() {
_updateRole: function() {
let a11yRoles = {};
a11yRoles[ShellMenu.MenuTrackerItemRole.NORMAL] = Atk.Role.MENU_ITEM;
a11yRoles[ShellMenu.MenuTrackerItemRole.RADIO] = Atk.Role.RADIO_MENU_ITEM;
@@ -180,7 +180,7 @@ var RemoteMenu = new Lang.Class({
Name: 'RemoteMenu',
Extends: PopupMenu.PopupMenu,
_init(sourceActor, model, actionGroup) {
_init: function(sourceActor, model, actionGroup) {
this.parent(sourceActor, 0.0, St.Side.TOP);
this._model = model;
@@ -196,7 +196,7 @@ var RemoteMenu = new Lang.Class({
return this._actionGroup;
},
destroy() {
destroy: function() {
this._tracker.destroy();
this.parent();
},

View File

@@ -143,7 +143,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
// Special case gnome-control-center to be always active and always first
sortOrder.unshift('gnome-control-center.desktop');
loadedProviders = loadedProviders.filter(provider => {
loadedProviders = loadedProviders.filter(function(provider) {
let appId = provider.appInfo.get_id();
if (provider.defaultEnabled) {
@@ -155,7 +155,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
}
});
loadedProviders.sort((providerA, providerB) => {
loadedProviders.sort(function(providerA, providerB) {
let idxA, idxB;
let appIdA, appIdB;
@@ -191,7 +191,7 @@ function loadRemoteSearchProviders(searchSettings, callback) {
var RemoteSearchProvider = new Lang.Class({
Name: 'RemoteSearchProvider',
_init(appInfo, dbusName, dbusPath, autoStart, proxyInfo) {
_init: function(appInfo, dbusName, dbusPath, autoStart, proxyInfo) {
if (!proxyInfo)
proxyInfo = SearchProviderProxyInfo;
@@ -215,7 +215,7 @@ var RemoteSearchProvider = new Lang.Class({
this.canLaunchSearch = false;
},
createIcon(size, meta) {
createIcon: function(size, meta) {
let gicon = null;
let icon = null;
@@ -236,17 +236,17 @@ var RemoteSearchProvider = new Lang.Class({
return icon;
},
filterResults(results, maxNumber) {
filterResults: function(results, maxNumber) {
if (results.length <= maxNumber)
return results;
let regularResults = results.filter(r => !r.startsWith('special:'));
let specialResults = results.filter(r => r.startsWith('special:'));
let regularResults = results.filter(function(r) { return !r.startsWith('special:'); });
let specialResults = results.filter(function(r) { return r.startsWith('special:'); });
return regularResults.slice(0, maxNumber).concat(specialResults.slice(0, maxNumber));
},
_getResultsFinished(results, error, callback) {
_getResultsFinished: function(results, error, callback) {
if (error) {
if (error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
return;
@@ -259,23 +259,19 @@ var RemoteSearchProvider = new Lang.Class({
callback(results[0]);
},
getInitialResultSet(terms, callback, cancellable) {
getInitialResultSet: function(terms, callback, cancellable) {
this.proxy.GetInitialResultSetRemote(terms,
(results, error) => {
this._getResultsFinished(results, error, callback);
},
Lang.bind(this, this._getResultsFinished, callback),
cancellable);
},
getSubsearchResultSet(previousResults, newTerms, callback, cancellable) {
getSubsearchResultSet: function(previousResults, newTerms, callback, cancellable) {
this.proxy.GetSubsearchResultSetRemote(previousResults, newTerms,
(results, error) => {
this._getResultsFinished(results, error, callback);
},
Lang.bind(this, this._getResultsFinished, callback),
cancellable);
},
_getResultMetasFinished(results, error, callback) {
_getResultMetasFinished: function(results, error, callback) {
if (error) {
if (!error.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
log('Received error from DBus search provider %s during GetResultMetas: %s'.format(this.id, String(error)));
@@ -294,27 +290,24 @@ var RemoteSearchProvider = new Lang.Class({
resultMetas.push({ id: metas[i]['id'],
name: metas[i]['name'],
description: metas[i]['description'],
createIcon: size => {
this.createIcon(size, metas[i]);
},
createIcon: Lang.bind(this,
this.createIcon, metas[i]),
clipboardText: metas[i]['clipboardText'] });
}
callback(resultMetas);
},
getResultMetas(ids, callback, cancellable) {
getResultMetas: function(ids, callback, cancellable) {
this.proxy.GetResultMetasRemote(ids,
(results, error) => {
this._getResultMetasFinished(results, error, callback);
},
Lang.bind(this, this._getResultMetasFinished, callback),
cancellable);
},
activateResult(id) {
activateResult: function(id) {
this.proxy.ActivateResultRemote(id);
},
launchSearch(terms) {
launchSearch: function(terms) {
// the provider is not compatible with the new version of the interface, launch
// the app itself but warn so we can catch the error in logs
log('Search provider ' + this.appInfo.get_id() + ' does not implement LaunchSearch');
@@ -326,17 +319,17 @@ var RemoteSearchProvider2 = new Lang.Class({
Name: 'RemoteSearchProvider2',
Extends: RemoteSearchProvider,
_init(appInfo, dbusName, dbusPath, autoStart) {
_init: function(appInfo, dbusName, dbusPath, autoStart) {
this.parent(appInfo, dbusName, dbusPath, autoStart, SearchProvider2ProxyInfo);
this.canLaunchSearch = true;
},
activateResult(id, terms) {
activateResult: function(id, terms) {
this.proxy.ActivateResultRemote(id, terms, global.get_current_time());
},
launchSearch(terms) {
launchSearch: function(terms) {
this.proxy.LaunchSearchRemote(terms, global.get_current_time());
}
});

View File

@@ -34,35 +34,36 @@ var RunDialog = new Lang.Class({
Name: 'RunDialog',
Extends: ModalDialog.ModalDialog,
_init() {
_init : function() {
this.parent({ styleClass: 'run-dialog',
destroyOnClose: false });
this._lockdownSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA });
this._terminalSettings = new Gio.Settings({ schema_id: TERMINAL_SCHEMA });
global.settings.connect('changed::development-tools', () => {
global.settings.connect('changed::development-tools', Lang.bind(this, function () {
this._enableInternalCommands = global.settings.get_boolean('development-tools');
});
}));
this._enableInternalCommands = global.settings.get_boolean('development-tools');
this._internalCommands = { 'lg': () => {
this._internalCommands = { 'lg':
Lang.bind(this, function() {
Main.createLookingGlass().open();
},
}),
'r': this._restart.bind(this),
'r': Lang.bind(this, this._restart),
// Developer brain backwards compatibility
'restart': this._restart.bind(this),
'restart': Lang.bind(this, this._restart),
'debugexit': () => {
'debugexit': Lang.bind(this, function() {
Meta.quit(Meta.ExitCode.ERROR);
},
}),
// rt is short for "reload theme"
'rt': () => {
'rt': Lang.bind(this, function() {
Main.reloadThemeResource();
Main.loadTheme();
}
})
};
@@ -106,7 +107,7 @@ var RunDialog = new Lang.Class({
this._errorBox.hide();
this.setButtons([{ action: this.close.bind(this),
this.setButtons([{ action: Lang.bind(this, this.close),
label: _("Close"),
key: Clutter.Escape }]);
@@ -114,7 +115,7 @@ var RunDialog = new Lang.Class({
this._history = new History.HistoryManager({ gsettingsKey: HISTORY_KEY,
entry: this._entryText });
this._entryText.connect('key-press-event', (o, e) => {
this._entryText.connect('key-press-event', Lang.bind(this, function(o, e) {
let symbol = e.get_key_symbol();
if (symbol == Clutter.Return || symbol == Clutter.KP_Enter) {
this.popModal();
@@ -141,10 +142,10 @@ var RunDialog = new Lang.Class({
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
});
}));
},
_getCommandCompletion(text) {
_getCommandCompletion: function(text) {
function _getCommon(s1, s2) {
if (s1 == null)
return s2;
@@ -161,7 +162,7 @@ var RunDialog = new Lang.Class({
let paths = GLib.getenv('PATH').split(':');
paths.push(GLib.get_home_dir());
let someResults = paths.map(path => {
let someResults = paths.map(function(path) {
let results = [];
try {
let file = Gio.File.new_for_path(path);
@@ -179,7 +180,9 @@ var RunDialog = new Lang.Class({
return results;
}
});
let results = someResults.reduce((a, b) => a.concat(b), []);
let results = someResults.reduce(function(a, b) {
return a.concat(b);
}, []);
if (!results.length)
return null;
@@ -188,7 +191,7 @@ var RunDialog = new Lang.Class({
return common.substr(text.length);
},
_getCompletion(text) {
_getCompletion : function(text) {
if (text.indexOf('/') != -1) {
return this._pathCompleter.get_completion_suffix(text);
} else {
@@ -196,7 +199,7 @@ var RunDialog = new Lang.Class({
}
},
_run(input, inTerminal) {
_run : function(input, inTerminal) {
let command = input;
this._history.addItem(input);
@@ -247,7 +250,7 @@ var RunDialog = new Lang.Class({
}
},
_showError(message) {
_showError : function(message) {
this._commandError = true;
this._errorMessage.set_text(message);
@@ -260,15 +263,16 @@ var RunDialog = new Lang.Class({
{ height: parentActor.height + errorBoxNaturalHeight,
time: DIALOG_GROW_TIME,
transition: 'easeOutQuad',
onComplete: () => {
parentActor.set_height(-1);
this._errorBox.show();
}
onComplete: Lang.bind(this,
function() {
parentActor.set_height(-1);
this._errorBox.show();
})
});
}
},
_restart() {
_restart: function() {
if (Meta.is_wayland_compositor()) {
this._showError(_("Restart is not available on Wayland"));
return;
@@ -278,7 +282,7 @@ var RunDialog = new Lang.Class({
Meta.restart(_("Restarting…"));
},
open() {
open: function() {
this._history.lastItem();
this._errorBox.hide();
this._entryText.set_text('');

View File

@@ -63,7 +63,7 @@ var CURTAIN_SLIDE_TIME = 0.3;
var Clock = new Lang.Class({
Name: 'ScreenShieldClock',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ style_class: 'screen-shield-clock',
vertical: true });
@@ -74,12 +74,12 @@ var Clock = new Lang.Class({
this.actor.add(this._date, { x_align: St.Align.MIDDLE });
this._wallClock = new GnomeDesktop.WallClock({ time_only: true });
this._wallClock.connect('notify::clock', this._updateClock.bind(this));
this._wallClock.connect('notify::clock', Lang.bind(this, this._updateClock));
this._updateClock();
},
_updateClock() {
_updateClock: function() {
this._time.text = this._wallClock.clock;
let date = new Date();
@@ -89,7 +89,7 @@ var Clock = new Lang.Class({
this._date.text = date.toLocaleFormat(dateFormat);
},
destroy() {
destroy: function() {
this.actor.destroy();
this._wallClock.run_dispose();
}
@@ -98,7 +98,7 @@ var Clock = new Lang.Class({
var NotificationsBox = new Lang.Class({
Name: 'NotificationsBox',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ vertical: true,
name: 'screenShieldNotifications',
style_class: 'screen-shield-notifications-container' });
@@ -112,15 +112,15 @@ var NotificationsBox = new Lang.Class({
this.actor.add(this._scrollView, { x_fill: true, x_align: St.Align.START });
this._sources = new Map();
Main.messageTray.getSources().forEach(source => {
Main.messageTray.getSources().forEach(Lang.bind(this, function(source) {
this._sourceAdded(Main.messageTray, source, true);
});
}));
this._updateVisibility();
this._sourceAddedId = Main.messageTray.connect('source-added', this._sourceAdded.bind(this));
this._sourceAddedId = Main.messageTray.connect('source-added', Lang.bind(this, this._sourceAdded));
},
destroy() {
destroy: function() {
if (this._sourceAddedId) {
Main.messageTray.disconnect(this._sourceAddedId);
this._sourceAddedId = 0;
@@ -134,21 +134,22 @@ var NotificationsBox = new Lang.Class({
this.actor.destroy();
},
_updateVisibility() {
this._notificationBox.visible =
this._notificationBox.get_children().some(a => a.visible);
_updateVisibility: function() {
this._notificationBox.visible = this._notificationBox.get_children().some(function(a) {
return a.visible;
});
this.actor.visible = this._notificationBox.visible;
},
_makeNotificationCountText(count, isChat) {
_makeNotificationCountText: function(count, isChat) {
if (isChat)
return ngettext("%d new message", "%d new messages", count).format(count);
else
return ngettext("%d new notification", "%d new notifications", count).format(count);
},
_makeNotificationSource(source, box) {
_makeNotificationSource: function(source, box) {
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
box.add(sourceActor.actor, { y_fill: true });
@@ -168,7 +169,7 @@ var NotificationsBox = new Lang.Class({
return [title, countLabel];
},
_makeNotificationDetailedSource(source, box) {
_makeNotificationDetailedSource: function(source, box) {
let sourceActor = new MessageTray.SourceActor(source, SUMMARY_ICON_SIZE);
let sourceBin = new St.Bin({ y_align: St.Align.START,
x_align: St.Align.START,
@@ -206,7 +207,7 @@ var NotificationsBox = new Lang.Class({
return [title, null];
},
_showSource(source, obj, box) {
_showSource: function(source, obj, box) {
if (obj.detailed) {
[obj.titleLabel, obj.countLabel] = this._makeNotificationDetailedSource(source, box);
} else {
@@ -216,7 +217,7 @@ var NotificationsBox = new Lang.Class({
box.visible = obj.visible && (source.unseenCount > 0);
},
_sourceAdded(tray, source, initial) {
_sourceAdded: function(tray, source, initial) {
let obj = {
visible: source.policy.showInLockScreen,
detailed: source.policy.detailsInLockScreen,
@@ -234,21 +235,21 @@ var NotificationsBox = new Lang.Class({
this._showSource(source, obj, obj.sourceBox);
this._notificationBox.add(obj.sourceBox, { x_fill: false, x_align: St.Align.START });
obj.sourceCountChangedId = source.connect('count-updated', source => {
obj.sourceCountChangedId = source.connect('count-updated', Lang.bind(this, function(source) {
this._countChanged(source, obj);
});
obj.sourceTitleChangedId = source.connect('title-changed', source => {
}));
obj.sourceTitleChangedId = source.connect('title-changed', Lang.bind(this, function(source) {
this._titleChanged(source, obj);
});
obj.policyChangedId = source.policy.connect('policy-changed', (policy, key) => {
}));
obj.policyChangedId = source.policy.connect('policy-changed', Lang.bind(this, function(policy, key) {
if (key == 'show-in-lock-screen')
this._visibleChanged(source, obj);
else
this._detailedChanged(source, obj);
});
obj.sourceDestroyId = source.connect('destroy', source => {
}));
obj.sourceDestroyId = source.connect('destroy', Lang.bind(this, function(source) {
this._onSourceDestroy(source, obj);
});
}));
this._sources.set(source, obj);
@@ -265,7 +266,7 @@ var NotificationsBox = new Lang.Class({
{ height: natHeight,
transition: 'easeOutQuad',
time: 0.25,
onComplete() {
onComplete: function() {
this._scrollView.vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
widget.set_height(-1);
},
@@ -278,11 +279,11 @@ var NotificationsBox = new Lang.Class({
}
},
_titleChanged(source, obj) {
_titleChanged: function(source, obj) {
obj.titleLabel.text = source.title;
},
_countChanged(source, obj) {
_countChanged: function(source, obj) {
if (obj.detailed) {
// A new notification was pushed, or a previous notification was destroyed.
// Give up, and build the list again.
@@ -302,7 +303,7 @@ var NotificationsBox = new Lang.Class({
this.emit('wake-up-screen');
},
_visibleChanged(source, obj) {
_visibleChanged: function(source, obj) {
if (obj.visible == source.policy.showInLockScreen)
return;
@@ -314,7 +315,7 @@ var NotificationsBox = new Lang.Class({
this.emit('wake-up-screen');
},
_detailedChanged(source, obj) {
_detailedChanged: function(source, obj) {
if (obj.detailed == source.policy.detailsInLockScreen)
return;
@@ -325,12 +326,12 @@ var NotificationsBox = new Lang.Class({
this._showSource(source, obj, obj.sourceBox);
},
_onSourceDestroy(source, obj) {
_onSourceDestroy: function(source, obj) {
this._removeSource(source, obj);
this._updateVisibility();
},
_removeSource(source, obj) {
_removeSource: function(source, obj) {
obj.sourceBox.destroy();
obj.sourceBox = obj.titleLabel = obj.countLabel = null;
@@ -348,19 +349,19 @@ var Arrow = new Lang.Class({
Name: 'Arrow',
Extends: St.Bin,
_init(params) {
_init: function(params) {
this.parent(params);
this.x_fill = this.y_fill = true;
this._drawingArea = new St.DrawingArea();
this._drawingArea.connect('repaint', this._drawArrow.bind(this));
this._drawingArea.connect('repaint', Lang.bind(this, this._drawArrow));
this.child = this._drawingArea;
this._shadowHelper = null;
this._shadowWidth = this._shadowHeight = 0;
},
_drawArrow(arrow) {
_drawArrow: function(arrow) {
let cr = arrow.get_context();
let [w, h] = arrow.get_surface_size();
let node = this.get_theme_node();
@@ -378,7 +379,7 @@ var Arrow = new Lang.Class({
cr.$dispose();
},
vfunc_get_paint_volume(volume) {
vfunc_get_paint_volume: function(volume) {
if (!this.parent(volume))
return false;
@@ -394,7 +395,7 @@ var Arrow = new Lang.Class({
return true;
},
vfunc_style_changed() {
vfunc_style_changed: function() {
let node = this.get_theme_node();
this._shadow = node.get_shadow('-arrow-shadow');
if (this._shadow)
@@ -405,7 +406,7 @@ var Arrow = new Lang.Class({
this.parent();
},
vfunc_paint() {
vfunc_paint: function() {
if (this._shadowHelper) {
this._shadowHelper.update(this._drawingArea);
@@ -433,7 +434,7 @@ function clamp(value, min, max) {
var ScreenShield = new Lang.Class({
Name: 'ScreenShield',
_init() {
_init: function() {
this.actor = Main.layoutManager.screenShieldGroup;
this._lockScreenState = MessageTray.State.HIDDEN;
@@ -445,9 +446,9 @@ var ScreenShield = new Lang.Class({
visible: false,
});
this._lockScreenGroup.connect('key-press-event',
this._onLockScreenKeyPress.bind(this));
Lang.bind(this, this._onLockScreenKeyPress));
this._lockScreenGroup.connect('scroll-event',
this._onLockScreenScroll.bind(this));
Lang.bind(this, this._onLockScreenScroll));
Main.ctrlAltTabManager.addGroup(this._lockScreenGroup, _("Lock"), 'changes-prevent-symbolic');
this._lockScreenContents = new St.Widget({ layout_manager: new Clutter.BinLayout(),
@@ -463,7 +464,7 @@ var ScreenShield = new Lang.Class({
this._bgManagers = [];
this._updateBackgrounds();
Main.layoutManager.connect('monitors-changed', this._updateBackgrounds.bind(this));
Main.layoutManager.connect('monitors-changed', Lang.bind(this, this._updateBackgrounds));
this._arrowAnimationId = 0;
this._arrowWatchId = 0;
@@ -484,9 +485,9 @@ var ScreenShield = new Lang.Class({
this._lockScreenContents.add_actor(this._arrowContainer);
this._dragAction = new Clutter.GestureAction();
this._dragAction.connect('gesture-begin', this._onDragBegin.bind(this));
this._dragAction.connect('gesture-progress', this._onDragMotion.bind(this));
this._dragAction.connect('gesture-end', this._onDragEnd.bind(this));
this._dragAction.connect('gesture-begin', Lang.bind(this, this._onDragBegin));
this._dragAction.connect('gesture-progress', Lang.bind(this, this._onDragMotion));
this._dragAction.connect('gesture-end', Lang.bind(this, this._onDragEnd));
this._lockScreenGroup.add_action(this._dragAction);
this._lockDialogGroup = new St.Widget({ x_expand: true,
@@ -498,54 +499,53 @@ var ScreenShield = new Lang.Class({
this.actor.add_actor(this._lockDialogGroup);
this.actor.add_actor(this._lockScreenGroup);
this._presence = new GnomeSession.Presence((proxy, error) => {
this._presence = new GnomeSession.Presence(Lang.bind(this, function(proxy, error) {
if (error) {
logError(error, 'Error while reading gnome-session presence');
return;
}
this._onStatusChanged(proxy.status);
});
this._presence.connectSignal('StatusChanged', (proxy, senderName, [status]) => {
}));
this._presence.connectSignal('StatusChanged', Lang.bind(this, function(proxy, senderName, [status]) {
this._onStatusChanged(status);
});
}));
this._screenSaverDBus = new ShellDBus.ScreenSaverDBus(this);
this._smartcardManager = SmartcardManager.getSmartcardManager();
this._smartcardManager.connect('smartcard-inserted',
(manager, token) => {
Lang.bind(this, function(manager, token) {
if (this._isLocked && token.UsedToLogin)
this._liftShield(true, 0);
});
}));
this._oVirtCredentialsManager = OVirt.getOVirtCredentialsManager();
this._oVirtCredentialsManager.connect('user-authenticated',
() => {
Lang.bind(this, function() {
if (this._isLocked)
this._liftShield(true, 0);
});
}));
this._loginManager = LoginManager.getLoginManager();
this._loginManager.connect('prepare-for-sleep',
this._prepareForSleep.bind(this));
Lang.bind(this, this._prepareForSleep));
this._loginSession = null;
this._loginManager.getCurrentSessionProxy(sessionProxy => {
this._loginSession = sessionProxy;
this._loginSession.connectSignal('Lock',
() => { this.lock(false); });
this._loginSession.connectSignal('Unlock',
() => { this.deactivate(false); });
this._loginSession.connect('g-properties-changed', this._syncInhibitor.bind(this));
this._syncInhibitor();
});
this._loginManager.getCurrentSessionProxy(Lang.bind(this,
function(sessionProxy) {
this._loginSession = sessionProxy;
this._loginSession.connectSignal('Lock', Lang.bind(this, function() { this.lock(false); }));
this._loginSession.connectSignal('Unlock', Lang.bind(this, function() { this.deactivate(false); }));
this._loginSession.connect('g-properties-changed', Lang.bind(this, this._syncInhibitor));
this._syncInhibitor();
}));
this._settings = new Gio.Settings({ schema_id: SCREENSAVER_SCHEMA });
this._settings.connect('changed::' + LOCK_ENABLED_KEY, this._syncInhibitor.bind(this));
this._settings.connect('changed::' + LOCK_ENABLED_KEY, Lang.bind(this, this._syncInhibitor));
this._lockSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA });
this._lockSettings.connect('changed::' + DISABLE_LOCK_KEY, this._syncInhibitor.bind(this));
this._lockSettings.connect('changed::' + DISABLE_LOCK_KEY, Lang.bind(this, this._syncInhibitor));
this._isModal = false;
this._hasLockScreen = false;
@@ -563,11 +563,11 @@ var ScreenShield = new Lang.Class({
this._longLightbox = new Lightbox.Lightbox(Main.uiGroup,
{ inhibitEvents: true,
fadeFactor: 1 });
this._longLightbox.connect('shown', this._onLongLightboxShown.bind(this));
this._longLightbox.connect('shown', Lang.bind(this, this._onLongLightboxShown));
this._shortLightbox = new Lightbox.Lightbox(Main.uiGroup,
{ inhibitEvents: true,
fadeFactor: 1 });
this._shortLightbox.connect('shown', this._onShortLightboxShown.bind(this));
this._shortLightbox.connect('shown', Lang.bind(this, this._onShortLightboxShown));
this.idleMonitor = Meta.IdleMonitor.get_core();
this._cursorTracker = Meta.CursorTracker.get_for_screen(global.screen);
@@ -575,7 +575,7 @@ var ScreenShield = new Lang.Class({
this._syncInhibitor();
},
_setActive(active) {
_setActive: function(active) {
let prevIsActive = this._isActive;
this._isActive = active;
@@ -588,7 +588,7 @@ var ScreenShield = new Lang.Class({
this._syncInhibitor();
},
_createBackground(monitorIndex) {
_createBackground: function(monitorIndex) {
let monitor = Main.layoutManager.monitors[monitorIndex];
let widget = new St.Widget({ style_class: 'screen-shield-background',
x: monitor.x,
@@ -606,7 +606,7 @@ var ScreenShield = new Lang.Class({
this._backgroundGroup.add_child(widget);
},
_updateBackgrounds() {
_updateBackgrounds: function() {
for (let i = 0; i < this._bgManagers.length; i++)
this._bgManagers[i].destroy();
@@ -617,7 +617,7 @@ var ScreenShield = new Lang.Class({
this._createBackground(i);
},
_liftShield(onPrimary, velocity) {
_liftShield: function(onPrimary, velocity) {
if (this._isLocked) {
if (this._ensureUnlockDialog(onPrimary, true /* allowCancel */))
this._hideLockScreen(true /* animate */, velocity);
@@ -626,7 +626,7 @@ var ScreenShield = new Lang.Class({
}
},
_maybeCancelDialog() {
_maybeCancelDialog: function() {
if (!this._dialog)
return;
@@ -641,7 +641,7 @@ var ScreenShield = new Lang.Class({
}
},
_becomeModal() {
_becomeModal: function() {
if (this._isModal)
return true;
@@ -656,7 +656,7 @@ var ScreenShield = new Lang.Class({
return this._isModal;
},
_onLockScreenKeyPress(actor, event) {
_onLockScreenKeyPress: function(actor, event) {
let symbol = event.get_key_symbol();
let unichar = event.get_key_unicode();
@@ -686,7 +686,7 @@ var ScreenShield = new Lang.Class({
return Clutter.EVENT_STOP;
},
_onLockScreenScroll(actor, event) {
_onLockScreenScroll: function(actor, event) {
if (this._lockScreenState != MessageTray.State.SHOWN)
return Clutter.EVENT_PROPAGATE;
@@ -706,18 +706,18 @@ var ScreenShield = new Lang.Class({
return Clutter.EVENT_STOP;
},
_syncInhibitor() {
_syncInhibitor: function() {
let lockEnabled = this._settings.get_boolean(LOCK_ENABLED_KEY);
let lockLocked = this._lockSettings.get_boolean(DISABLE_LOCK_KEY);
let inhibit = (this._loginSession && this._loginSession.Active &&
!this._isActive && lockEnabled && !lockLocked);
if (inhibit) {
this._loginManager.inhibit(_("GNOME needs to lock the screen"),
inhibitor => {
if (this._inhibitor)
this._inhibitor.close(null);
this._inhibitor = inhibitor;
});
Lang.bind(this, function(inhibitor) {
if (this._inhibitor)
this._inhibitor.close(null);
this._inhibitor = inhibitor;
}));
} else {
if (this._inhibitor)
this._inhibitor.close(null);
@@ -725,7 +725,7 @@ var ScreenShield = new Lang.Class({
}
},
_prepareForSleep(loginManager, aboutToSuspend) {
_prepareForSleep: function(loginManager, aboutToSuspend) {
if (aboutToSuspend) {
if (this._settings.get_boolean(LOCK_ENABLED_KEY))
this.lock(true);
@@ -734,7 +734,7 @@ var ScreenShield = new Lang.Class({
}
},
_animateArrows() {
_animateArrows: function() {
let arrows = this._arrowContainer.get_children();
let unitaryDelay = ARROW_ANIMATION_TIME / (arrows.length + 1);
let maxOpacity = 255 * ARROW_ANIMATION_PEAK_OPACITY;
@@ -744,7 +744,7 @@ var ScreenShield = new Lang.Class({
{ opacity: 0,
delay: unitaryDelay * (N_ARROWS - (i + 1)),
time: ARROW_ANIMATION_TIME,
transition(t, b, c, d) {
transition: function(t, b, c, d) {
if (t < d/2)
return TweenerEquations.easeOutQuad(t, 0, maxOpacity, d/2);
else
@@ -756,7 +756,7 @@ var ScreenShield = new Lang.Class({
return GLib.SOURCE_CONTINUE;
},
_onDragBegin() {
_onDragBegin: function() {
Tweener.removeTweens(this._lockScreenGroup);
this._lockScreenState = MessageTray.State.HIDING;
@@ -766,7 +766,7 @@ var ScreenShield = new Lang.Class({
return true;
},
_onDragMotion() {
_onDragMotion: function() {
let [origX, origY] = this._dragAction.get_press_coords(0);
let [currentX, currentY] = this._dragAction.get_motion_coords(0);
@@ -778,7 +778,7 @@ var ScreenShield = new Lang.Class({
return true;
},
_onDragEnd(action, actor, eventX, eventY, modifiers) {
_onDragEnd: function(action, actor, eventX, eventY, modifiers) {
if (this._lockScreenState != MessageTray.State.HIDING)
return;
if (this._lockScreenGroup.y < -(ARROW_DRAG_THRESHOLD * global.stage.height)) {
@@ -795,7 +795,7 @@ var ScreenShield = new Lang.Class({
{ y: 0,
time: time,
transition: 'easeInQuad',
onComplete() {
onComplete: function() {
this._lockScreenGroup.fixed_position_set = false;
this._lockScreenState = MessageTray.State.SHOWN;
},
@@ -806,7 +806,7 @@ var ScreenShield = new Lang.Class({
}
},
_onStatusChanged(status) {
_onStatusChanged: function(status) {
if (status != GnomeSession.PresenceStatus.IDLE)
return;
@@ -846,26 +846,26 @@ var ScreenShield = new Lang.Class({
if (shouldLock) {
let lockTimeout = Math.max(STANDARD_FADE_TIME, this._settings.get_uint(LOCK_DELAY_KEY));
this._lockTimeoutId = Mainloop.timeout_add(lockTimeout * 1000,
() => {
Lang.bind(this, function() {
this._lockTimeoutId = 0;
this.lock(false);
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(this._lockTimeoutId, '[gnome-shell] this.lock');
}
this._activateFade(this._longLightbox, STANDARD_FADE_TIME);
},
_activateFade(lightbox, time) {
_activateFade: function(lightbox, time) {
Main.uiGroup.set_child_above_sibling(lightbox.actor, null);
lightbox.show(time);
if (this._becameActiveId == 0)
this._becameActiveId = this.idleMonitor.add_user_active_watch(this._onUserBecameActive.bind(this));
this._becameActiveId = this.idleMonitor.add_user_active_watch(Lang.bind(this, this._onUserBecameActive));
},
_onUserBecameActive() {
_onUserBecameActive: function() {
// This function gets called here when the user becomes active
// after we activated a lightbox
// There are two possibilities here:
@@ -895,15 +895,15 @@ var ScreenShield = new Lang.Class({
}
},
_onLongLightboxShown() {
_onLongLightboxShown: function() {
this.activate(false);
},
_onShortLightboxShown() {
_onShortLightboxShown: function() {
this._completeLockScreenShown();
},
showDialog() {
showDialog: function() {
if (!this._becomeModal()) {
// In the login screen, this is a hard error. Fail-whale
log('Could not acquire modal grab for the login screen. Aborting login process.');
@@ -917,7 +917,7 @@ var ScreenShield = new Lang.Class({
this._hideLockScreen(false, 0);
},
_hideLockScreenComplete() {
_hideLockScreenComplete: function() {
if (Main.sessionMode.currentMode == 'lock-screen')
Main.sessionMode.popMode('lock-screen');
@@ -930,7 +930,7 @@ var ScreenShield = new Lang.Class({
}
},
_hideLockScreen(animate, velocity) {
_hideLockScreen: function(animate, velocity) {
if (this._lockScreenState == MessageTray.State.HIDDEN)
return;
@@ -954,7 +954,7 @@ var ScreenShield = new Lang.Class({
{ y: -h,
time: time,
transition: 'easeInQuad',
onComplete: this._hideLockScreenComplete.bind(this),
onComplete: Lang.bind(this, this._hideLockScreenComplete),
});
} else {
this._hideLockScreenComplete();
@@ -963,7 +963,7 @@ var ScreenShield = new Lang.Class({
this._cursorTracker.set_pointer_visible(true);
},
_ensureUnlockDialog(onPrimary, allowCancel) {
_ensureUnlockDialog: function(onPrimary, allowCancel) {
if (!this._dialog) {
let constructor = Main.sessionMode.unlockDialog;
if (!constructor) {
@@ -984,19 +984,19 @@ var ScreenShield = new Lang.Class({
return false;
}
this._dialog.connect('failed', this._onUnlockFailed.bind(this));
this._dialog.connect('failed', Lang.bind(this, this._onUnlockFailed));
}
this._dialog.allowCancel = allowCancel;
return true;
},
_onUnlockFailed() {
_onUnlockFailed: function() {
this._resetLockScreen({ animateLockScreen: true,
fadeToBlack: false });
},
_resetLockScreen(params) {
_resetLockScreen: function(params) {
// Don't reset the lock screen unless it is completely hidden
// This prevents the shield going down if the lock-delay timeout
// fires while the user is dragging (which has the potential
@@ -1020,7 +1020,7 @@ var ScreenShield = new Lang.Class({
{ y: 0,
time: MANUAL_FADE_TIME,
transition: 'easeOutQuad',
onComplete() {
onComplete: function() {
this._lockScreenShown({ fadeToBlack: fadeToBlack,
animateFade: true });
},
@@ -1038,31 +1038,31 @@ var ScreenShield = new Lang.Class({
Main.sessionMode.pushMode('lock-screen');
},
_startArrowAnimation() {
_startArrowAnimation: function() {
this._arrowActiveWatchId = 0;
if (!this._arrowAnimationId) {
this._arrowAnimationId = Mainloop.timeout_add(6000, this._animateArrows.bind(this));
this._arrowAnimationId = Mainloop.timeout_add(6000, Lang.bind(this, this._animateArrows));
GLib.Source.set_name_by_id(this._arrowAnimationId, '[gnome-shell] this._animateArrows');
this._animateArrows();
}
if (!this._arrowWatchId)
this._arrowWatchId = this.idleMonitor.add_idle_watch(ARROW_IDLE_TIME,
this._pauseArrowAnimation.bind(this));
Lang.bind(this, this._pauseArrowAnimation));
},
_pauseArrowAnimation() {
_pauseArrowAnimation: function() {
if (this._arrowAnimationId) {
Mainloop.source_remove(this._arrowAnimationId);
this._arrowAnimationId = 0;
}
if (!this._arrowActiveWatchId)
this._arrowActiveWatchId = this.idleMonitor.add_user_active_watch(this._startArrowAnimation.bind(this));
this._arrowActiveWatchId = this.idleMonitor.add_user_active_watch(Lang.bind(this, this._startArrowAnimation));
},
_stopArrowAnimation() {
_stopArrowAnimation: function() {
if (this._arrowAnimationId) {
Mainloop.source_remove(this._arrowAnimationId);
this._arrowAnimationId = 0;
@@ -1077,7 +1077,7 @@ var ScreenShield = new Lang.Class({
}
},
_checkArrowAnimation() {
_checkArrowAnimation: function() {
let idleTime = this.idleMonitor.get_idletime();
if (idleTime < ARROW_IDLE_TIME)
@@ -1086,7 +1086,7 @@ var ScreenShield = new Lang.Class({
this._pauseArrowAnimation();
},
_lockScreenShown(params) {
_lockScreenShown: function(params) {
if (this._dialog && !this._isGreeter) {
this._dialog.destroy();
this._dialog = null;
@@ -1094,14 +1094,14 @@ var ScreenShield = new Lang.Class({
this._checkArrowAnimation();
let motionId = global.stage.connect('captured-event', (stage, event) => {
let motionId = global.stage.connect('captured-event', Lang.bind(this, function(stage, event) {
if (event.type() == Clutter.EventType.MOTION) {
this._cursorTracker.set_pointer_visible(true);
global.stage.disconnect(motionId);
}
return Clutter.EVENT_PROPAGATE;
});
}));
this._cursorTracker.set_pointer_visible(false);
this._lockScreenState = MessageTray.State.SHOWN;
@@ -1111,10 +1111,10 @@ var ScreenShield = new Lang.Class({
if (params.fadeToBlack && params.animateFade) {
// Take a beat
let id = Mainloop.timeout_add(1000 * MANUAL_FADE_TIME, () => {
let id = Mainloop.timeout_add(1000 * MANUAL_FADE_TIME, Lang.bind(this, function() {
this._activateFade(this._shortLightbox, MANUAL_FADE_TIME);
return GLib.SOURCE_REMOVE;
});
}));
GLib.Source.set_name_by_id(id, '[gnome-shell] this._activateFade');
} else {
if (params.fadeToBlack)
@@ -1124,14 +1124,14 @@ var ScreenShield = new Lang.Class({
}
},
_completeLockScreenShown() {
_completeLockScreenShown: function() {
this._setActive(true);
this.emit('lock-screen-shown');
},
// Some of the actors in the lock screen are heavy in
// resources, so we only create them when needed
_ensureLockScreen() {
_ensureLockScreen: function() {
if (this._hasLockScreen)
return;
@@ -1148,7 +1148,7 @@ var ScreenShield = new Lang.Class({
this._lockScreenContents.add_actor(this._lockScreenContentsBox);
this._notificationsBox = new NotificationsBox();
this._wakeUpScreenId = this._notificationsBox.connect('wake-up-screen', this._wakeUpScreen.bind(this));
this._wakeUpScreenId = this._notificationsBox.connect('wake-up-screen', Lang.bind(this, this._wakeUpScreen));
this._lockScreenContentsBox.add(this._notificationsBox.actor, { x_fill: true,
y_fill: true,
expand: true });
@@ -1156,12 +1156,12 @@ var ScreenShield = new Lang.Class({
this._hasLockScreen = true;
},
_wakeUpScreen() {
_wakeUpScreen: function() {
this._onUserBecameActive();
this.emit('wake-up-screen');
},
_clearLockScreen() {
_clearLockScreen: function() {
this._clock.destroy();
this._clock = null;
@@ -1190,14 +1190,16 @@ var ScreenShield = new Lang.Class({
return this._activationTime;
},
deactivate(animate) {
deactivate: function(animate) {
if (this._dialog)
this._dialog.finish(() => { this._continueDeactivate(animate); });
this._dialog.finish(Lang.bind(this, function() {
this._continueDeactivate(animate);
}));
else
this._continueDeactivate(animate);
},
_continueDeactivate(animate) {
_continueDeactivate: function(animate) {
this._hideLockScreen(animate, 0);
if (this._hasLockScreen)
@@ -1234,12 +1236,12 @@ var ScreenShield = new Lang.Class({
scale_y: 0,
time: animate ? Overview.ANIMATION_TIME : 0,
transition: 'easeOutQuad',
onComplete: this._completeDeactivate.bind(this),
onComplete: Lang.bind(this, this._completeDeactivate),
onCompleteScope: this
});
},
_completeDeactivate() {
_completeDeactivate: function() {
if (this._dialog) {
this._dialog.destroy();
this._dialog = null;
@@ -1266,7 +1268,7 @@ var ScreenShield = new Lang.Class({
global.set_runtime_state(LOCKED_STATE_STR, null);
},
activate(animate) {
activate: function(animate) {
if (this._activationTime == 0)
this._activationTime = GLib.get_monotonic_time();
@@ -1298,7 +1300,7 @@ var ScreenShield = new Lang.Class({
// activate without animation in that case.
},
lock(animate) {
lock: function(animate) {
if (this._lockSettings.get_boolean(DISABLE_LOCK_KEY)) {
log('Screen lock is locked down, not locking') // lock, lock - who's there?
return;
@@ -1331,15 +1333,15 @@ var ScreenShield = new Lang.Class({
},
// If the previous shell crashed, and gnome-session restarted us, then re-lock
lockIfWasLocked() {
lockIfWasLocked: function() {
if (!this._settings.get_boolean(LOCK_ENABLED_KEY))
return;
let wasLocked = global.get_runtime_state('b', LOCKED_STATE_STR);
if (wasLocked === null)
return;
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
this.lock(false);
});
}));
}
});
Signals.addSignalMethods(ScreenShield.prototype);

View File

@@ -35,7 +35,7 @@ const ScreencastIface = '<node> \
var ScreencastService = new Lang.Class({
Name: 'ScreencastService',
_init() {
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreencastIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/Screencast');
@@ -45,28 +45,28 @@ var ScreencastService = new Lang.Class({
this._lockdownSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.lockdown' });
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
},
get isRecording() {
return this._recorders.size > 0;
},
_ensureRecorderForSender(sender) {
_ensureRecorderForSender: function(sender) {
let recorder = this._recorders.get(sender);
if (!recorder) {
recorder = new Shell.Recorder({ stage: global.stage,
screen: global.screen });
recorder._watchNameId =
Gio.bus_watch_name(Gio.BusType.SESSION, sender, 0, null,
this._onNameVanished.bind(this));
Lang.bind(this, this._onNameVanished));
this._recorders.set(sender, recorder);
this.emit('updated');
}
return recorder;
},
_sessionUpdated() {
_sessionUpdated: function() {
if (Main.sessionMode.allowScreencast)
return;
@@ -74,11 +74,11 @@ var ScreencastService = new Lang.Class({
this._stopRecordingForSender(sender);
},
_onNameVanished(connection, name) {
_onNameVanished: function(connection, name) {
this._stopRecordingForSender(name);
},
_stopRecordingForSender(sender) {
_stopRecordingForSender: function(sender) {
let recorder = this._recorders.get(sender);
if (!recorder)
return false;
@@ -91,7 +91,7 @@ var ScreencastService = new Lang.Class({
return true;
},
_applyOptionalParameters(recorder, options) {
_applyOptionalParameters: function(recorder, options) {
for (let option in options)
options[option] = options[option].deep_unpack();
@@ -103,7 +103,7 @@ var ScreencastService = new Lang.Class({
recorder.set_draw_cursor(options['draw-cursor']);
},
ScreencastAsync(params, invocation) {
ScreencastAsync: function(params, invocation) {
let returnValue = [false, ''];
if (!Main.sessionMode.allowScreencast ||
this._lockdownSettings.get_boolean('disable-save-to-disk')) {
@@ -127,7 +127,7 @@ var ScreencastService = new Lang.Class({
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
},
ScreencastAreaAsync(params, invocation) {
ScreencastAreaAsync: function(params, invocation) {
let returnValue = [false, ''];
if (!Main.sessionMode.allowScreencast ||
this._lockdownSettings.get_boolean('disable-save-to-disk')) {
@@ -163,7 +163,7 @@ var ScreencastService = new Lang.Class({
invocation.return_value(GLib.Variant.new('(bs)', returnValue));
},
StopScreencastAsync(params, invocation) {
StopScreencastAsync: function(params, invocation) {
let success = this._stopRecordingForSender(invocation.get_sender());
invocation.return_value(GLib.Variant.new('(b)', [success]));
}

View File

@@ -61,7 +61,7 @@ const ScreenshotIface = '<node> \
var ScreenshotService = new Lang.Class({
Name: 'ScreenshotService',
_init() {
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenshotIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell/Screenshot');
@@ -72,7 +72,7 @@ var ScreenshotService = new Lang.Class({
Gio.DBus.session.own_name('org.gnome.Shell.Screenshot', Gio.BusNameOwnerFlags.REPLACE, null, null);
},
_createScreenshot(invocation) {
_createScreenshot: function(invocation) {
let sender = invocation.get_sender();
if (this._screenShooter.has(sender) ||
this._lockdownSettings.get_boolean('disable-save-to-disk')) {
@@ -83,18 +83,18 @@ var ScreenshotService = new Lang.Class({
let shooter = new Shell.Screenshot();
shooter._watchNameId =
Gio.bus_watch_name(Gio.BusType.SESSION, sender, 0, null,
this._onNameVanished.bind(this));
Lang.bind(this, this._onNameVanished));
this._screenShooter.set(sender, shooter);
return shooter;
},
_onNameVanished(connection, name) {
_onNameVanished: function(connection, name) {
this._removeShooterForSender(name);
},
_removeShooterForSender(sender) {
_removeShooterForSender: function(sender) {
let shooter = this._screenShooter.get(sender);
if (!shooter)
return;
@@ -103,20 +103,20 @@ var ScreenshotService = new Lang.Class({
this._screenShooter.delete(sender);
},
_checkArea(x, y, width, height) {
_checkArea: function(x, y, width, height) {
return x >= 0 && y >= 0 &&
width > 0 && height > 0 &&
x + width <= global.screen_width &&
y + height <= global.screen_height;
},
_onScreenshotComplete(obj, result, area, filenameUsed, flash, invocation) {
_onScreenshotComplete: function(obj, result, area, filenameUsed, flash, invocation) {
if (result) {
if (flash) {
let flashspot = new Flashspot(area);
flashspot.fire(() => {
flashspot.fire(Lang.bind(this, function() {
this._removeShooterForSender(invocation.get_sender());
});
}));
}
else
this._removeShooterForSender(invocation.get_sender());
@@ -126,7 +126,7 @@ var ScreenshotService = new Lang.Class({
invocation.return_value(retval);
},
_scaleArea(x, y, width, height) {
_scaleArea: function(x, y, width, height) {
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
x *= scaleFactor;
y *= scaleFactor;
@@ -135,7 +135,7 @@ var ScreenshotService = new Lang.Class({
return [x, y, width, height];
},
_unscaleArea(x, y, width, height) {
_unscaleArea: function(x, y, width, height) {
let scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
x /= scaleFactor;
y /= scaleFactor;
@@ -144,7 +144,7 @@ var ScreenshotService = new Lang.Class({
return [x, y, width, height];
},
ScreenshotAreaAsync(params, invocation) {
ScreenshotAreaAsync : function (params, invocation) {
let [x, y, width, height, flash, filename, callback] = params;
[x, y, width, height] = this._scaleArea(x, y, width, height);
if (!this._checkArea(x, y, width, height)) {
@@ -157,53 +157,48 @@ var ScreenshotService = new Lang.Class({
if (!screenshot)
return;
screenshot.screenshot_area (x, y, width, height, filename,
(obj, result, area, filenameUsed) => {
this._onScreenshotComplete(obj, result, area, filenameUsed,
flash, invocation);
});
Lang.bind(this, this._onScreenshotComplete,
flash, invocation));
},
ScreenshotWindowAsync(params, invocation) {
ScreenshotWindowAsync : function (params, invocation) {
let [include_frame, include_cursor, flash, filename] = params;
let screenshot = this._createScreenshot(invocation);
if (!screenshot)
return;
screenshot.screenshot_window (include_frame, include_cursor, filename,
(obj, result, area, filenameUsed) => {
this._onScreenshotComplete(obj, result, area, filenameUsed,
flash, invocation);
});
Lang.bind(this, this._onScreenshotComplete,
flash, invocation));
},
ScreenshotAsync(params, invocation) {
ScreenshotAsync : function (params, invocation) {
let [include_cursor, flash, filename] = params;
let screenshot = this._createScreenshot(invocation);
if (!screenshot)
return;
screenshot.screenshot(include_cursor, filename,
(obj, result, area, filenameUsed) => {
this._onScreenshotComplete(obj, result, area, filenameUsed,
flash, invocation);
});
Lang.bind(this, this._onScreenshotComplete,
flash, invocation));
},
SelectAreaAsync(params, invocation) {
SelectAreaAsync: function (params, invocation) {
let selectArea = new SelectArea();
selectArea.show();
selectArea.connect('finished', (selectArea, areaRectangle) => {
if (areaRectangle) {
let retRectangle = this._unscaleArea(areaRectangle.x, areaRectangle.y,
areaRectangle.width, areaRectangle.height);
let retval = GLib.Variant.new('(iiii)', retRectangle);
invocation.return_value(retval);
} else {
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
"Operation was cancelled");
}
});
selectArea.connect('finished', Lang.bind(this,
function(selectArea, areaRectangle) {
if (areaRectangle) {
let retRectangle = this._unscaleArea(areaRectangle.x, areaRectangle.y,
areaRectangle.width, areaRectangle.height);
let retval = GLib.Variant.new('(iiii)', retRectangle);
invocation.return_value(retval);
} else {
invocation.return_error_literal(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED,
"Operation was cancelled");
}
}));
},
FlashAreaAsync(params, invocation) {
FlashAreaAsync: function(params, invocation) {
let [x, y, width, height] = params;
[x, y, width, height] = this._scaleArea(x, y, width, height);
if (!this._checkArea(x, y, width, height)) {
@@ -221,7 +216,7 @@ var ScreenshotService = new Lang.Class({
var SelectArea = new Lang.Class({
Name: 'SelectArea',
_init() {
_init: function() {
this._startX = -1;
this._startY = -1;
this._lastX = 0;
@@ -239,11 +234,11 @@ var SelectArea = new Lang.Class({
this._grabHelper = new GrabHelper.GrabHelper(this._group);
this._group.connect('button-press-event',
this._onButtonPress.bind(this));
Lang.bind(this, this._onButtonPress));
this._group.connect('button-release-event',
this._onButtonRelease.bind(this));
Lang.bind(this, this._onButtonRelease));
this._group.connect('motion-event',
this._onMotionEvent.bind(this));
Lang.bind(this, this._onMotionEvent));
let constraint = new Clutter.BindConstraint({ source: global.stage,
coordinate: Clutter.BindCoordinate.ALL });
@@ -256,9 +251,9 @@ var SelectArea = new Lang.Class({
this._group.add_actor(this._rubberband);
},
show() {
show: function() {
if (!this._grabHelper.grab({ actor: this._group,
onUngrab: this._onUngrab.bind(this) }))
onUngrab: Lang.bind(this, this._onUngrab) }))
return;
global.screen.set_cursor(Meta.Cursor.CROSSHAIR);
@@ -266,7 +261,7 @@ var SelectArea = new Lang.Class({
this._group.visible = true;
},
_initRubberbandColors() {
_initRubberbandColors: function() {
function colorFromRGBA(rgba) {
return new Clutter.Color({ red: rgba.red * 255,
green: rgba.green * 255,
@@ -285,14 +280,14 @@ var SelectArea = new Lang.Class({
this._border = colorFromRGBA(context.get_border_color(Gtk.StateFlags.NORMAL));
},
_getGeometry() {
_getGeometry: function() {
return { x: Math.min(this._startX, this._lastX),
y: Math.min(this._startY, this._lastY),
width: Math.abs(this._startX - this._lastX) + 1,
height: Math.abs(this._startY - this._lastY) + 1 };
},
_onMotionEvent(actor, event) {
_onMotionEvent: function(actor, event) {
if (this._startX == -1 || this._startY == -1)
return Clutter.EVENT_PROPAGATE;
@@ -307,7 +302,7 @@ var SelectArea = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onButtonPress(actor, event) {
_onButtonPress: function(actor, event) {
[this._startX, this._startY] = event.get_coords();
this._startX = Math.floor(this._startX);
this._startY = Math.floor(this._startY);
@@ -316,27 +311,29 @@ var SelectArea = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_onButtonRelease(actor, event) {
_onButtonRelease: function(actor, event) {
this._result = this._getGeometry();
Tweener.addTween(this._group,
{ opacity: 0,
time: 0.2,
transition: 'easeOutQuad',
onComplete: () => {
this._grabHelper.ungrab();
}
onComplete: Lang.bind(this,
function() {
this._grabHelper.ungrab();
})
});
return Clutter.EVENT_PROPAGATE;
},
_onUngrab() {
_onUngrab: function() {
global.screen.set_cursor(Meta.Cursor.DEFAULT);
this.emit('finished', this._result);
GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
this._group.destroy();
return GLib.SOURCE_REMOVE;
});
GLib.idle_add(GLib.PRIORITY_DEFAULT, Lang.bind(this,
function() {
this._group.destroy();
return GLib.SOURCE_REMOVE;
}));
}
});
Signals.addSignalMethods(SelectArea.prototype);
@@ -347,7 +344,7 @@ var Flashspot = new Lang.Class({
Name: 'Flashspot',
Extends: Lightbox.Lightbox,
_init(area) {
_init: function(area) {
this.parent(Main.uiGroup, { inhibitEvents: true,
width: area.width,
height: area.height });
@@ -356,18 +353,18 @@ var Flashspot = new Lang.Class({
this.actor.set_position(area.x, area.y);
},
fire(doneCallback) {
fire: function(doneCallback) {
this.actor.show();
this.actor.opacity = 255;
Tweener.addTween(this.actor,
{ opacity: 0,
time: FLASHSPOT_ANIMATION_OUT_TIME,
transition: 'easeOutQuad',
onComplete: () => {
onComplete: Lang.bind(this, function() {
if (doneCallback)
doneCallback();
this.destroy();
}
})
});
}
});

View File

@@ -40,14 +40,16 @@ const Params = imports.misc.params;
function sleep(milliseconds) {
let cb;
let id = Mainloop.timeout_add(milliseconds, () => {
if (cb)
cb();
return GLib.SOURCE_REMOVE;
});
let id = Mainloop.timeout_add(milliseconds, function() {
if (cb)
cb();
return GLib.SOURCE_REMOVE;
});
GLib.Source.set_name_by_id(id, '[gnome-shell] sleep');
return callback => { cb = callback; };
return function(callback) {
cb = callback;
};
}
/**
@@ -60,12 +62,14 @@ function sleep(milliseconds) {
function waitLeisure() {
let cb;
global.run_at_leisure(() => {
if (cb)
cb();
});
global.run_at_leisure(function() {
if (cb)
cb();
});
return callback => { cb = callback; };
return function(callback) {
cb = callback;
};
}
const PerfHelperIface = '<node> \
@@ -99,19 +103,19 @@ function _callRemote(obj, method, ...args) {
let cb;
let errcb;
args.push((result, excp) => {
if (excp) {
if (errcb)
errcb(excp);
} else {
if (cb)
cb();
}
});
args.push(function(result, excp) {
if (excp) {
if (errcb)
errcb(excp);
} else {
if (cb)
cb();
}
});
method.apply(obj, args);
return (callback, error_callback) => {
return function(callback, error_callback) {
cb = callback;
errcb = error_callback;
};
@@ -209,10 +213,10 @@ function collectStatistics() {
function _step(g, finish, onError) {
try {
let waitFunction = g.next();
waitFunction(() => {
waitFunction(function() {
_step(g, finish, onError);
},
err => {
function(err) {
if (onError)
onError(err);
});
@@ -235,7 +239,7 @@ function _collect(scriptModule, outputFile) {
}
Shell.PerfLog.get_default().replay(
(time, eventName, signature, arg) => {
function(time, eventName, signature, arg) {
if (eventName in eventHandlers)
eventHandlers[eventName](time, arg);
});
@@ -366,7 +370,7 @@ function runPerfScript(scriptModule, outputFile) {
let g = scriptModule.run();
_step(g,
() => {
function() {
try {
_collect(scriptModule, outputFile);
} catch (err) {
@@ -375,7 +379,7 @@ function runPerfScript(scriptModule, outputFile) {
}
Meta.exit(Meta.ExitCode.SUCCESS);
},
err => {
function(err) {
log("Script failed: " + err + "\n" + err.stack);
Meta.exit(Meta.ExitCode.ERROR);
});

View File

@@ -28,7 +28,7 @@ var MaxWidthBin = new Lang.Class({
Name: 'MaxWidthBin',
Extends: St.Bin,
vfunc_allocate(box, flags) {
vfunc_allocate: function(box, flags) {
let themeNode = this.get_theme_node();
let maxWidth = themeNode.get_max_width();
let availWidth = box.x2 - box.x1;
@@ -47,7 +47,7 @@ var MaxWidthBin = new Lang.Class({
var SearchResult = new Lang.Class({
Name: 'SearchResult',
_init(provider, metaInfo, resultsView) {
_init: function(provider, metaInfo, resultsView) {
this.provider = provider;
this.metaInfo = metaInfo;
this._resultsView = resultsView;
@@ -59,10 +59,10 @@ var SearchResult = new Lang.Class({
y_fill: true });
this.actor._delegate = this;
this.actor.connect('clicked', this.activate.bind(this));
this.actor.connect('clicked', Lang.bind(this, this.activate));
},
activate() {
activate: function() {
this.emit('activate', this.metaInfo.id);
}
});
@@ -74,7 +74,7 @@ var ListSearchResult = new Lang.Class({
ICON_SIZE: 24,
_init(provider, metaInfo, resultsView) {
_init: function(provider, metaInfo, resultsView) {
this.parent(provider, metaInfo, resultsView);
this.actor.style_class = 'list-search-result';
@@ -116,20 +116,20 @@ var ListSearchResult = new Lang.Class({
this._termsChangedId =
this._resultsView.connect('terms-changed',
this._highlightTerms.bind(this));
Lang.bind(this, this._highlightTerms));
this._highlightTerms();
}
this.actor.connect('destroy', this._onDestroy.bind(this));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
},
_highlightTerms() {
_highlightTerms: function() {
let markup = this._resultsView.highlightTerms(this.metaInfo['description'].split('\n')[0]);
this._descriptionLabel.clutter_text.set_markup(markup);
},
_onDestroy() {
_onDestroy: function() {
if (this._termsChangedId)
this._resultsView.disconnect(this._termsChangedId);
this._termsChangedId = 0;
@@ -140,7 +140,7 @@ var GridSearchResult = new Lang.Class({
Name: 'GridSearchResult',
Extends: SearchResult,
_init(provider, metaInfo, resultsView) {
_init: function(provider, metaInfo, resultsView) {
this.parent(provider, metaInfo, resultsView);
this.actor.style_class = 'grid-search-result';
@@ -156,7 +156,7 @@ var GridSearchResult = new Lang.Class({
var SearchResultsBase = new Lang.Class({
Name: 'SearchResultsBase',
_init(provider, resultsView) {
_init: function(provider, resultsView) {
this.provider = provider;
this._resultsView = resultsView;
@@ -179,19 +179,19 @@ var SearchResultsBase = new Lang.Class({
this._cancellable = new Gio.Cancellable();
},
destroy() {
destroy: function() {
this.actor.destroy();
this._terms = [];
},
_createResultDisplay(meta) {
_createResultDisplay: function(meta) {
if (this.provider.createResultObject)
return this.provider.createResultObject(meta, this._resultsView);
return null;
},
clear() {
clear: function() {
for (let resultId in this._resultDisplays)
this._resultDisplays[resultId].actor.destroy();
this._resultDisplays = {};
@@ -199,24 +199,24 @@ var SearchResultsBase = new Lang.Class({
this.actor.hide();
},
_keyFocusIn(actor) {
_keyFocusIn: function(actor) {
this.emit('key-focus-in', actor);
},
_activateResult(result, id) {
_activateResult: function(result, id) {
this.provider.activateResult(id, this._terms);
if (result.metaInfo.clipboardText)
this._clipboard.set_text(St.ClipboardType.CLIPBOARD, result.metaInfo.clipboardText);
Main.overview.toggle();
},
_setMoreCount(count) {
_setMoreCount: function(count) {
},
_ensureResultActors(results, callback) {
let metasNeeded = results.filter(
resultId => this._resultDisplays[resultId] === undefined
);
_ensureResultActors: function(results, callback) {
let metasNeeded = results.filter(Lang.bind(this, function(resultId) {
return this._resultDisplays[resultId] === undefined;
}));
if (metasNeeded.length === 0) {
callback(true);
@@ -224,32 +224,34 @@ var SearchResultsBase = new Lang.Class({
this._cancellable.cancel();
this._cancellable.reset();
this.provider.getResultMetas(metasNeeded, metas => {
this.provider.getResultMetas(metasNeeded, Lang.bind(this, function(metas) {
if (metas.length != metasNeeded.length) {
log('Wrong number of result metas returned by search provider ' + this.provider.id +
': expected ' + metasNeeded.length + ' but got ' + metas.length);
callback(false);
return;
}
if (metas.some(meta => !meta.name || !meta.id)) {
if (metas.some(function(meta) {
return !meta.name || !meta.id;
})) {
log('Invalid result meta returned from search provider ' + this.provider.id);
callback(false);
return;
}
metasNeeded.forEach((resultId, i) => {
metasNeeded.forEach(Lang.bind(this, function(resultId, i) {
let meta = metas[i];
let display = this._createResultDisplay(meta);
display.connect('activate', this._activateResult.bind(this));
display.actor.connect('key-focus-in', this._keyFocusIn.bind(this));
display.connect('activate', Lang.bind(this, this._activateResult));
display.actor.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
this._resultDisplays[resultId] = display;
});
}));
callback(true);
}, this._cancellable);
}), this._cancellable);
}
},
updateSearch(providerResults, terms, callback) {
updateSearch: function(providerResults, terms, callback) {
this._terms = terms;
if (providerResults.length == 0) {
this._clearResultDisplay();
@@ -260,7 +262,7 @@ var SearchResultsBase = new Lang.Class({
let results = this.provider.filterResults(providerResults, maxResults);
let moreCount = Math.max(providerResults.length - results.length, 0);
this._ensureResultActors(results, successful => {
this._ensureResultActors(results, Lang.bind(this, function(successful) {
if (!successful) {
this._clearResultDisplay();
callback();
@@ -272,13 +274,13 @@ var SearchResultsBase = new Lang.Class({
// content while filling in the results.
this.actor.hide();
this._clearResultDisplay();
results.forEach(resultId => {
results.forEach(Lang.bind(this, function(resultId) {
this._addItem(this._resultDisplays[resultId]);
});
}));
this._setMoreCount(this.provider.canLaunchSearch ? moreCount : 0);
this.actor.show();
callback();
});
}));
}
}
});
@@ -287,17 +289,18 @@ var ListSearchResults = new Lang.Class({
Name: 'ListSearchResults',
Extends: SearchResultsBase,
_init(provider, resultsView) {
_init: function(provider, resultsView) {
this.parent(provider, resultsView);
this._container = new St.BoxLayout({ style_class: 'search-section-content' });
this.providerInfo = new ProviderInfo(provider);
this.providerInfo.connect('key-focus-in', this._keyFocusIn.bind(this));
this.providerInfo.connect('clicked', () => {
this.providerInfo.animateLaunch();
provider.launchSearch(this._terms);
Main.overview.toggle();
});
this.providerInfo.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
this.providerInfo.connect('clicked', Lang.bind(this,
function() {
this.providerInfo.animateLaunch();
provider.launchSearch(this._terms);
Main.overview.toggle();
}));
this._container.add(this.providerInfo, { x_fill: false,
y_fill: false,
@@ -311,28 +314,28 @@ var ListSearchResults = new Lang.Class({
this._resultDisplayBin.set_child(this._container);
},
_setMoreCount(count) {
_setMoreCount: function(count) {
this.providerInfo.setMoreCount(count);
},
_getMaxDisplayedResults() {
_getMaxDisplayedResults: function() {
return MAX_LIST_SEARCH_RESULTS_ROWS;
},
_clearResultDisplay() {
_clearResultDisplay: function () {
this._content.remove_all_children();
},
_createResultDisplay(meta) {
_createResultDisplay: function(meta) {
return this.parent(meta, this._resultsView) ||
new ListSearchResult(this.provider, meta, this._resultsView);
},
_addItem(display) {
_addItem: function(display) {
this._content.add_actor(display.actor);
},
getFirstResult() {
getFirstResult: function() {
if (this._content.get_n_children() > 0)
return this._content.get_child_at_index(0)._delegate;
else
@@ -345,7 +348,7 @@ var GridSearchResults = new Lang.Class({
Name: 'GridSearchResults',
Extends: SearchResultsBase,
_init(provider, resultsView) {
_init: function(provider, resultsView) {
this.parent(provider, resultsView);
// We need to use the parent container to know how much results we can show.
// None of the actors in this class can be used for that, since the main actor
@@ -362,26 +365,26 @@ var GridSearchResults = new Lang.Class({
this._resultDisplayBin.set_child(this._bin);
},
_getMaxDisplayedResults() {
_getMaxDisplayedResults: function() {
let parentThemeNode = this._parentContainer.get_theme_node();
let availableWidth = parentThemeNode.adjust_for_width(this._parentContainer.width);
return this._grid.columnsForWidth(availableWidth) * this._grid.getRowLimit();
},
_clearResultDisplay() {
_clearResultDisplay: function () {
this._grid.removeAll();
},
_createResultDisplay(meta) {
_createResultDisplay: function(meta) {
return this.parent(meta, this._resultsView) ||
new GridSearchResult(this.provider, meta, this._resultsView);
},
_addItem(display) {
_addItem: function(display) {
this._grid.addItem(display);
},
getFirstResult() {
getFirstResult: function() {
if (this._grid.visibleItemsCount() > 0)
return this._grid.getItemAtIndex(0)._delegate;
else
@@ -393,7 +396,7 @@ Signals.addSignalMethods(GridSearchResults.prototype);
var SearchResults = new Lang.Class({
Name: 'SearchResults',
_init() {
_init: function() {
this.actor = new St.BoxLayout({ name: 'searchResults',
vertical: true });
@@ -414,7 +417,7 @@ var SearchResults = new Lang.Class({
this._scrollView.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
this._scrollView.add_actor(scrollChild);
let action = new Clutter.PanAction({ interpolate: true });
action.connect('pan', this._onPan.bind(this));
action.connect('pan', Lang.bind(this, this._onPan));
this._scrollView.add_action(action);
this.actor.add(this._scrollView, { x_fill: true,
@@ -441,10 +444,10 @@ var SearchResults = new Lang.Class({
this._highlightRegex = null;
this._searchSettings = new Gio.Settings({ schema_id: SEARCH_PROVIDERS_SCHEMA });
this._searchSettings.connect('changed::disabled', this._reloadRemoteProviders.bind(this));
this._searchSettings.connect('changed::enabled', this._reloadRemoteProviders.bind(this));
this._searchSettings.connect('changed::disable-external', this._reloadRemoteProviders.bind(this));
this._searchSettings.connect('changed::sort-order', this._reloadRemoteProviders.bind(this));
this._searchSettings.connect('changed::disabled', Lang.bind(this, this._reloadRemoteProviders));
this._searchSettings.connect('changed::enabled', Lang.bind(this, this._reloadRemoteProviders));
this._searchSettings.connect('changed::disable-external', Lang.bind(this, this._reloadRemoteProviders));
this._searchSettings.connect('changed::sort-order', Lang.bind(this, this._reloadRemoteProviders));
this._searchTimeoutId = 0;
this._cancellable = new Gio.Cancellable();
@@ -453,23 +456,25 @@ var SearchResults = new Lang.Class({
this._reloadRemoteProviders();
},
_reloadRemoteProviders() {
let remoteProviders = this._providers.filter(p => p.isRemoteProvider);
remoteProviders.forEach(provider => {
_reloadRemoteProviders: function() {
let remoteProviders = this._providers.filter(function(provider) {
return provider.isRemoteProvider;
});
remoteProviders.forEach(Lang.bind(this, function(provider) {
this._unregisterProvider(provider);
});
}));
RemoteSearch.loadRemoteSearchProviders(this._searchSettings, providers => {
providers.forEach(this._registerProvider.bind(this));
});
RemoteSearch.loadRemoteSearchProviders(this._searchSettings, Lang.bind(this, function(providers) {
providers.forEach(Lang.bind(this, this._registerProvider));
}));
},
_registerProvider(provider) {
_registerProvider: function (provider) {
this._providers.push(provider);
this._ensureProviderDisplay(provider);
},
_unregisterProvider(provider) {
_unregisterProvider: function (provider) {
let index = this._providers.indexOf(provider);
this._providers.splice(index, 1);
@@ -477,19 +482,19 @@ var SearchResults = new Lang.Class({
provider.display.destroy();
},
_gotResults(results, provider) {
_gotResults: function(results, provider) {
this._results[provider.id] = results;
this._updateResults(provider, results);
},
_clearSearchTimeout() {
_clearSearchTimeout: function() {
if (this._searchTimeoutId > 0) {
GLib.source_remove(this._searchTimeoutId);
this._searchTimeoutId = 0;
}
},
_reset() {
_reset: function() {
this._terms = [];
this._results = {};
this._clearDisplay();
@@ -500,43 +505,34 @@ var SearchResults = new Lang.Class({
this._updateSearchProgress();
},
_doSearch() {
_doSearch: function() {
this._startingSearch = false;
let previousResults = this._results;
this._results = {};
this._providers.forEach(provider => {
this._providers.forEach(Lang.bind(this, function(provider) {
provider.searchInProgress = true;
let previousProviderResults = previousResults[provider.id];
if (this._isSubSearch && previousProviderResults)
provider.getSubsearchResultSet(previousProviderResults,
this._terms,
results => {
this._gotResults(results, provider);
},
this._cancellable);
provider.getSubsearchResultSet(previousProviderResults, this._terms, Lang.bind(this, this._gotResults, provider), this._cancellable);
else
provider.getInitialResultSet(this._terms,
results => {
this._gotResults(results, provider);
},
this._cancellable);
});
provider.getInitialResultSet(this._terms, Lang.bind(this, this._gotResults, provider), this._cancellable);
}));
this._updateSearchProgress();
this._clearSearchTimeout();
},
_onSearchTimeout() {
_onSearchTimeout: function() {
this._searchTimeoutId = 0;
this._doSearch();
return GLib.SOURCE_REMOVE;
},
setTerms(terms) {
setTerms: function(terms) {
// Check for the case of making a duplicate previous search before
// setting state of the current search or cancelling the search.
// This will prevent incorrect state being as a result of a duplicate
@@ -565,7 +561,7 @@ var SearchResults = new Lang.Class({
this._updateSearchProgress();
if (this._searchTimeoutId == 0)
this._searchTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, this._onSearchTimeout.bind(this));
this._searchTimeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 150, Lang.bind(this, this._onSearchTimeout));
let escapedTerms = this._terms.map(term => Shell.util_regex_escape(term));
this._highlightRegex = new RegExp(`(${escapedTerms.join('|')})`, 'gi');
@@ -573,18 +569,18 @@ var SearchResults = new Lang.Class({
this.emit('terms-changed');
},
_onPan(action) {
_onPan: function(action) {
let [dist, dx, dy] = action.get_motion_delta(0);
let adjustment = this._scrollView.vscroll.adjustment;
adjustment.value -= (dy / this.actor.height) * adjustment.page_size;
return false;
},
_keyFocusIn(provider, actor) {
_keyFocusIn: function(provider, actor) {
Util.ensureActorVisibleInScrollView(this._scrollView, actor);
},
_ensureProviderDisplay(provider) {
_ensureProviderDisplay: function(provider) {
if (provider.display)
return;
@@ -594,19 +590,19 @@ var SearchResults = new Lang.Class({
else
providerDisplay = new GridSearchResults(provider, this);
providerDisplay.connect('key-focus-in', this._keyFocusIn.bind(this));
providerDisplay.connect('key-focus-in', Lang.bind(this, this._keyFocusIn));
providerDisplay.actor.hide();
this._content.add(providerDisplay.actor);
provider.display = providerDisplay;
},
_clearDisplay() {
this._providers.forEach(provider => {
_clearDisplay: function() {
this._providers.forEach(function(provider) {
provider.display.clear();
});
},
_maybeSetInitialSelection() {
_maybeSetInitialSelection: function() {
let newDefaultResult = null;
let providers = this._providers;
@@ -636,11 +632,13 @@ var SearchResults = new Lang.Class({
if (this._startingSearch)
return true;
return this._providers.some(p => p.searchInProgress);
return this._providers.some(function(provider) {
return provider.searchInProgress;
});
},
_updateSearchProgress() {
let haveResults = this._providers.some(provider => {
_updateSearchProgress: function () {
let haveResults = this._providers.some(function(provider) {
let display = provider.display;
return (display.getFirstResult() != null);
});
@@ -657,19 +655,19 @@ var SearchResults = new Lang.Class({
}
},
_updateResults(provider, results) {
_updateResults: function(provider, results) {
let terms = this._terms;
let display = provider.display;
display.updateSearch(results, terms, () => {
display.updateSearch(results, terms, Lang.bind(this, function() {
provider.searchInProgress = false;
this._maybeSetInitialSelection();
this._updateSearchProgress();
});
}));
},
activateDefault() {
activateDefault: function() {
// If we have a search queued up, force the search now.
if (this._searchTimeoutId > 0)
this._doSearch();
@@ -678,12 +676,12 @@ var SearchResults = new Lang.Class({
this._defaultResult.activate();
},
highlightDefault(highlight) {
highlightDefault: function(highlight) {
this._highlightDefault = highlight;
this._setSelected(this._defaultResult, highlight);
},
popupMenuDefault() {
popupMenuDefault: function() {
// If we have a search queued up, force the search now.
if (this._searchTimeoutId > 0)
this._doSearch();
@@ -692,7 +690,7 @@ var SearchResults = new Lang.Class({
this._defaultResult.actor.popup_menu();
},
navigateFocus(direction) {
navigateFocus: function(direction) {
let rtl = this.actor.get_text_direction() == Clutter.TextDirection.RTL;
if (direction == Gtk.DirectionType.TAB_BACKWARD ||
direction == (rtl ? Gtk.DirectionType.RIGHT
@@ -706,7 +704,7 @@ var SearchResults = new Lang.Class({
this.actor.navigate_focus(from, direction, false);
},
_setSelected(result, selected) {
_setSelected: function(result, selected) {
if (!result)
return;
@@ -718,7 +716,7 @@ var SearchResults = new Lang.Class({
}
},
highlightTerms(description) {
highlightTerms: function(description) {
if (!description)
return '';
@@ -736,7 +734,7 @@ var ProviderInfo = new Lang.Class({
PROVIDER_ICON_SIZE: 32,
_init(provider) {
_init: function(provider) {
this.provider = provider;
this.parent({ style_class: 'search-provider-icon',
reactive: true,
@@ -768,14 +766,14 @@ var ProviderInfo = new Lang.Class({
this._content.add_actor(detailsBox);
},
animateLaunch() {
animateLaunch: function() {
let appSys = Shell.AppSystem.get_default();
let app = appSys.lookup_app(this.provider.appInfo.get_id());
if (app.state == Shell.AppState.STOPPED)
IconGrid.zoomOutActor(this._content);
},
setMoreCount(count) {
setMoreCount: function(count) {
this._moreLabel.text = ngettext("%d more", "%d more", count).format(count);
this._moreLabel.visible = count > 0;
}

View File

@@ -138,7 +138,7 @@ function _loadModes() {
function listModes() {
_loadModes();
let id = Mainloop.idle_add(() => {
let id = Mainloop.idle_add(function() {
let names = Object.getOwnPropertyNames(_modes);
for (let i = 0; i < names.length; i++)
if (_modes[names[i]].isPrimary)
@@ -152,7 +152,7 @@ function listModes() {
var SessionMode = new Lang.Class({
Name: 'SessionMode',
_init() {
_init: function() {
_loadModes();
let isPrimary = (_modes[global.session_mode] &&
_modes[global.session_mode].isPrimary);
@@ -161,19 +161,19 @@ var SessionMode = new Lang.Class({
this._sync();
},
pushMode(mode) {
pushMode: function(mode) {
this._modeStack.push(mode);
this._sync();
},
popMode(mode) {
popMode: function(mode) {
if (this.currentMode != mode || this._modeStack.length === 1)
throw new Error("Invalid SessionMode.popMode");
this._modeStack.pop();
this._sync();
},
switchMode(to) {
switchMode: function(to) {
if (this.currentMode == to)
return;
this._modeStack[this._modeStack.length - 1] = to;
@@ -184,7 +184,7 @@ var SessionMode = new Lang.Class({
return this._modeStack[this._modeStack.length - 1];
},
_sync() {
_sync: function() {
let params = _modes[this.currentMode];
let defaults;
if (params.parentMode)

View File

@@ -82,7 +82,7 @@ const ScreenSaverIface = '<node> \
var GnomeShell = new Lang.Class({
Name: 'GnomeShellDBus',
_init() {
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
@@ -92,16 +92,16 @@ var GnomeShell = new Lang.Class({
this._grabbedAccelerators = new Map();
this._grabbers = new Map();
global.display.connect('accelerator-activated',
(display, action, deviceid, timestamp) => {
global.display.connect('accelerator-activated', Lang.bind(this,
function(display, action, deviceid, timestamp) {
this._emitAcceleratorActivated(action, deviceid, timestamp);
});
}));
this._cachedOverviewVisible = false;
Main.overview.connect('showing',
this._checkOverviewVisibleChanged.bind(this));
Lang.bind(this, this._checkOverviewVisibleChanged));
Main.overview.connect('hidden',
this._checkOverviewVisibleChanged.bind(this));
Lang.bind(this, this._checkOverviewVisibleChanged));
},
/**
@@ -118,7 +118,7 @@ var GnomeShell = new Lang.Class({
* [false, JSON.stringify(exception)];
*
*/
Eval(code) {
Eval: function(code) {
if (!global.settings.get_boolean('development-tools'))
return [false, ''];
@@ -137,11 +137,11 @@ var GnomeShell = new Lang.Class({
return [success, returnValue];
},
FocusSearch() {
FocusSearch: function() {
Main.overview.focusSearch();
},
ShowOSD(params) {
ShowOSD: function(params) {
for (let param in params)
params[param] = params[param].deep_unpack();
@@ -156,23 +156,23 @@ var GnomeShell = new Lang.Class({
Main.osdWindowManager.show(monitorIndex, icon, label, level);
},
FocusApp(id) {
FocusApp: function(id) {
this.ShowApplications();
Main.overview.viewSelector.appDisplay.selectApp(id);
},
ShowApplications() {
ShowApplications: function() {
Main.overview.viewSelector.showApps();
},
GrabAcceleratorAsync(params, invocation) {
GrabAcceleratorAsync: function(params, invocation) {
let [accel, flags] = params;
let sender = invocation.get_sender();
let bindingAction = this._grabAcceleratorForSender(accel, flags, sender);
return invocation.return_value(GLib.Variant.new('(u)', [bindingAction]));
},
GrabAcceleratorsAsync(params, invocation) {
GrabAcceleratorsAsync: function(params, invocation) {
let [accels] = params;
let sender = invocation.get_sender();
let bindingActions = [];
@@ -183,7 +183,7 @@ var GnomeShell = new Lang.Class({
return invocation.return_value(GLib.Variant.new('(au)', [bindingActions]));
},
UngrabAcceleratorAsync(params, invocation) {
UngrabAcceleratorAsync: function(params, invocation) {
let [action] = params;
let grabbedBy = this._grabbedAccelerators.get(action);
if (invocation.get_sender() != grabbedBy)
@@ -195,7 +195,7 @@ var GnomeShell = new Lang.Class({
return invocation.return_value(GLib.Variant.new('(b)', [ungrabSucceeded]));
},
_emitAcceleratorActivated(action, deviceid, timestamp) {
_emitAcceleratorActivated: function(action, deviceid, timestamp) {
let destination = this._grabbedAccelerators.get(action);
if (!destination)
return;
@@ -212,7 +212,7 @@ var GnomeShell = new Lang.Class({
GLib.Variant.new('(ua{sv})', [action, params]));
},
_grabAcceleratorForSender(accelerator, flags, sender) {
_grabAcceleratorForSender: function(accelerator, flags, sender) {
let bindingAction = global.display.grab_accelerator(accelerator);
if (bindingAction == Meta.KeyBindingAction.NONE)
return Meta.KeyBindingAction.NONE;
@@ -224,20 +224,20 @@ var GnomeShell = new Lang.Class({
if (!this._grabbers.has(sender)) {
let id = Gio.bus_watch_name(Gio.BusType.SESSION, sender, 0, null,
this._onGrabberBusNameVanished.bind(this));
Lang.bind(this, this._onGrabberBusNameVanished));
this._grabbers.set(sender, id);
}
return bindingAction;
},
_ungrabAccelerator(action) {
_ungrabAccelerator: function(action) {
let ungrabSucceeded = global.display.ungrab_accelerator(action);
if (ungrabSucceeded)
this._grabbedAccelerators.delete(action);
},
_onGrabberBusNameVanished(connection, name) {
_onGrabberBusNameVanished: function(connection, name) {
let grabs = this._grabbedAccelerators.entries();
for (let [action, sender] of grabs) {
if (sender == name)
@@ -247,19 +247,19 @@ var GnomeShell = new Lang.Class({
this._grabbers.delete(name);
},
ShowMonitorLabelsAsync(params, invocation) {
ShowMonitorLabelsAsync: function(params, invocation) {
let sender = invocation.get_sender();
let [dict] = params;
Main.osdMonitorLabeler.show(sender, dict);
},
ShowMonitorLabels2Async(params, invocation) {
ShowMonitorLabels2Async: function(params, invocation) {
let sender = invocation.get_sender();
let [dict] = params;
Main.osdMonitorLabeler.show2(sender, dict);
},
HideMonitorLabelsAsync(params, invocation) {
HideMonitorLabelsAsync: function(params, invocation) {
let sender = invocation.get_sender();
Main.osdMonitorLabeler.hide(sender);
},
@@ -267,7 +267,7 @@ var GnomeShell = new Lang.Class({
Mode: global.session_mode,
_checkOverviewVisibleChanged() {
_checkOverviewVisibleChanged: function() {
if (Main.overview.visible !== this._cachedOverviewVisible) {
this._cachedOverviewVisible = Main.overview.visible;
this._dbusImpl.emit_property_changed('OverviewActive', new GLib.Variant('b', this._cachedOverviewVisible));
@@ -329,15 +329,15 @@ const GnomeShellExtensionsIface = '<node> \
var GnomeShellExtensions = new Lang.Class({
Name: 'GnomeShellExtensionsDBus',
_init() {
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
ExtensionSystem.connect('extension-state-changed',
this._extensionStateChanged.bind(this));
Lang.bind(this, this._extensionStateChanged));
},
ListExtensions() {
ListExtensions: function() {
let out = {};
for (let uuid in ExtensionUtils.extensions) {
let dbusObj = this.GetExtensionInfo(uuid);
@@ -346,7 +346,7 @@ var GnomeShellExtensions = new Lang.Class({
return out;
},
GetExtensionInfo(uuid) {
GetExtensionInfo: function(uuid) {
let extension = ExtensionUtils.extensions[uuid];
if (!extension)
return {};
@@ -357,7 +357,7 @@ var GnomeShellExtensions = new Lang.Class({
// Only serialize the properties that we actually need.
const serializedProperties = ["type", "state", "path", "error", "hasPrefs"];
serializedProperties.forEach(prop => {
serializedProperties.forEach(function(prop) {
obj[prop] = extension[prop];
});
@@ -384,7 +384,7 @@ var GnomeShellExtensions = new Lang.Class({
return out;
},
GetExtensionErrors(uuid) {
GetExtensionErrors: function(uuid) {
let extension = ExtensionUtils.extensions[uuid];
if (!extension)
return [];
@@ -395,15 +395,15 @@ var GnomeShellExtensions = new Lang.Class({
return extension.errors;
},
InstallRemoteExtensionAsync([uuid], invocation) {
InstallRemoteExtensionAsync: function([uuid], invocation) {
return ExtensionDownloader.installExtension(uuid, invocation);
},
UninstallExtension(uuid) {
UninstallExtension: function(uuid) {
return ExtensionDownloader.uninstallExtension(uuid);
},
LaunchExtensionPrefs(uuid) {
LaunchExtensionPrefs: function(uuid) {
let appSys = Shell.AppSystem.get_default();
let app = appSys.lookup_app('gnome-shell-extension-prefs.desktop');
let info = app.get_app_info();
@@ -412,7 +412,7 @@ var GnomeShellExtensions = new Lang.Class({
global.create_app_launch_context(timestamp, -1));
},
ReloadExtension(uuid) {
ReloadExtension: function(uuid) {
let extension = ExtensionUtils.extensions[uuid];
if (!extension)
return;
@@ -420,13 +420,13 @@ var GnomeShellExtensions = new Lang.Class({
ExtensionSystem.reloadExtension(extension);
},
CheckForUpdates() {
CheckForUpdates: function() {
ExtensionDownloader.checkForUpdates();
},
ShellVersion: Config.PACKAGE_VERSION,
_extensionStateChanged(_, newState) {
_extensionStateChanged: function(_, newState) {
this._dbusImpl.emit_signal('ExtensionStatusChanged',
GLib.Variant.new('(sis)', [newState.uuid, newState.state, newState.error]));
}
@@ -435,16 +435,16 @@ var GnomeShellExtensions = new Lang.Class({
var ScreenSaverDBus = new Lang.Class({
Name: 'ScreenSaverDBus',
_init(screenShield) {
_init: function(screenShield) {
this.parent();
this._screenShield = screenShield;
screenShield.connect('active-changed', shield => {
screenShield.connect('active-changed', Lang.bind(this, function(shield) {
this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.active]));
});
screenShield.connect('wake-up-screen', shield => {
}));
screenShield.connect('wake-up-screen', Lang.bind(this, function(shield) {
this._dbusImpl.emit_signal('WakeUpScreen', null);
});
}));
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');
@@ -452,28 +452,28 @@ var ScreenSaverDBus = new Lang.Class({
Gio.DBus.session.own_name('org.gnome.ScreenSaver', Gio.BusNameOwnerFlags.REPLACE, null, null);
},
LockAsync(parameters, invocation) {
let tmpId = this._screenShield.connect('lock-screen-shown', () => {
LockAsync: function(parameters, invocation) {
let tmpId = this._screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
this._screenShield.disconnect(tmpId);
invocation.return_value(null);
});
}));
this._screenShield.lock(true);
},
SetActive(active) {
SetActive: function(active) {
if (active)
this._screenShield.activate(true);
else
this._screenShield.deactivate(false);
},
GetActive() {
GetActive: function() {
return this._screenShield.active;
},
GetActiveTime() {
GetActiveTime: function() {
let started = this._screenShield.activationTime;
if (started > 0)
return Math.floor((GLib.get_monotonic_time() - started) / 1000000);

View File

@@ -14,7 +14,7 @@ var EntryMenu = new Lang.Class({
Name: 'ShellEntryMenu',
Extends: PopupMenu.PopupMenu,
_init(entry) {
_init: function(entry) {
this.parent(entry, 0, St.Side.TOP);
this._entry = entry;
@@ -23,12 +23,12 @@ var EntryMenu = new Lang.Class({
// Populate menu
let item;
item = new PopupMenu.PopupMenuItem(_("Copy"));
item.connect('activate', this._onCopyActivated.bind(this));
item.connect('activate', Lang.bind(this, this._onCopyActivated));
this.addMenuItem(item);
this._copyItem = item;
item = new PopupMenu.PopupMenuItem(_("Paste"));
item.connect('activate', this._onPasteActivated.bind(this));
item.connect('activate', Lang.bind(this, this._onPasteActivated));
this.addMenuItem(item);
this._pasteItem = item;
@@ -38,9 +38,10 @@ var EntryMenu = new Lang.Class({
this.actor.hide();
},
_makePasswordItem() {
_makePasswordItem: function() {
let item = new PopupMenu.PopupMenuItem('');
item.connect('activate', this._onPasswordActivated.bind(this));
item.connect('activate', Lang.bind(this,
this._onPasswordActivated));
this.addMenuItem(item);
this._passwordItem = item;
},
@@ -63,7 +64,7 @@ var EntryMenu = new Lang.Class({
}
},
open(animate) {
open: function(animate) {
this._updatePasteItem();
this._updateCopyItem();
if (this._passwordItem)
@@ -77,20 +78,20 @@ var EntryMenu = new Lang.Class({
this.actor.grab_key_focus();
},
_updateCopyItem() {
_updateCopyItem: function() {
let selection = this._entry.clutter_text.get_selection();
this._copyItem.setSensitive(!this._entry.clutter_text.password_char &&
selection && selection != '');
},
_updatePasteItem() {
this._clipboard.get_text(St.ClipboardType.CLIPBOARD,
(clipboard, text) => {
_updatePasteItem: function() {
this._clipboard.get_text(St.ClipboardType.CLIPBOARD, Lang.bind(this,
function(clipboard, text) {
this._pasteItem.setSensitive(text && text != '');
});
}));
},
_updatePasswordItem() {
_updatePasswordItem: function() {
let textHidden = (this._entry.clutter_text.password_char);
if (textHidden)
this._passwordItem.label.set_text(_("Show Text"));
@@ -98,23 +99,23 @@ var EntryMenu = new Lang.Class({
this._passwordItem.label.set_text(_("Hide Text"));
},
_onCopyActivated() {
_onCopyActivated: function() {
let selection = this._entry.clutter_text.get_selection();
this._clipboard.set_text(St.ClipboardType.CLIPBOARD, selection);
},
_onPasteActivated() {
this._clipboard.get_text(St.ClipboardType.CLIPBOARD,
(clipboard, text) => {
_onPasteActivated: function() {
this._clipboard.get_text(St.ClipboardType.CLIPBOARD, Lang.bind(this,
function(clipboard, text) {
if (!text)
return;
this._entry.clutter_text.delete_selection();
let pos = this._entry.clutter_text.get_cursor_position();
this._entry.clutter_text.insert_text(text, pos);
});
}));
},
_onPasswordActivated() {
_onPasswordActivated: function() {
let visible = !!(this._entry.clutter_text.password_char);
this._entry.clutter_text.set_password_char(visible ? '' : '\u25cf');
}
@@ -160,16 +161,12 @@ function addContextMenu(entry, params) {
// Add an event handler to both the entry and its clutter_text; the former
// so padding is included in the clickable area, the latter because the
// event processing of ClutterText prevents event-bubbling.
entry.clutter_text.connect('button-press-event', (actor, event) => {
_onButtonPressEvent(actor, event, entry);
});
entry.connect('button-press-event', (actor, event) => {
_onButtonPressEvent(actor, event, entry);
});
entry.clutter_text.connect('button-press-event', Lang.bind(null, _onButtonPressEvent, entry));
entry.connect('button-press-event', Lang.bind(null, _onButtonPressEvent, entry));
entry.connect('popup-menu', actor => { _onPopup(actor, entry); });
entry.connect('popup-menu', Lang.bind(null, _onPopup, entry));
entry.connect('destroy', () => {
entry.connect('destroy', function() {
entry.menu.destroy();
entry.menu = null;
entry._menuManager = null;

View File

@@ -39,8 +39,9 @@ function _setButtonsForChoices(dialog, choices) {
for (let idx = 0; idx < choices.length; idx++) {
let button = idx;
buttons.unshift({ label: choices[idx],
action: () => { dialog.emit('response', button); }
});
action: Lang.bind(dialog, function() {
dialog.emit('response', button);
})});
}
dialog.setButtons(buttons);
@@ -63,7 +64,7 @@ function _createIcon(gicon) {
var ListItem = new Lang.Class({
Name: 'ListItem',
_init(app) {
_init: function(app) {
this._app = app;
let layout = new St.BoxLayout({ vertical: false});
@@ -87,10 +88,10 @@ var ListItem = new Lang.Class({
child: this._nameLabel });
layout.add(labelBin);
this.actor.connect('clicked', this._onClicked.bind(this));
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
},
_onClicked() {
_onClicked: function() {
this.emit('activate');
this._app.activate();
}
@@ -100,7 +101,7 @@ Signals.addSignalMethods(ListItem.prototype);
var ShellMountOperation = new Lang.Class({
Name: 'ShellMountOperation',
_init(source, params) {
_init: function(source, params) {
params = Params.parse(params, { existingDialog: null });
this._dialog = null;
@@ -111,20 +112,20 @@ var ShellMountOperation = new Lang.Class({
this.mountOp = new Shell.MountOperation();
this.mountOp.connect('ask-question',
this._onAskQuestion.bind(this));
Lang.bind(this, this._onAskQuestion));
this.mountOp.connect('ask-password',
this._onAskPassword.bind(this));
Lang.bind(this, this._onAskPassword));
this.mountOp.connect('show-processes-2',
this._onShowProcesses2.bind(this));
Lang.bind(this, this._onShowProcesses2));
this.mountOp.connect('aborted',
this.close.bind(this));
Lang.bind(this, this.close));
this.mountOp.connect('show-unmount-progress',
this._onShowUnmountProgress.bind(this));
Lang.bind(this, this._onShowUnmountProgress));
this._gicon = source.get_icon();
},
_closeExistingDialog() {
_closeExistingDialog: function() {
if (!this._existingDialog)
return;
@@ -132,23 +133,23 @@ var ShellMountOperation = new Lang.Class({
this._existingDialog = null;
},
_onAskQuestion(op, message, choices) {
_onAskQuestion: function(op, message, choices) {
this._closeExistingDialog();
this._dialog = new ShellMountQuestionDialog(this._gicon);
this._dialogId = this._dialog.connect('response',
(object, choice) => {
this._dialogId = this._dialog.connect('response', Lang.bind(this,
function(object, choice) {
this.mountOp.set_choice(choice);
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
this.close();
});
}));
this._dialog.update(message, choices);
this._dialog.open();
},
_onAskPassword(op, message, defaultUser, defaultDomain, flags) {
_onAskPassword: function(op, message, defaultUser, defaultDomain, flags) {
if (this._existingDialog) {
this._dialog = this._existingDialog;
this._dialog.reaskPassword();
@@ -156,8 +157,8 @@ var ShellMountOperation = new Lang.Class({
this._dialog = new ShellMountPasswordDialog(message, this._gicon, flags);
}
this._dialogId = this._dialog.connect('response',
(object, choice, password, remember) => {
this._dialogId = this._dialog.connect('response', Lang.bind(this,
function(object, choice, password, remember) {
if (choice == -1) {
this.mountOp.reply(Gio.MountOperationResult.ABORTED);
} else {
@@ -169,11 +170,11 @@ var ShellMountOperation = new Lang.Class({
this.mountOp.set_password(password);
this.mountOp.reply(Gio.MountOperationResult.HANDLED);
}
});
}));
this._dialog.open();
},
close(op) {
close: function(op) {
this._closeExistingDialog();
this._processesDialog = null;
@@ -188,7 +189,7 @@ var ShellMountOperation = new Lang.Class({
}
},
_onShowProcesses2(op) {
_onShowProcesses2: function(op) {
this._closeExistingDialog();
let processes = op.get_show_processes_pids();
@@ -199,8 +200,8 @@ var ShellMountOperation = new Lang.Class({
this._processesDialog = new ShellProcessesDialog(this._gicon);
this._dialog = this._processesDialog;
this._dialogId = this._processesDialog.connect('response',
(object, choice) => {
this._dialogId = this._processesDialog.connect('response', Lang.bind(this,
function(object, choice) {
if (choice == -1) {
this.mountOp.reply(Gio.MountOperationResult.ABORTED);
} else {
@@ -209,14 +210,14 @@ var ShellMountOperation = new Lang.Class({
}
this.close();
});
}));
this._processesDialog.open();
}
this._processesDialog.update(message, processes, choices);
},
_onShowUnmountProgress(op, message, timeLeft, bytesLeft) {
_onShowUnmountProgress: function(op, message, timeLeft, bytesLeft) {
if (!this._notifier)
this._notifier = new ShellUnmountNotifier();
@@ -226,7 +227,7 @@ var ShellMountOperation = new Lang.Class({
this._notifier.show(message);
},
borrowDialog() {
borrowDialog: function() {
if (this._dialogId != 0) {
this._dialog.disconnect(this._dialogId);
this._dialogId = 0;
@@ -240,14 +241,14 @@ var ShellUnmountNotifier = new Lang.Class({
Name: 'ShellUnmountNotifier',
Extends: MessageTray.Source,
_init() {
_init: function() {
this.parent('', 'media-removable');
this._notification = null;
Main.messageTray.add(this);
},
show(message) {
show: function(message) {
let [header, text] = message.split('\n', 2);
if (!this._notification) {
@@ -261,7 +262,7 @@ var ShellUnmountNotifier = new Lang.Class({
this.notify(this._notification);
},
done(message) {
done: function(message) {
if (this._notification) {
this._notification.destroy();
this._notification = null;
@@ -280,14 +281,14 @@ var ShellMountQuestionDialog = new Lang.Class({
Name: 'ShellMountQuestionDialog',
Extends: ModalDialog.ModalDialog,
_init(icon) {
_init: function(icon) {
this.parent({ styleClass: 'mount-dialog' });
this._content = new Dialog.MessageDialogContent({ icon });
this.contentLayout.add(this._content, { x_fill: true, y_fill: false });
},
update(message, choices) {
update: function(message, choices) {
_setLabelsForMessage(this._content, message);
_setButtonsForChoices(this, choices);
}
@@ -298,7 +299,7 @@ var ShellMountPasswordDialog = new Lang.Class({
Name: 'ShellMountPasswordDialog',
Extends: ModalDialog.ModalDialog,
_init(message, icon, flags) {
_init: function(message, icon, flags) {
let strings = message.split('\n');
let title = strings.shift() || null;
let body = strings.shift() || null;
@@ -318,7 +319,7 @@ var ShellMountPasswordDialog = new Lang.Class({
text: "",
can_focus: true});
ShellEntry.addContextMenu(this._passwordEntry, { isPassword: true });
this._passwordEntry.clutter_text.connect('activate', this._onEntryActivate.bind(this));
this._passwordEntry.clutter_text.connect('activate', Lang.bind(this, this._onEntryActivate));
this._passwordEntry.clutter_text.set_password_char('\u25cf'); // ● U+25CF BLACK CIRCLE
this._passwordBox.add(this._passwordEntry, {expand: true });
this.setInitialKeyFocus(this._passwordEntry);
@@ -341,31 +342,31 @@ var ShellMountPasswordDialog = new Lang.Class({
}
let buttons = [{ label: _("Cancel"),
action: this._onCancelButton.bind(this),
action: Lang.bind(this, this._onCancelButton),
key: Clutter.Escape
},
{ label: _("Unlock"),
action: this._onUnlockButton.bind(this),
action: Lang.bind(this, this._onUnlockButton),
default: true
}];
this.setButtons(buttons);
},
reaskPassword() {
reaskPassword: function() {
this._passwordEntry.set_text('');
this._errorMessageLabel.show();
},
_onCancelButton() {
_onCancelButton: function() {
this.emit('response', -1, '', false);
},
_onUnlockButton() {
_onUnlockButton: function() {
this._onEntryActivate();
},
_onEntryActivate() {
_onEntryActivate: function() {
global.settings.set_boolean(REMEMBER_MOUNT_PASSWORD_KEY,
this._rememberChoice && this._rememberChoice.actor.checked);
this.emit('response', 1,
@@ -379,7 +380,7 @@ var ShellProcessesDialog = new Lang.Class({
Name: 'ShellProcessesDialog',
Extends: ModalDialog.ModalDialog,
_init(icon) {
_init: function(icon) {
this.parent({ styleClass: 'mount-dialog' });
this._content = new Dialog.MessageDialogContent({ icon });
@@ -396,22 +397,24 @@ var ShellProcessesDialog = new Lang.Class({
this._applicationList = new St.BoxLayout({ vertical: true });
scrollView.add_actor(this._applicationList);
this._applicationList.connect('actor-added', () => {
if (this._applicationList.get_n_children() == 1)
scrollView.show();
});
this._applicationList.connect('actor-added',
Lang.bind(this, function() {
if (this._applicationList.get_n_children() == 1)
scrollView.show();
}));
this._applicationList.connect('actor-removed', () => {
if (this._applicationList.get_n_children() == 0)
scrollView.hide();
});
this._applicationList.connect('actor-removed',
Lang.bind(this, function() {
if (this._applicationList.get_n_children() == 0)
scrollView.hide();
}));
},
_setAppsForPids(pids) {
_setAppsForPids: function(pids) {
// remove all the items
this._applicationList.destroy_all_children();
pids.forEach(pid => {
pids.forEach(Lang.bind(this, function(pid) {
let tracker = Shell.WindowTracker.get_default();
let app = tracker.get_app_from_pid(pid);
@@ -421,14 +424,15 @@ var ShellProcessesDialog = new Lang.Class({
let item = new ListItem(app);
this._applicationList.add(item.actor, { x_fill: true });
item.connect('activate', () => {
// use -1 to indicate Cancel
this.emit('response', -1);
});
});
item.connect('activate',
Lang.bind(this, function() {
// use -1 to indicate Cancel
this.emit('response', -1);
}));
}));
},
update(message, processes, choices) {
update: function(message, processes, choices) {
this._setAppsForPids(processes);
_setLabelsForMessage(this._content, message);
_setButtonsForChoices(this, choices);
@@ -479,7 +483,7 @@ var ShellMountOperationType = {
var GnomeShellMountOpHandler = new Lang.Class({
Name: 'GnomeShellMountOpHandler',
_init() {
_init: function() {
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellMountOpIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gtk/MountOperationHandler');
Gio.bus_own_name_on_connection(Gio.DBus.session, 'org.gtk.MountOperationHandler',
@@ -491,13 +495,13 @@ var GnomeShellMountOpHandler = new Lang.Class({
this._ensureEmptyRequest();
},
_ensureEmptyRequest() {
_ensureEmptyRequest: function() {
this._currentId = null;
this._currentInvocation = null;
this._currentType = ShellMountOperationType.NONE;
},
_clearCurrentRequest(response, details) {
_clearCurrentRequest: function(response, details) {
if (this._currentInvocation) {
this._currentInvocation.return_value(
GLib.Variant.new('(ua{sv})', [response, details]));
@@ -506,7 +510,7 @@ var GnomeShellMountOpHandler = new Lang.Class({
this._ensureEmptyRequest();
},
_setCurrentRequest(invocation, id, type) {
_setCurrentRequest: function(invocation, id, type) {
let oldId = this._currentId;
let oldType = this._currentType;
let requestId = id + '@' + invocation.get_sender();
@@ -523,14 +527,14 @@ var GnomeShellMountOpHandler = new Lang.Class({
return false;
},
_closeDialog() {
_closeDialog: function() {
if (this._dialog) {
this._dialog.close();
this._dialog = null;
}
},
_createGIcon(iconName) {
_createGIcon: function(iconName) {
let realIconName = iconName ? iconName : 'drive-harddisk';
return new Gio.ThemedIcon({ name: realIconName,
use_default_fallbacks: true });
@@ -557,7 +561,7 @@ var GnomeShellMountOpHandler = new Lang.Class({
* the existing dialog and update it with a message indicating the previous
* attempt went wrong.
*/
AskPasswordAsync(params, invocation) {
AskPasswordAsync: function(params, invocation) {
let [id, message, iconName, defaultUser, defaultDomain, flags] = params;
if (this._setCurrentRequest(invocation, id, ShellMountOperationType.ASK_PASSWORD)) {
@@ -568,8 +572,8 @@ var GnomeShellMountOpHandler = new Lang.Class({
this._closeDialog();
this._dialog = new ShellMountPasswordDialog(message, this._createGIcon(iconName), flags);
this._dialog.connect('response',
(object, choice, password, remember) => {
this._dialog.connect('response', Lang.bind(this,
function(object, choice, password, remember) {
let details = {};
let response;
@@ -584,7 +588,7 @@ var GnomeShellMountOpHandler = new Lang.Class({
}
this._clearCurrentRequest(response, details);
});
}));
this._dialog.open();
},
@@ -606,7 +610,7 @@ var GnomeShellMountOpHandler = new Lang.Class({
* Calling AskQuestion again for the same id will have the effect to clear
* update the dialog with the new question.
*/
AskQuestionAsync(params, invocation) {
AskQuestionAsync: function(params, invocation) {
let [id, message, iconName, choices] = params;
if (this._setCurrentRequest(invocation, id, ShellMountOperationType.ASK_QUESTION)) {
@@ -617,10 +621,11 @@ var GnomeShellMountOpHandler = new Lang.Class({
this._closeDialog();
this._dialog = new ShellMountQuestionDialog(this._createGIcon(iconName), message);
this._dialog.connect('response', (object, choice) => {
this._clearCurrentRequest(Gio.MountOperationResult.HANDLED,
{ choice: GLib.Variant.new('i', choice) });
});
this._dialog.connect('response', Lang.bind(this,
function(object, choice) {
this._clearCurrentRequest(Gio.MountOperationResult.HANDLED,
{ choice: GLib.Variant.new('i', choice) });
}));
this._dialog.update(message, choices);
this._dialog.open();
@@ -645,7 +650,7 @@ var GnomeShellMountOpHandler = new Lang.Class({
* the existing dialog and update it with the new message and the new list
* of processes.
*/
ShowProcessesAsync(params, invocation) {
ShowProcessesAsync: function(params, invocation) {
let [id, message, iconName, applicationPids, choices] = params;
if (this._setCurrentRequest(invocation, id, ShellMountOperationType.SHOW_PROCESSES)) {
@@ -656,19 +661,20 @@ var GnomeShellMountOpHandler = new Lang.Class({
this._closeDialog();
this._dialog = new ShellProcessesDialog(this._createGIcon(iconName));
this._dialog.connect('response', (object, choice) => {
let response;
let details = {};
this._dialog.connect('response', Lang.bind(this,
function(object, choice) {
let response;
let details = {};
if (choice == -1) {
response = Gio.MountOperationResult.ABORTED;
} else {
response = Gio.MountOperationResult.HANDLED;
details['choice'] = GLib.Variant.new('i', choice);
}
if (choice == -1) {
response = Gio.MountOperationResult.ABORTED;
} else {
response = Gio.MountOperationResult.HANDLED;
details['choice'] = GLib.Variant.new('i', choice);
}
this._clearCurrentRequest(response, details);
});
this._clearCurrentRequest(response, details);
}));
this._dialog.update(message, applicationPids, choices);
this._dialog.open();
@@ -680,7 +686,7 @@ var GnomeShellMountOpHandler = new Lang.Class({
* Closes a dialog previously opened by AskPassword, AskQuestion or ShowProcesses.
* If no dialog is open, does nothing.
*/
Close(params, invocation) {
Close: function(params, invocation) {
this._clearCurrentRequest(Gio.MountOperationResult.UNHANDLED, {});
this._closeDialog();
}

View File

@@ -12,7 +12,7 @@ var SLIDER_SCROLL_STEP = 0.02; /* Slider scrolling step in % */
var Slider = new Lang.Class({
Name: "Slider",
_init(value) {
_init: function(value) {
if (isNaN(value))
// Avoid spreading NaNs around
throw TypeError('The slider value must be a number');
@@ -23,11 +23,11 @@ var Slider = new Lang.Class({
can_focus: true,
reactive: true,
accessible_role: Atk.Role.SLIDER });
this.actor.connect('repaint', this._sliderRepaint.bind(this));
this.actor.connect('button-press-event', this._startDragging.bind(this));
this.actor.connect('touch-event', this._touchDragging.bind(this));
this.actor.connect('scroll-event', this._onScrollEvent.bind(this));
this.actor.connect('key-press-event', this.onKeyPressEvent.bind(this));
this.actor.connect('repaint', Lang.bind(this, this._sliderRepaint));
this.actor.connect('button-press-event', Lang.bind(this, this._startDragging));
this.actor.connect('touch-event', Lang.bind(this, this._touchDragging));
this.actor.connect('scroll-event', Lang.bind(this, this._onScrollEvent));
this.actor.connect('key-press-event', Lang.bind(this, this.onKeyPressEvent));
this.actor.connect('allocation-changed', (actor, box) => {
this._sliderWidth = box.get_width();
});
@@ -38,16 +38,16 @@ var Slider = new Lang.Class({
this._customAccessible = St.GenericAccessible.new_for_actor(this.actor);
this.actor.set_accessible(this._customAccessible);
this._customAccessible.connect('get-current-value', this._getCurrentValue.bind(this));
this._customAccessible.connect('get-minimum-value', this._getMinimumValue.bind(this));
this._customAccessible.connect('get-maximum-value', this._getMaximumValue.bind(this));
this._customAccessible.connect('get-minimum-increment', this._getMinimumIncrement.bind(this));
this._customAccessible.connect('set-current-value', this._setCurrentValue.bind(this));
this._customAccessible.connect('get-current-value', Lang.bind(this, this._getCurrentValue));
this._customAccessible.connect('get-minimum-value', Lang.bind(this, this._getMinimumValue));
this._customAccessible.connect('get-maximum-value', Lang.bind(this, this._getMaximumValue));
this._customAccessible.connect('get-minimum-increment', Lang.bind(this, this._getMinimumIncrement));
this._customAccessible.connect('set-current-value', Lang.bind(this, this._setCurrentValue));
this.connect('value-changed', this._valueChanged.bind(this));
this.connect('value-changed', Lang.bind(this, this._valueChanged));
},
setValue(value) {
setValue: function(value) {
if (isNaN(value))
throw TypeError('The slider value must be a number');
@@ -55,7 +55,7 @@ var Slider = new Lang.Class({
this.actor.queue_repaint();
},
_sliderRepaint(area) {
_sliderRepaint: function(area) {
let cr = area.get_context();
let themeNode = area.get_theme_node();
let [width, height] = area.get_surface_size();
@@ -115,11 +115,11 @@ var Slider = new Lang.Class({
cr.$dispose();
},
_startDragging(actor, event) {
_startDragging: function(actor, event) {
return this.startDragging(event);
},
startDragging(event) {
startDragging: function(event) {
if (this._dragging)
return Clutter.EVENT_PROPAGATE;
@@ -137,8 +137,8 @@ var Slider = new Lang.Class({
this._grabbedSequence = sequence;
if (sequence == null) {
this._releaseId = this.actor.connect('button-release-event', this._endDragging.bind(this));
this._motionId = this.actor.connect('motion-event', this._motionEvent.bind(this));
this._releaseId = this.actor.connect('button-release-event', Lang.bind(this, this._endDragging));
this._motionId = this.actor.connect('motion-event', Lang.bind(this, this._motionEvent));
}
// We need to emit 'drag-begin' before moving the handle to make
@@ -151,7 +151,7 @@ var Slider = new Lang.Class({
return Clutter.EVENT_STOP;
},
_endDragging() {
_endDragging: function() {
if (this._dragging) {
if (this._releaseId)
this.actor.disconnect(this._releaseId);
@@ -172,7 +172,7 @@ var Slider = new Lang.Class({
return Clutter.EVENT_STOP;
},
_touchDragging(actor, event) {
_touchDragging: function(actor, event) {
let device = event.get_device();
let sequence = event.get_event_sequence();
@@ -190,7 +190,7 @@ var Slider = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
scroll(event) {
scroll: function(event) {
let direction = event.get_scroll_direction();
let delta;
@@ -215,18 +215,18 @@ var Slider = new Lang.Class({
return Clutter.EVENT_STOP;
},
_onScrollEvent(actor, event) {
_onScrollEvent: function(actor, event) {
return this.scroll(event);
},
_motionEvent(actor, event) {
_motionEvent: function(actor, event) {
let absX, absY;
[absX, absY] = event.get_coords();
this._moveHandle(absX, absY);
return Clutter.EVENT_STOP;
},
onKeyPressEvent(actor, event) {
onKeyPressEvent: function (actor, event) {
let key = event.get_key_symbol();
if (key == Clutter.KEY_Right || key == Clutter.KEY_Left) {
let delta = key == Clutter.KEY_Right ? 0.1 : -0.1;
@@ -240,7 +240,7 @@ var Slider = new Lang.Class({
return Clutter.EVENT_PROPAGATE;
},
_moveHandle(absX, absY) {
_moveHandle: function(absX, absY) {
let relX, relY, sliderX, sliderY;
[sliderX, sliderY] = this.actor.get_transformed_position();
relX = absX - sliderX;
@@ -261,27 +261,27 @@ var Slider = new Lang.Class({
this.emit('value-changed', this._value);
},
_getCurrentValue(actor) {
_getCurrentValue: function (actor) {
return this._value;
},
_getMinimumValue(actor) {
_getMinimumValue: function (actor) {
return 0;
},
_getMaximumValue(actor) {
_getMaximumValue: function (actor) {
return 1;
},
_getMinimumIncrement(actor) {
_getMinimumIncrement: function (actor) {
return 0.1;
},
_setCurrentValue(actor, value) {
_setCurrentValue: function (actor, value) {
this._value = value;
},
_valueChanged(slider, value, property) {
_valueChanged: function (slider, value, property) {
this._customAccessible.notify ("accessible-value");
},

View File

@@ -38,7 +38,7 @@ var ATIndicator = new Lang.Class({
Name: 'ATIndicator',
Extends: PanelMenu.Button,
_init() {
_init: function() {
this.parent(0.0, _("Accessibility"));
this._hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' });
@@ -49,7 +49,7 @@ var ATIndicator = new Lang.Class({
this.actor.add_child(this._hbox);
this._a11ySettings = new Gio.Settings({ schema_id: A11Y_SCHEMA });
this._a11ySettings.connect('changed::' + KEY_ALWAYS_SHOW, this._queueSyncMenuVisibility.bind(this));
this._a11ySettings.connect('changed::' + KEY_ALWAYS_SHOW, Lang.bind(this, this._queueSyncMenuVisibility));
let highContrast = this._buildHCItem();
this.menu.addMenuItem(highContrast);
@@ -87,55 +87,57 @@ var ATIndicator = new Lang.Class({
this._syncMenuVisibility();
},
_syncMenuVisibility() {
_syncMenuVisibility: function() {
this._syncMenuVisibilityIdle = 0;
let alwaysShow = this._a11ySettings.get_boolean(KEY_ALWAYS_SHOW);
let items = this.menu._getMenuItems();
this.actor.visible = alwaysShow || items.some(f => !!f.state);
this.actor.visible = alwaysShow || items.some(function(f) { return !!f.state; });
return GLib.SOURCE_REMOVE;
},
_queueSyncMenuVisibility() {
_queueSyncMenuVisibility: function() {
if (this._syncMenuVisibilityIdle)
return;
this._syncMenuVisibilityIdle = Mainloop.idle_add(this._syncMenuVisibility.bind(this));
this._syncMenuVisibilityIdle = Mainloop.idle_add(Lang.bind(this, this._syncMenuVisibility));
GLib.Source.set_name_by_id(this._syncMenuVisibilityIdle, '[gnome-shell] this._syncMenuVisibility');
},
_buildItemExtended(string, initial_value, writable, on_set) {
_buildItemExtended: function(string, initial_value, writable, on_set) {
let widget = new PopupMenu.PopupSwitchMenuItem(string, initial_value);
if (!writable)
widget.actor.reactive = false;
else
widget.connect('toggled', item => {
widget.connect('toggled', function(item) {
on_set(item.state);
});
return widget;
},
_buildItem(string, schema, key) {
_buildItem: function(string, schema, key) {
let settings = new Gio.Settings({ schema_id: schema });
settings.connect('changed::'+key, () => {
settings.connect('changed::'+key, Lang.bind(this, function() {
widget.setToggleState(settings.get_boolean(key));
this._queueSyncMenuVisibility();
});
}));
let widget = this._buildItemExtended(string,
settings.get_boolean(key),
settings.is_writable(key),
enabled => settings.set_boolean(key, enabled));
function(enabled) {
return settings.set_boolean(key, enabled);
});
return widget;
},
_buildHCItem() {
_buildHCItem: function() {
let interfaceSettings = new Gio.Settings({ schema_id: DESKTOP_INTERFACE_SCHEMA });
let wmSettings = new Gio.Settings({ schema_id: WM_SCHEMA });
interfaceSettings.connect('changed::' + KEY_GTK_THEME, () => {
interfaceSettings.connect('changed::' + KEY_GTK_THEME, Lang.bind(this, function() {
let value = interfaceSettings.get_string(KEY_GTK_THEME);
if (value == HIGH_CONTRAST_THEME) {
highContrast.setToggleState(true);
@@ -145,13 +147,13 @@ var ATIndicator = new Lang.Class({
}
this._queueSyncMenuVisibility();
});
interfaceSettings.connect('changed::' + KEY_ICON_THEME, () => {
}));
interfaceSettings.connect('changed::' + KEY_ICON_THEME, function() {
let value = interfaceSettings.get_string(KEY_ICON_THEME);
if (value != HIGH_CONTRAST_THEME)
iconTheme = value;
});
wmSettings.connect('changed::' + KEY_WM_THEME, () => {
wmSettings.connect('changed::' + KEY_WM_THEME, function() {
let value = wmSettings.get_string(KEY_WM_THEME);
if (value != HIGH_CONTRAST_THEME)
wmTheme = value;
@@ -167,7 +169,7 @@ var ATIndicator = new Lang.Class({
interfaceSettings.is_writable(KEY_GTK_THEME) &&
interfaceSettings.is_writable(KEY_ICON_THEME) &&
wmSettings.is_writable(KEY_WM_THEME),
enabled => {
function (enabled) {
if (enabled) {
interfaceSettings.set_string(KEY_GTK_THEME, HIGH_CONTRAST_THEME);
interfaceSettings.set_string(KEY_ICON_THEME, HIGH_CONTRAST_THEME);
@@ -185,22 +187,22 @@ var ATIndicator = new Lang.Class({
return highContrast;
},
_buildFontItem() {
_buildFontItem: function() {
let settings = new Gio.Settings({ schema_id: DESKTOP_INTERFACE_SCHEMA });
settings.connect('changed::' + KEY_TEXT_SCALING_FACTOR, () => {
settings.connect('changed::' + KEY_TEXT_SCALING_FACTOR, Lang.bind(this, function() {
let factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
let active = (factor > 1.0);
widget.setToggleState(active);
this._queueSyncMenuVisibility();
});
}));
let factor = settings.get_double(KEY_TEXT_SCALING_FACTOR);
let initial_setting = (factor > 1.0);
let widget = this._buildItemExtended(_("Large Text"),
initial_setting,
settings.is_writable(KEY_TEXT_SCALING_FACTOR),
enabled => {
function (enabled) {
if (enabled)
settings.set_double(KEY_TEXT_SCALING_FACTOR,
DPI_FACTOR_LARGE);

View File

@@ -27,7 +27,7 @@ var Indicator = new Lang.Class({
Name: 'BTIndicator',
Extends: PanelMenu.SystemIndicator,
_init() {
_init: function() {
this.parent();
this._indicator = this._addIndicator();
@@ -35,23 +35,23 @@ var Indicator = new Lang.Class({
this._hadSetupDevices = global.settings.get_boolean(HAD_BLUETOOTH_DEVICES_SETUP);
this._proxy = new RfkillManagerProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
(proxy, error) => {
Lang.bind(this, function(proxy, error) {
if (error) {
log(error.message);
return;
}
this._sync();
});
this._proxy.connect('g-properties-changed', this._sync.bind(this));
}));
this._proxy.connect('g-properties-changed', Lang.bind(this, this._sync));
this._item = new PopupMenu.PopupSubMenuMenuItem(_("Bluetooth"), true);
this._item.icon.icon_name = 'bluetooth-active-symbolic';
this._toggleItem = new PopupMenu.PopupMenuItem('');
this._toggleItem.connect('activate', () => {
this._toggleItem.connect('activate', Lang.bind(this, function() {
this._proxy.BluetoothAirplaneMode = !this._proxy.BluetoothAirplaneMode;
});
}));
this._item.menu.addMenuItem(this._toggleItem);
this._item.menu.addSettingsAction(_("Bluetooth Settings"), 'gnome-bluetooth-panel.desktop');
@@ -59,14 +59,14 @@ var Indicator = new Lang.Class({
this._client = new GnomeBluetooth.Client();
this._model = this._client.get_model();
this._model.connect('row-changed', this._sync.bind(this));
this._model.connect('row-deleted', this._sync.bind(this));
this._model.connect('row-inserted', this._sync.bind(this));
Main.sessionMode.connect('updated', this._sync.bind(this));
this._model.connect('row-changed', Lang.bind(this, this._sync));
this._model.connect('row-deleted', Lang.bind(this, this._sync));
this._model.connect('row-inserted', Lang.bind(this, this._sync));
Main.sessionMode.connect('updated', Lang.bind(this, this._sync));
this._sync();
},
_getDefaultAdapter() {
_getDefaultAdapter: function() {
let [ret, iter] = this._model.get_iter_first();
while (ret) {
let isDefault = this._model.get_value(iter,
@@ -87,7 +87,7 @@ var Indicator = new Lang.Class({
//
// nConnectedDevices is the number of devices connected to the default
// adapter if one exists and is powered, or -1 if it's not available.
_getNDevices() {
_getNDevices: function() {
let adapter = this._getDefaultAdapter();
if (!adapter)
return [ this._hadSetupDevices ? 1 : -1, -1 ];
@@ -118,7 +118,7 @@ var Indicator = new Lang.Class({
return [ nDevices, nConnectedDevices];
},
_sync() {
_sync: function() {
let [ nDevices, nConnectedDevices ] = this._getNDevices();
let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;

View File

@@ -23,45 +23,45 @@ var Indicator = new Lang.Class({
Name: 'BrightnessIndicator',
Extends: PanelMenu.SystemIndicator,
_init() {
_init: function() {
this.parent('display-brightness-symbolic');
this._proxy = new BrightnessProxy(Gio.DBus.session, BUS_NAME, OBJECT_PATH,
(proxy, error) => {
Lang.bind(this, function(proxy, error) {
if (error) {
log(error.message);
return;
}
this._proxy.connect('g-properties-changed', this._sync.bind(this));
this._proxy.connect('g-properties-changed', Lang.bind(this, this._sync));
this._sync();
});
}));
this._item = new PopupMenu.PopupBaseMenuItem({ activate: false });
this.menu.addMenuItem(this._item);
this._slider = new Slider.Slider(0);
this._slider.connect('value-changed', this._sliderChanged.bind(this));
this._slider.connect('value-changed', Lang.bind(this, this._sliderChanged));
this._slider.actor.accessible_name = _("Brightness");
let icon = new St.Icon({ icon_name: 'display-brightness-symbolic',
style_class: 'popup-menu-icon' });
this._item.actor.add(icon);
this._item.actor.add(this._slider.actor, { expand: true });
this._item.actor.connect('button-press-event', (actor, event) => {
this._item.actor.connect('button-press-event', Lang.bind(this, function(actor, event) {
return this._slider.startDragging(event);
});
this._item.actor.connect('key-press-event', (actor, event) => {
}));
this._item.actor.connect('key-press-event', Lang.bind(this, function(actor, event) {
return this._slider.onKeyPressEvent(actor, event);
});
}));
},
_sliderChanged(slider, value) {
_sliderChanged: function(slider, value) {
let percent = value * 100;
this._proxy.Brightness = percent;
},
_sync() {
_sync: function() {
let visible = this._proxy.Brightness >= 0;
this._item.actor.visible = visible;
if (visible)

View File

@@ -3,7 +3,6 @@
const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const IBus = imports.gi.IBus;
const Lang = imports.lang;
const Meta = imports.gi.Meta;
const Shell = imports.gi.Shell;
@@ -11,6 +10,7 @@ const Signals = imports.signals;
const St = imports.gi.St;
const Gettext = imports.gettext;
const IBus = imports.misc.ibusManager.IBus;
const IBusManager = imports.misc.ibusManager;
const KeyboardManager = imports.misc.keyboardManager;
const Main = imports.ui.main;
@@ -26,7 +26,7 @@ var LayoutMenuItem = new Lang.Class({
Name: 'LayoutMenuItem',
Extends: PopupMenu.PopupBaseMenuItem,
_init(displayName, shortName) {
_init: function(displayName, shortName) {
this.parent();
this.label = new St.Label({ text: displayName });
@@ -40,7 +40,7 @@ var LayoutMenuItem = new Lang.Class({
var InputSource = new Lang.Class({
Name: 'InputSource',
_init(type, id, displayName, shortName, index) {
_init: function(type, id, displayName, shortName, index) {
this.type = type;
this.id = id;
this.displayName = displayName;
@@ -61,11 +61,11 @@ var InputSource = new Lang.Class({
this.emit('changed');
},
activate(interactive) {
activate: function(interactive) {
this.emit('activate', !!interactive);
},
_getXkbId() {
_getXkbId: function() {
let engineDesc = IBusManager.getIBusManager().getEngineDesc(this.id);
if (!engineDesc)
return this.id;
@@ -82,7 +82,7 @@ var InputSourcePopup = new Lang.Class({
Name: 'InputSourcePopup',
Extends: SwitcherPopup.SwitcherPopup,
_init(items, action, actionBackward) {
_init: function(items, action, actionBackward) {
this.parent(items);
this._action = action;
@@ -91,7 +91,7 @@ var InputSourcePopup = new Lang.Class({
this._switcherList = new InputSourceSwitcher(this._items);
},
_keyPressHandler(keysym, action) {
_keyPressHandler: function(keysym, action) {
if (action == this._action)
this._select(this._next());
else if (action == this._actionBackward)
@@ -106,7 +106,7 @@ var InputSourcePopup = new Lang.Class({
return Clutter.EVENT_STOP;
},
_finish() {
_finish : function() {
this.parent();
this._items[this._selectedIndex].activate(true);
@@ -117,14 +117,14 @@ var InputSourceSwitcher = new Lang.Class({
Name: 'InputSourceSwitcher',
Extends: SwitcherPopup.SwitcherList,
_init(items) {
_init: function(items) {
this.parent(true);
for (let i = 0; i < items.length; i++)
this._addIcon(items[i]);
},
_addIcon(item) {
_addIcon: function(item) {
let box = new St.BoxLayout({ vertical: true });
let bin = new St.Bin({ style_class: 'input-source-switcher-symbol' });
@@ -143,15 +143,15 @@ var InputSourceSettings = new Lang.Class({
Name: 'InputSourceSettings',
Abstract: true,
_emitInputSourcesChanged() {
_emitInputSourcesChanged: function() {
this.emit('input-sources-changed');
},
_emitKeyboardOptionsChanged() {
_emitKeyboardOptionsChanged: function() {
this.emit('keyboard-options-changed');
},
_emitPerWindowChanged() {
_emitPerWindowChanged: function() {
this.emit('per-window-changed');
},
@@ -186,7 +186,7 @@ var InputSourceSystemSettings = new Lang.Class({
_BUS_IFACE: 'org.freedesktop.locale1',
_BUS_PROPS_IFACE: 'org.freedesktop.DBus.Properties',
_init() {
_init: function() {
this._layouts = '';
this._variants = '';
this._options = '';
@@ -199,17 +199,17 @@ var InputSourceSystemSettings = new Lang.Class({
this._BUS_PATH,
null,
Gio.DBusSignalFlags.NONE,
this._reload.bind(this));
Lang.bind(this, this._reload));
},
_reload() {
_reload: function() {
Gio.DBus.system.call(this._BUS_NAME,
this._BUS_PATH,
this._BUS_PROPS_IFACE,
'GetAll',
new GLib.Variant('(s)', [this._BUS_IFACE]),
null, Gio.DBusCallFlags.NONE, -1, null,
(conn, result) => {
Lang.bind(this, function(conn, result) {
let props;
try {
props = conn.call_finish(result).deep_unpack()[0];
@@ -231,7 +231,7 @@ var InputSourceSystemSettings = new Lang.Class({
this._options = options;
this._emitKeyboardOptionsChanged();
}
});
}));
},
get inputSources() {
@@ -263,14 +263,14 @@ var InputSourceSessionSettings = new Lang.Class({
_KEY_KEYBOARD_OPTIONS: 'xkb-options',
_KEY_PER_WINDOW: 'per-window',
_init() {
_init: function() {
this._settings = new Gio.Settings({ schema_id: this._DESKTOP_INPUT_SOURCES_SCHEMA });
this._settings.connect('changed::' + this._KEY_INPUT_SOURCES, this._emitInputSourcesChanged.bind(this));
this._settings.connect('changed::' + this._KEY_KEYBOARD_OPTIONS, this._emitKeyboardOptionsChanged.bind(this));
this._settings.connect('changed::' + this._KEY_PER_WINDOW, this._emitPerWindowChanged.bind(this));
this._settings.connect('changed::' + this._KEY_INPUT_SOURCES, Lang.bind(this, this._emitInputSourcesChanged));
this._settings.connect('changed::' + this._KEY_KEYBOARD_OPTIONS, Lang.bind(this, this._emitKeyboardOptionsChanged));
this._settings.connect('changed::' + this._KEY_PER_WINDOW, Lang.bind(this, this._emitPerWindowChanged));
},
_getSourcesList(key) {
_getSourcesList: function(key) {
let sourcesList = [];
let sources = this._settings.get_value(key);
let nSources = sources.n_children();
@@ -307,7 +307,7 @@ var InputSourceSessionSettings = new Lang.Class({
var InputSourceManager = new Lang.Class({
Name: 'InputSourceManager',
_init() {
_init: function() {
// All valid input sources currently in the gsettings
// KEY_INPUT_SOURCES list indexed by their index there
this._inputSources = {};
@@ -327,47 +327,47 @@ var InputSourceManager = new Lang.Class({
new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings" }),
Meta.KeyBindingFlags.NONE,
Shell.ActionMode.ALL,
this._switchInputSource.bind(this));
Lang.bind(this, this._switchInputSource));
this._keybindingActionBackward =
Main.wm.addKeybinding('switch-input-source-backward',
new Gio.Settings({ schema_id: "org.gnome.desktop.wm.keybindings" }),
Meta.KeyBindingFlags.IS_REVERSED,
Shell.ActionMode.ALL,
this._switchInputSource.bind(this));
Lang.bind(this, this._switchInputSource));
if (Main.sessionMode.isGreeter)
this._settings = new InputSourceSystemSettings();
else
this._settings = new InputSourceSessionSettings();
this._settings.connect('input-sources-changed', this._inputSourcesChanged.bind(this));
this._settings.connect('keyboard-options-changed', this._keyboardOptionsChanged.bind(this));
this._settings.connect('input-sources-changed', Lang.bind(this, this._inputSourcesChanged));
this._settings.connect('keyboard-options-changed', Lang.bind(this, this._keyboardOptionsChanged));
this._xkbInfo = KeyboardManager.getXkbInfo();
this._keyboardManager = KeyboardManager.getKeyboardManager();
this._ibusReady = false;
this._ibusManager = IBusManager.getIBusManager();
this._ibusManager.connect('ready', this._ibusReadyCallback.bind(this));
this._ibusManager.connect('properties-registered', this._ibusPropertiesRegistered.bind(this));
this._ibusManager.connect('property-updated', this._ibusPropertyUpdated.bind(this));
this._ibusManager.connect('set-content-type', this._ibusSetContentType.bind(this));
this._ibusManager.connect('ready', Lang.bind(this, this._ibusReadyCallback));
this._ibusManager.connect('properties-registered', Lang.bind(this, this._ibusPropertiesRegistered));
this._ibusManager.connect('property-updated', Lang.bind(this, this._ibusPropertyUpdated));
this._ibusManager.connect('set-content-type', Lang.bind(this, this._ibusSetContentType));
global.display.connect('modifiers-accelerator-activated', this._modifiersSwitcher.bind(this));
global.display.connect('modifiers-accelerator-activated', Lang.bind(this, this._modifiersSwitcher));
this._sourcesPerWindow = false;
this._focusWindowNotifyId = 0;
this._overviewShowingId = 0;
this._overviewHiddenId = 0;
this._settings.connect('per-window-changed', this._sourcesPerWindowChanged.bind(this));
this._settings.connect('per-window-changed', Lang.bind(this, this._sourcesPerWindowChanged));
this._sourcesPerWindowChanged();
this._disableIBus = false;
},
reload() {
reload: function() {
this._keyboardManager.setKeyboardOptions(this._settings.keyboardOptions);
this._inputSourcesChanged();
},
_ibusReadyCallback(im, ready) {
_ibusReadyCallback: function(im, ready) {
if (this._ibusReady == ready)
return;
@@ -376,7 +376,7 @@ var InputSourceManager = new Lang.Class({
this._inputSourcesChanged();
},
_modifiersSwitcher() {
_modifiersSwitcher: function() {
let sourceIndexes = Object.keys(this._inputSources);
if (sourceIndexes.length == 0) {
KeyboardManager.releaseKeyboard();
@@ -398,7 +398,7 @@ var InputSourceManager = new Lang.Class({
return true;
},
_switchInputSource(display, screen, window, binding) {
_switchInputSource: function(display, screen, window, binding) {
if (this._mruSources.length < 2)
return;
@@ -417,12 +417,12 @@ var InputSourceManager = new Lang.Class({
popup.destroy();
},
_keyboardOptionsChanged() {
_keyboardOptionsChanged: function() {
this._keyboardManager.setKeyboardOptions(this._settings.keyboardOptions);
this._keyboardManager.reapply();
},
_updateMruSettings() {
_updateMruSettings: function() {
// If IBus is not ready we don't have a full picture of all
// the available sources, so don't update the setting
if (!this._ibusReady)
@@ -441,7 +441,7 @@ var InputSourceManager = new Lang.Class({
this._settings.mruSources = sourcesList;
},
_currentInputSourceChanged(newSource) {
_currentInputSourceChanged: function(newSource) {
let oldSource;
[oldSource, this._currentSource] = [this._currentSource, newSource];
@@ -457,7 +457,7 @@ var InputSourceManager = new Lang.Class({
this._changePerWindowSource();
},
activateInputSource(is, interactive) {
activateInputSource: function(is, interactive) {
KeyboardManager.holdKeyboard();
this._keyboardManager.apply(is.xkbId);
@@ -480,12 +480,12 @@ var InputSourceManager = new Lang.Class({
this._updateMruSettings();
},
_updateMruSources() {
_updateMruSources: function() {
let sourcesList = [];
for (let i in this._inputSources)
sourcesList.push(this._inputSources[i]);
this._keyboardManager.setUserLayouts(sourcesList.map(x => x.xkbId));
this._keyboardManager.setUserLayouts(sourcesList.map(function(x) { return x.xkbId; }));
if (!this._disableIBus && this._mruSourcesBackup) {
this._mruSources = this._mruSourcesBackup;
@@ -525,7 +525,7 @@ var InputSourceManager = new Lang.Class({
this._mruSources = mruSources.concat(sourcesList);
},
_inputSourcesChanged() {
_inputSourcesChanged: function() {
let sources = this._settings.inputSources;
let nSources = sources.length;
@@ -578,7 +578,7 @@ var InputSourceManager = new Lang.Class({
infosList[i].displayName,
infosList[i].shortName,
i);
is.connect('activate', this.activateInputSource.bind(this));
is.connect('activate', Lang.bind(this, this.activateInputSource));
if (!(is.shortName in inputSourcesByShortName))
inputSourcesByShortName[is.shortName] = [];
@@ -610,7 +610,7 @@ var InputSourceManager = new Lang.Class({
this._ibusManager.preloadEngines(Object.keys(this._ibusSources));
},
_makeEngineShortName(engineDesc) {
_makeEngineShortName: function(engineDesc) {
let symbol = engineDesc.get_symbol();
if (symbol && symbol[0])
return symbol;
@@ -622,7 +622,7 @@ var InputSourceManager = new Lang.Class({
return String.fromCharCode(0x2328); // keyboard glyph
},
_ibusPropertiesRegistered(im, engineName, props) {
_ibusPropertiesRegistered: function(im, engineName, props) {
let source = this._ibusSources[engineName];
if (!source)
return;
@@ -633,7 +633,7 @@ var InputSourceManager = new Lang.Class({
this.emit('current-source-changed', null);
},
_ibusPropertyUpdated(im, engineName, prop) {
_ibusPropertyUpdated: function(im, engineName, prop) {
let source = this._ibusSources[engineName];
if (!source)
return;
@@ -643,7 +643,7 @@ var InputSourceManager = new Lang.Class({
this.emit('current-source-changed', null);
},
_updateSubProperty(props, prop) {
_updateSubProperty: function(props, prop) {
if (!props)
return false;
@@ -660,7 +660,7 @@ var InputSourceManager = new Lang.Class({
return false;
},
_ibusSetContentType(im, purpose, hints) {
_ibusSetContentType: function(im, purpose, hints) {
if (purpose == IBus.InputPurpose.PASSWORD) {
if (Object.keys(this._inputSources).length == Object.keys(this._ibusSources).length)
return;
@@ -677,7 +677,7 @@ var InputSourceManager = new Lang.Class({
this.reload();
},
_getNewInputSource(current) {
_getNewInputSource: function(current) {
let sourceIndexes = Object.keys(this._inputSources);
if (sourceIndexes.length == 0)
return null;
@@ -694,14 +694,14 @@ var InputSourceManager = new Lang.Class({
return this._inputSources[sourceIndexes[0]];
},
_getCurrentWindow() {
_getCurrentWindow: function() {
if (Main.overview.visible)
return Main.overview;
else
return global.display.focus_window;
},
_setPerWindowInputSource() {
_setPerWindowInputSource: function() {
let window = this._getCurrentWindow();
if (!window)
return;
@@ -715,16 +715,16 @@ var InputSourceManager = new Lang.Class({
window._currentSource.activate(false);
},
_sourcesPerWindowChanged() {
_sourcesPerWindowChanged: function() {
this._sourcesPerWindow = this._settings.perWindow;
if (this._sourcesPerWindow && this._focusWindowNotifyId == 0) {
this._focusWindowNotifyId = global.display.connect('notify::focus-window',
this._setPerWindowInputSource.bind(this));
Lang.bind(this, this._setPerWindowInputSource));
this._overviewShowingId = Main.overview.connect('showing',
this._setPerWindowInputSource.bind(this));
Lang.bind(this, this._setPerWindowInputSource));
this._overviewHiddenId = Main.overview.connect('hidden',
this._setPerWindowInputSource.bind(this));
Lang.bind(this, this._setPerWindowInputSource));
} else if (!this._sourcesPerWindow && this._focusWindowNotifyId != 0) {
global.display.disconnect(this._focusWindowNotifyId);
this._focusWindowNotifyId = 0;
@@ -733,7 +733,9 @@ var InputSourceManager = new Lang.Class({
Main.overview.disconnect(this._overviewHiddenId);
this._overviewHiddenId = 0;
let windows = global.get_window_actors().map(w => w.meta_window);
let windows = global.get_window_actors().map(function(w) {
return w.meta_window;
});
for (let i = 0; i < windows.length; ++i) {
delete windows[i]._inputSources;
delete windows[i]._currentSource;
@@ -743,7 +745,7 @@ var InputSourceManager = new Lang.Class({
}
},
_changePerWindowSource() {
_changePerWindowSource: function() {
if (!this._sourcesPerWindow)
return;
@@ -777,16 +779,16 @@ var InputSourceIndicator = new Lang.Class({
Name: 'InputSourceIndicator',
Extends: PanelMenu.Button,
_init() {
_init: function() {
this.parent(0.0, _("Keyboard"));
this._menuItems = {};
this._indicatorLabels = {};
this._container = new Shell.GenericContainer();
this._container.connect('get-preferred-width', this._containerGetPreferredWidth.bind(this));
this._container.connect('get-preferred-height', this._containerGetPreferredHeight.bind(this));
this._container.connect('allocate', this._containerAllocate.bind(this));
this._container.connect('get-preferred-width', Lang.bind(this, this._containerGetPreferredWidth));
this._container.connect('get-preferred-height', Lang.bind(this, this._containerGetPreferredHeight));
this._container.connect('allocate', Lang.bind(this, this._containerAllocate));
this._hbox = new St.BoxLayout({ style_class: 'panel-status-menu-box' });
this._hbox.add_child(this._container);
@@ -801,18 +803,18 @@ var InputSourceIndicator = new Lang.Class({
this._propSection.actor.hide();
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), this._showLayout.bind(this));
this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, this._showLayout));
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
this._sessionUpdated();
this._inputSourceManager = getInputSourceManager();
this._inputSourceManager.connect('sources-changed', this._sourcesChanged.bind(this));
this._inputSourceManager.connect('current-source-changed', this._currentSourceChanged.bind(this));
this._inputSourceManager.connect('sources-changed', Lang.bind(this, this._sourcesChanged));
this._inputSourceManager.connect('current-source-changed', Lang.bind(this, this._currentSourceChanged));
this._inputSourceManager.reload();
},
_sessionUpdated() {
_sessionUpdated: function() {
// re-using "allowSettings" for the keyboard layout is a bit shady,
// but at least for now it is used as "allow popping up windows
// from shell menus"; we can always add a separate sessionMode
@@ -820,7 +822,7 @@ var InputSourceIndicator = new Lang.Class({
this._showLayoutItem.actor.visible = Main.sessionMode.allowSettings;
},
_sourcesChanged() {
_sourcesChanged: function() {
for (let i in this._menuItems)
this._menuItems[i].destroy();
for (let i in this._indicatorLabels)
@@ -834,14 +836,16 @@ var InputSourceIndicator = new Lang.Class({
let is = this._inputSourceManager.inputSources[i];
let menuItem = new LayoutMenuItem(is.displayName, is.shortName);
menuItem.connect('activate', () => { is.activate(true); });
menuItem.connect('activate', function() {
is.activate(true);
});
let indicatorLabel = new St.Label({ text: is.shortName,
visible: false });
this._menuItems[i] = menuItem;
this._indicatorLabels[i] = indicatorLabel;
is.connect('changed', () => {
is.connect('changed', function() {
menuItem.indicator.set_text(is.shortName);
indicatorLabel.set_text(is.shortName);
});
@@ -851,7 +855,7 @@ var InputSourceIndicator = new Lang.Class({
}
},
_currentSourceChanged(manager, oldSource) {
_currentSourceChanged: function(manager, oldSource) {
let nVisibleSources = Object.keys(this._inputSourceManager.inputSources).length;
let newSource = this._inputSourceManager.currentSource;
@@ -880,7 +884,7 @@ var InputSourceIndicator = new Lang.Class({
this._indicatorLabels[newSource.index].show();
},
_buildPropSection(properties) {
_buildPropSection: function(properties) {
this._propSeparator.actor.hide();
this._propSection.actor.hide();
this._propSection.removeAll();
@@ -893,7 +897,7 @@ var InputSourceIndicator = new Lang.Class({
}
},
_buildPropSubMenu(menu, props) {
_buildPropSubMenu: function(menu, props) {
if (!props)
return;
@@ -935,7 +939,7 @@ var InputSourceIndicator = new Lang.Class({
item.radioGroup = radioGroup;
item.setOrnament(prop.get_state() == IBus.PropState.CHECKED ?
PopupMenu.Ornament.DOT : PopupMenu.Ornament.NONE);
item.connect('activate', () => {
item.connect('activate', Lang.bind(this, function() {
if (item.prop.get_state() == IBus.PropState.CHECKED)
return;
@@ -953,13 +957,13 @@ var InputSourceIndicator = new Lang.Class({
IBus.PropState.UNCHECKED);
}
}
});
}));
break;
case IBus.PropType.TOGGLE:
item = new PopupMenu.PopupSwitchMenuItem(prop.get_label().get_text(), prop.get_state() == IBus.PropState.CHECKED);
item.prop = prop;
item.connect('toggled', () => {
item.connect('toggled', Lang.bind(this, function() {
if (item.state) {
item.prop.set_state(IBus.PropState.CHECKED);
ibusManager.activateProperty(item.prop.get_key(),
@@ -969,16 +973,16 @@ var InputSourceIndicator = new Lang.Class({
ibusManager.activateProperty(item.prop.get_key(),
IBus.PropState.UNCHECKED);
}
});
}));
break;
case IBus.PropType.NORMAL:
item = new PopupMenu.PopupMenuItem(prop.get_label().get_text());
item.prop = prop;
item.connect('activate', () => {
item.connect('activate', Lang.bind(this, function() {
ibusManager.activateProperty(item.prop.get_key(),
item.prop.get_state());
});
}));
break;
case IBus.PropType.SEPARATOR:
@@ -995,7 +999,7 @@ var InputSourceIndicator = new Lang.Class({
}
},
_showLayout() {
_showLayout: function() {
Main.overview.hide();
let source = this._inputSourceManager.currentSource;
@@ -1022,7 +1026,7 @@ var InputSourceIndicator = new Lang.Class({
Util.spawn(['gkbd-keyboard-display', '-l', description]);
},
_containerGetPreferredWidth(container, for_height, alloc) {
_containerGetPreferredWidth: function(container, for_height, alloc) {
// Here, and in _containerGetPreferredHeight, we need to query
// for the height of all children, but we ignore the results
// for those we don't actually display.
@@ -1039,7 +1043,7 @@ var InputSourceIndicator = new Lang.Class({
alloc.natural_size = max_natural_width;
},
_containerGetPreferredHeight(container, for_width, alloc) {
_containerGetPreferredHeight: function(container, for_width, alloc) {
let max_min_height = 0, max_natural_height = 0;
for (let i in this._inputSourceManager.inputSources) {
@@ -1053,7 +1057,7 @@ var InputSourceIndicator = new Lang.Class({
alloc.natural_size = max_natural_height;
},
_containerAllocate(container, box, flags) {
_containerAllocate: function(container, box, flags) {
// translate box to (0, 0)
box.x2 -= box.x1;
box.x1 = 0;

View File

@@ -68,14 +68,14 @@ var Indicator = new Lang.Class({
Name: 'LocationIndicator',
Extends: PanelMenu.SystemIndicator,
_init() {
_init: function() {
this.parent();
this._settings = new Gio.Settings({ schema_id: LOCATION_SCHEMA });
this._settings.connect('changed::' + ENABLED,
this._onMaxAccuracyLevelChanged.bind(this));
Lang.bind(this, this._onMaxAccuracyLevelChanged));
this._settings.connect('changed::' + MAX_ACCURACY_LEVEL,
this._onMaxAccuracyLevelChanged.bind(this));
Lang.bind(this, this._onMaxAccuracyLevelChanged));
this._indicator = this._addIndicator();
this._indicator.icon_name = 'find-location-symbolic';
@@ -87,7 +87,7 @@ var Indicator = new Lang.Class({
this._agent.export(Gio.DBus.system, '/org/freedesktop/GeoClue2/Agent');
this._item.label.text = _("Location Enabled");
this._onOffAction = this._item.menu.addAction(_("Disable"), this._onOnOffAction.bind(this));
this._onOffAction = this._item.menu.addAction(_("Disable"), Lang.bind(this, this._onOnOffAction));
this._item.menu.addSettingsAction(_("Privacy Settings"), 'gnome-privacy-panel.desktop');
this.menu.addMenuItem(this._item);
@@ -95,9 +95,9 @@ var Indicator = new Lang.Class({
this._watchId = Gio.bus_watch_name(Gio.BusType.SYSTEM,
'org.freedesktop.GeoClue2',
0,
this._connectToGeoclue.bind(this),
this._onGeoclueVanished.bind(this));
Main.sessionMode.connect('updated', this._onSessionUpdated.bind(this));
Lang.bind(this, this._connectToGeoclue),
Lang.bind(this, this._onGeoclueVanished));
Main.sessionMode.connect('updated', Lang.bind(this, this._onSessionUpdated));
this._onSessionUpdated();
this._onMaxAccuracyLevelChanged();
this._connectToGeoclue();
@@ -108,7 +108,7 @@ var Indicator = new Lang.Class({
return this._getMaxAccuracyLevel();
},
AuthorizeAppAsync(params, invocation) {
AuthorizeAppAsync: function(params, invocation) {
let [desktopId, reqAccuracyLevel] = params;
let authorizer = new AppAuthorizer(desktopId,
@@ -116,14 +116,14 @@ var Indicator = new Lang.Class({
this._permStoreProxy,
this._getMaxAccuracyLevel());
authorizer.authorize(accuracyLevel => {
authorizer.authorize(Lang.bind(this, function(accuracyLevel) {
let ret = (accuracyLevel != GeoclueAccuracyLevel.NONE);
invocation.return_value(GLib.Variant.new('(bu)',
[ret, accuracyLevel]));
});
}));
},
_syncIndicator() {
_syncIndicator: function() {
if (this._managerProxy == null) {
this._indicator.visible = false;
this._item.actor.visible = false;
@@ -135,7 +135,7 @@ var Indicator = new Lang.Class({
this._updateMenuLabels();
},
_connectToGeoclue() {
_connectToGeoclue: function() {
if (this._managerProxy != null || this._connecting)
return false;
@@ -143,11 +143,11 @@ var Indicator = new Lang.Class({
new GeoclueManager(Gio.DBus.system,
'org.freedesktop.GeoClue2',
'/org/freedesktop/GeoClue2/Manager',
this._onManagerProxyReady.bind(this));
Lang.bind(this, this._onManagerProxyReady));
return true;
},
_onManagerProxyReady(proxy, error) {
_onManagerProxyReady: function(proxy, error) {
if (error != null) {
log(error.message);
this._connecting = false;
@@ -156,14 +156,14 @@ var Indicator = new Lang.Class({
this._managerProxy = proxy;
this._propertiesChangedId = this._managerProxy.connect('g-properties-changed',
this._onGeocluePropsChanged.bind(this));
Lang.bind(this, this._onGeocluePropsChanged));
this._syncIndicator();
this._managerProxy.AddAgentRemote('gnome-shell', this._onAgentRegistered.bind(this));
this._managerProxy.AddAgentRemote('gnome-shell', Lang.bind(this, this._onAgentRegistered));
},
_onAgentRegistered(result, error) {
_onAgentRegistered: function(result, error) {
this._connecting = false;
this._notifyMaxAccuracyLevel();
@@ -171,7 +171,7 @@ var Indicator = new Lang.Class({
log(error.message);
},
_onGeoclueVanished() {
_onGeoclueVanished: function() {
if (this._propertiesChangedId) {
this._managerProxy.disconnect(this._propertiesChangedId);
this._propertiesChangedId = 0;
@@ -181,17 +181,17 @@ var Indicator = new Lang.Class({
this._syncIndicator();
},
_onOnOffAction() {
_onOnOffAction: function() {
let enabled = this._settings.get_boolean(ENABLED);
this._settings.set_boolean(ENABLED, !enabled);
},
_onSessionUpdated() {
_onSessionUpdated: function() {
let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;
this.menu.setSensitive(sensitive);
},
_updateMenuLabels() {
_updateMenuLabels: function() {
if (this._settings.get_boolean(ENABLED)) {
this._item.label.text = this._indicator.visible ? _("Location In Use")
: _("Location Enabled");
@@ -202,7 +202,7 @@ var Indicator = new Lang.Class({
}
},
_onMaxAccuracyLevelChanged() {
_onMaxAccuracyLevelChanged: function() {
this._updateMenuLabels();
// Gotta ensure geoclue is up and we are registered as agent to it
@@ -211,7 +211,7 @@ var Indicator = new Lang.Class({
this._notifyMaxAccuracyLevel();
},
_getMaxAccuracyLevel() {
_getMaxAccuracyLevel: function() {
if (this._settings.get_boolean(ENABLED)) {
let level = this._settings.get_string(MAX_ACCURACY_LEVEL);
@@ -222,23 +222,23 @@ var Indicator = new Lang.Class({
}
},
_notifyMaxAccuracyLevel() {
_notifyMaxAccuracyLevel: function() {
let variant = new GLib.Variant('u', this._getMaxAccuracyLevel());
this._agent.emit_property_changed('MaxAccuracyLevel', variant);
},
_onGeocluePropsChanged(proxy, properties) {
_onGeocluePropsChanged: function(proxy, properties) {
let unpacked = properties.deep_unpack();
if ("InUse" in unpacked)
this._syncIndicator();
},
_connectToPermissionStore() {
_connectToPermissionStore: function() {
this._permStoreProxy = null;
new PermissionStore.PermissionStore(this._onPermStoreProxyReady.bind(this));
new PermissionStore.PermissionStore(Lang.bind(this, this._onPermStoreProxyReady), null);
},
_onPermStoreProxyReady(proxy, error) {
_onPermStoreProxyReady: function(proxy, error) {
if (error != null) {
log(error.message);
return;
@@ -255,7 +255,7 @@ function clamp(value, min, max) {
var AppAuthorizer = new Lang.Class({
Name: 'LocationAppAuthorizer',
_init(desktopId,
_init: function(desktopId,
reqAccuracyLevel,
permStoreProxy,
maxAccuracyLevel) {
@@ -268,7 +268,7 @@ var AppAuthorizer = new Lang.Class({
this._accuracyLevel = GeoclueAccuracyLevel.NONE;
},
authorize(onAuthDone) {
authorize: function(onAuthDone) {
this._onAuthDone = onAuthDone;
let appSystem = Shell.AppSystem.get_default();
@@ -281,10 +281,11 @@ var AppAuthorizer = new Lang.Class({
this._permStoreProxy.LookupRemote(APP_PERMISSIONS_TABLE,
APP_PERMISSIONS_ID,
this._onPermLookupDone.bind(this));
Lang.bind(this,
this._onPermLookupDone));
},
_onPermLookupDone(result, error) {
_onPermLookupDone: function(result, error) {
if (error != null) {
if (error.domain == Gio.DBusError) {
// Likely no xdg-app installed, just authorize the app
@@ -317,7 +318,7 @@ var AppAuthorizer = new Lang.Class({
}
},
_userAuthorizeApp() {
_userAuthorizeApp: function() {
let name = this._app.get_name();
let appInfo = this._app.get_app_info();
let reason = appInfo.get_locale_string("X-Geoclue-Reason");
@@ -325,21 +326,22 @@ var AppAuthorizer = new Lang.Class({
this._showAppAuthDialog(name, reason);
},
_showAppAuthDialog(name, reason) {
_showAppAuthDialog: function(name, reason) {
this._dialog = new GeolocationDialog(name,
reason,
this.reqAccuracyLevel);
let responseId = this._dialog.connect('response', (dialog, level) => {
this._dialog.disconnect(responseId);
this._accuracyLevel = level;
this._completeAuth();
});
let responseId = this._dialog.connect('response', Lang.bind(this,
function(dialog, level) {
this._dialog.disconnect(responseId);
this._accuracyLevel = level;
this._completeAuth();
}));
this._dialog.open();
},
_completeAuth() {
_completeAuth: function() {
if (this._accuracyLevel != GeoclueAccuracyLevel.NONE) {
this._accuracyLevel = clamp(this._accuracyLevel,
0,
@@ -350,7 +352,7 @@ var AppAuthorizer = new Lang.Class({
this._onAuthDone(this._accuracyLevel);
},
_saveToPermissionStore() {
_saveToPermissionStore: function() {
if (this._permStoreProxy == null)
return;
@@ -365,7 +367,7 @@ var AppAuthorizer = new Lang.Class({
APP_PERMISSIONS_ID,
this._permissions,
data,
(result, error) => {
function (result, error) {
if (error != null)
log(error.message);
});
@@ -376,7 +378,7 @@ var GeolocationDialog = new Lang.Class({
Name: 'GeolocationDialog',
Extends: ModalDialog.ModalDialog,
_init(name, subtitle, reqAccuracyLevel) {
_init: function(name, subtitle, reqAccuracyLevel) {
this.parent({ styleClass: 'geolocation-dialog' });
this.reqAccuracyLevel = reqAccuracyLevel;
@@ -391,20 +393,20 @@ var GeolocationDialog = new Lang.Class({
this.contentLayout.add_actor(content);
let button = this.addButton({ label: _("Deny Access"),
action: this._onDenyClicked.bind(this),
action: Lang.bind(this, this._onDenyClicked),
key: Clutter.KEY_Escape });
this.addButton({ label: _("Grant Access"),
action: this._onGrantClicked.bind(this) });
action: Lang.bind(this, this._onGrantClicked) });
this.setInitialKeyFocus(button);
},
_onGrantClicked() {
_onGrantClicked: function() {
this.emit('response', this.reqAccuracyLevel);
this.close();
},
_onDenyClicked() {
_onDenyClicked: function() {
this.emit('response', GeoclueAccuracyLevel.NONE);
this.close();
}

Some files were not shown because too many files have changed in this diff Show More