MODULE test_platform ; (* m2-GTK4 test - the platform namespaces: Gdk, Gsk, libspelling and libpanel. Requires a display. libspelling/libpanel are optional. *) FROM GtkApplication IMPORT gtk_application_new; FROM Gio IMPORT g_application_run, g_application_quit; FROM GtkWindow IMPORT gtk_application_window_new, gtk_window_set_child, gtk_window_present; FROM GtkLabel IMPORT gtk_label_new; FROM GtkUtils IMPORT Connect; FROM GdkDisplay IMPORT gdk_display_get_default; FROM GskTransform IMPORT gsk_transform_new, gsk_transform_scale, gsk_transform_to_string; FROM SpellingFunctions IMPORT spelling_init; FROM SpellingChecker IMPORT spelling_checker_get_default; FROM PanelFunctions IMPORT panel_init, panel_get_major_version; FROM PanelActionMuxer IMPORT panel_action_muxer_new; FROM PanelFrame IMPORT panel_frame_new; FROM SYSTEM IMPORT ADDRESS, ADR; FROM libc IMPORT printf; CONST AppId = "org.example.m2gtk4.TestPlatform"; VAR app: ADDRESS; passed: BOOLEAN; failures: INTEGER; PROCEDURE Check (cond: BOOLEAN; what: ARRAY OF CHAR); BEGIN IF cond THEN printf(" ok - %s\n", what) ELSE printf(" NOT OK - %s\n", what); INC(failures) END END Check; PROCEDURE OnActivate (application: ADDRESS; data: ADDRESS); VAR window, label: ADDRESS; t, t2: ADDRESS; s: ADDRESS; sx, sy: SHORTREAL; BEGIN failures := 0; Check(gdk_display_get_default () # NIL, "GdkDisplay::get_default"); t := gsk_transform_new(); sx := 2.0; sy := 2.0; t2 := gsk_transform_scale (t, sx, sy); s := gsk_transform_to_string (t2); Check((t # NIL) AND (t2 # NIL) AND (s # NIL), "GskTransform scale/string"); panel_init(); Check(panel_get_major_version () >= 1, "libpanel version"); Check(panel_action_muxer_new () # NIL, "PanelActionMuxer"); Check(panel_frame_new () # NIL, "PanelFrame"); spelling_init(); Check(spelling_checker_get_default () # NIL, "SpellingChecker::get_default"); window := gtk_application_window_new(application); label := gtk_label_new("platform namespaces: Gdk / Gsk / libspelling / libpanel"); gtk_window_set_child(window, label); gtk_window_present(window); passed := (failures = 0); g_application_quit(application) END OnActivate; VAR rc: INTEGER; BEGIN passed := FALSE; failures := 0; app := gtk_application_new(AppId, 0); IF app = NIL THEN printf("test_platform: FAIL (no app)\n"); HALT(1) END; Connect(app, "activate", ADR(OnActivate), NIL); rc := g_application_run(app, 0, NIL); IF passed THEN printf("test_platform: PASS\n"); HALT(0) ELSE printf("test_platform: FAIL\n"); HALT(1) END END test_platform.