comparison frontends/src/primitivus/chat.py @ 1158:c0f15e52695a

primitivus: use of new keys modules from Urwid SàText
author Goffi <goffi@goffi.org>
date Thu, 04 Sep 2014 19:05:57 +0200
parents 75025461141f
children cae023216bba
comparison
equal deleted inserted replaced
1157:c4b62e6b7377 1158:c0f15e52695a
24 from sat_frontends.quick_frontend.quick_chat import QuickChat 24 from sat_frontends.quick_frontend.quick_chat import QuickChat
25 from sat_frontends.primitivus.card_game import CardGame 25 from sat_frontends.primitivus.card_game import CardGame
26 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate 26 from sat_frontends.quick_frontend.quick_utils import escapePrivate, unescapePrivate
27 from sat_frontends.primitivus import xmlui 27 from sat_frontends.primitivus import xmlui
28 from sat_frontends.primitivus.constants import Const as C 28 from sat_frontends.primitivus.constants import Const as C
29 from sat_frontends.primitivus.keys import action_key_map as a_key
29 import time 30 import time
30 from sat_frontends.tools.jid import JID 31 from sat_frontends.tools.jid import JID
31 32
32 33
33 class ChatText(urwid.FlowWidget): 34 class ChatText(urwid.FlowWidget):
93 self.show_short_nick = False 94 self.show_short_nick = False
94 self.show_title = 1 #0: clip title; 1: full title; 2: no title 95 self.show_title = 1 #0: clip title; 1: full title; 2: no title
95 self.subject = None 96 self.subject = None
96 97
97 def keypress(self, size, key): 98 def keypress(self, size, key):
98 if key == "meta p": #user wants to (un)hide the presents panel 99 if key == a_key['OCCUPANTS_HIDE']: #user wants to (un)hide the presents panel
99 if self.type == 'group': 100 if self.type == 'group':
100 widgets = [widget for (widget, options) in self.chat_colums.contents] 101 widgets = [widget for (widget, options) in self.chat_colums.contents]
101 if self.present_panel in widgets: 102 if self.present_panel in widgets:
102 self.__removePresentPanel() 103 self.__removePresentPanel()
103 else: 104 else:
104 self.__appendPresentPanel() 105 self.__appendPresentPanel()
105 elif key == "meta t": #user wants to (un)hide timestamp 106 elif key == a_key['TIMESTAMP_HIDE']: #user wants to (un)hide timestamp
106 self.show_timestamp = not self.show_timestamp 107 self.show_timestamp = not self.show_timestamp
107 for wid in self.content: 108 for wid in self.content:
108 wid._invalidate() 109 wid._invalidate()
109 elif key == "meta n": #user wants to (not) use short nick 110 elif key == a_key['SHORT_NICKNAME']: #user wants to (not) use short nick
110 self.show_short_nick = not self.show_short_nick 111 self.show_short_nick = not self.show_short_nick
111 for wid in self.content: 112 for wid in self.content:
112 wid._invalidate() 113 wid._invalidate()
113 elif key == "meta l": #user wants to (un)hide widget decoration 114 elif key == a_key['DECORATION_HIDE']: #user wants to (un)hide widget decoration
114 show = not isinstance(self._w, sat_widgets.LabelLine) 115 show = not isinstance(self._w, sat_widgets.LabelLine)
115 self.showDecoration(show) 116 self.showDecoration(show)
116 self._invalidate() 117 self._invalidate()
117 elif key == "meta s": #user wants to (un)hide group's subject or change its apperance 118 elif key == a_key['SUBJECT_SWITCH']: #user wants to (un)hide group's subject or change its apperance
118 if self.subject: 119 if self.subject:
119 self.show_title = (self.show_title + 1) % 3 120 self.show_title = (self.show_title + 1) % 3
120 if self.show_title == 0: 121 if self.show_title == 0:
121 self.setSubject(self.subject,'clip') 122 self.setSubject(self.subject,'clip')
122 elif self.show_title == 1: 123 elif self.show_title == 1: