From 0bdb9114157cb037ebfe83b7513ed0dccd369615 Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 14 Jul 2010 16:14:48 +0800 Subject: [PATCH] Primitivus: subject in group chat can now be shown in 3 ways: clip, full, or hidden --- frontends/primitivus/chat.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/frontends/primitivus/chat.py b/frontends/primitivus/chat.py index 904e8358..ea05baf8 100644 --- a/frontends/primitivus/chat.py +++ b/frontends/primitivus/chat.py @@ -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