title: How to use cairo with gtk2 in C?
body: <p>I have a huge problem with cairo and gtk2. I was following this tutorial: 
  <a href="http://zetcode.com/gfx/cairo/cairobackends/" rel="nofollow">http://zetcode.com/gfx/cairo/cairobackends/</a> (GTK Window header). Unfortunately nothing appears in the window.</p>
  
  <p>Code from tutorial:</p>
  
  <pre><code>#include &lt;cairo.h&gt;
  #include &lt;gtk/gtk.h&gt;
  
  static void do_drawing(cairo_t *);
  
  static gboolean on_draw_event(GtkWidget *widget, cairo_t *cr, 
      gpointer user_data)
  {      
    do_drawing(cr);
  
    return FALSE;
  }
  
  static void do_drawing(cairo_t *cr)
  {
    cairo_set_source_rgb(cr, 0, 0, 0);
    cairo_select_font_face(cr, "Sans", CAIRO_FONT_SLANT_NORMAL,
        CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size(cr, 40.0);
  
    cairo_move_to(cr, 10.0, 50.0);
    cairo_show_text(cr, "Disziplin ist Macht.");    
  }
  
  
  int main(int argc, char *argv[])
  {
    GtkWidget *window;
    GtkWidget *darea;
  
    gtk_init(&amp;argc, &amp;argv);
  
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  
    darea = gtk_drawing_area_new();
    gtk_container_add(GTK_CONTAINER(window), darea);
  
    g_signal_connect(G_OBJECT(darea), "draw", 
        G_CALLBACK(on_draw_event), NULL); 
    g_signal_connect(window, "destroy",
        G_CALLBACK(gtk_main_quit), NULL);
  
    gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
    gtk_window_set_default_size(GTK_WINDOW(window), 400, 90); 
    gtk_window_set_title(GTK_WINDOW(window), "GTK window");
  
    gtk_widget_show_all(window);
  
    gtk_main();
  
    return 0;
  }
  </code></pre>
  
  <p>I figured out that I should use "expose_event" istead of "draw", but there is still problem. </p>
  
  <p>I found something like this:</p>
  
  <pre><code>gboolean
  expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
  {
    gdk_draw_arc (widget-&gt;window,
                  widget-&gt;style-&gt;fg_gc[gtk_widget_get_state (widget)],
                  TRUE,
                  0, 0, widget-&gt;allocation.width, widget-&gt;allocation.height,
                  0, 64 * 360);
    return TRUE;
  }
  [...]
    GtkWidget *drawing_area = gtk_drawing_area_new ();
    gtk_widget_set_size_request (drawing_area, 100, 100);
    g_signal_connect (G_OBJECT (drawing_area), "expose_event",
                      G_CALLBACK (expose_event_callback), NULL);
  </code></pre>
  
  <p>This piece of code works, it draws something. Could you tell me what should I do to have a working functions like in the first example with one where I can put a code I want to draw (something like do_drawing). Thanks in advance.</p>