8
from gconfhelper import GconfHelper
10
from notifier import Notifier
12
GLADE_FILE = os.path.join(GLADE_BASE_PATH, "popupmenu.glade")
15
def __init__(self, checker, stop_cb):
17
self.checker = checker
18
self.checker.add_status_cb(self.set_status)
19
self.checker.init_checkers(self.no_config)
20
self.stop_main_loop = stop_cb
22
gtk.window_set_default_icon_from_file(NOMAIL_ICON)
24
self.widgets = gtk.glade.XML(GLADE_FILE, domain="cgmail")
25
self.menu = self.widgets.get_widget("menu")
27
"on_update_activate" : self.on_update_activate,
28
"on_reshow_last_notification_activate" : self.on_reshow_last_notification,
29
"on_exit_activate" : self.exit
32
self.widgets.signal_autoconnect(dic)
34
self.status_icon = gtk.StatusIcon()
35
#self.status_icon.set_from_stock(gtk.STOCK_CLOSE)
36
self.status_icon.set_from_file(NOMAIL_ICON)
37
self.status_icon.connect("popup-menu", self.on_popup_menu)
38
self.status_icon.connect("activate", self.on_activate)
40
self.call_manage_accounts = False
42
self.gconf_helper = GconfHelper()
44
#If the user click on systray icon we reshow this message
45
self.notification_message = ""
46
self.notification_title = ""
48
self.notifier = Notifier()
53
self.status_icon.set_visible(False)
57
self.status_icon.set_visible(True)
61
print "No accounts configured founded"
62
AccountsDialog().run()
63
#self.checker.init_checkers(None)
66
def set_status(self, mcount, title, message):
69
self.status_icon.set_from_file(NOMAIL_ICON)
70
self.notification_message = ""
71
self.notification_title = ""
73
self.status_icon.set_from_file(MORE_NEWMAIL_ICON)
76
self.status_icon.set_from_file(NEWMAIL_ICON_BASE_PATH % mcount)
80
self.notification_title = title
81
if message is not None:
82
self.notification_message = message
84
def on_reshow_last_notification(self, arg):
85
self.on_activate(None)
87
def on_activate(self, arg):
89
if self.notification_message != "":
90
title = self.notification_title
91
message = self.notification_message
94
title = _("No messages")
95
message = _("There are no new messages in your mailboxes")
98
self.notifier.notify(title, message,
99
msec = 10000, force = True, buttons = but)
101
def on_update_activate(self, arg):
103
self.status_icon.set_from_file(NOMAIL_ICON)
106
thread.start_new_thread(self.checker.check, ())
110
def on_popup_menu(self, si, button, time):
111
#self.menu.popup(None, None, None, button, time, si)
112
self.menu.popup(None, None, gtk.status_icon_position_menu,
116
self.stop_main_loop()