<s> from scudcloud . resources import Resources <EOL> import scudcloud <EOL> from PyQt4 import QtCore , QtGui <EOL> class Systray ( QtGui . QSystemTrayIcon ) : <EOL> urgent = False <EOL> def __init__ ( self , window ) : <EOL> super ( Systray , self ) . __init__ ( QtGui . QIcon . fromTheme ( "<STR_LIT>" ) , window ) <EOL> self . connect ( self , QtCore . SIGNAL ( "<STR_LIT>" ) , self . activatedEvent ) <EOL> self . window = window <EOL> self . setToolTip ( '<STR_LIT>' ) <EOL> self . menu = QtGui . QMenu ( self . window ) <EOL> self . menu . addAction ( '<STR_LIT>' , self . restore ) <EOL> if scudcloud . scudcloud . Unity is None : <EOL> self . menu . addAction ( '<STR_LIT>' , self . toggleMenuBar ) <EOL> self . menu . addSeparator ( ) <EOL> self . menu . addAction ( self . window . menus [ "<STR_LIT:file>" ] [ "<STR_LIT>" ] ) <EOL> self . menu . addAction ( self . window . menus [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> self . menu . addSeparator ( ) <EOL> self . menu . addAction ( self . window . menus [ "<STR_LIT:file>" ] [ "<STR_LIT>" ] ) <EOL> self . setContextMenu ( self . menu ) <EOL> def alert ( self ) : <EOL> if not self . urgent : <EOL> self . urgent = True <EOL> self . setIcon ( QtGui . QIcon . fromTheme ( "<STR_LIT>" ) ) <EOL> def stopAlert ( self ) : <EOL> self . urgent = False <EOL> self . setIcon ( QtGui . QIcon . fromTheme ( "<STR_LIT>" ) ) <EOL> def setCounter ( self , i ) : <EOL> if <NUM_LIT:0> == i : <EOL> if True == self . urgent : <EOL> self . setIcon ( QtGui . QIcon . fromTheme ( "<STR_LIT>" ) ) <EOL> else : <EOL> self . setIcon ( QtGui . QIcon . fromTheme ( "<STR_LIT>" ) ) <EOL> elif i > <NUM_LIT:0> and i < <NUM_LIT:10> : <EOL> self . setIcon ( QtGui . QIcon . fromTheme ( "<STR_LIT>" + str ( int ( i ) ) ) ) <EOL> elif i > <NUM_LIT:9> : <EOL> self . setIcon ( QtGui . QIcon . fromTheme ( "<STR_LIT>" ) ) <EOL> def restore ( self ) : <EOL> self . window . show ( ) <EOL> self . stopAlert ( ) <EOL> def toggleMenuBar ( self ) : <EOL> self . window . toggleMenuBar ( ) <EOL> def activatedEvent ( self , reason ) : <EOL> if reason in [ QtGui . QSystemTrayIcon . MiddleClick , QtGui . QSystemTrayIcon . Trigger ] : <EOL> if self . window . isHidden ( ) or self . window . isMinimized ( ) or not self . window . isActiveWindow ( ) : <EOL> self . restore ( ) <EOL> else : <EOL> self . window . hide ( ) </s>
