comparison frontends/src/primitivus/chat.py @ 812:084b52afdceb

frontends: fixed /me usage + renamed a couple of "type" parameters to type_
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:51:16 +0100
parents 1fe00f0c9a91
children f3513c8cc2e6
comparison
equal deleted inserted replaced
811:1fe00f0c9a91 812:084b52afdceb
74 return urwid.Text(render_txt, align=self.align) 74 return urwid.Text(render_txt, align=self.align)
75 75
76 76
77 class Chat(urwid.WidgetWrap, QuickChat): 77 class Chat(urwid.WidgetWrap, QuickChat):
78 78
79 def __init__(self, target, host, type='one2one'): 79 def __init__(self, target, host, type_='one2one'):
80 self.target = target 80 self.target = target
81 QuickChat.__init__(self, target, host, type) 81 QuickChat.__init__(self, target, host, type_)
82 self.content = urwid.SimpleListWalker([]) 82 self.content = urwid.SimpleListWalker([])
83 self.text_list = urwid.ListBox(self.content) 83 self.text_list = urwid.ListBox(self.content)
84 self.chat_widget = urwid.Frame(self.text_list) 84 self.chat_widget = urwid.Frame(self.text_list)
85 self.chat_colums = urwid.Columns([('weight', 8, self.chat_widget)]) 85 self.chat_colums = urwid.Columns([('weight', 8, self.chat_widget)])
86 self.chat_colums = urwid.Columns([('weight', 8, self.chat_widget)]) 86 self.chat_colums = urwid.Columns([('weight', 8, self.chat_widget)])
87 self.pile = urwid.Pile([self.chat_colums]) 87 self.pile = urwid.Pile([self.chat_colums])
88 urwid.WidgetWrap.__init__(self, self.__getDecoration(self.pile)) 88 urwid.WidgetWrap.__init__(self, self.__getDecoration(self.pile))
89 self.setType(type) 89 self.setType(type_)
90 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time 90 self.day_change = time.strptime(time.strftime("%a %b %d 00:00:00 %Y")) #struct_time of day changing time
91 self.show_timestamp = True 91 self.show_timestamp = True
92 self.show_short_nick = False 92 self.show_short_nick = False
93 self.show_title = 1 #0: clip title; 1: full title; 2: no title 93 self.show_title = 1 #0: clip title; 1: full title; 2: no title
94 self.subject = None 94 self.subject = None
137 menu.addMenu(muc, _("Configure room"), self.onConfigureRoom) 137 menu.addMenu(muc, _("Configure room"), self.onConfigureRoom)
138 elif self.type == 'one2one': 138 elif self.type == 'one2one':
139 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest) 139 menu.addMenu(_("Action"), _("Send file"), self.onSendFileRequest)
140 return menu 140 return menu
141 141
142 def setType(self, type): 142 def setType(self, type_):
143 QuickChat.setType(self, type) 143 QuickChat.setType(self, type_)
144 if type == 'one2one': 144 if type_ == 'one2one':
145 self.historyPrint(profile=self.host.profile) 145 self.historyPrint(profile=self.host.profile)
146 elif type == 'group': 146 elif type_ == 'group':
147 if len(self.chat_colums.contents) == 1: 147 if len(self.chat_colums.contents) == 1:
148 present_widget = self.__buildPresentList() 148 present_widget = self.__buildPresentList()
149 self.present_panel = sat_widgets.VerticalSeparator(present_widget) 149 self.present_panel = sat_widgets.VerticalSeparator(present_widget)
150 self.__appendPresentPanel() 150 self.__appendPresentPanel()
151 151
291 self._notify(from_jid, msg) 291 self._notify(from_jid, msg)
292 292
293 def printInfo(self, msg, type_='normal', timestamp=""): 293 def printInfo(self, msg, type_='normal', timestamp=""):
294 """Print general info 294 """Print general info
295 @param msg: message to print 295 @param msg: message to print
296 @type: one of: 296 @type_: one of:
297 normal: general info like "toto has joined the room" 297 normal: general info like "toto has joined the room"
298 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist" 298 me: "/me" information like "/me clenches his fist" ==> "toto clenches his fist"
299 """ 299 """
300 _widget = ChatText(self, timestamp or None, None, False, msg, is_info=True) 300 _widget = ChatText(self, timestamp or None, None, False, msg, is_info=True)
301 self.content.append(_widget) 301 self.content.append(_widget)