From fb927d5196eb5d5f09b2c29383e719a7d75726ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 8 Mar 2023 20:25:13 +0100 Subject: [PATCH] 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: --- tests/interactive/test-title.js | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/tests/interactive/test-title.js b/tests/interactive/test-title.js index 0a468ddd5..a147a3a29 100755 --- a/tests/interactive/test-title.js +++ b/tests/interactive/test-title.js @@ -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);