builder-tool Make preview closeable

This commit is contained in:
Timm Bäder 2020-05-18 14:02:32 +02:00
parent 20b906cee8
commit b92f4177aa

View File

@ -50,6 +50,17 @@ set_window_title (GtkWindow *window,
g_free (name);
}
static void
quit_cb (GtkWidget *widget,
gpointer user_data)
{
gboolean *is_done = user_data;
*is_done = TRUE;
g_main_context_wakeup (NULL);
}
static void
preview_file (const char *filename,
const char *id,
@ -59,6 +70,7 @@ preview_file (const char *filename,
GError *error = NULL;
GObject *object;
GtkWidget *window;
gboolean done = FALSE;
if (cssfile)
{
@ -144,8 +156,9 @@ preview_file (const char *filename,
}
gtk_window_present (GTK_WINDOW (window));
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
while (TRUE)
while (!done)
g_main_context_iteration (NULL, TRUE);
g_object_unref (builder);