diff --git a/Window.py b/Window.py index 1f58eb1..f6f2aa5 100755 --- a/Window.py +++ b/Window.py @@ -6,6 +6,7 @@ import imaplib class Window(object): def __init__(self, title, conf): self.conf = conf + self.count = 0 self.connection = None if not 'width' in self.conf: @@ -18,6 +19,8 @@ class Window(object): self.conf['updaterate'] = 5000 if not 'bgcolor' in self.conf: self.conf['bgcolor'] = (1.0, 0.5, 0.0) + if not 'font_size' in self.conf: + self.conf['font_size'] = 18 sticky = True if 'sticky' in self.conf: sticky = self.conf['sticky'] @@ -76,13 +79,20 @@ class Window(object): try: self.connection.select(self.conf['mailbox']) msgs = self.connection.search(None, 'UnSeen')[1][0].split() - count = len(msgs) - self.label.set_text(str(count)) + self.count = len(msgs) except: self.connection = None - self.label.set_text('-') + self.update_count() return self.connection is not None + def update_count(self): + if self.connection is None: + self.label.set_text('-') + else: + self.label.set_markup( + ('%d' + % (1024 * self.conf['font_size'], self.count))) + def destroy_event(self): self.disconnect() self.update_conf()