forked from AuroraMiddleware/gtk
tests: Use new drawing area APIs
This commit is contained in:
parent
295066dad8
commit
915e791586
@ -307,12 +307,16 @@ close_app (GtkWidget *widget, gpointer data)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
draw_cb (GtkWidget *drawing_area, cairo_t *cr, gpointer data)
|
||||
static void
|
||||
draw_func (GtkDrawingArea *darea,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (drawing_area),
|
||||
pixbuf = (GdkPixbuf *) g_object_get_data (G_OBJECT (darea),
|
||||
"pixbuf");
|
||||
|
||||
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
|
||||
@ -369,11 +373,11 @@ main (int argc, char **argv)
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
drawing_area = gtk_drawing_area_new ();
|
||||
gtk_widget_set_size_request (GTK_WIDGET (drawing_area),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
g_signal_connect (drawing_area, "draw",
|
||||
G_CALLBACK (draw_cb), NULL);
|
||||
gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (drawing_area),
|
||||
gdk_pixbuf_get_width (pixbuf));
|
||||
gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (drawing_area),
|
||||
gdk_pixbuf_get_height (pixbuf));
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (drawing_area), draw_func, NULL, NULL);
|
||||
|
||||
g_signal_connect (drawing_area, "configure_event",
|
||||
G_CALLBACK (configure_cb), NULL);
|
||||
|
@ -31,14 +31,14 @@ overall_changed_cb (GtkAdjustment *adjustment, gpointer data)
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
|
||||
static void
|
||||
draw_func (GtkDrawingArea *darea,
|
||||
cairo_t *cr,
|
||||
int width,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GdkPixbuf *dest;
|
||||
int width, height;
|
||||
|
||||
width = gtk_widget_get_allocated_width (widget);
|
||||
height = gtk_widget_get_allocated_height (widget);
|
||||
|
||||
dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, width, height);
|
||||
|
||||
@ -54,8 +54,6 @@ draw_cb (GtkWidget *widget, cairo_t *cr, gpointer data)
|
||||
cairo_paint (cr);
|
||||
|
||||
g_object_unref (dest);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
@ -135,8 +133,7 @@ main(int argc, char **argv)
|
||||
darea = gtk_drawing_area_new ();
|
||||
gtk_box_pack_start (GTK_BOX (vbox), darea, TRUE, TRUE);
|
||||
|
||||
g_signal_connect (darea, "draw",
|
||||
G_CALLBACK (draw_cb), NULL);
|
||||
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (darea), draw_func, NULL, NULL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (window),
|
||||
gdk_pixbuf_get_width (pixbuf),
|
||||
|
Loading…
Reference in New Issue
Block a user