def construct(self): item = self.item subject = item.subject if not subject or item.is_communication(): return builder = new_builder("message-editor") sort_data = self.MESSAGE_SORT lifeline = get_lifeline(item, item.tail) # disallow connecting two delete messages to a lifeline if (lifeline and lifeline.is_destroyed and subject.messageSort != "deleteMessage"): sort_data = list(sort_data) assert sort_data[4][1] == "deleteMessage" del sort_data[4] self.model = ComboModel(sort_data) combo = builder.get_object("message-combo") combo.set_model(self.model) index = self.model.get_index(subject.messageSort) combo.set_active(index) builder.connect_signals( {"message-combo-changed": (self._on_message_sort_change, )}) return builder.get_object("message-editor")
def _on_message_sort_change(self, combo): """Update message item's message sort information.""" ms = self.model.get_value(combo.get_active()) item = self.item subject = item.subject lifeline = get_lifeline(item, item.tail) # allow only one delete message to connect to lifeline's lifetime # destroyed status can be changed only by delete message itself if lifeline and (subject.messageSort == "deleteMessage" or not lifeline.is_destroyed): is_destroyed = ms == "deleteMessage" lifeline.is_destroyed = is_destroyed lifeline.request_update() subject.messageSort = ms item.request_update()