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:
parent
99973f56fd
commit
fb927d5196
@ -1,8 +1,7 @@
|
|||||||
#!/usr/bin/env gjs
|
#!/usr/bin/env gjs
|
||||||
|
|
||||||
imports.gi.versions.Gtk = '3.0';
|
imports.gi.versions.Gtk = '4.0';
|
||||||
|
const {Gtk} = imports.gi;
|
||||||
const { GLib, Gtk } = imports.gi;
|
|
||||||
|
|
||||||
function nextTitle() {
|
function nextTitle() {
|
||||||
let length = Math.random() * 20;
|
let length = Math.random() * 20;
|
||||||
@ -16,22 +15,14 @@ function nextTitle() {
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function main() {
|
const application = new Gtk.Application({application_id: 'org.gnome.TestTitle'});
|
||||||
Gtk.init(null);
|
application.connect('activate', () => {
|
||||||
|
const win = new Gtk.Window({
|
||||||
let win = new Gtk.Window({ title: nextTitle() });
|
application,
|
||||||
win.connect('destroy', () => {
|
title: nextTitle(),
|
||||||
Gtk.main_quit();
|
|
||||||
});
|
});
|
||||||
win.present();
|
win.present();
|
||||||
|
|
||||||
GLib.timeout_add(GLib.PRIORITY_DEFAULT, 5000, function() {
|
setInterval(() => (win.title = nextTitle()), 5000);
|
||||||
win.title = nextTitle();
|
});
|
||||||
return true;
|
application.run(null);
|
||||||
});
|
|
||||||
|
|
||||||
Gtk.main();
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user