The most easy way to show the frequency readout is to use a text rather than an image.
gboolean front_panel(GtkWidget *widget, GdkEventExpose *event, gpointer data) { int x, y, width, height; double color, barlength; x = event->area.x; y = event->area.y; width = event->area.width; height = event->area.height; cairo_t *cr = gdk_cairo_create(widget->window); cairo_rectangle(cr, x, y, width, height); cairo_clip(cr); barlength = (s_meter/255.0) * (width-20); color = 0.0; for(int i=0; i<barlength; i+=10) { if((i/10)%10 == 0) cairo_set_source_rgb(cr, 0x33/256.0, 0x66/256.0, 0x99/256.0); else cairo_set_source_rgb(cr, color, 1.0-color, 0.1); cairo_rectangle(cr, x+10+i, y+10, 10, height-20); color += 0.020; if(color > 1.0) color = 0.0; cairo_fill(cr); } char string[128]; sprintf(string,"%12.3f",freq_show/1000.0); cairo_set_source_rgb(cr, 1.0, 0.0, 0.0); cairo_select_font_face(cr, "FreeSans", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_NORMAL); cairo_set_font_size(cr, 46.0); cairo_move_to(cr, width-270.0, height-8.0); cairo_show_text(cr, string); cairo_set_source_rgb(cr,0,0,0); cairo_destroy(cr); return FALSE; }
This code is very dirty, but it works. The first half is for the S-meter, and the latter half for the Frequency Display.