[gtk/matthiasc/gl-media-stream] fishbowl: Add a "video view" for comparison
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/gl-media-stream] fishbowl: Add a "video view" for comparison
- Date: Sat, 2 Jan 2021 15:02:38 +0000 (UTC)
commit bc9bc96049d479c9815d83cbf14142bd9e948a3f
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 2 10:01:50 2021 -0500
fishbowl: Add a "video view" for comparison
This is like the Video case, but uses a single
media stream with multiple views.
demos/gtk-demo/fishbowl.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
---
diff --git a/demos/gtk-demo/fishbowl.c b/demos/gtk-demo/fishbowl.c
index 4c596b9e48..96254029e7 100644
--- a/demos/gtk-demo/fishbowl.c
+++ b/demos/gtk-demo/fishbowl.c
@@ -146,6 +146,57 @@ create_video (void)
return w;
}
+static GtkMediaStream *view_stream;
+static int n_views;
+
+static void
+on_map_view (GtkWidget *w)
+{
+ if (n_views == 0)
+ {
+ GdkSurface *surface;
+
+ surface = gtk_native_get_surface (gtk_widget_get_native (w));
+
+ view_stream = gtk_media_file_new ();
+
+ gtk_media_stream_realize (view_stream, surface);
+ gtk_media_stream_set_loop (view_stream, TRUE);
+
+ gtk_media_file_set_resource (GTK_MEDIA_FILE (view_stream), "/images/gtk-logo.webm");
+
+ gtk_media_stream_play (view_stream);
+ }
+
+ gtk_picture_set_paintable (GTK_PICTURE (w), GDK_PAINTABLE (view_stream));
+ n_views++;
+}
+
+static void
+on_unrealize_view (GtkWidget *w)
+{
+ n_views--;
+
+ if (n_views == 0)
+ {
+ gtk_media_stream_pause (view_stream);
+ g_clear_object (&view_stream);
+ }
+}
+
+static GtkWidget *
+create_video_view (void)
+{
+ GtkWidget *w = gtk_picture_new ();
+
+ gtk_widget_set_size_request (w, 128, 128);
+
+ g_signal_connect_after (w, "map", G_CALLBACK (on_map_view), NULL);
+ g_signal_connect_after (w, "unrealize", G_CALLBACK (on_unrealize_view), NULL);
+
+ return w;
+}
+
static GtkWidget *
create_gears (void)
{
@@ -231,6 +282,7 @@ static const struct {
{ "Spinner", create_spinner },
{ "Spinbutton", create_spinbutton },
{ "Video", create_video },
+ { "Video View", create_video_view },
{ "Gears", create_gears },
{ "Switch", create_switch },
{ "Menubutton", create_menu_button },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]