Re: Changing the graph color at run time



I haven't examined the source code for gtkdatabox, but if the code for
gtk_databox_add_graph calls gdk at any time, that would surely require
some sort of synchronization between multiple threads. The best (and
so-called "correct") approach for such problems is to put all code
that touches gdk in one thread, and use glib's "g_idle_add" or
"g_timeout_add" functions from the secondary threads. The idle or
timeout callback will get called by the GMainContext running in your
primary thread, so all will be well. This has the added benefit of
being portable to Win32 and other ports of gtk/glib, since the
gdk_thread stuff only seems to work well under X11.

-Jim

On Wed, Apr 2, 2008 at 12:58 AM, Roland Bock <box2OO6 eudoxos de> wrote:
> Hi Nisha,
>
>  I see no reason why this should not work in principle.
>
>  Remarks:
>
>  a) To me (not knowing your application) it seems a little strange that
>  you want to put each graph into a different box? Your introduction
>  sounds different.
>
>  b) If p and i are shared among the threads, you need some thread
>  synchronization. Otherwise you could have situations where i does not
>  stay the same during that code sequence
>
>
>  Regards,
>
>  Roland
>
>
>
>  nisha jain wrote:
>  > Hi All,
>  >
>  > I would like to change the color of signals at run time also
>  > i want to draw signals on gtk data box at run time.
>  > I am not sure how should i do it? I am using following
>  > code to currently draw the signals on the gtk data box
>  >
>  > where the p is a structure array containing the GtkColor and
>  > graph as the memmbers..
>  >
>  >   p[i]->color.red = 65535;
>  >   p[i]->color.green = 65535;
>  >   p[i]->color.blue = 0;
>  >   p[i]->graph = gtk_databox_lines_new (POINTS, p[i]->signalX_acc,
>  > p[i]->signalY_acc, &p[i]->color, 1);
>  >   gtk_databox_graph_add(GTK_DATABOX (box[i]), p[i]->graph);
>  >
>  > when i tried to move this in a thread at run time i am getting run time
>  > exceptions
>  > I am not sure if i can do it or not?
>  >
>  > Thanks and Regards,
>  > Nisha
>  >
>  >
>  > ------------------------------------------------------------------------
>  >
>  > _______________________________________________
>  > gtkdatabox-list mailing list
>  > gtkdatabox-list gnome org
>  > http://mail.gnome.org/mailman/listinfo/gtkdatabox-list
>
>  _______________________________________________
>  gtkdatabox-list mailing list
>  gtkdatabox-list gnome org
>  http://mail.gnome.org/mailman/listinfo/gtkdatabox-list
>


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