def update_view(self): #from common.notifications import set_active #set_active(get_notifications()) notifications, contact = self.notifications, self.for_contact if contact is not None: contact = contact.idstr() contactobj = contact showing_contacts = True already_added, root = [], [] gnots = {} if None not in notifications else notifications[None] for topic, notif in get_notification_info().iteritems(): events, desc = [], notif['description'] if contact is None: if topic in gnots: p = deepcopy(gnots[topic]) events.extend(p) # Grab events for contacts (maybe) if showing_contacts: for subcontact in (set(notifications.keys()) - set([None])): if subcontact in self.notifications: if topic in self.notifications[subcontact]: c_events = deepcopy(notifications[subcontact][topic]) if c_events: events.extend([(dictadd({'contact': subcontact}, e)) for e in c_events]) if events: already_added += [topic] root.append(ActionEntry(topic, events, description = desc, icon_skinpath = notif.get('notification_icon', None))) else: if contact in notifications: if topic in notifications[contact]: events = deepcopy(notifications[contact][topic]) if events: already_added += [topic] root.append(ActionEntry(topic, events, description = desc, icon_skinpath = notif.get('notification_icon', None))) # Add event categories with no events set for topic, notif in get_notification_info().iteritems(): if not topic in already_added: root.append(ActionEntry(topic, description = notif['description'], icon_skinpath = notif.get('notification_icon', None))) self.set_root(root)
def on_add(self, e): i = self.GetSelection() if i != -1: if isinstance(self[i], EventEntry): i = self.model.index_of(self.GetParent(self[i])) topic = self[i].topic assert isinstance(topic, basestring), 'topic is a %s' % type(topic) # Display the event edit dialog. diag = EventDialog(self, get_notification_info()[topic]['description']) res = diag.ShowModal() if res == wx.ID_OK: contact = self.for_contact.idstr( ) if self.for_contact else None if contact not in self.notifications: self.notifications[contact] = dict() if topic not in self.notifications[contact]: self.notifications[contact][topic] = list() self.notifications[contact][topic].append(deepcopy( diag.info())) diag.Destroy() self.CallAll(NotificationView.update_view)
def on_add(self, e): i = self.GetSelection() if i != -1: if isinstance(self[i], EventEntry): i = self.model.index_of(self.GetParent(self[i])) topic = self[i].topic assert isinstance(topic, basestring), 'topic is a %s' % type(topic) # Display the event edit dialog. diag = EventDialog(self, get_notification_info()[topic]['description']) res = diag.ShowModal() if res == wx.ID_OK: contact = self.for_contact.idstr() if self.for_contact else None if contact not in self.notifications: self.notifications[contact] = dict() if topic not in self.notifications[contact]: self.notifications[contact][topic] = list() self.notifications[contact][topic].append(deepcopy(diag.info())) diag.Destroy() self.CallAll(NotificationView.update_view)
def main(): from common.notifications import get_notification_info from common.notifications import Popup userInfo = {None: {'contact.available': [{'reaction': Popup}], 'contact.away': [{'reaction': Popup}], 'email.new': [{'reaction': Popup}], 'error': [{'reaction': Popup}], 'facebook.alert': [{'reaction': Popup}], 'filetransfer.request': [{'reaction': Popup}], 'message.received.background': [{'reaction': Popup}], 'myspace.alert': [{'reaction': Popup}]}} from tests.testapp import testapp app = testapp('../../..') f = wx.Frame(None, -1, 'notifications gui test') p = NotifyPanel(f) n = p.NotifyView n.NotificationInfo = get_notification_info() n.UserNotifications = userInfo f.Show() app.MainLoop()
def build_notification_area(parent): notification_viewer = pref('notifications.editor.view', type=str, default='simple') if notification_viewer == 'tree': # use the treelist view to edit notifications from gui.notificationview import NotificationView return NotificationView(parent, profile.notifications) else: # use a simple viewer with checkboxes for Popup and Sound from common.notifications import get_notification_info notifypanel = NotifyPanel(parent) n = notifypanel.NotifyView n.SetNotificationInfo(get_notification_info()) n.SetUserNotifications(profile.notifications) n.UpdateSkin() return notifypanel
def build_notification_area(parent): notification_viewer = pref("notifications.editor.view", type=str, default="simple") if notification_viewer == "tree": # use the treelist view to edit notifications from gui.notificationview import NotificationView return NotificationView(parent, profile.notifications) else: # use a simple viewer with checkboxes for Popup and Sound from common.notifications import get_notification_info notifypanel = NotifyPanel(parent) n = notifypanel.NotifyView n.SetNotificationInfo(get_notification_info()) n.SetUserNotifications(profile.notifications) n.UpdateSkin() return notifypanel
def on_add_or_edit(self, e = None): i = self.GetSelection() if i == -1: return obj = self[i] if isinstance(obj, ActionEntry): return self.on_add(e) else: parent = self.model.parent_of(obj) description = get_notification_info()[parent.topic]['description'] diag = EventDialog(self, description, event = obj.event) res = diag.ShowModal() if res == wx.ID_OK: contact = None if self.for_contact is None else self.for_contact.idstr() if 'contact' in obj.event: contact = obj.event['contact'] nots = self.notifications[contact] notif = nots[parent.topic] notif.insert(notif.index(obj.event), deepcopy(diag.info())) notif.remove(obj.event) self.CallAll(NotificationView.update_view) diag.Destroy()
def on_add_or_edit(self, e=None): i = self.GetSelection() if i == -1: return obj = self[i] if isinstance(obj, ActionEntry): return self.on_add(e) else: parent = self.model.parent_of(obj) description = get_notification_info()[parent.topic]['description'] diag = EventDialog(self, description, event=obj.event) res = diag.ShowModal() if res == wx.ID_OK: contact = None if self.for_contact is None else self.for_contact.idstr( ) if 'contact' in obj.event: contact = obj.event['contact'] nots = self.notifications[contact] notif = nots[parent.topic] notif.insert(notif.index(obj.event), deepcopy(diag.info())) notif.remove(obj.event) self.CallAll(NotificationView.update_view) diag.Destroy()
def update_view(self): #from common.notifications import set_active #set_active(get_notifications()) notifications, contact = self.notifications, self.for_contact if contact is not None: contact = contact.idstr() contactobj = contact showing_contacts = True already_added, root = [], [] gnots = {} if None not in notifications else notifications[None] for topic, notif in get_notification_info().iteritems(): events, desc = [], notif['description'] if contact is None: if topic in gnots: p = deepcopy(gnots[topic]) events.extend(p) # Grab events for contacts (maybe) if showing_contacts: for subcontact in (set(notifications.keys()) - set([None])): if subcontact in self.notifications: if topic in self.notifications[subcontact]: c_events = deepcopy( notifications[subcontact][topic]) if c_events: events.extend([ (dictadd({'contact': subcontact}, e)) for e in c_events ]) if events: already_added += [topic] root.append( ActionEntry(topic, events, description=desc, icon_skinpath=notif.get( 'notification_icon', None))) else: if contact in notifications: if topic in notifications[contact]: events = deepcopy(notifications[contact][topic]) if events: already_added += [topic] root.append( ActionEntry(topic, events, description=desc, icon_skinpath=notif.get( 'notification_icon', None))) # Add event categories with no events set for topic, notif in get_notification_info().iteritems(): if not topic in already_added: root.append( ActionEntry(topic, description=notif['description'], icon_skinpath=notif.get( 'notification_icon', None))) self.set_root(root)