Stop using gtk_main and gtk_main_quit

Replace these calls with direct use of GMainContext api.
This commit is contained in:
Matthias Clasen 2020-02-09 22:24:47 -05:00
parent c789711652
commit a6c5466900
121 changed files with 1198 additions and 292 deletions

View File

@ -308,7 +308,8 @@ int main (int argc, char **argv)
toplevels = get_all_widgets ();
queue_show ();
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -87,7 +87,11 @@ quit_main_loop_callback (GtkWidget *widget,
GdkFrameClock *frame_clock,
gpointer user_data)
{
gtk_main_quit ();
gboolean *done = user_data;
*done = TRUE;
g_main_context_wakeup (NULL);
return G_SOURCE_REMOVE;
}
@ -108,6 +112,7 @@ void
gtk_test_widget_wait_for_draw (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
gboolean done = FALSE;
/* We can do this here because the whole tick procedure does not
* reenter the main loop. Otherwise we'd need to manually get the
@ -115,10 +120,11 @@ gtk_test_widget_wait_for_draw (GtkWidget *widget)
*/
gtk_widget_add_tick_callback (widget,
quit_main_loop_callback,
NULL,
&done,
NULL);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
}
static GType *all_registered_types = NULL;

View File

@ -143,7 +143,8 @@ preview_file (const char *filename,
gtk_window_present (GTK_WINDOW (window));
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
g_object_unref (builder);
}

View File

@ -160,6 +160,17 @@ static GOptionEntry options[] = {
{ NULL }
};
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main(int argc, char **argv)
{
@ -168,6 +179,7 @@ main(int argc, char **argv)
GdkDisplay *display;
GdkMonitor *monitor;
GdkRectangle monitor_bounds;
gboolean done = FALSE;
GOptionContext *context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
@ -194,7 +206,7 @@ main(int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), da);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
G_CALLBACK (quit_cb), NULL);
g_signal_connect (window, "map",
G_CALLBACK (on_map), NULL);
@ -206,7 +218,8 @@ main(int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -17,6 +17,17 @@ toggle_reveal (GtkRevealer *revealer)
gtk_revealer_set_reveal_child (revealer, !gtk_revealer_get_reveal_child (revealer));
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main(int argc, char **argv)
{
@ -24,6 +35,7 @@ main(int argc, char **argv)
GtkCssProvider *cssprovider;
GError *error = NULL;
guint x, y;
gboolean done = FALSE;
GOptionContext *context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
@ -38,7 +50,7 @@ main(int argc, char **argv)
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
frame_stats_ensure (GTK_WINDOW (window));
revealer = gtk_revealer_new ();
@ -70,7 +82,8 @@ main(int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -102,7 +102,7 @@ on_frame_clock_after_paint (GdkFrameClock *frame_clock,
variable_init (&frame_stats->latency);
if (frame_stats->num_stats == max_stats)
gtk_main_quit ();
exit (0);
}
frame_stats->frames_since_last_print++;

View File

@ -107,6 +107,17 @@ less_gears (GtkButton *button, gpointer data)
gtk_widget_destroy (gears);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -114,13 +125,14 @@ main (int argc, char *argv[])
*fps_label, *gears, *extra_hbox, *bbox, *overlay,
*revealer, *frame, *label, *scrolled, *popover;
int i;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_titlebar (GTK_WINDOW (window), g_object_new (GTK_TYPE_HEADER_BAR, "visible", TRUE, "title", "GdkGears", NULL));
gtk_window_set_default_size (GTK_WINDOW (window), 640, 640);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
overlay = gtk_overlay_new ();
g_object_set (overlay, "margin", 12, NULL);
@ -244,7 +256,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}

View File

@ -226,7 +226,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -34,6 +34,17 @@ on_draw (GtkDrawingArea *da,
cairo_stroke (cr);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -43,6 +54,7 @@ main (int argc, char **argv)
GtkWidget *scale;
GtkWidget *da;
GtkEventController *controller;
gboolean done = FALSE;
gtk_init ();
@ -71,10 +83,11 @@ main (int argc, char **argv)
gtk_widget_add_controller (da, controller);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -39,6 +39,17 @@ mode_changed (GtkComboBox *combo, GtkScrolledWindow *sw)
gtk_scrolled_window_set_overlay_scrolling (sw, active == 1);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -50,12 +61,13 @@ main (int argc, char *argv[])
GtkWidget *sb2;
GtkWidget *combo;
GtkAdjustment *adj;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
gtk_container_add (GTK_CONTAINER (window), box);
@ -92,7 +104,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -92,6 +92,17 @@ static GOptionEntry options[] = {
{ NULL }
};
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -101,6 +112,7 @@ main (int argc, char **argv)
GtkWidget *grid;
GError *error = NULL;
int i;
gboolean done = FALSE;
GOptionContext *context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
@ -142,8 +154,10 @@ main (int argc, char **argv)
gtk_widget_show (window);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
gtk_main ();
G_CALLBACK (quit_cb), &done);
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -119,6 +119,17 @@ deserialize_error_func (const GtkCssSection *section,
g_free (section_str);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -130,6 +141,7 @@ main (int argc, char **argv)
graphene_rect_t node_bounds;
GOptionContext *option_context;
GError *error = NULL;
gboolean done = FALSE;
option_context = g_option_context_new ("NODE-FILE [-o OUTPUT] [--compare]");
g_option_context_add_main_entries (option_context, options, NULL);
@ -223,9 +235,11 @@ main (int argc, char **argv)
MAX (600, node_bounds.size.width),
MAX (500, node_bounds.size.height));
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -25,17 +25,29 @@ hello (void)
g_print ("hello world\n");
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *button;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "hello world");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
button = gtk_button_new ();
gtk_button_set_label (GTK_BUTTON (button), "hello world");
@ -45,7 +57,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -63,7 +63,8 @@ main (int argc, char *argv[])
gtk_widget_show (win);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -128,7 +128,8 @@ main (gint argc, gchar **argv)
gtk_widget_show (dialog);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -30,6 +30,7 @@ enum {
TEST_WIDGET_LAST
};
static gboolean done = FALSE;
static GtkWidget *test_widgets[TEST_WIDGET_LAST];
static GtkWidget*
@ -57,6 +58,17 @@ create_button (void)
return gtk_button_new_with_label ("BUTTON!");
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
static void
open_test_window (void)
{
@ -66,7 +78,7 @@ open_test_window (void)
test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (test_window), "Tests");
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), test_window);
g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_resizable (GTK_WINDOW (test_window), FALSE);
@ -131,7 +143,7 @@ open_control_window (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Controls");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
@ -230,7 +242,7 @@ open_alignment_window (void)
test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (test_window), "Alignment");
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_resizable (GTK_WINDOW (test_window), TRUE);
gtk_window_set_default_size (GTK_WINDOW (test_window), 500, 500);
@ -291,7 +303,7 @@ open_margin_window (void)
test_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (test_window), "Margin");
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_resizable (GTK_WINDOW (test_window), TRUE);
@ -317,7 +329,7 @@ open_valigned_label_window (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (test_window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show (box);
@ -372,7 +384,8 @@ main (int argc, char *argv[])
open_margin_window ();
open_valigned_label_window ();
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -151,11 +151,23 @@ button_clicked (GtkButton *b,
g_free (path);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
GtkWidget *w1;
gchar *path;
gboolean done = FALSE;
gtk_init ();
@ -221,9 +233,10 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (toplevel), grid);
gtk_widget_show (toplevel);
g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (toplevel, "destroy", G_CALLBACK (quit_cb), &done);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}

View File

@ -60,11 +60,23 @@ action_cb (GtkAppChooserButton *b,
g_print ("Activated custom item %s\n", item_name);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc,
char **argv)
{
GtkWidget *w;
gboolean done = FALSE;
gtk_init ();
@ -126,9 +138,10 @@ main (int argc,
#endif
gtk_widget_show (toplevel);
g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (toplevel, "destroy", G_CALLBACK (quit_cb), &done);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}

View File

@ -690,11 +690,23 @@ struct {
{ "page-flipping assistant", create_page_flipping_assistant },
};
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, gchar *argv[])
{
GtkWidget *window, *box, *button;
gint i;
gboolean done = FALSE;
gtk_init ();
@ -704,7 +716,7 @@ main (int argc, gchar *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), box);
@ -721,7 +733,9 @@ main (int argc, gchar *argv[])
}
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -66,6 +66,17 @@ set_font_size (GtkWidget *widget, gint size)
gtk_style_context_add_class (gtk_widget_get_style_context (widget), class[size]);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc,
char **argv)
@ -75,6 +86,7 @@ main (int argc,
GtkAdjustment *adjustment;
int i, j;
GtkCssProvider *provider;
gboolean done = FALSE;
gtk_init ();
@ -88,7 +100,7 @@ main (int argc,
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (quit_cb), &done);
notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (window), notebook);
@ -380,7 +392,8 @@ main (int argc,
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -72,6 +72,17 @@ value_changed_cb2 (GtkRange *range,
g_free (text);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -79,11 +90,12 @@ main (int argc, char **argv)
GtkWidget *blur_box;
GtkWidget *scale;
GtkWidget *value_label;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
blur_box = g_object_new (gtk_blur_box_get_type (),
"orientation", GTK_ORIENTATION_VERTICAL,
@ -115,7 +127,9 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), blur_box);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -76,6 +76,16 @@ static const char *css =
"}"
;
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
@ -86,6 +96,7 @@ main (int argc, char **argv)
GtkWidget *bottom;
GtkWidget *w;
GtkCssProvider *provider;
gboolean done = FALSE;
gtk_init ();
@ -151,10 +162,11 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (box), top);
gtk_container_add (GTK_CONTAINER (box), bottom);
gtk_container_add (GTK_CONTAINER (window), box);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);
}

View File

@ -124,7 +124,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -115,7 +115,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -184,10 +184,22 @@ on_draw (GtkDrawingArea *darea,
cairo_surface_destroy (circles);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
GtkWidget *window, *darea;
gboolean done = FALSE;
gtk_init ();
@ -200,11 +212,12 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), darea);
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (darea), on_draw, NULL, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -163,6 +163,17 @@ create_frame (const char *caption,
return frame;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
static void
create_calendar(void)
{
@ -182,11 +193,12 @@ create_calendar(void)
{ "show-day-names", "Show Day Names", calendar },
{ "show-week-numbers", "Show Week Numbers", calendar },
};
gboolean done = FALSE;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
gtk_window_set_title (GTK_WINDOW (window), "GtkCalendar Example");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
@ -281,7 +293,7 @@ create_calendar(void)
gtk_widget_set_halign (bbox, GTK_ALIGN_END);
button = gtk_button_new_with_label ("Close");
g_signal_connect (button, "clicked", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (button, "clicked", G_CALLBACK (quit_cb), &done);
gtk_container_add (GTK_CONTAINER (bbox), button);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, DEF_PAD_SMALL);
@ -297,11 +309,11 @@ create_calendar(void)
gtk_window_set_default_widget (GTK_WINDOW (window), button);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 0);
g_signal_connect (window, "close-request", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "close-request", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main();
while (!done)
g_main_context_iteration (NULL, TRUE);
}

View File

@ -612,7 +612,8 @@ main (int argc, char *argv[])
focus_cell_area ();
background_area ();
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -246,6 +246,17 @@ create_tree (gboolean rtl)
return sw;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -253,12 +264,13 @@ main (int argc, char **argv)
GtkWidget *vbox;
GtkWidget *label;
GtkWidget *tree;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_container_add (GTK_CONTAINER (window), vbox);
@ -282,7 +294,9 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (vbox), tree);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -1,11 +1,23 @@
#include <gtk/gtk.h>
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *box;
GtkWidget *child;
gboolean done = FALSE;
gtk_init ();
@ -28,11 +40,12 @@ main (int argc, char *argv[])
gtk_label_set_ellipsize (GTK_LABEL (child), PANGO_ELLIPSIZE_END);
gtk_center_box_set_end_widget (GTK_CENTER_BOX (box), child);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -383,11 +383,23 @@ get_window_contents (GdkDisplay *display,
return box;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
GtkWidget *window;
GdkDisplay *alt_display;
gboolean done = FALSE;
gtk_init ();
@ -396,14 +408,15 @@ main (int argc, char **argv)
alt_display = gdk_display_get_default ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_container_add (GTK_CONTAINER (window),
get_window_contents (gtk_widget_get_display (window),
alt_display));
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -10,6 +10,8 @@ color_changed (GObject *o, GParamSpec *pspect, gpointer data)
color.red, color.green, color.blue, color.alpha);
}
static gboolean done = FALSE;
static void
dialog_response (GtkDialog *dialog, gint response)
{
@ -27,7 +29,9 @@ dialog_response (GtkDialog *dialog, gint response)
break;
}
gtk_main_quit ();
done = TRUE;
g_main_context_wakeup (NULL);
}
int
@ -96,7 +100,8 @@ main (int argc, char *argv[])
gtk_widget_show (dialog);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -53,7 +53,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -919,6 +919,17 @@ displayed_row_changed (GtkComboBox *combo,
gtk_tree_path_free (path);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -932,6 +943,7 @@ main (int argc, char **argv)
GtkCellArea *area;
gchar *text;
gint i;
gboolean done = FALSE;
gtk_init ();
@ -939,7 +951,7 @@ main (int argc, char **argv)
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
mainbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_container_add (GTK_CONTAINER (window), mainbox);
@ -1286,7 +1298,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -420,7 +420,8 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (vbox), button);
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -583,6 +583,17 @@ test_init (void)
g_setenv ("GTK_IM_MODULE_FILE", "../modules/input/immodules.cache", TRUE);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -598,6 +609,7 @@ main (int argc, char **argv)
GtkDragSource *source;
GdkContentFormats *targets;
GtkDropTarget *dest;
gboolean done = FALSE;
test_init ();
@ -605,7 +617,7 @@ main (int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
G_CALLBACK (quit_cb), &done);
grid = gtk_grid_new ();
@ -679,7 +691,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -443,7 +443,8 @@ main (int argc, char *Argv[])
gtk_grid_attach (GTK_GRID (grid), make_image ("dialog-information", CENTER), 1, 3, 1, 1);
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -392,7 +392,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -94,17 +94,29 @@ overlay_draw (GtkDrawingArea *da,
cairo_stroke (cr);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *vbox, *label;
GtkWidget *combo, *scale, *overlay, *da;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), vbox);
@ -141,7 +153,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -35,7 +35,8 @@ int main (int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -286,6 +286,17 @@ match_selected_cb (GtkEntryCompletion *completion,
return TRUE;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -295,11 +306,12 @@ main (int argc, char *argv[])
GtkEntryCompletion *completion;
GtkTreeModel *completion_model;
GtkCellRenderer *cell;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_container_add (GTK_CONTAINER (window), vbox);
@ -407,7 +419,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -74,6 +74,17 @@ icon_pressed_cb (GtkGesture *gesture,
g_print ("You clicked me!\n");
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -90,6 +101,7 @@ main (int argc, char **argv)
GIcon *icon;
GdkContentProvider *content;
GValue value = G_VALUE_INIT;
gboolean done = FALSE;
gtk_init ();
@ -97,7 +109,7 @@ main (int argc, char **argv)
gtk_window_set_title (GTK_WINDOW (window), "Gtk Entry Icons Test");
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit), NULL);
G_CALLBACK (quit_cb), &done);
grid = gtk_grid_new ();
gtk_container_add (GTK_CONTAINER (window), grid);
@ -284,7 +296,9 @@ main (int argc, char **argv)
gtk_css_provider_load_from_data (provider, cssdata, -1);
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
gtk_widget_show (window);
gtk_main();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -156,7 +156,8 @@ main (int argc, char *argv[])
create_box_window ();
create_grid_window ();
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -12,9 +12,13 @@ do_not_expand (GtkWidget *child, gpointer data)
}
static void
response_cb (GtkDialog *dialog, gint response_id)
response_cb (GtkDialog *dialog, gint response_id, gpointer data)
{
gtk_main_quit ();
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
@ -26,6 +30,7 @@ main (int argc, char *argv[])
GtkWidget *sw;
GtkWidget *tv;
GtkTextBuffer *buffer;
gboolean done = FALSE;
gtk_init ();
@ -71,11 +76,12 @@ main (int argc, char *argv[])
g_signal_connect (expander, "notify::expanded",
G_CALLBACK (expander_cb), dialog);
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), NULL);
g_signal_connect (dialog, "response", G_CALLBACK (response_cb), &done);
gtk_window_present (GTK_WINDOW (dialog));
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -70,8 +70,11 @@ print_selected (GtkFileChooser *chooser)
static void
response_cb (GtkDialog *dialog,
gint response_id)
gint response_id,
gpointer data)
{
gboolean *done = data;
if (response_id == GTK_RESPONSE_OK)
{
GSList *list;
@ -98,7 +101,9 @@ response_cb (GtkDialog *dialog,
else
g_print ("Dialog was closed\n");
gtk_main_quit ();
*done = TRUE;
g_main_context_wakeup (NULL);
}
static gboolean
@ -540,6 +545,7 @@ main (int argc, char **argv)
{ NULL }
};
GOptionContext *context;
gboolean done = FALSE;
context = g_option_context_new ("");
g_option_context_add_main_entries (context, options, NULL);
@ -615,7 +621,7 @@ main (int argc, char **argv)
g_signal_connect (dialog, "current-folder-changed",
G_CALLBACK (print_current_folder), NULL);
g_signal_connect (dialog, "response",
G_CALLBACK (response_cb), NULL);
G_CALLBACK (response_cb), &done);
g_signal_connect (dialog, "confirm-overwrite",
G_CALLBACK (confirm_overwrite_cb), NULL);
@ -768,7 +774,8 @@ main (int argc, char **argv)
* someone else destroys them. We explicitly destroy windows to catch leaks.
*/
g_object_ref (dialog);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (dialog);
g_object_unref (dialog);

View File

@ -242,6 +242,16 @@ add_new_filechooser_button (const gchar *mnemonic,
gtk_container_add (GTK_CONTAINER (hbox), button);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc,
@ -251,6 +261,7 @@ main (int argc,
GtkSizeGroup *label_group;
GOptionContext *context;
gchar *cwd;
gboolean done = FALSE;
context = g_option_context_new ("- test GtkFileChooserButton widget");
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
@ -269,7 +280,7 @@ main (int argc,
win = gtk_dialog_new_with_buttons ("TestFileChooserButton", NULL, 0,
"_Quit", GTK_RESPONSE_CLOSE, NULL);
g_signal_connect (win, "response", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (win, "response", G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 18);
g_object_set (vbox, "margin", 6, NULL);
@ -304,7 +315,8 @@ main (int argc,
gtk_widget_show (win);
gtk_window_present (GTK_WINDOW (win));
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -626,20 +626,33 @@ create_window (void)
return window;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
gboolean done = FALSE;
gtk_init ();
window = create_window ();
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -54,12 +54,24 @@ font_activated_cb (GtkFontChooser *chooser, const gchar *font_name, gpointer dat
g_debug ("font-activated: %s", font_name);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *box;
GtkWidget *fontchooser;
gboolean done = FALSE;
gtk_init ();
@ -73,7 +85,7 @@ main (int argc, char *argv[])
gtk_widget_show (window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
g_signal_connect (fontchooser, "notify::font",
G_CALLBACK (notify_font_cb), NULL);
g_signal_connect (fontchooser, "notify::preview-text",
@ -85,7 +97,8 @@ main (int argc, char *argv[])
gtk_font_chooser_set_preview_text (GTK_FONT_CHOOSER (fontchooser), "[user@host ~]$ &>>");
gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (fontchooser), FALSE);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -64,11 +64,23 @@ font_activated_cb (GtkFontChooser *chooser, const gchar *font_name, gpointer dat
g_debug ("font-activated: %s", font_name);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *font_button;
gboolean done = FALSE;
gtk_init ();
@ -111,9 +123,10 @@ main (int argc, char *argv[])
monospace_filter, NULL, NULL);
}
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -85,7 +85,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -124,6 +124,17 @@ draw_border_cb (GtkToggleButton *toggle_button, GtkFrame *frame)
gtk_frame_set_shadow_type (frame, shadow_type);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int main (int argc, char **argv)
{
GtkWidget *window, *widget;
@ -132,13 +143,14 @@ int main (int argc, char **argv)
GtkGrid *grid;
gfloat xalign;
gboolean draw_border;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 5));
g_object_set (vbox, "margin", 12, NULL);
@ -194,7 +206,8 @@ int main (int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -68,7 +68,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -136,13 +136,8 @@ int main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -19,6 +19,17 @@
#include <gtk/gtk.h>
#include <glib/gstdio.h>
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc,
char **argv)
@ -28,6 +39,7 @@ main (int argc,
GIcon *emblemed;
GEmblem *emblem;
gchar *str;
gboolean done = FALSE;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
@ -70,9 +82,10 @@ main (int argc,
gtk_widget_show (toplevel);
g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (toplevel, "destroy", G_CALLBACK (quit_cb), &done);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -391,11 +391,23 @@ create_axis_slider (int axis)
return box;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *box, *button, *controls;
int i;
gboolean done = FALSE;
gtk_init ();
@ -406,7 +418,7 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GtkGLArea - Triangle");
gtk_window_set_default_size (GTK_WINDOW (window), 400, 600);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, FALSE);
gtk_box_set_spacing (GTK_BOX (box), 6);
@ -438,7 +450,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}

View File

@ -3,17 +3,29 @@
#include "gtkgears.h"
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *fixed, *gears, *spinner;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Test GL/gtk inter-blending");
gtk_window_set_default_size (GTK_WINDOW (window), 250, 250);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
fixed = gtk_fixed_new ();
gtk_container_add (GTK_CONTAINER (window), fixed);
@ -75,7 +87,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}

View File

@ -597,6 +597,17 @@ create_add_remove_buttons (GActionGroup *group,
#define BUS_NAME "org.gtk.TestMenus"
#define OBJ_PATH "/org/gtk/TestMenus"
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -617,6 +628,7 @@ main (int argc, char *argv[])
{ NULL, }
};
GOptionContext *context;
gboolean done = FALSE;
context = g_option_context_new ("");
g_option_context_add_main_entries (context, entries, NULL);
@ -630,7 +642,7 @@ main (int argc, char *argv[])
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), box);
@ -681,7 +693,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -471,7 +471,8 @@ main (int argc, char *argv[])
empty_grid ();
spanning_grid ();
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -53,6 +53,7 @@ main (int argc, char *argv[])
gtk_grid_attach (GTK_GRID (grid), label4, 1, 1, 1, 1);
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -97,6 +97,17 @@ tree_view_select_func (GtkTreeSelection *selection,
return FALSE;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -104,13 +115,14 @@ main (int argc, char **argv)
GtkTreeModel *model;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
gboolean done = FALSE;
gtk_init ();
model = create_model ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 320, 480);
sw = gtk_scrolled_window_new (NULL, NULL);
@ -148,7 +160,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -49,6 +49,8 @@
#include "test.xpm"
static gboolean done = FALSE;
gboolean
file_exists (const char *filename)
{
@ -1701,8 +1703,8 @@ create_key_lookup (GtkWidget *widget)
static gboolean
cmw_destroy_cb(GtkWidget *widget)
{
/* This is needed to get out of gtk_main */
gtk_main_quit ();
done = TRUE;
g_main_context_wakeup (NULL);
return FALSE;
}
@ -1724,7 +1726,8 @@ cmw_color (GtkWidget *widget, GtkWidget *parent)
/* wait until destroy calls gtk_main_quit */
gtk_widget_show (csd);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
}
static void
@ -1748,7 +1751,8 @@ cmw_file (GtkWidget *widget, GtkWidget *parent)
/* wait until destroy calls gtk_main_quit */
gtk_widget_show (fs);
gtk_main();
while (!done)
g_main_context_iteration (NULL, TRUE);
}
@ -1804,7 +1808,8 @@ create_modal_window (GtkWidget *widget)
gtk_widget_show (window);
/* wait until dialog get destroyed */
gtk_main();
while (!done)
g_main_context_iteration (NULL, TRUE);
}
/*
@ -5680,65 +5685,6 @@ create_timeout_test (GtkWidget *widget)
gtk_widget_destroy (window);
}
/*
* Test of recursive mainloop
*/
void
mainloop_destroyed (GtkWidget *w, GtkWidget **window)
{
*window = NULL;
gtk_main_quit ();
}
void
create_mainloop (GtkWidget *widget)
{
static GtkWidget *window = NULL;
GtkWidget *content_area;
GtkWidget *label;
if (!window)
{
window = gtk_dialog_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (widget));
gtk_window_set_title (GTK_WINDOW (window), "Test Main Loop");
g_signal_connect (window, "destroy",
G_CALLBACK (mainloop_destroyed),
&window);
content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
label = gtk_label_new ("In recursive main loop...");
g_object_set (label, "margin", 20, NULL);
gtk_container_add (GTK_CONTAINER (content_area), label);
gtk_widget_show (label);
gtk_dialog_add_button (GTK_DIALOG (window),
"Leave",
GTK_RESPONSE_OK);
g_signal_connect_swapped (window, "response",
G_CALLBACK (gtk_widget_destroy),
window);
}
if (!gtk_widget_get_visible (window))
{
gtk_widget_show (window);
g_print ("create_mainloop: start\n");
gtk_main ();
g_print ("create_mainloop: done\n");
}
else
gtk_widget_destroy (window);
}
static void
show_native (GtkWidget *button,
GtkFileChooserNative *native)
@ -6125,7 +6071,8 @@ void
do_exit (GtkWidget *widget, GtkWidget *window)
{
gtk_widget_destroy (window);
gtk_main_quit ();
done = TRUE;
g_main_context_wakeup (NULL);
}
struct {
@ -6164,7 +6111,6 @@ struct {
{ "size groups", create_size_groups },
{ "spinbutton", create_spins },
{ "statusbar", create_statusbar },
{ "test mainloop", create_mainloop, TRUE },
{ "test timeout", create_timeout_test },
{ "toggle buttons", create_toggle_buttons },
{ "tooltips", create_tooltips },
@ -6174,6 +6120,17 @@ struct {
};
int nbuttons = sizeof (buttons) / sizeof (buttons[0]);
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
void
create_main_window (void)
{
@ -6191,7 +6148,7 @@ create_main_window (void)
gtk_widget_set_name (window, "main_window");
gtk_window_set_default_size (GTK_WINDOW (window), -1, 400);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box1);
@ -6476,7 +6433,8 @@ main (int argc, char *argv[])
create_main_window ();
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
if (1)
{

View File

@ -70,6 +70,19 @@ toggle_fullscreen (GtkButton *button, gpointer data)
}
}
static gboolean done = FALSE;
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
static void
change_header (GtkButton *button, gpointer data)
{
@ -100,7 +113,7 @@ change_header (GtkButton *button, gpointer data)
widget = gtk_button_new_with_label ("_Close");
gtk_button_set_use_underline (GTK_BUTTON (widget), TRUE);
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "suggested-action");
g_signal_connect (widget, "clicked", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (widget, "clicked", G_CALLBACK (quit_cb), &done);
gtk_header_bar_pack_end (GTK_HEADER_BAR (header), widget);
@ -142,7 +155,6 @@ main (int argc, char *argv[])
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
content = gtk_image_new_from_icon_name ("start-here-symbolic");
gtk_image_set_pixel_size (GTK_IMAGE (content), 512);
@ -162,7 +174,8 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (box), footer);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);

View File

@ -830,20 +830,33 @@ create_window (void)
return window;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window;
gboolean done = FALSE;
gtk_init ();
window = create_window ();
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -32,6 +32,17 @@ usage (void)
);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -71,6 +82,7 @@ main (int argc, char *argv[])
{
GtkIconPaintable *icon;
GtkWidget *window, *image;
gboolean done = FALSE;
if (argc < 4)
{
@ -97,10 +109,11 @@ main (int argc, char *argv[])
gtk_image_set_from_paintable (GTK_IMAGE (image), GDK_PAINTABLE (icon));
g_object_unref (icon);
gtk_container_add (GTK_CONTAINER (window), image);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
}
else if (strcmp (argv[1], "list") == 0)
{

View File

@ -261,7 +261,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -588,7 +588,8 @@ main (gint argc, gchar **argv)
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -11,6 +11,19 @@ on_button_clicked (GtkWidget *widget, gpointer data)
g_print ("Button %d clicked\n", GPOINTER_TO_INT (data));
}
static gboolean done = FALSE;
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
static void
kinetic_scrolling (void)
{
@ -26,7 +39,7 @@ kinetic_scrolling (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
grid = gtk_grid_new ();
@ -136,7 +149,8 @@ main (int argc, char **argv)
kinetic_scrolling ();
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -64,6 +64,17 @@ toggle (GtkSwitch *sw, GParamSpec *pspec, GtkLevelBar *bar)
gtk_level_bar_set_mode (bar, GTK_LEVEL_BAR_MODE_CONTINUOUS);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -72,6 +83,7 @@ main (int argc, char *argv[])
GtkWidget *bar;
GtkWidget *box2;
GtkWidget *sw;
gboolean done = FALSE;
gtk_init ();
@ -93,10 +105,11 @@ main (int argc, char *argv[])
gtk_widget_show (window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
g_timeout_add (100, increase_level, bar);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -367,7 +367,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -95,11 +95,23 @@ create_row (const gchar *text)
return row;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int main (int argc, char *argv[])
{
GtkWidget *window, *list, *sw, *row;
gint i;
gchar *text;
gboolean done = FALSE;
gtk_init ();
@ -120,10 +132,11 @@ int main (int argc, char *argv[])
gtk_list_box_insert (GTK_LIST_BOX (list), row, -1);
}
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -196,7 +196,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -263,7 +263,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_widget_show (dialog);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -129,7 +129,8 @@ int main (int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -26,6 +26,7 @@ static gboolean dont_ask_domain = FALSE;
static gboolean dont_ask_password = FALSE;
static gboolean dont_save_password = FALSE;
static gboolean done = FALSE;
static void
got_reply (GMountOperation *op,
@ -87,7 +88,8 @@ got_reply (GMountOperation *op,
else if (G_MOUNT_OPERATION_UNHANDLED)
g_assert_not_reached ();
gtk_main_quit ();
done = TRUE;
g_main_context_wakeup (NULL);
}
int
@ -163,6 +165,7 @@ main (int argc, char *argv[])
flags);
}
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -43,7 +43,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -308,10 +308,22 @@ create_trash_button (void)
return button;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
gint
main (gint argc, gchar *argv[])
{
GtkWidget *window, *grid;
gboolean done = FALSE;
gtk_init ();
@ -341,11 +353,12 @@ main (gint argc, gchar *argv[])
gtk_container_add (GTK_CONTAINER (window), grid);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -43,6 +43,17 @@ orient_toggled (GtkToggleButton *button, gpointer user_data)
}
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -50,6 +61,7 @@ main (int argc, char **argv)
GtkWidget *grid;
GtkWidget *box, *button;
GList *orientables = NULL;
gboolean done = FALSE;
gtk_init ();
@ -83,9 +95,10 @@ main (int argc, char **argv)
gtk_widget_show (window);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
G_CALLBACK (quit_cb), &done);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -73,6 +73,16 @@ static const char *css =
""
;
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
@ -83,6 +93,7 @@ main (int argc, char **argv)
GtkWidget *bottom;
GtkWidget *w;
GtkCssProvider *provider;
gboolean done = FALSE;
gtk_init ();
@ -149,8 +160,9 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (box), top);
gtk_container_add (GTK_CONTAINER (box), bottom);
gtk_container_add (GTK_CONTAINER (window), box);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
}

View File

@ -529,7 +529,8 @@ main (int argc, char *argv[])
win8 = test_input_stacking ();
gtk_widget_show (win8);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -156,7 +156,8 @@ main (int argc, char *argv[])
gtk_widget_show (win);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -56,6 +56,17 @@ draw_func (GtkDrawingArea *darea,
g_object_unref (dest);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main(int argc, char **argv)
{
@ -66,6 +77,7 @@ main(int argc, char **argv)
GtkRequisition scratch_requisition;
const gchar *creator;
GError *error;
gboolean done = FALSE;
gtk_init ();
@ -89,7 +101,7 @@ main(int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_main_quit), NULL);
G_CALLBACK (quit_cb), &done);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
@ -141,7 +153,8 @@ main(int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -2,11 +2,23 @@
#define GTK_COMPILATION
#include "gtk/gtkplacesviewprivate.h"
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *win;
GtkWidget *view;
gboolean done = FALSE;
gtk_init ();
@ -18,9 +30,10 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (win), view);
gtk_widget_show (win);
g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), win);
g_signal_connect (win, "destroy", G_CALLBACK (quit_cb), &done);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -31,6 +31,17 @@ static GActionEntry entries[] = {
{ "action10", activate, NULL, NULL, NULL }
};
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -51,6 +62,7 @@ main (int argc, char *argv[])
GtkWidget *check;
GtkWidget *combo;
GtkWidget *header_bar;
gboolean done = FALSE;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
@ -167,10 +179,11 @@ main (int argc, char *argv[])
g_object_unref (builder);
g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (win, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (win);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -163,7 +163,8 @@ main (gint argc,
gtk_grid_attach (GTK_GRID (box), revealer, 3, 4, 1, 1);
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);

View File

@ -88,6 +88,17 @@ extra (GtkToggleButton *button)
}
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int main (int argc, char *argv[])
{
GtkWidget *window;
@ -113,12 +124,13 @@ int main (int argc, char *argv[])
gdouble pos_marks[4] = { 0.0, 33.3, 66.6, 100.0 };
const gchar *pos_labels[4] = { "Left", "Right", "Top", "Bottom" };
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Ranges with marks");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
flipbox = box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_widget_set_hexpand (flipbox, TRUE);
@ -228,7 +240,8 @@ int main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (box2), button);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -129,7 +129,8 @@ main (int argc, char *argv[])
gtk_widget_show (win);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -327,7 +327,8 @@ main (int argc, char *argv[])
scrollable_policy ();
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -213,7 +213,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -81,7 +81,8 @@ int main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -20,12 +20,17 @@
static gint num_windows = 0;
static gboolean done = FALSE;
static gboolean
on_delete (GtkWindow *w)
{
num_windows--;
if (num_windows == 0)
gtk_main_quit ();
{
done = TRUE;
g_main_context_wakeup (NULL);
}
return FALSE;
}
@ -76,7 +81,8 @@ main (int argc, char **argv)
prepare_window_for_orientation (GTK_ORIENTATION_HORIZONTAL);
prepare_window_for_orientation (GTK_ORIENTATION_VERTICAL);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -73,7 +73,8 @@ main (int argc, char *argv[])
G_BINDING_DEFAULT);
gtk_window_present (GTK_WINDOW (win));
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -257,7 +257,8 @@ main (gint argc,
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
gtk_widget_destroy (window);

View File

@ -39,7 +39,8 @@ main (int argc, char *argv[])
gtk_window_present (GTK_WINDOW (win));
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -147,17 +147,29 @@ make_delayed_switch (gboolean is_on,
return hbox;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *vbox, *hbox;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "GtkSwitch");
gtk_window_set_default_size (GTK_WINDOW (window), 400, -1);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_widget_show (window);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
@ -178,7 +190,8 @@ int main (int argc, char *argv[])
hbox = make_delayed_switch (FALSE, TRUE);
gtk_container_add (GTK_CONTAINER (vbox), hbox);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return EXIT_SUCCESS;
}

View File

@ -100,6 +100,17 @@ gtk_texture_view_class_init (GtkTextureViewClass *klass)
widget_class->snapshot = gtk_texture_view_snapshot;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char **argv)
{
@ -108,6 +119,7 @@ main (int argc, char **argv)
GdkTexture *texture;
GFile *file;
GError *error = NULL;
gboolean done = FALSE;
gtk_init ();
@ -127,15 +139,16 @@ main (int argc, char **argv)
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
view = g_object_new (GTK_TYPE_TEXTURE_VIEW, NULL);
((GtkTextureView*)view)->texture = g_steal_pointer (&texture);
gtk_container_add (GTK_CONTAINER (window), view);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
g_object_unref (file);

View File

@ -202,7 +202,8 @@ main (int argc, char **argv)
gtk_widget_show (window);
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -171,16 +171,28 @@ update_mark_position (void)
gtk_text_buffer_move_mark (buffer, the_mark, &iter);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
GtkWidget *window, *sw, *box, *box2, *button;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
@ -232,7 +244,8 @@ main (int argc, char *argv[])
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -34,7 +34,8 @@ int main (int argc, char *argv[])
gtk_widget_show (GTK_WIDGET (window));
gtk_main ();
while (TRUE)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -260,6 +260,17 @@ query_tooltip_label_cb (GtkWidget *widget,
return TRUE;
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -281,12 +292,13 @@ main (int argc, char *argv[])
GtkTextTag *tag;
gchar *text, *markup;
gboolean done = FALSE;
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Tooltips test");
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 3);
gtk_container_add (GTK_CONTAINER (window), box);
@ -436,7 +448,8 @@ main (int argc, char *argv[])
/* Done! */
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -464,6 +464,17 @@ setup_sanity_checks (GtkTreeView *treeview)
selection_changed_cb (gtk_tree_view_get_selection (treeview), NULL);
}
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc,
char **argv)
@ -473,6 +484,7 @@ main (int argc,
GtkWidget *treeview;
GtkTreeModel *model;
guint i;
gboolean done = FALSE;
gtk_init ();
@ -480,7 +492,7 @@ main (int argc,
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 430, 400);
sw = gtk_scrolled_window_new (NULL, NULL);
@ -509,7 +521,8 @@ main (int argc,
g_idle_add (dance, treeview);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

View File

@ -707,6 +707,17 @@ static const char *row_targets[] = {
"GTK_TREE_MODEL_ROW"
};
static void
quit_cb (GtkWidget *widget,
gpointer data)
{
gboolean *done = data;
*done = TRUE;
g_main_context_wakeup (NULL);
}
int
main (int argc, char *argv[])
{
@ -720,6 +731,7 @@ main (int argc, char *argv[])
GtkTreeModel *sample_model;
GdkContentFormats *targets;
gint i;
gboolean done = FALSE;
gtk_init ();
@ -744,7 +756,7 @@ main (int argc, char *argv[])
/* Set up the test windows. */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
gtk_window_set_title (GTK_WINDOW (window), "Top Window");
swindow = gtk_scrolled_window_new (NULL, NULL);
@ -753,7 +765,7 @@ main (int argc, char *argv[])
gtk_widget_show (window);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
gtk_window_set_title (GTK_WINDOW (window), "Bottom Window");
swindow = gtk_scrolled_window_new (NULL, NULL);
@ -763,7 +775,7 @@ main (int argc, char *argv[])
/* Set up the main window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
gtk_window_set_default_size (GTK_WINDOW (window), 500, 300);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
@ -897,7 +909,9 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (hbox), button);
gtk_widget_show (window);
gtk_main ();
while (!done)
g_main_context_iteration (NULL, TRUE);
return 0;
}

Some files were not shown because too many files have changed in this diff Show More