gtk-demo: Use a native filechooser in the words demo

This commit is contained in:
Matthias Clasen 2020-12-03 22:31:05 -05:00
parent d83554121f
commit 423b8209a1

View File

@ -142,11 +142,11 @@ load_file (GtkStringList *list,
} }
static void static void
open_response_cb (GtkWidget *dialog, open_response_cb (GtkNativeDialog *dialog,
int response, int response,
GtkStringList *stringlist) GtkStringList *stringlist)
{ {
gtk_widget_hide (dialog); gtk_native_dialog_hide (dialog);
if (response == GTK_RESPONSE_ACCEPT) if (response == GTK_RESPONSE_ACCEPT)
{ {
@ -157,27 +157,24 @@ open_response_cb (GtkWidget *dialog,
g_object_unref (file); g_object_unref (file);
} }
gtk_window_destroy (GTK_WINDOW (dialog)); gtk_native_dialog_destroy (dialog);
} }
static void static void
file_open_cb (GtkWidget *button, file_open_cb (GtkWidget *button,
GtkStringList *stringlist) GtkStringList *stringlist)
{ {
GtkWidget *dialog; GtkFileChooserNative *dialog;
dialog = gtk_file_chooser_dialog_new ("Open file", dialog = gtk_file_chooser_native_new ("Open file",
GTK_WINDOW (gtk_widget_get_root (button)), GTK_WINDOW (gtk_widget_get_root (button)),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_FILE_CHOOSER_ACTION_OPEN,
"_Cancel", GTK_RESPONSE_CANCEL, "_Load",
"_Load", GTK_RESPONSE_ACCEPT, "_Cancel");
NULL); gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), stringlist); g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), stringlist);
gtk_widget_show (dialog); gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
} }
GtkWidget * GtkWidget *