Re: text widget performance



On Thu, May 16, 2002 at 01:39:30PM +0200, Francois Chenais wrote:
Hello, 

      I'm build a GTK-- GUI for a log server. 
      I uses Gtk::Text widget to print logs that come from the server.


      Basic solution
      ----------------------------------------------------------------------
      In my main program, I set a callback to read new datas received 
      on my socket :

              gdk_input_add (sock, GDK_INPUT_READ, netInputCallback, data);

      and the netInputCallback does 

              text->insert(dataRed)
      

      But I have a lake of performance when I receive many logs.


      (not) Improved solution
      ----------------------------------------------------------------------
      To improve the performances, I canged netInputCallback introducing
      a buffer and a timer.

      netInputCallback does

              _buffer+=datared

      I create a timer like this

              SigC::Slot0<gint> my_slot = bind(slot(this, flushText), 0);
              _connection = Gtk::Main::timeout.connect(my_slot, 500);

      where flushText does

              text->insert(_buffer)
              _buffer=""

      But it doesn't improve anything, the GUI is frozen while receiving datas :-|


      Is there any GTK's way to do this ?


              Thanks a lot

              François                
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
---end quoted text---

Hi,

500ms is very low due to high-traffic..
you can either increase this to, maybe, 1000ms, or gtk_idle_add_priority()
and set the socket to non-blocking or use select()..
then gtk will only call your callback when it's idle.. don't forget to give
the lowest priority to the socket..
I liked more the second one.. :)

[]'s
-- 
Marcelo R Leitner <mrl netbank com br>



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