Example #1
0
    def WhenStateChange(self, acct, attr, old, new):
        """
        When the account state changes this calls everything that sets up the
        the elements of the panel and determines whether it shows or hides
        """
        # An if self check becasue it's posible the callback could trigger between
        # the time the object is destroyed and the observer is removed
        account = self.account

        #When in the WILL_RECONNECT state, registered to refresh every 1 second
        from gui.toolbox.refreshtimer import refreshtimer
        if account.offline_reason == OfflineReason.WILL_RECONNECT:
            self.reason = lambda: profile.account_manager.state_desc(self.
                                                                     account)
            refreshtimer().Register(self)
        else:
            self.reason = profile.account_manager.state_desc(
                account
            ) if account.state == ProtocolStatus.OFFLINE and account.offline_reason else _(
                account.state)
            refreshtimer().UnRegister(self)

        self.stateicon = account.statusicon.ResizedSmaller(16)

        if not wx.IsDestroyed(self):
            self.MakeLink()
            self.CalcLayout()
            self.Refresh()
            #Tells DetermineShow to delay the hide if state changed to ONLINE or OFFLINE
            delayed = (account.state == ProtocolStatus.ONLINE) or (
                account.state == ProtocolStatus.OFFLINE
                and account.offline_reason == OfflineReason.NONE)
            self.DetermineShow(delayed)
            self.Parent.SelfSize()
            self.GrandParent.Parent.Layout()
Example #2
0
    def WhenStateChange(self, acct, attr, old, new):
        """
        When the account state changes this calls everything that sets up the
        the elements of the panel and determines whether it shows or hides
        """
        # An if self check becasue it's posible the callback could trigger between
        # the time the object is destroyed and the observer is removed
        account = self.account

        #When in the WILL_RECONNECT state, registered to refresh every 1 second
        from gui.toolbox.refreshtimer import refreshtimer
        if account.offline_reason == OfflineReason.WILL_RECONNECT:
            self.reason = lambda: profile.account_manager.state_desc(self.account)
            refreshtimer().Register(self)
        else:
            self.reason = profile.account_manager.state_desc(account) if account.state==ProtocolStatus.OFFLINE and account.offline_reason else _(account.state)
            refreshtimer().UnRegister(self)

        self.stateicon = account.statusicon.ResizedSmaller(16)

        if not wx.IsDestroyed(self):
            self.MakeLink()
            self.CalcLayout()
            self.Refresh()
            #Tells DetermineShow to delay the hide if state changed to ONLINE or OFFLINE
            delayed = (account.state == ProtocolStatus.ONLINE) or (account.state == ProtocolStatus.OFFLINE and account.offline_reason == OfflineReason.NONE)
            self.DetermineShow(delayed)
            self.Parent.SelfSize()
            self.GrandParent.Parent.Layout()
Example #3
0
    def WhenStateChanged(self, acct, attr, old, new):
        'This handles all changes on an account level.'

        #update new item count
        if attr in ('count', 'alerts', 'alias'):
            wx.CallAfter(self.CalledAfterRefreshLine, acct)
        #rebuild list when account is disabled or enabled
        elif attr == 'enabled':
            wx.CallAfter(self.BuildList)
        #Offline reason has changed, set up message
        elif attr == 'state' or attr == 'offline_reason':
            if acct.offline_reason == acct.Reasons.WILL_RECONNECT:
                self.willreconaccts.add(acct)
            else:
                self.willreconaccts.discard(acct)

            if len(self.willreconaccts):
                refreshtimer().Register(self)
            else:
                refreshtimer().UnRegister(self)

            self.Refresh()
Example #4
0
    def WhenStateChanged(self, acct, attr, old, new):
        'This handles all changes on an account level.'

        #update new item count
        if attr in ('count', 'alerts', 'alias'):
            wx.CallAfter(self.CalledAfterRefreshLine,acct)
        #rebuild list when account is disabled or enabled
        elif attr == 'enabled':
            wx.CallAfter(self.BuildList)
        #Offline reason has changed, set up message
        elif attr == 'state' or attr == 'offline_reason':
            if acct.offline_reason == acct.Reasons.WILL_RECONNECT:
                self.willreconaccts.add(acct)
            else:
                self.willreconaccts.discard(acct)

            if len(self.willreconaccts):
                refreshtimer().Register(self)
            else:
                refreshtimer().UnRegister(self)

            self.Refresh()
Example #5
0
    def Error(self, message = None, link = None, callback = None):
        """
            This shows the panel with the message provided.
            Has a link in the lower right if a link string and callback are provided.
            If message is None, the panel is hidden.
            If the message is a callable, then the panel is added to the refresh
            timer and message is called every 1 second, expecting a string to be
            returned.
        """

        self.message = message

        #destroy old link if there is one
        self.link=''

        if message:
            # if link and callback are provided, make a ClearLink object
            if link and callback:
                self.linkcb = lambda *a: (wx.GetTopLevelParent(self).Hide(), callback(*a))
                self.link = link
                linksize = wx.Size(GetTextWidth(link,self.linkf),self.linkf.Height)
                self.linkrect = wx.Rect(self.Size.width-linksize.width-self.padding.x,self.Size.height-linksize.height-self.padding.y,*linksize)

            self.Show(True)

            self.MinSize = wx.Size(-1, 5 * max(self.labelf.Height, self.linkf.Height))

            self.GrandParent.DoSizeMagic()
            self.Refresh()
        else:
            self.Show(False)

        #if message is a callable, register with refresh timer
        if callable(message):
            refreshtimer().Register(self)
        else:
            refreshtimer().UnRegister(self)
Example #6
0
 def __dtor__(self):
     from gui.toolbox.refreshtimer import refreshtimer
     refreshtimer().UnRegister(self)
Example #7
0
 def __dtor__(self):
     from gui.toolbox.refreshtimer import refreshtimer
     refreshtimer().UnRegister(self)