Exemplo n.º 1
0
    def on_remove(self, e):
        i = self.GetSelection()
        if i == -1: return

        obj = self[i]

        if isinstance(obj, ActionEntry):
            return

        contact = obj.event.get('contact', # buddy specific
                                None if self.for_contact is None # global
                                else self.for_contact.idstr())   # buddy specific window

        if 'contact' in obj.event:
            contact = obj.event['contact']

        if isinstance(obj, EventEntry):
            parent = self.GetParent(obj)
            parent.remove(obj)

            topic = self.notifications[contact][parent.topic]
            topic.remove(dictsub(obj.event, {'contact':None}))
            if len(topic) == 0:
                del self.notifications[contact][parent.topic]
            self.CallAll(NotificationView.update_view)

        elif isinstance(obj, NotificationEntry):
            n = len(obj.events)
            msg = ngettext(_('Are you sure you want to remove %d event?') % n,
                           _('Are you sure you want to remove %d events?') % n,
                           n)
            if wx.YES == wx.MessageBox(msg, _('Remove Events: {notification_desc}').format(notification_desc=obj.description),
                          style = wx.YES_NO):
                del self.notifications[contact][obj.topic]
                self.update_view()
Exemplo n.º 2
0
    def on_selection(self, e):
        'When an event is selected, "preview" it.'

        sel = self.GetSelection()
        if sel != -1:
            obj = self[sel]
            if isinstance(obj, EventEntry):
                obj.event['reaction'](**dictsub(obj.event, {'reaction': None})).preview()
Exemplo n.º 3
0
    def on_selection(self, e):
        'When an event is selected, "preview" it.'

        sel = self.GetSelection()
        if sel != -1:
            obj = self[sel]
            if isinstance(obj, EventEntry):
                obj.event['reaction'](
                    **dictsub(obj.event, {'reaction': None})).preview()
Exemplo n.º 4
0
    def on_remove(self, e):
        i = self.GetSelection()
        if i == -1: return

        obj = self[i]

        if isinstance(obj, ActionEntry):
            return

        contact = obj.event.get(
            'contact',  # buddy specific
            None if self.for_contact is None  # global
            else self.for_contact.idstr())  # buddy specific window

        if 'contact' in obj.event:
            contact = obj.event['contact']

        if isinstance(obj, EventEntry):
            parent = self.GetParent(obj)
            parent.remove(obj)

            topic = self.notifications[contact][parent.topic]
            topic.remove(dictsub(obj.event, {'contact': None}))
            if len(topic) == 0:
                del self.notifications[contact][parent.topic]
            self.CallAll(NotificationView.update_view)

        elif isinstance(obj, NotificationEntry):
            n = len(obj.events)
            msg = ngettext(
                _('Are you sure you want to remove %d event?') % n,
                _('Are you sure you want to remove %d events?') % n, n)
            if wx.YES == wx.MessageBox(
                    msg,
                    _('Remove Events: {notification_desc}').format(
                        notification_desc=obj.description),
                    style=wx.YES_NO):
                del self.notifications[contact][obj.topic]
                self.update_view()