Re: button event release



Hi Jonathan,

Thanks for the reply. This was my first post in this forum as I joined the forum today and I am happy to get 
a reply as in the past months I was asking questions in gtk and gnome forums with a single or no reply at all.

I will surely look into the archive now. Actually, I am dealing with Bluetooth sockets in this case,

best regards,

Bluezapper.

Jonathan Winterflood <jonathan winterflood gmail com> wrote: Hi,

There's been some talk about threads in the last couple of weeks on this list, you should be able to lift 
them from the archive if you just subscribed.

An easy alternative to threads in this case would  be to connect the socket to a GIOChannel, and have the gtk 
main loop deal with the data asynchronously: the button will release immediately and the data will get 
processed when it gets back. 

  A friend and I did this in a program we developped recently, using the gnet library (a glib based library 
for portable network communication), but you might not need that. 

_very_ crudely:
   gnet_tcp_socket_connect_async(adress, port, &(_socketConnectAsyncCallback),this); // on the button clic 

 void _socketConnectAsyncCallback(GTcpSocket *socket,GTcpSocketConnectAsyncS tatus status, gpointer data)  is 
called when the connection is established (or fails to)
 then get the channel: _channel = gnet_tcp_socket_get_io_channel(socket); 
 register data arrival handler: g_io_add_watch(_channel, G_IO_IN, &(_imageDataReadyForReading), this); 
send your request: gnet_io_channel_write_%something
gboolean _imageDataReadyForReading(GIOChannel *, GIOCondition, gpointer data) is called when some data 
arrives 

Voilà

Hope it helps,
Jonathan
 

On 5/23/07, Bluezapper <enigma_enu yahoo com > wrote:   Hello all,

I have a question about button release event. I have a GTK_PANE window.

When I press the button I open a socket connection and get back some data from it. Since the opening of 
socket and getting the data back takes some time I want to display some status messages to the user in a 
text_view which is added to the lower Pane.  

My problem is until the button releases my whole application freezes and  text_view gets updated after 
release.

How do I start two threads in Gtk so that one thread opens the socket and other thread updates the text_view. 
 

Thanks for having the patience to read my long complete email,

regards,

Bluezapper.


---------------------------------
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.  
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org 
 http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list 
 

       
---------------------------------
Be a better Heartthrob. Get better relationship answers from someone who knows.
Yahoo! Answers - Check it out. 


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