in reply to zimg -- Perl/Gtk2 quick slideshow

This is awesome, but it's possible to decrease the delay to a point where load_image is called more often than gtk can update the screen. This results in the title changing, but the image displayed not changing. Is there a method to call in gtk that will wait until it has finished updating the screen? I tried searching the docs on
http://gtk2-perl.sourceforge.net/doc/pod/index.html
but came up empty.

Replies are listed 'Best First'.
Re^2: zimg -- Perl/Gtk2 quick slideshow
by zentara (Cardinal) on Oct 27, 2006 at 09:31 UTC
    Just about everything in Gtk2 is event-driven, so if you add an event-watcher to the $image, as it's being loaded, it emits an "expose event" when displayed.
    sub load_image { ... .... .... $vp->add( $image ); # add event watcher $image->signal_connect( event => sub { my ( $item, $event ) = @_; warn "event " . $event->type . "\n"; return 0; #return 1 prevents window from closing # return 0 lets the signal thru } ); ..... ..... }
    Now, it would seem that you could just wait until the expose event occurs before proceeding. What the best way to do that is probably a resettable flag $is_image_exposed, and go into a non-blocking delay until it is 1.

    I havn't tested that, and there may be other ways. Read "perldoc Gtk2::Widget" and look for things like "$widget->has_screen" ( and others).

    The docs for Gtk2 are pretty meager, and require alot of experimentation to get the right code.

    But if you ask me, just set the delay slower. :-)


    I'm not really a human, but I play one on earth. Cogito ergo sum a bum