tests: Port to Gtk4

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>
This commit is contained in:
Florian Müllner 2023-03-08 20:25:13 +01:00 committed by Marge Bot
parent 99973f56fd
commit fb927d5196

View File

@ -1,8 +1,7 @@
#!/usr/bin/env gjs
imports.gi.versions.Gtk = '3.0';
const { GLib, Gtk } = imports.gi;
imports.gi.versions.Gtk = '4.0';
const {Gtk} = imports.gi;
function nextTitle() {
let length = Math.random() * 20;
@ -16,22 +15,14 @@ function nextTitle() {
return str;
}
function main() {
Gtk.init(null);
let win = new Gtk.Window({ title: nextTitle() });
win.connect('destroy', () => {
Gtk.main_quit();
const application = new Gtk.Application({application_id: 'org.gnome.TestTitle'});
application.connect('activate', () => {
const win = new Gtk.Window({
application,
title: nextTitle(),
});
win.present();
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 5000, function() {
win.title = nextTitle();
return true;
});
Gtk.main();
}
main();
setInterval(() => (win.title = nextTitle()), 5000);
});
application.run(null);