dnl GTK is optional and only used in examples
HAVE_GTK=no
HAVE_GTK_X11=no
-GTK2_REQ=2.14.0
-GTK3_REQ=2.91.3
+GTK_REQ=3.0.0
if test "x$BUILD_EXAMPLES" = "xyes"; then
- AC_MSG_CHECKING([which gtk+ version to compile examples against (optional)])
- AC_ARG_WITH([gtk],
- AC_HELP_STRING([--with-gtk=3.0|2.0],
- [which gtk+ version to compile against (default: 2.0)]),
- [case "$with_gtk" in
- 2.0) GTK_REQ=$GTK2_REQ ;;
- 3.0) GTK_REQ=$GTK3_REQ ;;
- *) AC_MSG_ERROR([invalid gtk+ version specified]);;
- esac],
- [with_gtk=2.0
- GTK_REQ=$GTK2_REQ])
- AC_MSG_RESULT([$with_gtk (>= $GTK_REQ)])
- PKG_CHECK_MODULES(GTK, gtk+-$with_gtk >= $GTK_REQ, HAVE_GTK=yes, HAVE_GTK=no)
+ PKG_CHECK_MODULES(GTK, gtk+-3.0 >= $GTK_REQ, HAVE_GTK=yes, HAVE_GTK=no)
dnl some examples need gtk+-x11
- PKG_CHECK_MODULES(GTK_X11, gtk+-x11-$with_gtk >= $GTK_REQ, HAVE_GTK_X11=yes, HAVE_GTK_X11=no)
+ PKG_CHECK_MODULES(GTK_X11, gtk+-x11-3.0 >= $GTK_REQ, HAVE_GTK_X11=yes, HAVE_GTK_X11=no)
AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_CFLAGS)
fi
GST_DEBUG_CATEGORY_STATIC (seek_debug);
#define GST_CAT_DEFAULT (seek_debug)
-#if (!GTK_CHECK_VERSION(2, 23, 0) || GTK_CHECK_VERSION(2, 90, 0)) && !GTK_CHECK_VERSION(2, 91, 1)
-#define gtk_combo_box_text_new gtk_combo_box_new_text
-#define gtk_combo_box_text_append_text gtk_combo_box_append_text
-#define gtk_combo_box_text_remove gtk_combo_box_remove_text
-#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
-#endif
-
-#if !GTK_CHECK_VERSION (2, 17, 7)
-static void
-gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
-{
- *a = w->allocation;
-}
-#endif
-
/* configuration */
//#define SOURCE "filesrc"
state = STOP_STATE;
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
+ gtk_widget_queue_draw (video_window);
is_live = FALSE;
buffering = FALSE;
#endif
static gboolean
-handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
+draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
{
if (state < GST_STATE_PAUSED) {
- GtkAllocation allocation;
- GdkWindow *window = gtk_widget_get_window (widget);
- cairo_t *cr;
+ int width, height;
- gtk_widget_get_allocation (widget, &allocation);
- cr = gdk_cairo_create (window);
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
- cairo_destroy (cr);
+ return TRUE;
}
return FALSE;
}
static void
realize_cb (GtkWidget * widget, gpointer data)
{
-#if GTK_CHECK_VERSION(2,18,0)
- {
- GdkWindow *window = gtk_widget_get_window (widget);
+ GdkWindow *window = gtk_widget_get_window (widget);
- /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
- * as well */
- if (!gdk_window_ensure_native (window))
- g_error ("Couldn't create native window needed for GstXOverlay!");
- }
-#endif
+ /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
+ * as well */
+ if (!gdk_window_ensure_native (window))
+ g_error ("Couldn't create native window needed for GstXOverlay!");
#ifdef HAVE_X
- {
- GdkWindow *window = gtk_widget_get_window (video_window);
-
- embed_xid = GDK_WINDOW_XID (window);
- g_print ("Window realize: video window XID = %lu\n", embed_xid);
- }
+ embed_xid = GDK_WINDOW_XID (window);
+ g_print ("Window realize: video window XID = %lu\n", embed_xid);
#endif
}
/* initialize gui elements ... */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
video_window = gtk_drawing_area_new ();
- g_signal_connect (video_window, "expose-event",
- G_CALLBACK (handle_expose_cb), NULL);
+ g_signal_connect (video_window, "draw", G_CALLBACK (draw_cb), NULL);
g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), NULL);
gtk_widget_set_double_buffered (video_window, FALSE);
#include <gst/interfaces/xoverlay.h>
-#if (!GTK_CHECK_VERSION(2, 23, 0) || GTK_CHECK_VERSION(2, 90, 0)) && !GTK_CHECK_VERSION(2, 91, 1)
-#define gtk_combo_box_text_new gtk_combo_box_new_text
-#define gtk_combo_box_text_append_text gtk_combo_box_append_text
-#define gtk_combo_box_text_remove gtk_combo_box_remove_text
-#define GTK_COMBO_BOX_TEXT GTK_COMBO_BOX
-#endif
-
GST_DEBUG_CATEGORY_STATIC (seek_debug);
#define GST_CAT_DEFAULT (seek_debug)
-#if !GTK_CHECK_VERSION (2, 17, 7)
-static void
-gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
-{
- *a = w->allocation;
-}
-#endif
-
/* configuration */
#define SOURCE "filesrc"
state = STOP_STATE;
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
+ gtk_widget_queue_draw (video_window);
is_live = FALSE;
buffering = FALSE;
#endif
static gboolean
-handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
+draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
{
if (state < GST_STATE_PAUSED) {
- GtkAllocation allocation;
- GdkWindow *window = gtk_widget_get_window (widget);
- cairo_t *cr;
+ int width, height;
- gtk_widget_get_allocation (widget, &allocation);
- cr = gdk_cairo_create (window);
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
cairo_set_source_rgb (cr, 0, 0, 0);
- cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
- cairo_destroy (cr);
+ return TRUE;
}
return FALSE;
}
static void
realize_cb (GtkWidget * widget, gpointer data)
{
-#if GTK_CHECK_VERSION(2,18,0)
- {
- GdkWindow *window = gtk_widget_get_window (widget);
+ GdkWindow *window = gtk_widget_get_window (widget);
- /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
- * as well */
- if (!gdk_window_ensure_native (window))
- g_error ("Couldn't create native window needed for GstXOverlay!");
- }
-#endif
-
-#if defined (GDK_WINDOWING_X11) || defined (GDK_WINDOWING_WIN32)
- {
- GdkWindow *window = gtk_widget_get_window (video_window);
+ /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
+ * as well */
+ if (!gdk_window_ensure_native (window))
+ g_error ("Couldn't create native window needed for GstXOverlay!");
#if defined (GDK_WINDOWING_WIN32)
- embed_xid = GDK_WINDOW_HWND (window);
+ embed_xid = GDK_WINDOW_HWND (window);
+ g_print ("Window realize: video window HWND = %lu\n", embed_xid);
#else
- embed_xid = GDK_WINDOW_XID (window);
-#endif
- g_print ("Window realize: video window XID = %lu\n", embed_xid);
- }
+ embed_xid = GDK_WINDOW_XID (window);
+ g_print ("Window realize: video window XID = %lu\n", embed_xid);
#endif
}
/* initialize gui elements ... */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
video_window = gtk_drawing_area_new ();
- g_signal_connect (video_window, "expose-event",
- G_CALLBACK (handle_expose_cb), NULL);
+ g_signal_connect (video_window, "draw", G_CALLBACK (draw_cb), NULL);
g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), NULL);
gtk_widget_set_double_buffered (video_window, FALSE);
#include <gst/interfaces/xoverlay.h>
#include <gst/interfaces/propertyprobe.h>
-#if !GTK_CHECK_VERSION (2, 17, 7)
-static void
-gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
-{
- *a = w->allocation;
-}
-#endif
-
static GtkWidget *video_window = NULL;
static GstElement *sink = NULL;
static gulong embed_xid = 0;
}
static gboolean
-handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
+draw_cb (GtkWidget * widget, cairo_t * cr, gpointer data)
{
redraw_overlay (widget);
return FALSE;
static void
realize_cb (GtkWidget * widget, gpointer data)
{
-#if GTK_CHECK_VERSION(2,18,0)
- {
- GdkWindow *window = gtk_widget_get_window (widget);
-
- /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
- * as well */
- if (!gdk_window_ensure_native (window))
- g_error ("Couldn't create native window needed for GstXOverlay!");
- }
-#endif
+ GdkWindow *window = gtk_widget_get_window (widget);
- {
- GdkWindow *window = gtk_widget_get_window (video_window);
+ /* This is here just for pedagogical purposes, GDK_WINDOW_XID will call it
+ * as well */
+ if (!gdk_window_ensure_native (window))
+ g_error ("Couldn't create native window needed for GstXOverlay!");
- embed_xid = GDK_WINDOW_XID (window);
- g_print ("Window realize: video window XID = %lu\n", embed_xid);
- }
+ embed_xid = GDK_WINDOW_XID (window);
+ g_print ("Window realize: video window XID = %lu\n", embed_xid);
}
static void
video_window = gtk_drawing_area_new ();
g_signal_connect (G_OBJECT (video_window), "configure-event",
G_CALLBACK (handle_resize_cb), NULL);
- g_signal_connect (G_OBJECT (video_window), "expose-event",
- G_CALLBACK (handle_expose_cb), NULL);
+ g_signal_connect (G_OBJECT (video_window), "draw",
+ G_CALLBACK (draw_cb), NULL);
g_signal_connect (video_window, "realize", G_CALLBACK (realize_cb), NULL);
gtk_widget_set_double_buffered (video_window, FALSE);
gtk_container_add (GTK_CONTAINER (window), video_window);
#include <gst/interfaces/xoverlay.h>
#include <gst/video/gstvideosink.h>
-#if !GTK_CHECK_VERSION (2, 17, 7)
-static void
-gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
-{
- *a = w->allocation;
-}
-#endif
-
static struct
{
gint w, h;
}
static gboolean
-handle_expose_cb (GtkWidget * widget, GdkEventExpose * event,
- gpointer user_data)
+handle_draw_cb (GtkWidget * widget, cairo_t * cr, gpointer user_data)
{
GstVideoRectangle *r = &anim_state.rect;
- GtkAllocation allocation;
- GdkWindow *window;
GtkStyle *style;
- cairo_t *cr;
+ int width, height;
+
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
style = gtk_widget_get_style (widget);
- window = gtk_widget_get_window (widget);
- gtk_widget_get_allocation (widget, &allocation);
- cr = gdk_cairo_create (window);
gdk_cairo_set_source_color (cr, &style->bg[GTK_STATE_NORMAL]);
/* we should only redraw outside of the video rect! */
- cairo_rectangle (cr, 0, event->area.y, r->x, event->area.height);
- cairo_rectangle (cr, r->x + r->w, event->area.y,
- allocation.width - (r->x + r->w), event->area.height);
+ cairo_rectangle (cr, 0, 0, r->x, height);
+ cairo_rectangle (cr, r->x + r->w, 0, width - (r->x + r->w), height);
- cairo_rectangle (cr, event->area.x, 0, event->area.width, r->y);
- cairo_rectangle (cr, event->area.x, r->y + r->h,
- event->area.width, allocation.height - (r->y + r->h));
+ cairo_rectangle (cr, 0, 0, width, r->y);
+ cairo_rectangle (cr, 0, r->y + r->h, width, height - (r->y + r->h));
cairo_fill (cr);
- cairo_destroy (cr);
-
if (verbose) {
- g_print ("expose(%p)\n", widget);
+ g_print ("draw(%p)\n", widget);
}
gst_x_overlay_expose (anim_state.overlay);
return FALSE;
handle_resize_cb (video_window, NULL, sink);
g_signal_connect (video_window, "configure-event",
G_CALLBACK (handle_resize_cb), NULL);
- g_signal_connect (video_window, "expose-event",
- G_CALLBACK (handle_expose_cb), NULL);
+ g_signal_connect (video_window, "draw", G_CALLBACK (handle_draw_cb), NULL);
g_timeout_add (50, (GSourceFunc) animate_render_rect, NULL);