Re: How to periodically update GTK tree view



On Sat, 2007-04-07 at 16:54 -0700, ahti rahman wrote:
> I am thinking about the following two designs to implement this: 
> (1) If the gui can receieve  periodic event then this event handler
> can query the server for the latest user/room list and the client can
> update the GUI. Is there a way to ask for a periodic event from the
> GTK GUI?

Basically you are wondering how you can read from a socket and post the
data into the gui somehow, correct?

Several ways come to mind

1. Spawn a thread that uses conventional socket programming to poll or
select for data.  Then post this to the GUI using some form of IPC, such
as a buffer synchronized with a counting semaphore[1].  Then have a
tiemout on the gui that periodically checks the buffer for new data and
does something with it.
2. Use giochannels to have the GTK main loop poll the socket for new
data and then process the data in a normal callback (just as if it was
an event).
3. Use a GLib-based library such as gnet[2]  

To get the GUI to periodically poll something, look at g_idle_add or
g_timeout_add calls.

> (2) The client periodically queries the server for updated user lists.
> Once the client receives the list, client will display this list in
> the gui.But, how do I display it in the gui once I have the user list
> information? 

Can you not use normal GTK calls to do this?  If you need instructions
on how to do the GTK Treeview, see the gtk-demo program; it has example
code for setting up the treeview.  



> 
> Any help on this is appreciated. Please let me know if you need any
> further clarifications on my design.
> 
> Thanks,
> Ahti

[1] http://en.wikipedia.org/wiki/Producer-consumer_problem
[2] http://gnetlibrary.org





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