Mercurial > libervia-backend
comparison frontends/primitivus/chat.py @ 130:5a88ad24ccc0
Primitivus: subject in group chat can now be shown in 3 ways: clip, full, or hidden
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 14 Jul 2010 16:14:48 +0800 |
parents | 1b33b681ebd8 |
children | 227394eb080c |
comparison
equal
deleted
inserted
replaced
129:542682d67282 | 130:5a88ad24ccc0 |
---|---|
83 urwid.WidgetWrap.__init__(self, self.__getDecoration(self.columns)) | 83 urwid.WidgetWrap.__init__(self, self.__getDecoration(self.columns)) |
84 self.setType(type) | 84 self.setType(type) |
85 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time | 85 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time |
86 self.show_timestamp = True | 86 self.show_timestamp = True |
87 self.show_short_nick = False | 87 self.show_short_nick = False |
88 self.show_title = True | 88 self.show_title = 1 #0: clip title; 1: full title; 2: no title |
89 self.subject = None | 89 self.subject = None |
90 | 90 |
91 def keypress(self, size, key): | 91 def keypress(self, size, key): |
92 if key == "meta p": #user wants to (un)hide the presents panel | 92 if key == "meta p": #user wants to (un)hide the presents panel |
93 if self.type == 'group': | 93 if self.type == 'group': |
108 show = not self._w.__class__ == custom_widgets.LabelLine | 108 show = not self._w.__class__ == custom_widgets.LabelLine |
109 self.showDecoration(show) | 109 self.showDecoration(show) |
110 self._invalidate() | 110 self._invalidate() |
111 elif key == "meta s": #user wants to (un)hide group's subject | 111 elif key == "meta s": #user wants to (un)hide group's subject |
112 if self.subject: | 112 if self.subject: |
113 self.show_title = not self.show_title | 113 self.show_title = (self.show_title + 1) % 3 |
114 if self.show_title: | 114 if self.show_title == 0: |
115 self.setSubject(self.subject) | 115 self.setSubject(self.subject,'clip') |
116 else: | 116 elif self.show_title == 1: |
117 self.setSubject(self.subject,'space') | |
118 elif self.show_title == 2: | |
117 self.chat_widget.header = None | 119 self.chat_widget.header = None |
118 self._invalidate() | 120 self._invalidate() |
119 | 121 |
120 | 122 |
121 return super(Chat, self).keypress(size, key) | 123 return super(Chat, self).keypress(size, key) |
152 def __removePresentPanel(self): | 154 def __removePresentPanel(self): |
153 self.columns.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.columns | 155 self.columns.set_focus(0) #necessary as the focus change to the next object, we can go out of range if we are on the last object of self.columns |
154 self.columns.widget_list.remove(self.present_panel) | 156 self.columns.widget_list.remove(self.present_panel) |
155 del self.columns.column_types[-1] | 157 del self.columns.column_types[-1] |
156 | 158 |
157 def setSubject(self, subject): | 159 def setSubject(self, subject, wrap='space'): |
158 """Set title for a group chat""" | 160 """Set title for a group chat""" |
159 QuickChat.setSubject(self, subject) | 161 QuickChat.setSubject(self, subject) |
160 self.subject = subject | 162 self.subject = subject |
161 self.chat_widget.header = urwid.AttrMap(urwid.Text(unicode(subject),align='center'),'title') | 163 self.subj_wid = urwid.Text(unicode(subject.replace('\n','|') if wrap == 'clip' else subject ), |
164 align='left' if wrap=='clip' else 'center',wrap=wrap) | |
165 self.chat_widget.header = urwid.AttrMap(self.subj_wid,'title') | |
166 self.host.redraw() | |
162 | 167 |
163 def setPresents(self, param_nicks): | 168 def setPresents(self, param_nicks): |
164 """Set the users presents in the contact list for a group chat | 169 """Set the users presents in the contact list for a group chat |
165 @param nicks: list of nicknames | 170 @param nicks: list of nicknames |
166 """ | 171 """ |