Exemplo n.º 1
0
    def __init__(self,
                 parent,
                 text,
                 on_click=None,
                 should_be_active=None,
                 align='right'):

        self._on_click = Delegate()

        if on_click:
            self._on_click += on_click

        ClearLink.__init__(self,
                           parent,
                           -1,
                           text,
                           on_click,
                           style=wx.NO_BORDER
                           | getattr(wx, 'HL_ALIGN_%s' % align.upper()))
        linkfont = skin.get('filetransfers.fonts.link', default_font)

        self.SetFont(linkfont)

        self._is_active = Delegate(collect_values=True)
        if should_be_active:
            self._is_active += should_be_active
Exemplo n.º 2
0
    def __init__(self, parent):
        wx.VListBox.__init__(self, parent)

        import common.favicons
        common.favicons.on_icon += self.OnFaviconReceived

        self.emails = []
        self.account = None
        self.itemheight = 0

        self.preview_offset = 0
        self.preview_timer = wx.PyTimer(self.on_preview_timer)
        self.marquee_timer = wx.PyTimer(self.on_marquee)

        self.SetItemCount(len(self.emails))

        self.linkage = PseudoSizer()
        self.linkage.Show(False)
        self.errorlink = None

        self.UpdateSkin()

        #links as (object name, String to be displayed,
        #   callback in self.account fitting this call callback(email))
        links = [('olink', 'Open', 'OnClickEmail'),
                 ('rlink', 'Mark as Read', 'markAsRead'),
                 ('alink', 'Archive', 'archive'),
                 ('dlink', 'Delete', 'delete'),
                 ('slink', 'Report Spam', 'reportSpam')]

        # Use the above list to generate ClearLink objects
        for attr, text, method in links:
            link = ClearLink(self,
                             -1,
                             text,
                             method,
                             style=wx.NO_BORDER | wx.HL_ALIGN_CENTRE)
            link.NormalColour = link.HoverColour = link.VisitedColour = self.hoverlinkfc
            link.Font = self.linkfont
            setattr(self, attr, link)

            self.linkage.Add(link)

        self.BBind(HYPERLINK=self.OnLink,
                   MOTION=self.OnMouseMotion,
                   LEFT_DCLICK=self.OnDblClick,
                   LEAVE_WINDOW=self.OnMouseOut,
                   MOUSEWHEEL=self.OnMouseWheel,
                   PAINT=self.OnPaint,
                   SHOW=self.OnShow)

        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
Exemplo n.º 3
0
    def __init__(self, parent, text, on_click=None, should_be_active=None, align='right'):

        self._on_click = Delegate()

        if on_click:
            self._on_click += on_click

        ClearLink.__init__(self, parent, -1, text, on_click, style = wx.NO_BORDER | getattr(wx, 'HL_ALIGN_%s' % align.upper()))
        linkfont = skin.get('filetransfers.fonts.link', default_font)

        self.SetFont(linkfont)

        self._is_active = Delegate(collect_values=True)
        if should_be_active:
            self._is_active += should_be_active
Exemplo n.º 4
0
    def __init__(self, parent):
        wx.VListBox.__init__(self, parent)

        import common.favicons
        common.favicons.on_icon += self.OnFaviconReceived

        self.emails     = []
        self.account    = None
        self.itemheight = 0

        self.preview_offset = 0
        self.preview_timer = wx.PyTimer(self.on_preview_timer)
        self.marquee_timer = wx.PyTimer(self.on_marquee)

        self.SetItemCount(len(self.emails))

        self.linkage = PseudoSizer()
        self.linkage.Show(False)
        self.errorlink=None

        self.UpdateSkin()

        #links as (object name, String to be displayed,
        #   callback in self.account fitting this call callback(email))
        links = [('olink', 'Open', 'OnClickEmail'),
                 ('rlink', 'Mark as Read', 'markAsRead'),
                 ('alink', 'Archive', 'archive'),
                 ('dlink', 'Delete', 'delete'),
                 ('slink', 'Report Spam', 'reportSpam')]

        # Use the above list to generate ClearLink objects
        for attr, text, method in links:
            link = ClearLink(self, -1, text, method, style = wx.NO_BORDER | wx.HL_ALIGN_CENTRE)
            link.NormalColour=link.HoverColour=link.VisitedColour=self.hoverlinkfc
            link.Font=self.linkfont
            setattr(self, attr, link)

            self.linkage.Add(link)

        self.BBind(HYPERLINK        = self.OnLink,
                   MOTION           = self.OnMouseMotion,
                   LEFT_DCLICK      = self.OnDblClick,
                   LEAVE_WINDOW     = self.OnMouseOut,
                   MOUSEWHEEL       = self.OnMouseWheel,
                   PAINT            = self.OnPaint,
                   SHOW             = self.OnShow)

        self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
Exemplo n.º 5
0
    def SetAccount(self, account):
        """
            Set an account to the header
            Handles unloading the previous acount and setting up the links
            and observer callbacks for the new account
        """

        if account is self.account:
            return

        if self.account is not None:
            try:
                self.account.unobserve_count(self.Refreshxor)
            except NotImplementedError:
                pass
            try:
                self.account.unobserve_state(self.Refreshxor)
            except NotImplementedError:
                pass

        self.account = account
        self.icon = account.icon.Resized(16)

        # Construct action links
        self.linkage.Clear(True)
        for linkfunc in account.header_funcs:
            link = ClearLink(self,
                             -1,
                             linkfunc[0],
                             lambda l=linkfunc: self.do_link(l),
                             style=link_style,
                             pos=(-400, -400))
            link.NormalColour = link.HoverColour = link.VisitedColour = self.linkfc
            link.Font = self.linkfont
            self.linkage.Add(link)

        self.linkage.Layout()

        if self.extralinkage:
            self.extralinkage.Show(False)
            self.extralinkage.Destroy()
            self.extralinkage = None

        if getattr(account, 'extra_header_func', None) is not None:
            self.extralinkage = elink = ClearLink(
                self,
                -1,
                account.extra_header_func[0],
                lambda l=account.extra_header_func: self.do_link(l),
                style=link_style,
                pos=(-400, -400))

            elink.NormalColour = elink.HoverColour = elink.VisitedColour = self.linkfc
            elink.Font = self.elinkfont

            self.ExtraLinkLayout()

        try:
            self._unbound_cbs.clear()
        except AttributeError:
            pass

        try:
            account.observe_count(self.Refreshxor)
        except NotImplementedError:
            pass
        try:
            account.observe_state(self.Refreshxor)
        except NotImplementedError:
            pass

        self.Refresh(False)
Exemplo n.º 6
0
    def SetAccount(self, account):
        """
            Set an account to the header
            Handles unloading the previous acount and setting up the links
            and observer callbacks for the new account
        """

        if account is self.account:
            return

        if self.account is not None:
            try:
                self.account.unobserve_count(self.Refreshxor)
            except NotImplementedError:
                pass
            try:
                self.account.unobserve_state(self.Refreshxor)
            except NotImplementedError:
                pass

        self.account = account
        self.icon    = account.icon.Resized(16)

        # Construct action links
        self.linkage.Clear(True)
        for linkfunc in account.header_funcs:
            link = ClearLink(self, -1, linkfunc[0], lambda l=linkfunc: self.do_link(l),
                             style = link_style, pos = (-400, -400))
            link.NormalColour = link.HoverColour = link.VisitedColour = self.linkfc
            link.Font = self.linkfont
            self.linkage.Add(link)

        self.linkage.Layout()

        if self.extralinkage:
            self.extralinkage.Show(False)
            self.extralinkage.Destroy()
            self.extralinkage = None

        if getattr(account, 'extra_header_func', None) is not None:
            self.extralinkage = elink =  ClearLink(self, -1, account.extra_header_func[0], lambda l=account.extra_header_func: self.do_link(l),
                                          style = link_style, pos = (-400, -400))

            elink.NormalColour = elink.HoverColour = elink.VisitedColour = self.linkfc
            elink.Font = self.elinkfont

            self.ExtraLinkLayout()




        try:
            self._unbound_cbs.clear()
        except AttributeError:
            pass

        try:
            account.observe_count(self.Refreshxor)
        except NotImplementedError:
            pass
        try:
            account.observe_state(self.Refreshxor)
        except NotImplementedError:
            pass


        self.Refresh(False)