2013-06-29 23:24:22 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
const gchar *display_name;
|
|
|
|
GdkDisplay *display;
|
|
|
|
GtkWidget *win, *but;
|
2016-12-28 13:53:22 +00:00
|
|
|
gboolean has_display;
|
2013-06-29 23:24:22 +00:00
|
|
|
|
|
|
|
g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL);
|
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gdk_set_allowed_backends ("x11");
|
|
|
|
display_name = g_getenv ("DISPLAY");
|
|
|
|
g_unsetenv ("DISPLAY");
|
|
|
|
has_display = gtk_init_check ();
|
|
|
|
g_assert (!has_display);
|
2013-06-29 23:24:22 +00:00
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
display = gdk_display_open (display_name);
|
2013-06-29 23:24:22 +00:00
|
|
|
|
|
|
|
if (!display)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
gdk_display_manager_set_default_display (gdk_display_manager_get (), display);
|
|
|
|
|
2020-02-14 19:55:36 +00:00
|
|
|
win = gtk_window_new ();
|
2013-06-29 23:24:22 +00:00
|
|
|
|
|
|
|
but = gtk_button_new_with_label ("Try to Exit");
|
|
|
|
g_signal_connect_swapped (but, "clicked",
|
|
|
|
G_CALLBACK (gtk_widget_destroy), win);
|
|
|
|
gtk_container_add (GTK_CONTAINER (win), but);
|
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (win);
|
2013-06-29 23:24:22 +00:00
|
|
|
|
|
|
|
gtk_test_widget_wait_for_draw (win);
|
|
|
|
|
|
|
|
gdk_display_close (display);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|