Gtk::Gdk->input_add problem.



Hi

I have tried to use the input_add but i ran into problem.

I have tried to ways to use input_add. 
1. Open a file for read and send in the filehandle to input_add.
   Here i never gets any calls to my function at all.

2. open a file and use fileno( filehandle ) as an input to input_add.
   Here the callback gets called all the time without any new data in  
the file to read.


Anybody who understand how to use input_add on a ordinary filhandle?
Please give me an short example.




Try 1: 
---------------------------------------------------------
if( open($fh,"/var/log/messages") ){
  while( defined (<$fh>) ){}
    $file_id = Gtk::Gdk->input_add( $fh, 'read', sub {
        my ( $source, $condition, @data ) = @_;
        print "$source, $condition, @data\n";
        print "Callback!!!!\n";
        while( defined (<$source>) ){}
        return 1;
       });
---------------------------------------------------------

Try 2:
---------------------------------------------------------
if( open($fh,"/var/log/messages") ){
  while( defined (<$fh>) ){}
    $file_id = Gtk::Gdk->input_add( fileno($fh), 'read', sub {
        my ( $source, $condition, @data ) = @_;
        print "$source, $condition, @data\n";
        print "Callback!!!!\n";
        while( defined (<$source>) ){}
        return 1;
       });
---------------------------------------------------------





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