diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2020-04-30 15:32:38 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2020-05-12 13:45:15 +0100 |
commit | 2090dbb27d4dd3afc76bff4631e5b506c5ee0009 (patch) | |
tree | 484fe38b641ce184b73e8d937b953bee837ed5d2 /tests/testappchooser.c | |
parent | 96856527e643cc8fc48fb78f40485974efd6a5a8 (diff) | |
download | gtk+-2090dbb27d4dd3afc76bff4631e5b506c5ee0009.tar.gz |
tests: Remove gtk_dialog_run()
Either use the "response" signal for dialogs that are already modal, or
use an explicit nested loop for tests that rely on the response id being
available in sequence.
Diffstat (limited to 'tests/testappchooser.c')
-rw-r--r-- | tests/testappchooser.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/tests/testappchooser.c b/tests/testappchooser.c index 281f96e9bb..63ec9bfdee 100644 --- a/tests/testappchooser.c +++ b/tests/testappchooser.c @@ -126,11 +126,31 @@ display_dialog (void) } static void +on_open_response (GtkWidget *file_chooser, + int response) +{ + if (response == GTK_RESPONSE_ACCEPT) + { + char *path; + + file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (file_chooser)); + path = g_file_get_path (file); + + gtk_button_set_label (GTK_BUTTON (file_l), path); + + g_free (path); + } + + gtk_window_destroy (GTK_WINDOW (file_chooser)); + + gtk_widget_set_sensitive (open, TRUE); +} + +static void button_clicked (GtkButton *b, gpointer user_data) { GtkWidget *w; - gchar *path; w = gtk_file_chooser_dialog_new ("Select file", GTK_WINDOW (toplevel), @@ -139,16 +159,13 @@ button_clicked (GtkButton *b, "_Open", GTK_RESPONSE_ACCEPT, NULL); - gtk_dialog_run (GTK_DIALOG (w)); - file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (w)); - path = g_file_get_path (file); - gtk_button_set_label (GTK_BUTTON (file_l), path); - - gtk_window_destroy (GTK_WINDOW (w)); + gtk_window_set_modal (GTK_WINDOW (w), TRUE); - gtk_widget_set_sensitive (open, TRUE); + g_signal_connect (w, "response", + G_CALLBACK (on_open_response), + NULL); - g_free (path); + gtk_window_present (GTK_WINDOW (w)); } static void @@ -180,7 +197,7 @@ main (int argc, char **argv) w1, 0, 0, 1, 1); file_l = gtk_button_new (); - path = g_build_filename (g_get_current_dir (), "apple-red.png", NULL); + path = g_build_filename (GTK_SRCDIR, "apple-red.png", NULL); file = g_file_new_for_path (path); gtk_button_set_label (GTK_BUTTON (file_l), path); g_free (path); |