From aef55501bccd52f63a84228cb2ee201ec4f5c301 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Mon, 4 Jul 2022 13:31:25 +0200 Subject: tests: replace gtk-embedder.py with a gtk3 app MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All linux CI machines have gtk3 installed. And Python GTK things are too complicate to setup. Pick-to: 6.4 6.3 6.2 5.15 Change-Id: I3c0d967f61aebea508784df79569b9d0064f66e2 Reviewed-by: Tor Arne Vestbø --- .../manual/xembed/gtk-container/gtk-container.cpp | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/manual/xembed/gtk-container/gtk-container.cpp (limited to 'tests/manual/xembed/gtk-container/gtk-container.cpp') diff --git a/tests/manual/xembed/gtk-container/gtk-container.cpp b/tests/manual/xembed/gtk-container/gtk-container.cpp new file mode 100644 index 0000000000..41d88e8d51 --- /dev/null +++ b/tests/manual/xembed/gtk-container/gtk-container.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include +#include + +gchar *cmd; + +void launch_app(GtkButton */* btn */, guint32 *id) +{ + gchar *command = g_strdup_printf("%s %u", cmd, *id); + g_spawn_command_line_async(command, NULL); +} + +gint main(gint argc, gchar **argv) +{ + if (argc <=1 || argc > 2) { + g_print("No client application defined.\n"); + return 0; + } + + cmd = g_strdup_printf("%s", argv[1]); + + gtk_init(&argc, &argv); + + GtkWidget *win = gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget *vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + GtkWidget *sock = gtk_socket_new(); + GtkWidget *btn = gtk_button_new_with_label("Hello, World!"); + g_signal_connect(sock, "plug-removed", gtk_main_quit, NULL); + g_signal_connect(win, "delete-event", gtk_main_quit, NULL); + gtk_widget_set_size_request(sock, 200, 200); + gtk_box_pack_start(GTK_BOX(vbox), btn, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), sock, TRUE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(win), vbox); + gtk_widget_show_all(win); + + guint32 id = gtk_socket_get_id(GTK_SOCKET(sock)); + g_signal_connect(btn, "clicked", G_CALLBACK(launch_app), &id); + + gtk_main(); + return 0; +} -- cgit v1.2.3