summaryrefslogtreecommitdiffstats
path: root/tests/manual/xembed/gtk-container/gtk-container.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2022-07-04 13:31:25 +0200
committerLiang Qi <liang.qi@qt.io>2022-08-06 01:24:41 +0200
commitaef55501bccd52f63a84228cb2ee201ec4f5c301 (patch)
tree447b4434e082d944de62939af239fde0338fd412 /tests/manual/xembed/gtk-container/gtk-container.cpp
parent8e9fdfec0afc01f192b222af60c13955a63b594f (diff)
tests: replace gtk-embedder.py with a gtk3 app
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ø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/manual/xembed/gtk-container/gtk-container.cpp')
-rw-r--r--tests/manual/xembed/gtk-container/gtk-container.cpp43
1 files changed, 43 insertions, 0 deletions
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 <gtk/gtk.h>
+#include <gtk/gtkx.h>
+
+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;
+}