cleanup: Use arrow notation for anonymous functions
Arrow notation is great, use it consistently through-out the code base to bind `this` to anonymous functions, replacing the more overbose Lang.bind(this, function() {}). https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/23
This commit is contained in:

committed by
Florian Müllner

parent
76f09b1e49
commit
213e38c2ef
@ -35,7 +35,7 @@ function test() {
|
||||
if (useCairo)
|
||||
obin.style = 'border: 3px solid green;';
|
||||
else
|
||||
obin.connect_after('paint', function(actor) {
|
||||
obin.connect_after('paint', actor => {
|
||||
Cogl.set_source_color4f(0, 1, 0, 1);
|
||||
|
||||
let geom = actor.get_allocation_geometry();
|
||||
|
@ -62,14 +62,14 @@ function test() {
|
||||
|
||||
resize_animated(label1);
|
||||
resize_animated(label2);
|
||||
Mainloop.timeout_add(DELAY, Lang.bind(this, function() {
|
||||
Mainloop.timeout_add(DELAY, () => {
|
||||
log(label1 + label1.get_size());
|
||||
resize_animated(label1);
|
||||
resize_animated(label2);
|
||||
return true;
|
||||
}));
|
||||
});
|
||||
|
||||
Mainloop.timeout_add(2 * DELAY, Lang.bind(this, function() {
|
||||
Mainloop.timeout_add(2 * DELAY, () => {
|
||||
iter += 1;
|
||||
iter %= shadowStyles.length;
|
||||
label1.set_style(get_css_style(shadowStyles[iter]));
|
||||
@ -77,7 +77,7 @@ function test() {
|
||||
label2.set_style(get_css_style(shadowStyles[iter]));
|
||||
label2.set_text(shadowStyles[iter]);
|
||||
return true;
|
||||
}));
|
||||
});
|
||||
|
||||
UI.main(stage);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ function main() {
|
||||
Gdk.set_program_class('test-gjsgapp');
|
||||
|
||||
let app = new Gtk.Application({ application_id: 'org.gnome.Shell.GtkApplicationTest' });
|
||||
app.connect('activate', function() {
|
||||
app.connect('activate', () => {
|
||||
print ("Activated");
|
||||
});
|
||||
|
||||
@ -95,11 +95,11 @@ function main() {
|
||||
|
||||
let window = null;
|
||||
|
||||
app.connect_after('startup', function(app) {
|
||||
app.connect_after('startup', app => {
|
||||
app.set_app_menu(menu);
|
||||
window = new Gtk.ApplicationWindow({ title: "Test Application", application: app });
|
||||
});
|
||||
app.connect('activate', function(app) {
|
||||
app.connect('activate', app => {
|
||||
window.present();
|
||||
});
|
||||
|
||||
|
@ -30,14 +30,14 @@ function test() {
|
||||
|
||||
button = new St.Button ({ label: 'Smaller', style_class: 'push-button' });
|
||||
hbox.add (button);
|
||||
button.connect('clicked', function() {
|
||||
button.connect('clicked', () => {
|
||||
size /= 1.2;
|
||||
update_size ();
|
||||
});
|
||||
|
||||
button = new St.Button ({ label: 'Bigger', style_class: 'push-button' });
|
||||
hbox.add (button);
|
||||
button.connect('clicked', function() {
|
||||
button.connect('clicked', () => {
|
||||
size *= 1.2;
|
||||
update_size ();
|
||||
});
|
||||
|
@ -321,8 +321,8 @@ function test() {
|
||||
scrollView.set_policy(Gtk.PolicyType[hpolicy.label], Gtk.PolicyType[vpolicy.label]);
|
||||
}
|
||||
|
||||
hpolicy.connect('clicked', function() { togglePolicy(hpolicy); });
|
||||
vpolicy.connect('clicked', function() { togglePolicy(vpolicy); });
|
||||
hpolicy.connect('clicked', () => { togglePolicy(hpolicy); });
|
||||
vpolicy.connect('clicked', () => { togglePolicy(vpolicy); });
|
||||
|
||||
let fadeBox = new St.BoxLayout({ vertical: false });
|
||||
mainBox.add(fadeBox);
|
||||
@ -361,7 +361,7 @@ function test() {
|
||||
scrollView.style += (button.label == 'Yes' ? 'padding: 10px;' : 'padding: 0;');
|
||||
}
|
||||
|
||||
paddingButton.connect('clicked', function() { togglePadding(paddingButton); });
|
||||
paddingButton.connect('clicked', () => { togglePadding(paddingButton); });
|
||||
|
||||
function toggleBorders(button) {
|
||||
switch(button.label) {
|
||||
@ -378,7 +378,7 @@ function test() {
|
||||
scrollView.style += (button.label == 'Yes' ? 'border: 2px solid red;' : 'border: 0;');
|
||||
}
|
||||
|
||||
borderButton.connect('clicked', function() { toggleBorders(borderButton); });
|
||||
borderButton.connect('clicked', () => { toggleBorders(borderButton); });
|
||||
|
||||
function toggleFade(button) {
|
||||
switch(button.label) {
|
||||
@ -392,7 +392,7 @@ function test() {
|
||||
scrollView.set_style_class_name(button.label == 'Yes' ? 'vfade' : '');
|
||||
}
|
||||
|
||||
vfade.connect('clicked', function() { toggleFade(vfade); });
|
||||
vfade.connect('clicked', () => { toggleFade(vfade); });
|
||||
toggleFade(vfade);
|
||||
|
||||
function toggleOverlay(button) {
|
||||
@ -407,7 +407,7 @@ function test() {
|
||||
scrollView.overlay_scrollbars = (button.label == 'Yes');
|
||||
}
|
||||
|
||||
overlay.connect('clicked', function() { toggleOverlay(overlay); });
|
||||
overlay.connect('clicked', () => { toggleOverlay(overlay); });
|
||||
|
||||
UI.main(stage);
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ function test() {
|
||||
let v = new St.ScrollView();
|
||||
vbox.add(v, { expand: true });
|
||||
|
||||
toggle.connect('notify::checked', function () {
|
||||
toggle.connect('notify::checked', () => {
|
||||
v.set_policy(toggle.checked ? Gtk.PolicyType.AUTOMATIC
|
||||
: Gtk.PolicyType.NEVER,
|
||||
Gtk.PolicyType.AUTOMATIC);
|
||||
|
@ -25,7 +25,7 @@ function init(stage) {
|
||||
|
||||
function main(stage) {
|
||||
stage.show();
|
||||
stage.connect('destroy', function() {
|
||||
stage.connect('destroy', () => {
|
||||
Clutter.main_quit();
|
||||
});
|
||||
Clutter.main();
|
||||
|
Reference in New Issue
Block a user