comparison frontends/src/primitivus/chat.py @ 2024:01aff34e8873

quick frontends, primitivus: messageState signal handling
author Goffi <goffi@goffi.org>
date Tue, 02 Aug 2016 23:11:44 +0200
parents 88c41a195728
children 62a99c214b57
comparison
equal deleted inserted replaced
2023:224c8b0886bc 2024:01aff34e8873
79 except AttributeError: 79 except AttributeError:
80 return C.MESS_TYPE_INFO 80 return C.MESS_TYPE_INFO
81 81
82 def redraw(self): 82 def redraw(self):
83 self._w.set_text(self.markup) 83 self._w.set_text(self.markup)
84 self.mess_data.parent.host.redraw() # FIXME: should not be necessary
84 85
85 def selectable(self): 86 def selectable(self):
86 return True 87 return True
87 88
88 def keypress(self, size, key): 89 def keypress(self, size, key):
106 """Generate text markup according to message data and Widget options""" 107 """Generate text markup according to message data and Widget options"""
107 markup = [] 108 markup = []
108 d = self.mess_data 109 d = self.mess_data
109 mention = d.mention 110 mention = d.mention
110 111
112 # message status
113 if d.status is None:
114 markup.append(u' ')
115 elif d.status == "delivered":
116 markup.append(('msg_status_received', u'✔'))
117 else:
118 log.warning(u"Unknown status: {}".format(d.status))
119
111 # timestamp 120 # timestamp
112 if self.parent.show_timestamp: 121 if self.parent.show_timestamp:
113 # if the message was sent before today, we print the full date 122 # if the message was sent before today, we print the full date
114 time_format = u"%c" if self.timestamp < self.parent.day_change else u"%H:%M" 123 time_format = u"%c" if self.timestamp < self.parent.day_change else u"%H:%M"
115 attr = 'msg_mention' if mention else 'date' 124 attr = 'msg_mention' if mention else 'date'
131 140
132 # message body 141 # message body
133 markup.append(msg) 142 markup.append(msg)
134 143
135 return markup 144 return markup
145
146 # events
147 def updated(self, attributes):
148 self.redraw()
136 149
137 @total_ordering 150 @total_ordering
138 class OccupantWidget(urwid.WidgetWrap): 151 class OccupantWidget(urwid.WidgetWrap):
139 152
140 def __init__(self, occupant_data): 153 def __init__(self, occupant_data):