fb927d5196
There's another remaining bit of Gtk3 code in a small test program that changes a window title to a random character sequence every five seconds. While the value of that test is a bit questionable, it doesn't hurt either and a port is trivial. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2733>
29 lines
621 B
JavaScript
Executable File
29 lines
621 B
JavaScript
Executable File
#!/usr/bin/env gjs
|
|
|
|
imports.gi.versions.Gtk = '4.0';
|
|
const {Gtk} = imports.gi;
|
|
|
|
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;
|
|
}
|
|
|
|
const application = new Gtk.Application({application_id: 'org.gnome.TestTitle'});
|
|
application.connect('activate', () => {
|
|
const win = new Gtk.Window({
|
|
application,
|
|
title: nextTitle(),
|
|
});
|
|
win.present();
|
|
|
|
setInterval(() => (win.title = nextTitle()), 5000);
|
|
});
|
|
application.run(null);
|