title: How to refresh cairo drawing in gtk2?
body: <p>I have a problem with refreshing my cairo drawing. It doesn't work and I don't know why. Could you help me? I want to create a new "drawing" whenever analyse function is executed.</p>
  
  <p>I created something like this:</p>
  
  <pre><code>d_area = gtk_drawing_area_new(); 
  </code></pre>
  
  <p>Then i packed it in scrolled window:</p>
  
  <pre><code>gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(formula_scrolled_window), d_area);
  </code></pre>
  
  <p>Then:</p>
  
  <pre><code>g_signal_connect(G_OBJECT(d_area), "expose_event", G_CALLBACK(expose_event_callback), NULL);
  </code></pre>
  
  <p>but before it I have got :</p>
  
  <pre><code>g_signal_connect(G_OBJECT(search_entry), "activate", G_CALLBACK(analyse), &amp;window_and_search_entry);
  </code></pre>
  
  <p>function analyse:</p>
  
  <pre><code>ELEMENT *analyse(GtkWidget *widget, WINDOW_AND_SEARCH_ENTRY *data)
  {
      const gchar *text = gtk_entry_get_text(GTK_ENTRY(data-&gt;search_entry));
      main_window = data-&gt;window;
      d_area = GTK_DRAWING_AREA(data-&gt;d_area); //do I nedd it?
  
  
      foo = operate(text, GTK_WIDGET(data-&gt;window));
  
      print_on_console_with_new_line(foo);
  
      g_signal_connect(G_OBJECT(d_area), "expose_event", G_CALLBACK(expose_event_callback), NULL); //do I need it??
      do_drawing(cr, foo); //is it good 
      g_signal_connect(G_OBJECT(d_area), "expose_event", G_CALLBACK(expose_event_callback), NULL); //do I need it??
  
  
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>gboolean expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data)
  {
  
  
    cr = gdk_cairo_create (gtk_widget_get_window (widget)); 
    do_drawing(cr, foo);
    return FALSE;
  }
  </code></pre>
  
  <p>Finally:</p>
  
  <pre><code>void do_drawing(cairo_t *cr, ELEMENT *p) 
  {
  gdouble font_size = 20.0;
  
  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, font_size);
  
  
  cairo_move_to(cr, lala, 30.0);
  cairo_show_text(cr, "6");  
  lala += 30;
  
  }
  </code></pre>