[gtk/matthiasc/gl-media-stream: 18/19] gtk-demo: Make the fishbowl video use GL
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/gl-media-stream: 18/19] gtk-demo: Make the fishbowl video use GL
- Date: Mon, 4 Jan 2021 20:03:54 +0000 (UTC)
commit 60fc31a3860dc4740021fb66f151972bfd337a15
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 2 09:49:05 2021 -0500
gtk-demo: Make the fishbowl video use GL
This shows the careful orchestration that is needed
to set things up in the right order.
demos/gtk-demo/fishbowl.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 659318b7cd..4c596b9e48 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -116,16 +116,32 @@ create_label (void)
return w;
}
-static GtkWidget *
-create_video (void)
+static void
+on_map (GtkWidget *w)
{
- GtkMediaStream *stream = gtk_media_file_new_for_resource ("/images/gtk-logo.webm");
- GtkWidget *w = gtk_picture_new_for_paintable (GDK_PAINTABLE (stream));
+ GtkMediaStream *stream = gtk_media_file_new ();
+ GdkSurface *surface;
+
+ surface = gtk_native_get_surface (gtk_widget_get_native (w));
- gtk_widget_set_size_request (w, 64, 64);
+ gtk_media_stream_realize (stream, surface);
gtk_media_stream_set_loop (stream, TRUE);
+
+ gtk_media_file_set_resource (GTK_MEDIA_FILE (stream), "/images/gtk-logo.webm");
+
gtk_media_stream_play (stream);
- g_object_unref (stream);
+
+ gtk_picture_set_paintable (GTK_PICTURE (w), GDK_PAINTABLE (stream));
+}
+
+static GtkWidget *
+create_video (void)
+{
+ GtkWidget *w = gtk_picture_new ();
+
+ gtk_widget_set_size_request (w, 128, 128);
+
+ g_signal_connect_after (w, "map", G_CALLBACK (on_map), NULL);
return w;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]