-
Notifications
You must be signed in to change notification settings - Fork 149
/
contactlistview.py
85 lines (69 loc) · 2.76 KB
/
contactlistview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from stringview import *
from imageview import *
from menuview import *
class ContactListView:
def __init__(self):
self.group_ids = []
class GroupView:
def __init__(self, core, uid, name, contact_ids=[], active=0):
self.uid = uid
self.contact_ids = set(contact_ids)
self.icon = ImageView() # TODO: expanded/collapsed icon
self.name = StringView() # TODO: default color from skin/settings
self.name.appendText(name) #TODO: parse for smileys
active = 0 #TODO
total = len(self.contact_ids)
self.name.appendText("(" + str(active) + "/" + str(total) + ")")
self.on_click = None #TODO: collapse, expand
self.on_double_click = None
self.on_right_click_popup_menu = GroupPopupMenu(core)
self.tooltip = None
self.context_menu = None
#TODO: @roproperty: context_menu, tooltip
""" a view of a contact on the contact list """
class ContactView:
def __init__(self, core, amsn_contact):
"""
@type core: aMSNCore
@type amsn_contact: aMSNContact
"""
self.uid = amsn_contact.uid
self.icon = amsn_contact.icon
#TODO: apply emblem on dp
self.dp = amsn_contact.dp.clone()
self.dp.appendImageView(amsn_contact.emblem)
self.name = StringView() # TODO : default colors
self.name.openTag("nickname")
self.name.appendStringView(amsn_contact.nickname) # TODO parse
self.name.closeTag("nickname")
self.name.appendText(" ")
self.name.openTag("status")
self.name.appendText("(")
self.name.appendStringView(amsn_contact.status)
self.name.appendText(")")
self.name.closeTag("status")
self.name.appendText(" ")
self.name.openTag("psm")
self.name.setItalic()
self.name.appendStringView(amsn_contact.personal_message)
self.name.unsetItalic()
self.name.closeTag("psm")
#TODO:
def startConversation_cb(c_uid):
core._conversation_manager.newConversation([c_uid])
self.on_click = startConversation_cb
self.on_double_click = None
self.on_right_click_popup_menu = ContactPopupMenu(core, amsn_contact)
self.tooltip = None
self.context_menu = None
#TODO: @roproperty: context_menu, tooltip
class ContactPopupMenu(MenuView):
def __init__(self, core, amsncontact):
MenuView.__init__(self)
remove = MenuItemView(MenuItemView.COMMAND,
label="Remove %s" % amsncontact.account,
command= lambda: core._contactlist_manager.removeContact(amsncontact.uid))
self.addItem(remove)
class GroupPopupMenu(MenuView):
def __init__(self, core):
MenuView.__init__(self)