#include static gboolean expose(GtkWidget *area, GdkEventExpose *expose, GtkWidget *label) { gchar *s; double x1,y1, x2,y2; cairo_t *cr; cr = gdk_cairo_create(area->window); cairo_arc(cr, 250.0, 250.0, 157.0, 5.147, 3.432); cairo_set_line_width(cr, 154.0); cairo_stroke_extents(cr, &x1,&y1, &x2,&y2); s = g_strdup_printf("arc stroke extents:\n%.2fx%.2f %.2fx%.2f\n", x1,y1, x2,y2); gtk_label_set_text(GTK_LABEL(label), s); g_free(s); cairo_set_source_rgba(cr, 0.0,0.0,1.0,0.7); cairo_stroke(cr); cairo_rectangle(cr, x1,y1,x2-x1,y2-y1); cairo_set_source_rgba(cr, 1.0,0.0,0.0,0.5); cairo_fill(cr); cairo_destroy(cr); return TRUE; } int main(int argc, char **argv) { GtkWidget *window; GtkWidget *vbox; GtkWidget *area; GtkWidget *label; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request(window, 550,550); g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), 0); vbox = gtk_vbox_new(FALSE, 6); gtk_container_add(GTK_CONTAINER(window), vbox); area = gtk_drawing_area_new(); gtk_box_pack_start(GTK_BOX(vbox), area, TRUE,TRUE, 0); label = gtk_label_new(""); gtk_label_set_selectable(GTK_LABEL(label), TRUE); gtk_box_pack_start(GTK_BOX(vbox), label, FALSE,FALSE, 2); g_signal_connect(area, "expose-event", G_CALLBACK(expose), label); gtk_widget_show_all(window); gtk_main(); return 0; }