summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2010-07-24 11:48:33 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2010-07-24 11:49:08 +0200
commitc1982cd6fe7ed111ee85d8e9b85365ecf72ccaf4 (patch)
tree2afb8723f0d133912747039ce81f59335ee424c3
parent5011cb2392ab8a24bc614948a25ae2f9481c1bae (diff)
examples: Use cairo instead of to-be-deprecated GDK API
Fixes bug #625001.
-rw-r--r--tests/examples/seek/jsseek.c9
-rw-r--r--tests/examples/seek/seek.c9
-rw-r--r--tests/icles/test-colorkey.c37
-rw-r--r--tests/icles/test-xoverlay.c27
4 files changed, 45 insertions, 37 deletions
diff --git a/tests/examples/seek/jsseek.c b/tests/examples/seek/jsseek.c
index 41b19f448..7e407d01e 100644
--- a/tests/examples/seek/jsseek.c
+++ b/tests/examples/seek/jsseek.c
@@ -2463,11 +2463,14 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
if (state < GST_STATE_PAUSED) {
GtkAllocation allocation;
GdkWindow *window = gtk_widget_get_window (widget);
- GtkStyle *style = gtk_widget_get_style (widget);
+ cairo_t *cr;
gtk_widget_get_allocation (widget, &allocation);
- gdk_draw_rectangle (window, style->black_gc, TRUE, 0, 0,
- allocation.width, allocation.height);
+ cr = gdk_cairo_create (window);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_fill (cr);
+ cairo_destroy (cr);
}
return FALSE;
}
diff --git a/tests/examples/seek/seek.c b/tests/examples/seek/seek.c
index 50f9fa8b0..1d6bdca2b 100644
--- a/tests/examples/seek/seek.c
+++ b/tests/examples/seek/seek.c
@@ -2449,11 +2449,14 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event, gpointer data)
if (state < GST_STATE_PAUSED) {
GtkAllocation allocation;
GdkWindow *window = gtk_widget_get_window (widget);
- GtkStyle *style = gtk_widget_get_style (widget);
+ cairo_t *cr;
gtk_widget_get_allocation (widget, &allocation);
- gdk_draw_rectangle (window, style->black_gc, TRUE, 0, 0,
- allocation.width, allocation.height);
+ cr = gdk_cairo_create (window);
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_fill (cr);
+ cairo_destroy (cr);
}
return FALSE;
}
diff --git a/tests/icles/test-colorkey.c b/tests/icles/test-colorkey.c
index 089ff4ebe..72967bc9a 100644
--- a/tests/icles/test-colorkey.c
+++ b/tests/icles/test-colorkey.c
@@ -45,29 +45,36 @@ gtk_widget_get_allocation (GtkWidget * w, GtkAllocation * a)
static GtkWidget *video_window = NULL;
static GstElement *sink = NULL;
static gulong embed_xid = 0;
-static GdkGC *trans_gc = NULL;
+static GdkColor trans_color;
+static gboolean trans_color_set = FALSE;
static void
redraw_overlay (GtkWidget * widget)
{
GtkAllocation allocation;
GdkWindow *window = gtk_widget_get_window (widget);
- GtkStyle *style = gtk_widget_get_style (widget);
+ cairo_t *cr;
+ cr = gdk_cairo_create (window);
gtk_widget_get_allocation (widget, &allocation);
- gdk_draw_rectangle (window, style->white_gc, TRUE, 0, 0,
- allocation.width, allocation.height);
- if (trans_gc) {
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_fill (cr);
+
+ if (trans_color_set) {
guint x, y;
guint h = allocation.height * 0.75;
- gdk_draw_rectangle (window, trans_gc, TRUE, 0, 0, allocation.width, h);
+ gdk_cairo_set_source_color (cr, &trans_color);
+ cairo_rectangle (cr, 0, 0, allocation.width, h);
+ cairo_fill (cr);
for (y = h; y < allocation.height; y++) {
for (x = 0; x < allocation.width; x++) {
if (((x & 1) || (y & 1)) && (x & 1) != (y & 1)) {
- gdk_draw_point (window, trans_gc, x, y);
+ cairo_move_to (cr, x, y);
+ cairo_paint (cr);
}
}
}
@@ -127,18 +134,14 @@ msg_state_changed (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
/* When state of the pipeline changes to paused or playing we start updating scale */
switch (GST_STATE_TRANSITION (old, new)) {
case GST_STATE_CHANGE_READY_TO_PAUSED:{
- GdkWindow *window = gtk_widget_get_window (video_window);
-
g_object_get (G_OBJECT (sink), "colorkey", &color, NULL);
if (color != -1) {
- GdkColor trans_color = { 0,
- (color & 0xff0000) >> 8,
- (color & 0xff00),
- (color & 0xff) << 8
- };
-
- trans_gc = gdk_gc_new (window);
- gdk_gc_set_rgb_fg_color (trans_gc, &trans_color);
+ trans_color.red = (color & 0xff0000) >> 8;
+ trans_color.green = (color & 0xff00);
+ trans_color.blue = (color & 0xff) << 8;
+ trans_color_set = TRUE;
+ } else {
+ trans_color_set = FALSE;
}
handle_resize_cb (video_window, NULL, NULL);
break;
diff --git a/tests/icles/test-xoverlay.c b/tests/icles/test-xoverlay.c
index e9dd1432f..12a7e27b7 100644
--- a/tests/icles/test-xoverlay.c
+++ b/tests/icles/test-xoverlay.c
@@ -106,29 +106,28 @@ handle_expose_cb (GtkWidget * widget, GdkEventExpose * event,
GtkAllocation allocation;
GdkWindow *window;
GtkStyle *style;
+ cairo_t *cr;
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! */
- /*
- gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE,
- 0, 0, widget->allocation.width, widget->allocation.height);
- gdk_draw_rectangle (widget->window, widget->style->bg_gc[0], TRUE,
- event->area.x, event->area.y, event->area.width, event->area.height);
- */
- gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
- 0, event->area.y, r->x, event->area.height);
- gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
- r->x + r->w, event->area.y,
+ 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);
- gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
- event->area.x, 0, event->area.width, r->y);
- gdk_draw_rectangle (window, style->bg_gc[0], TRUE,
- event->area.x, r->y + r->h,
+ 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_fill (cr);
+
+ cairo_destroy (cr);
+
if (verbose) {
g_print ("expose(%p)\n", widget);
}