gtk-demo: Add a file filter for the video player

We are only interested in video files here.
This commit is contained in:
Matthias Clasen 2020-08-09 22:27:32 -04:00
parent 17710709f9
commit 091289a85d

View File

@ -31,6 +31,7 @@ open_clicked_cb (GtkWidget *button,
GtkWidget *video)
{
GtkWidget *dialog;
GtkFileFilter *filter;
dialog = gtk_file_chooser_dialog_new ("Select a video",
GTK_WINDOW (gtk_widget_get_root (button)),
@ -38,6 +39,11 @@ open_clicked_cb (GtkWidget *button,
"_Cancel", GTK_RESPONSE_CANCEL,
"_Open", GTK_RESPONSE_ACCEPT,
NULL);
filter = gtk_file_filter_new ();
gtk_file_filter_add_mime_type (filter, "video/*");
gtk_file_filter_set_name (filter, "Video");
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
g_object_unref (filter);
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_dialog_response_cb), video);