[gtk/matthiasc/css-change-tracking-4: 7/20] node tests: Show the window



commit 66d8efca7ae6cee192519bf8f38f804dadc1a983
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jan 17 20:35:00 2020 -0500

    node tests: Show the window
    
    This avoids using default styles.

 testsuite/css/nodes/test-css-nodes.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/testsuite/css/nodes/test-css-nodes.c b/testsuite/css/nodes/test-css-nodes.c
index 54664c7d45..28bdfcb9b1 100644
--- a/testsuite/css/nodes/test-css-nodes.c
+++ b/testsuite/css/nodes/test-css-nodes.c
@@ -96,12 +96,23 @@ done:
   return diff;
 }
 
+static void
+style_context_changed (GtkWidget *window, const char **output)
+{
+  GtkStyleContext *context;
+
+  context = gtk_widget_get_style_context (window);
+
+  *output = gtk_style_context_to_string (context, GTK_STYLE_CONTEXT_PRINT_RECURSE);
+
+  g_main_context_wakeup (NULL);
+}
+
 static void
 load_ui_file (GFile *file, gboolean generate)
 {
   GtkBuilder *builder;
   GtkWidget *window;
-  GtkStyleContext *context;
   char *output, *diff;
   char *ui_file, *reference_file;
   GError *error = NULL;
@@ -118,9 +129,13 @@ load_ui_file (GFile *file, gboolean generate)
 
   g_assert (window != NULL);
 
-  context = gtk_widget_get_style_context (window);
+  output = NULL;
+  g_signal_connect (window, "map", G_CALLBACK (style_context_changed), &output);
+
+  gtk_widget_show (window);
 
-  output = gtk_style_context_to_string (context, GTK_STYLE_CONTEXT_PRINT_RECURSE);
+  while (!output)
+    g_main_context_iteration (NULL, FALSE);
 
   if (generate)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]