Re: Problem setting icon for Gtk2::StatusIcon



On Mon, 2 Mar 2009 13:33:54 +0100
January Weiner <january weiner gmail com> wrote:

Hello,

Problem:
 1) when the icon is changed, the icon first disappears completely
from the notification area, and then it appears again. Throughout this
process, the notification area "flickers" (adapts to the removed /
inserted icon).
 2) sometimes the second (gtk-refresh) icon is not displayed at all,
especially if the GUI is busy doing other things (ie. I am moving the
cursor, typing, ...)

What am I doing wrong?

Here is example code that demonstrates (on my system...) the problem:

#!/usr/bin/perl

use strict   ;
use warnings ;
use Gtk2 -init;

my $status_icon = Gtk2::StatusIcon->new_from_stock('gtk-apply') ;
my $timer = Glib::Timeout->add( 1000, \&update, $status_icon ) ;

Gtk2->main() ;

exit( 0 ) ;

sub update {
 my $icon = shift ;

 $icon->set_from_stock('gtk-refresh') ;
 while( Gtk2->events_pending() ) { Gtk2->main_iteration() ; }
 sleep 5 ;
 $icon->set_from_stock('gtk-apply') ;

 return 1 ;
}

Your script runs fine here, as is; BUT having a "sleep 5" in the main code
thread look awfully bad.  It's almost a rule.....do not use sleep in an event loop system,
like Gtk2.

You probably should change your timeout value to 5000, and have your callback
change the image (toggle) , and get rid of the sleep.


zentara


-- 
I'm not really a human, but I play one on earth.
http://www.zentara.net/~zentaran/My_Petition_to_the_Great_Cosmic_Conciousness.html 



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