examples: Use cairo instead of to-be-deprecated GDK API

Fixes bug #625002.
This commit is contained in:
Sebastian Dröge 2010-07-24 10:19:37 +02:00
parent eb4afca554
commit bba463be38
3 changed files with 27 additions and 18 deletions

View file

@ -79,18 +79,21 @@ draw_spectrum (gfloat * data)
{ {
gint i; gint i;
GdkRectangle rect = { 0, 0, spect_bands, spect_height }; GdkRectangle rect = { 0, 0, spect_bands, spect_height };
cairo_t *cr;
if (!drawingarea) if (!drawingarea)
return; return;
gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect); gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect);
gdk_draw_rectangle (gtk_widget_get_window (drawingarea), cr = gdk_cairo_create (gtk_widget_get_window (drawingarea));
gtk_widget_get_style (drawingarea)->black_gc,
TRUE, 0, 0, spect_bands, spect_height); cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, spect_bands, spect_height);
cairo_fill (cr);
for (i = 0; i < spect_bands; i++) { for (i = 0; i < spect_bands; i++) {
gdk_draw_rectangle (gtk_widget_get_window (drawingarea), cairo_set_source_rgb (cr, 1, 1, 1);
gtk_widget_get_style (drawingarea)->white_gc, cairo_rectangle (cr, i, -data[i], 1, spect_height + data[i]);
TRUE, i, -data[i], 1, spect_height + data[i]); cairo_fill (cr);
} }
gdk_window_end_paint (gtk_widget_get_window (drawingarea)); gdk_window_end_paint (gtk_widget_get_window (drawingarea));
} }

View file

@ -78,18 +78,21 @@ draw_spectrum (gfloat * data)
{ {
gint i; gint i;
GdkRectangle rect = { 0, 0, spect_bands, spect_height }; GdkRectangle rect = { 0, 0, spect_bands, spect_height };
cairo_t *cr;
if (!drawingarea) if (!drawingarea)
return; return;
gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect); gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect);
gdk_draw_rectangle (gtk_widget_get_window (drawingarea), cr = gdk_cairo_create (gtk_widget_get_window (drawingarea));
gtk_widget_get_style (drawingarea)->black_gc,
TRUE, 0, 0, spect_bands, spect_height); cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, spect_bands, spect_height);
cairo_fill (cr);
for (i = 0; i < spect_bands; i++) { for (i = 0; i < spect_bands; i++) {
gdk_draw_rectangle (gtk_widget_get_window (drawingarea), cairo_set_source_rgb (cr, 1, 1, 1);
gtk_widget_get_style (drawingarea)->white_gc, cairo_rectangle (cr, i, -data[i], 1, spect_height + data[i]);
TRUE, i, -data[i], 1, spect_height + data[i]); cairo_fill (cr);
} }
gdk_window_end_paint (gtk_widget_get_window (drawingarea)); gdk_window_end_paint (gtk_widget_get_window (drawingarea));
} }

View file

@ -67,18 +67,21 @@ draw_spectrum (gfloat * data)
{ {
gint i; gint i;
GdkRectangle rect = { 0, 0, spect_bands, spect_height }; GdkRectangle rect = { 0, 0, spect_bands, spect_height };
cairo_t *cr;
if (!drawingarea) if (!drawingarea)
return; return;
gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect); gdk_window_begin_paint_rect (gtk_widget_get_window (drawingarea), &rect);
gdk_draw_rectangle (gtk_widget_get_window (drawingarea), cr = gdk_cairo_create (gtk_widget_get_window (drawingarea));
gtk_widget_get_style (drawingarea)->black_gc,
TRUE, 0, 0, spect_bands, spect_height); cairo_set_source_rgb (cr, 0, 0, 0);
cairo_rectangle (cr, 0, 0, spect_bands, spect_height);
cairo_fill (cr);
for (i = 0; i < spect_bands; i++) { for (i = 0; i < spect_bands; i++) {
gdk_draw_rectangle (gtk_widget_get_window (drawingarea), cairo_set_source_rgb (cr, 1, 1, 1);
gtk_widget_get_style (drawingarea)->white_gc, cairo_rectangle (cr, i, -data[i], 1, spect_height + data[i]);
TRUE, i, -data[i], 1, spect_height + data[i]); cairo_fill (cr);
} }
gdk_window_end_paint (gtk_widget_get_window (drawingarea)); gdk_window_end_paint (gtk_widget_get_window (drawingarea));
} }