Primitivus: subject in group chat can now be shown in 3 ways: clip, full, or hidden

This commit is contained in:
Goffi 2010-07-14 16:14:48 +08:00
commit 0bdb911415

View file

@ -85,7 +85,7 @@ class Chat(urwid.WidgetWrap, QuickChat):
self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time
self.show_timestamp = True
self.show_short_nick = False
self.show_title = True
self.show_title = 1 #0: clip title; 1: full title; 2: no title
self.subject = None
def keypress(self, size, key):
@ -110,10 +110,12 @@ class Chat(urwid.WidgetWrap, QuickChat):
self._invalidate()
elif key == "meta s": #user wants to (un)hide group's subject
if self.subject:
self.show_title = not self.show_title
if self.show_title:
self.setSubject(self.subject)
else:
self.show_title = (self.show_title + 1) % 3
if self.show_title == 0:
self.setSubject(self.subject,'clip')
elif self.show_title == 1:
self.setSubject(self.subject,'space')
elif self.show_title == 2:
self.chat_widget.header = None
self._invalidate()
@ -154,11 +156,14 @@ class Chat(urwid.WidgetWrap, QuickChat):
self.columns.widget_list.remove(self.present_panel)
del self.columns.column_types[-1]
def setSubject(self, subject):
def setSubject(self, subject, wrap='space'):
"""Set title for a group chat"""
QuickChat.setSubject(self, subject)
self.subject = subject
self.chat_widget.header = urwid.AttrMap(urwid.Text(unicode(subject),align='center'),'title')
self.subj_wid = urwid.Text(unicode(subject.replace('\n','|') if wrap == 'clip' else subject ),
align='left' if wrap=='clip' else 'center',wrap=wrap)
self.chat_widget.header = urwid.AttrMap(self.subj_wid,'title')
self.host.redraw()
def setPresents(self, param_nicks):
"""Set the users presents in the contact list for a group chat