[gtk/matthiasc/for-master: 2/3] gtk-demo: Add a file filter for the video player




commit 091289a85d4826684673643cfec3a7c9b75f15e7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Aug 9 22:27:32 2020 -0400

    gtk-demo: Add a file filter for the video player
    
    We are only interested in video files here.

 demos/gtk-demo/video_player.c | 6 ++++++
 1 file changed, 6 insertions(+)
---
diff --git a/demos/gtk-demo/video_player.c b/demos/gtk-demo/video_player.c
index 1dd38645da..3dbbe4a592 100644
--- a/demos/gtk-demo/video_player.c
+++ b/demos/gtk-demo/video_player.c
@@ -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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]