Re: gtk_entry_set_text used twice or more



On Thu, 4 Oct 2001 06:58:10 -0500 author <millward Ms UManitoba CA> wrote:

void callback2(GtkWidget * widget, GtkWidget * entry )
{
  double dub = 0.0;
  char savebuf[50];
  gchar * xx;
  gchar * yy = "This is callback2... ";

  xx = gtk_entry_get_text(GTK_ENTRY(entry) );

  g_print("\nEntry Contents >  %s\n",  xx);

  dub = process(xx);

/* The next line is not executed. Why? */
  gtk_entry_set_text(GTK_ENTRY(entry), yy);

that last line is executed, but as you are still in your function, no event
is processed, and no redrawing of the widget occurs (you can test it when it
waits for the 10 s : do resize the window: it won't be refreshed)




  sleep(10);  /* in <unistd.h> */

  sprintf(savebuf,"%g",dub);  /* in <stdio.h> */
  gtk_entry_set_text(GTK_ENTRY(entry), (gchar *) savebuf );

}

Finally, the last 'gtk_entry_set_text' is executed (but still no redraw),
and then after exiting from your function (and returning to the main loop),
the event queue is processed and the widget will be redrawn (because the
text was changed) and will show the last text (gchar *) savebuf.

g_printf is not handled by the main loop, that's why you can see what it has
printed

Hth


-- 
Melvin Hadasht




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]