tests: require Gtk+ 3.0 for examples and Gtk-based test apps

The Gtk+ dependency is entirely optional, we're just not
supporting Gtk+ 2.x any longer.
This commit is contained in:
Tim-Philipp Müller 2011-11-12 15:51:52 +00:00
parent 394b1f8c3c
commit 12aab2cdcc
5 changed files with 56 additions and 152 deletions

View file

@ -283,24 +283,11 @@ AC_SUBST(GST_PREFIX)
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

View file

@ -50,21 +50,6 @@
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"
@ -1574,6 +1559,7 @@ stop_cb (GtkButton * button, gpointer data)
state = STOP_STATE;
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
gtk_widget_queue_draw (video_window);
is_live = FALSE;
buffering = FALSE;
@ -2469,19 +2455,17 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
#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;
}
@ -2489,24 +2473,16 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
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
}
@ -2754,8 +2730,7 @@ main (int argc, char **argv)
/* 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);

View file

@ -41,24 +41,9 @@
#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"
@ -1582,6 +1567,7 @@ stop_cb (GtkButton * button, gpointer data)
state = STOP_STATE;
gtk_statusbar_push (GTK_STATUSBAR (statusbar), status_id, "Stopped");
gtk_widget_queue_draw (video_window);
is_live = FALSE;
buffering = FALSE;
@ -2505,19 +2491,17 @@ bus_sync_handler (GstBus * bus, GstMessage * message, GstPipeline * data)
#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;
}
@ -2525,28 +2509,19 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
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
}
@ -2756,8 +2731,7 @@ main (int argc, char **argv)
/* 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);

View file

@ -34,14 +34,6 @@
#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;
@ -89,7 +81,7 @@ handle_resize_cb (GtkWidget * widget, GdkEventConfigure * event, gpointer data)
}
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;
@ -98,23 +90,15 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
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!");
{
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);
}
static void
@ -251,8 +235,8 @@ main (int argc, char **argv)
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);

View file

@ -35,14 +35,6 @@
#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;
@ -99,37 +91,30 @@ handle_resize_cb (GtkWidget * widget, GdkEventConfigure * event,
}
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;
@ -228,8 +213,7 @@ main (gint argc, gchar ** argv)
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);