gtk-demo: Add some example videos

Add buttons to show the gtk-logo animation and
the Big Buck Bunny trailer.
This commit is contained in:
Matthias Clasen 2020-09-13 01:50:31 -04:00
parent 22257b124a
commit 52304fe7da
3 changed files with 46 additions and 4 deletions

BIN
demos/gtk-demo/bbb.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -196,6 +196,9 @@
<file>floppybuddy.gif</file>
<file>gtk-logo.webm</file>
</gresource>
<gresource prefix="/video-player">
<file>bbb.png</file>
</gresource>
<gresource prefix="/sources">
<file>application_demo.c</file>
<file>assistant.c</file>

View File

@ -39,6 +39,7 @@ 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");
@ -50,6 +51,28 @@ open_clicked_cb (GtkWidget *button,
gtk_widget_show (dialog);
}
static void
logo_clicked_cb (GtkWidget *button,
gpointer video)
{
GFile *file;
file = g_file_new_for_uri ("resource:///images/gtk-logo.webm");
gtk_video_set_file (GTK_VIDEO (video), file);
g_object_unref (file);
}
static void
bbb_clicked_cb (GtkWidget *button,
gpointer video)
{
GFile *file;
file = g_file_new_for_uri ("https://download.blender.org/peach/trailer/trailer_400p.ogg");
gtk_video_set_file (GTK_VIDEO (video), file);
g_object_unref (file);
}
static void
fullscreen_clicked_cb (GtkWidget *button,
gpointer unused)
@ -64,7 +87,8 @@ do_video_player (GtkWidget *do_widget)
{
GtkWidget *title;
GtkWidget *video;
GtkWidget *open_button;
GtkWidget *button;
GtkWidget *image;
GtkWidget *fullscreen_button;
if (!window)
@ -77,14 +101,29 @@ do_video_player (GtkWidget *do_widget)
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
video = gtk_video_new ();
gtk_video_set_autoplay (GTK_VIDEO (video), TRUE);
gtk_window_set_child (GTK_WINDOW (window), video);
title = gtk_header_bar_new ();
gtk_window_set_titlebar (GTK_WINDOW (window), title);
open_button = gtk_button_new_with_mnemonic ("_Open");
g_signal_connect (open_button, "clicked", G_CALLBACK (open_clicked_cb), video);
gtk_header_bar_pack_start (GTK_HEADER_BAR (title), open_button);
button = gtk_button_new_with_mnemonic ("_Open");
g_signal_connect (button, "clicked", G_CALLBACK (open_clicked_cb), video);
gtk_header_bar_pack_start (GTK_HEADER_BAR (title), button);
button = gtk_button_new ();
image = gtk_image_new_from_resource ("/cursors/images/gtk_logo_cursor.png");
gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
gtk_button_set_child (GTK_BUTTON (button), image);
g_signal_connect (button, "clicked", G_CALLBACK (logo_clicked_cb), video);
gtk_header_bar_pack_start (GTK_HEADER_BAR (title), button);
button = gtk_button_new ();
image = gtk_image_new_from_resource ("/video-player/bbb.png");
gtk_image_set_pixel_size (GTK_IMAGE (image), 24);
gtk_button_set_child (GTK_BUTTON (button), image);
g_signal_connect (button, "clicked", G_CALLBACK (bbb_clicked_cb), video);
gtk_header_bar_pack_start (GTK_HEADER_BAR (title), button);
fullscreen_button = gtk_button_new_from_icon_name ("view-fullscreen-symbolic");
g_signal_connect (fullscreen_button, "clicked", G_CALLBACK (fullscreen_clicked_cb), NULL);