gnome-shell/tests/interactive/test-title.js
Florian Müllner 66c86109dd tests: Fix a warning
Gjs now warns about excess parameters passed to functions, so don't
use Gtk.main_quit directly as signal callback.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/38
2018-02-21 14:30:30 +01:00

39 lines
660 B
JavaScript
Executable File

#!/usr/bin/env gjs
imports.gi.versions.Gtk = '3.0';
const Gtk = imports.gi.Gtk;
const Mainloop = imports.mainloop;
function nextTitle() {
let length = Math.random() * 20;
let str = '';
for (let i = 0; i < length; i++) {
// 97 == 'a'
str += String.fromCharCode(97 + Math.random() * 26);
}
return str;
}
function main() {
Gtk.init(null);
let win = new Gtk.Window({ title: nextTitle() });
win.connect('destroy', () => {
Gtk.main_quit();
});
win.present();
Mainloop.timeout_add(5000, function() {
win.title = nextTitle();
return true;
});
Gtk.main();
}
main();