def __update_email_box (self, username, password): self._box.remove_all() try: if self.__google_account is None or username != self.__google_account.name: self.__google_account = libgmail.GmailAccount(username, password) self.__google_account.login() account = ThemedText(theme_hints=['header'], text=self.__google_account.name, font="14px Bold Italic") self._box.append(account) box = PrelightingCanvasBox() box.connect("button-release-event", self.create_label_slideout, self.__google_account) self._box.append(box) label = hippo.CanvasText(text=self.__folder, font="14px Bold Italic") box.append(label) if self.__folder == 'inbox': threads = self.__google_account.getMessagesByFolder(self.__folder) elif self.__folder == 'unread': threads = self.__google_account.getUnreadMessages() else: threads = self.__google_account.getMessagesByLabel(self.__folder) i = 0 for thread in threads: if i >= self.__display_limit: break subject = remove_strange_tags(thread.subject, True) box = PrelightingCanvasBox() box.connect("button-release-event", self.create_email_slideout, thread) self._box.append(box) email = hippo.CanvasText(markup=subject, xalign=hippo.ALIGNMENT_START) box.append(email) i += 1 labelsDict = self.__google_account.getFolderCounts() footer = ThemedText(theme_hints=['footer'], text="%s unread" % labelsDict['inbox'], font="14px Bold Italic") self._box.append(footer) print "updated mailbox" except libgmail.GmailLoginFailure: error = hippo.CanvasText(text="Error: Could not connect to gmail.", size_mode=hippo.CANVAS_SIZE_WRAP_WORD) self._box.append(error)
def __init__(self, ga): super(LabelSlideout, self).__init__() vbox = CanvasVBox(border_color=0x0000000ff, spacing=4) self.get_root().append(vbox) header = Header(topborder=False) account_text = ThemedText(theme_hints=['header'], text=ga.name, font="14px Bold") header.append(account_text, hippo.PACK_EXPAND) vbox.append(header) folderCounts = ga.getFolderCounts() folderCounts["unread"] = ga.getUnreadMsgCount() for label, number in folderCounts.iteritems(): box = PrelightingCanvasBox() box.connect('button-release-event', self.on_button_release_event, label) vbox.append(box) hbox = CanvasHBox(spacing=4, padding=4) text= hippo.CanvasText(text=label, xalign=hippo.ALIGNMENT_START) hbox.append(text) text= hippo.CanvasText(text=number, xalign=hippo.ALIGNMENT_START) hbox.append(text, flags=hippo.PACK_END) box.append(hbox)