tests: Stop using the delete-event signal

We can use ::destroy in most cases.
This commit is contained in:
Matthias Clasen 2017-12-31 12:52:54 -05:00
parent e7bd666711
commit 67649763b6
29 changed files with 40 additions and 123 deletions

View File

@ -55,7 +55,7 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 20);
gtk_container_add (GTK_CONTAINER (window), box);

View File

@ -218,7 +218,7 @@ main (int argc, char **argv)
MAX (600, node_bounds.size.width),
MAX (500, node_bounds.size.height));
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);
gtk_main ();

View File

@ -66,8 +66,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, "delete-event",
G_CALLBACK (gtk_main_quit), test_window);
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), test_window);
gtk_window_set_resizable (GTK_WINDOW (test_window), FALSE);
@ -132,8 +131,7 @@ open_control_window (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Controls");
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit), window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box);
@ -232,8 +230,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, "delete-event",
G_CALLBACK (gtk_main_quit), test_window);
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_resizable (GTK_WINDOW (test_window), TRUE);
gtk_window_set_default_size (GTK_WINDOW (test_window), 500, 500);
@ -294,8 +291,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, "delete-event",
G_CALLBACK (gtk_main_quit), test_window);
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_window_set_resizable (GTK_WINDOW (test_window), TRUE);
@ -321,8 +317,7 @@ open_valigned_label_window (void)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (test_window, "delete-event",
G_CALLBACK (gtk_main_quit), test_window);
g_signal_connect (test_window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show (box);

View File

@ -221,8 +221,7 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (toplevel), grid);
gtk_widget_show (toplevel);
g_signal_connect (toplevel, "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_main ();

View File

@ -126,8 +126,7 @@ main (int argc,
#endif
gtk_widget_show (toplevel);
g_signal_connect (toplevel, "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_main ();

View File

@ -703,11 +703,9 @@ main (int argc, gchar *argv[])
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
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), "delete-event",
G_CALLBACK (gtk_false), NULL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), box);

View File

@ -88,7 +88,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), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
notebook = gtk_notebook_new ();
gtk_container_add (GTK_CONTAINER (window), notebook);

View File

@ -121,7 +121,7 @@ main (int argc,
gtk_init ();
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);

View File

@ -151,7 +151,7 @@ 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, "delete-event", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
gtk_widget_show (window);
gtk_main ();

View File

@ -445,13 +445,9 @@ create_calendar(void)
calendar_data.settings[i] = 0;
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, "delete-event",
G_CALLBACK (gtk_false),
NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);

View File

@ -28,7 +28,7 @@ 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, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);

View File

@ -41,17 +41,6 @@ static GOptionEntry entries[] = {
static gchar *gtk_src_dir = NULL;
static gboolean
delete_event_cb (GtkWidget *editor,
gint response,
gpointer user_data)
{
gtk_widget_hide (editor);
return TRUE;
}
static void
print_selected_path_clicked_cb (GtkWidget *button,
gpointer user_data)
@ -122,6 +111,7 @@ tests_button_clicked_cb (GtkButton *real_button,
GtkWidget *box, *button;
tests = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_hide_on_close (GTK_WINDOW (tests), TRUE);
gtk_window_set_title (GTK_WINDOW (tests),
"Tests - TestFileChooserButton");
gtk_window_set_transient_for (GTK_WINDOW (tests),
@ -155,7 +145,6 @@ tests_button_clicked_cb (GtkButton *real_button,
gtk_box_pack_start (GTK_BOX (box), button);
gtk_widget_show (button);
g_signal_connect (tests, "delete-event", G_CALLBACK (delete_event_cb), NULL);
g_object_set_data (user_data, "tests-dialog", tests);
}

View File

@ -635,8 +635,7 @@ main (int argc, char *argv[])
window = create_window ();
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit), window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);

View File

@ -73,8 +73,7 @@ main (int argc, char *argv[])
gtk_widget_show (window);
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (fontchooser, "notify::font",
G_CALLBACK (notify_font_cb), NULL);
g_signal_connect (fontchooser, "notify::preview-text",

View File

@ -111,8 +111,7 @@ main (int argc, char *argv[])
monospace_filter, NULL, NULL);
}
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_main ();

View File

@ -153,7 +153,7 @@ int main (int argc, char **argv)
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
g_signal_connect (window, "delete-event", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
vbox = GTK_BOX (gtk_box_new (GTK_ORIENTATION_VERTICAL, 5));
g_object_set (vbox, "margin", 12, NULL);

View File

@ -70,8 +70,7 @@ main (int argc,
gtk_widget_show (toplevel);
g_signal_connect (toplevel, "delete-event",
G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (toplevel, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_main ();

View File

@ -597,15 +597,6 @@ create_add_remove_buttons (GActionGroup *group,
#define BUS_NAME "org.gtk.TestMenus"
#define OBJ_PATH "/org/gtk/TestMenus"
static gboolean
on_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
gtk_main_quit ();
return TRUE;
}
int
main (int argc, char *argv[])
{
@ -639,7 +630,7 @@ main (int argc, char *argv[])
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "delete-event", G_CALLBACK(on_delete_event), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
gtk_container_add (GTK_CONTAINER (window), box);

View File

@ -1939,14 +1939,10 @@ create_listbox (GtkWidget *widget)
int i;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
gtk_window_set_display (GTK_WINDOW (window), display);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&window);
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_true),
NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
gtk_window_set_title (GTK_WINDOW (window), "listbox");
@ -2283,15 +2279,11 @@ create_menus (GtkWidget *widget)
GdkDisplay *display = gtk_widget_get_display (widget);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_hide_on_close (GTK_WINDOW (window), TRUE);
gtk_window_set_display (GTK_WINDOW (window), display);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed),
&window);
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_true),
NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
accel_group = gtk_accel_group_new ();
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
@ -7928,12 +7920,7 @@ create_main_window (void)
gtk_window_move (GTK_WINDOW (window), 50, 20);
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, "delete-event",
G_CALLBACK (gtk_false),
NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
box1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add (GTK_CONTAINER (window), box1);

View File

@ -831,24 +831,6 @@ create_window (void)
return window;
}
static gboolean
main_window_delete_cb (GtkWidget *widget, GdkEvent *event, gpointer user_data)
{
gsize i;
for (i = 0; i < G_N_ELEMENTS (interfaces); ++i)
{
if (interfaces[i].window)
gtk_widget_destroy (interfaces[i].window);
}
gtk_widget_destroy (widget);
gtk_main_quit ();
return TRUE;
}
int
main (int argc, char *argv[])
{
@ -858,8 +840,7 @@ main (int argc, char *argv[])
window = create_window ();
g_signal_connect (window, "delete-event",
G_CALLBACK (main_window_delete_cb), window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);

View File

@ -122,8 +122,7 @@ main (int argc, char *argv[])
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
g_object_unref (pixbuf);
gtk_container_add (GTK_CONTAINER (window), image);
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit), window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);
gtk_main ();
@ -149,8 +148,7 @@ main (int argc, char *argv[])
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
image = gtk_image_new ();
gtk_container_add (GTK_CONTAINER (window), image);
g_signal_connect (window, "delete-event",
G_CALLBACK (gtk_main_quit), window);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);
info = gtk_icon_theme_lookup_icon_for_scale (icon_theme, argv[3], size, scale, flags);

View File

@ -55,15 +55,6 @@ increase_level (gpointer data)
return G_SOURCE_CONTINUE;
}
static gboolean
window_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer _data)
{
gtk_main_quit ();
return FALSE;
}
static void
toggle (GtkSwitch *sw, GParamSpec *pspec, GtkLevelBar *bar)
{
@ -102,8 +93,7 @@ main (int argc, char *argv[])
gtk_widget_show (window);
g_signal_connect (window, "delete-event",
G_CALLBACK (window_delete_event), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
g_timeout_add (100, increase_level, bar);
gtk_main ();

View File

@ -334,7 +334,7 @@ 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, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);

View File

@ -149,7 +149,7 @@ 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, "delete-event", gtk_main_quit, NULL);
g_signal_connect (window, "destroy", gtk_main_quit, NULL);
gtk_widget_show (window);
gtk_main ();

View File

@ -18,7 +18,7 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (win), view);
gtk_widget_show (win);
g_signal_connect (win, "delete-event", G_CALLBACK (gtk_main_quit), win);
g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), win);
gtk_main ();

View File

@ -156,7 +156,7 @@ main (int argc, char *argv[])
gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1);
g_signal_connect (win, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (win);
gtk_main ();

View File

@ -175,7 +175,7 @@ main (int argc, char **argv)
/* Window and box */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
gtk_container_add (GTK_CONTAINER (window), vbox);

View File

@ -287,7 +287,7 @@ main()
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_container_add (GTK_CONTAINER (window), widget);
g_signal_connect (window, "delete-event", G_CALLBACK (gtk_main_quit), NULL);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show (window);

View File

@ -42,9 +42,7 @@ create_dark_popup (GtkWidget *parent)
gtk_window_set_decorated (GTK_WINDOW (popup), FALSE);
gtk_widget_set_size_request (popup, 100, 100);
gtk_window_set_resizable (GTK_WINDOW (popup), FALSE);
g_signal_connect (popup, "delete-event",
G_CALLBACK (gtk_true), NULL);
gtk_window_set_hide_on_close (GTK_WINDOW (popup), TRUE);
gtk_container_add (GTK_CONTAINER (popup), button);
g_signal_connect (button, "toggled",