Problem setting icon for Gtk2::StatusIcon
- From: January Weiner <january weiner gmail com>
- To: gtk-perl-list gnome org
- Subject: Problem setting icon for Gtk2::StatusIcon
- Date: Mon, 2 Mar 2009 13:33:54 +0100
Hello,
I am trying to add a small notification feature for a program that I
wrote. This program runs in background and at regular intervals does
something. I have added a Gtk2::StatusIcon to let the user know what
is going on. The idea is that the icon changes when the program starts
doing its job.
I use Gtk2::StatusIcon->new_from_stock( 'gtk-apply' ) to set the initial icon.
I use $icon->set_from_stock( 'gtk-refresh' ) to change the icon when
the program is working. After calling set_from_stock, I run the
following to make sure that the icon is properly displayed:
while( Gtk2->events_pending() ) { Gtk2->main_iterate() ; }
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 ;
}
Thanks in advance,
January
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]