Re: Problem setting icon for Gtk2::StatusIcon



On Tue, 3 Mar 2009 00:18:19 +0100
January Weiner <january uni-muenster de> wrote:

my $image1 = Gtk2::Image->new_from_stock('gtk-refresh', 'menu' ) ;

what is this for?

If I recall correctly, you were making new Gtk2::Images in your callback,
everytime it was called.
This is inefficient, and in Tk it would probably cause a memory gain.
Gtk2 is much better about cleaning up it's closures, so it may not make a difference.
However, the idea is to only make 2 Gtk2::Image objects, and reuse them, for efficiency.
With only 2 images, why not pre-make them?


sub update {

Is there a real reason for using a global instead of passing arguments
to update?

Â$toggle *= -1; Â# +1 or -1 toggle

$toggle = !$toggle ;

if( $toggle ) { ... }

Yeah, I was lazy there just for demo purposes. You also could
do the toggle, by getting the current image, and switching to the other.
Of course, a global toggle is nice sometimes, as a flag to other portions
of the code, to signal what state you currently are in.


You seem to have a handle on what is happening, I'm just throwing some
confusion your way :-).

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]