thread question on GTK+2.0



Hi all:
     I'm a newbie in GTK. I'm trying to addition a GUI interface to a terminal program.
My idea is, this terminal program will fill a buffer in the main thread and another thread will redraw the drawing area continuous.

But, I saw 2 thread system were initialized, the g_thread and the gtk_thread. Because I'm putting my terminal program in the g_thread and the drawing area is in the gtk_thread. How could I pass the data from the g_thread to the gtk_thread?

Thanx!

int main (int argc, char *argv[])
{
  GtkWidget *window1;
#ifdef ENABLE_NLS
  bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
  textdomain (GETTEXT_PACKAGE);
#endif
  gtk_set_locale ();

  #if defined(G_THREADS_ENABLED) && ! defined(G_THREADS_IMPL_NONE)
   g_thread_init (NULL);

  gdk_threads_init();

  share_data_init();
  gtk_init (&argc, &argv);  g_thread_create(simulator_wrapper, _args , FALSE, NULL);

  GtkDrawingArea *sim_drawing_area =(GtkDrawingArea*) lookup_widget (window1, "drawingarea1");

  //the update thread will redraw the drawing area sim_drawing_area
  g_thread_create(the_update_thread,sim_drawing_area , FALSE, NULL);

  gtk_widget_show_all(window1);

  gdk_threads_enter();
  gtk_main ();
  gdk_threads_leave();


#endif
  return 0;
}



System  on Chip Design  Lab.
Dept. of Computer Science and Information Engineering,
National Chung Cheng University
E-mail : s88 tw acm org

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