mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
[864/906] examples: update to gtk3
This commit is contained in:
parent
7b031f648c
commit
14d4cc29b6
3 changed files with 59 additions and 44 deletions
|
@ -35,7 +35,7 @@
|
|||
|
||||
/* TODO: use video overlay in the proper way (like suggested in docs, see gtkvideooverlay example) */
|
||||
static gboolean
|
||||
expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
|
||||
expose_cb (GtkWidget * widget, gpointer data)
|
||||
{
|
||||
GstVideoOverlay *overlay =
|
||||
GST_VIDEO_OVERLAY (gst_bin_get_by_interface (GST_BIN (data),
|
||||
|
@ -69,7 +69,7 @@ apply_fx (GtkWidget * widget, gpointer data)
|
|||
(G_OBJECT (data)), "effect")
|
||||
)->enum_class;
|
||||
|
||||
fx = gtk_combo_box_get_active_text (GTK_COMBO_BOX (widget));
|
||||
fx = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (widget));
|
||||
g_print ("setting: %s - %s\n", fx, g_enum_get_value_by_nick (p_class,
|
||||
fx)->value_name);
|
||||
g_object_set (G_OBJECT (data), "effect", g_enum_get_value_by_nick (p_class,
|
||||
|
@ -190,34 +190,34 @@ main (gint argc, gchar * argv[])
|
|||
|
||||
gtk_widget_set_size_request (screen, 640, 480); // 500 x 376
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), screen, TRUE, TRUE, 0);
|
||||
|
||||
combo = gtk_combo_box_new_text ();
|
||||
combo = gtk_combo_box_text_new ();
|
||||
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "identity");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "mirror");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "squeeze");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "stretch");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "fisheye");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "twirl");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "bulge");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "tunnel");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "square");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "heat");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "xpro");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "lumaxpro");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "sepia");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "xray");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "sin");
|
||||
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "glow");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "identity");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "mirror");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "squeeze");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "stretch");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "fisheye");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "twirl");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "bulge");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "tunnel");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "square");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "heat");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "xpro");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "lumaxpro");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "sepia");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "xray");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "sin");
|
||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "glow");
|
||||
|
||||
g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (apply_fx), filter);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
||||
play = gtk_button_new_with_label ("PLAY");
|
||||
|
||||
|
@ -246,7 +246,7 @@ main (gint argc, gchar * argv[])
|
|||
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
g_signal_connect (screen, "expose-event", G_CALLBACK (expose_cb), pipeline);
|
||||
g_signal_connect (screen, "realize", G_CALLBACK (expose_cb), pipeline);
|
||||
|
||||
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
||||
if (ret == GST_STATE_CHANGE_FAILURE) {
|
||||
|
|
|
@ -72,7 +72,7 @@ message_cb (GstBus * bus, GstMessage * message, GstElement * pipeline)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
expose_cb (GtkWidget * widget, GdkEventExpose * event, GstElement * videosink)
|
||||
expose_cb (GtkWidget * widget, cairo_t * cr, GstElement * videosink)
|
||||
{
|
||||
gst_video_overlay_expose (GST_VIDEO_OVERLAY (videosink));
|
||||
return FALSE;
|
||||
|
@ -264,11 +264,11 @@ main (gint argc, gchar * argv[])
|
|||
|
||||
gtk_widget_set_size_request (screen, 640, 480); // 500 x 376
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (vbox), screen, TRUE, TRUE, 0);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
|
||||
play = gtk_button_new_with_label ("PLAY");
|
||||
|
||||
|
@ -307,7 +307,7 @@ main (gint argc, gchar * argv[])
|
|||
g_signal_connect (bus, "message::warning", G_CALLBACK (message_cb), pipeline);
|
||||
g_signal_connect (bus, "message::eos", G_CALLBACK (message_cb), pipeline);
|
||||
gst_object_unref (bus);
|
||||
g_signal_connect (screen, "expose-event", G_CALLBACK (expose_cb), sink);
|
||||
g_signal_connect (screen, "draw", G_CALLBACK (expose_cb), sink);
|
||||
|
||||
gtk_drag_dest_set (screen, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
|
||||
gtk_drag_dest_add_uri_targets (screen);
|
||||
|
|
|
@ -21,35 +21,50 @@
|
|||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <gst/gl/gl.h>
|
||||
#include "gstgtk.h"
|
||||
|
||||
#if defined(GDK_WINDOWING_WIN32)
|
||||
#if defined(GST_GL_HAVE_WINDOW_WIN32) && defined(GDK_WINDOWING_WIN32)
|
||||
#include <gdk/gdkwin32.h>
|
||||
#elif defined(GDK_WINDOWING_X11)
|
||||
#endif
|
||||
#if defined(GST_GL_HAVE_WINDOW_X11) && defined(GDK_WINDOWING_X11)
|
||||
#include <gdk/gdkx.h>
|
||||
#elif defined(GDK_WINDOWING_QUARTZ)
|
||||
#endif
|
||||
#if defined(GST_GL_HAVE_WINDOW_COCOA) && defined(GDK_WINDOWING_QUARTZ)
|
||||
#include <gdk/gdkquartz.h>
|
||||
#else
|
||||
#error unimplemented GTK backend
|
||||
#endif
|
||||
|
||||
|
||||
void
|
||||
gst_video_overlay_set_gtk_window (GstVideoOverlay * videooverlay,
|
||||
GtkWidget * window)
|
||||
GtkWidget * widget)
|
||||
{
|
||||
GdkWindow *window;
|
||||
GdkDisplay *display;
|
||||
const gchar *user_choice = g_getenv ("GST_GL_WINDOW");
|
||||
|
||||
#if defined(GDK_WINDOWING_WIN32)
|
||||
gst_video_overlay_set_window_handle (videooverlay,
|
||||
(guintptr) GDK_WINDOW_HWND (window->window));
|
||||
#elif defined(GDK_WINDOWING_QUARTZ)
|
||||
gst_video_overlay_set_window_handle (videooverlay,
|
||||
(guintptr) gdk_quartz_window_get_nswindow (window->window));
|
||||
#elif defined(GDK_WINDOWING_X11)
|
||||
gst_video_overlay_set_window_handle (videooverlay,
|
||||
GDK_WINDOW_XWINDOW (window->window));
|
||||
#else
|
||||
#error unimplemented GTK backend
|
||||
window = gtk_widget_get_window (widget);
|
||||
display = gdk_window_get_display (window);
|
||||
|
||||
#if defined(GST_GL_HAVE_WINDOW_WIN32) && defined(GDK_WINDOWING_WIN32)
|
||||
if (GDK_IS_WIN32_DISPLAY (display) && (!user_choice
|
||||
|| g_strcmp0 (user_choice, "win32") == 0)) {
|
||||
gst_video_overlay_set_window_handle (videooverlay,
|
||||
(guintptr) GDK_WINDOW_HWND (window));
|
||||
} else
|
||||
#endif
|
||||
|
||||
#if defined(GST_GL_HAVE_WINDOW_COCOA) && defined(GDK_WINDOWING_QUARTZ)
|
||||
if (GDK_IS_QUARTZ_DISPLAY (display) && (!user_choice
|
||||
|| g_strcmp0 (user_choice, "cocoa") == 0)) {
|
||||
gst_video_overlay_set_window_handle (videooverlay, (guintptr)
|
||||
gdk_quartz_window_get_nswindow (window));
|
||||
} else
|
||||
#endif
|
||||
#if defined(GST_GL_HAVE_WINDOW_X11) && defined(GDK_WINDOWING_X11)
|
||||
if (GDK_IS_X11_DISPLAY (display) && (!user_choice
|
||||
|| g_strcmp0 (user_choice, "x11") == 0)) {
|
||||
gst_video_overlay_set_window_handle (videooverlay, GDK_WINDOW_XID (window));
|
||||
} else
|
||||
#endif
|
||||
g_error ("Unsupported Gtk+ backend");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue