print_conversation can now have contact = 'info' to print information strings. Fixes #1531
This commit is contained in:
parent
8b1e70c396
commit
60a4b3cf20
2 changed files with 64 additions and 48 deletions
|
@ -542,8 +542,12 @@ class ConversationTextview(gtk.TextView):
|
||||||
other_tags_for_name = [], other_tags_for_time = [],
|
other_tags_for_name = [], other_tags_for_time = [],
|
||||||
other_tags_for_text = [], subject = None):
|
other_tags_for_text = [], subject = None):
|
||||||
'''prints 'chat' type messages'''
|
'''prints 'chat' type messages'''
|
||||||
|
print 'print_conv_line', kind
|
||||||
if kind == 'status' and not gajim.config.get('print_status_in_chats'):
|
if kind == 'status' and not gajim.config.get('print_status_in_chats'):
|
||||||
return
|
return
|
||||||
|
# kind = info, we print things as if it was a status: same color, ...
|
||||||
|
if kind == 'info':
|
||||||
|
kind = 'status'
|
||||||
buffer = self.get_buffer()
|
buffer = self.get_buffer()
|
||||||
buffer.begin_user_action()
|
buffer.begin_user_action()
|
||||||
end_iter = buffer.get_end_iter()
|
end_iter = buffer.get_end_iter()
|
||||||
|
|
|
@ -374,7 +374,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
def print_conversation(self, text, contact = '', tim = None):
|
def print_conversation(self, text, contact = '', tim = None):
|
||||||
'''Print a line in the conversation:
|
'''Print a line in the conversation:
|
||||||
if contact is set: it's a message from someone
|
if contact is set: it's a message from someone or an info message (contact
|
||||||
|
= 'info' in such a case)
|
||||||
if contact is not set: it's a message from the server or help'''
|
if contact is not set: it's a message from the server or help'''
|
||||||
if isinstance(text, str):
|
if isinstance(text, str):
|
||||||
text = unicode(text, 'utf-8')
|
text = unicode(text, 'utf-8')
|
||||||
|
@ -383,6 +384,9 @@ class GroupchatControl(ChatControlBase):
|
||||||
if contact:
|
if contact:
|
||||||
if contact == self.nick: # it's us
|
if contact == self.nick: # it's us
|
||||||
kind = 'outgoing'
|
kind = 'outgoing'
|
||||||
|
elif contact == 'info':
|
||||||
|
kind = 'info'
|
||||||
|
contact = None
|
||||||
else:
|
else:
|
||||||
kind = 'incoming'
|
kind = 'incoming'
|
||||||
# muc-specific chatstate
|
# muc-specific chatstate
|
||||||
|
@ -621,7 +625,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
'nick': nick,
|
'nick': nick,
|
||||||
'who': actor,
|
'who': actor,
|
||||||
'reason': reason }
|
'reason': reason }
|
||||||
self.print_conversation(s)
|
self.print_conversation(s, 'info')
|
||||||
elif statusCode == '301':
|
elif statusCode == '301':
|
||||||
if actor is None: # do not print 'banned by None'
|
if actor is None: # do not print 'banned by None'
|
||||||
s = _('%(nick)s has been banned: %(reason)s') % {
|
s = _('%(nick)s has been banned: %(reason)s') % {
|
||||||
|
@ -632,14 +636,14 @@ class GroupchatControl(ChatControlBase):
|
||||||
'nick': nick,
|
'nick': nick,
|
||||||
'who': actor,
|
'who': actor,
|
||||||
'reason': reason }
|
'reason': reason }
|
||||||
self.print_conversation(s, self.room_jid)
|
self.print_conversation(s, 'info')
|
||||||
elif statusCode == '303': # Someone changed his or her nick
|
elif statusCode == '303': # Someone changed his or her nick
|
||||||
if nick == self.nick: # We changed our nick
|
if nick == self.nick: # We changed our nick
|
||||||
self.nick = new_nick
|
self.nick = new_nick
|
||||||
s = _('You are now known as %s') % new_nick
|
s = _('You are now known as %s') % new_nick
|
||||||
else:
|
else:
|
||||||
s = _('%s is now known as %s') % (nick, new_nick)
|
s = _('%s is now known as %s') % (nick, new_nick)
|
||||||
self.print_conversation(s)
|
self.print_conversation(s, 'info')
|
||||||
|
|
||||||
if not gajim.awaiting_events[self.account].has_key(self.room_jid + '/' + nick):
|
if not gajim.awaiting_events[self.account].has_key(self.room_jid + '/' + nick):
|
||||||
self.remove_contact(nick)
|
self.remove_contact(nick)
|
||||||
|
@ -781,7 +785,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.on_send_pm(nick = nick)
|
self.on_send_pm(nick = nick)
|
||||||
self.clear(self.msg_textview)
|
self.clear(self.msg_textview)
|
||||||
else:
|
else:
|
||||||
self.print_conversation(_('Nickname not found: %s') % nick)
|
self.print_conversation(_('Nickname not found: %s') % nick,
|
||||||
|
'info')
|
||||||
else:
|
else:
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
return True
|
return True
|
||||||
|
@ -797,7 +802,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.on_send_pm(nick=nick, msg=privmsg)
|
self.on_send_pm(nick=nick, msg=privmsg)
|
||||||
self.clear(self.msg_textview)
|
self.clear(self.msg_textview)
|
||||||
else:
|
else:
|
||||||
self.print_conversation(_('Nickname not found: %s') % nick)
|
self.print_conversation(_('Nickname not found: %s') % nick,
|
||||||
|
'info')
|
||||||
else:
|
else:
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
return True
|
return True
|
||||||
|
@ -810,7 +816,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
gajim.connections[self.account].send_gc_subject(self.room_jid,
|
gajim.connections[self.account].send_gc_subject(self.room_jid,
|
||||||
new_topic)
|
new_topic)
|
||||||
else:
|
else:
|
||||||
self.print_conversation(self.subject)
|
self.print_conversation(self.subject, 'info')
|
||||||
self.clear(self.msg_textview)
|
self.clear(self.msg_textview)
|
||||||
return True
|
return True
|
||||||
elif command == 'invite':
|
elif command == 'invite':
|
||||||
|
@ -826,12 +832,12 @@ class GroupchatControl(ChatControlBase):
|
||||||
s = _('Invited %(contact_jid)s to %(room_jid)s.') % {
|
s = _('Invited %(contact_jid)s to %(room_jid)s.') % {
|
||||||
'contact_jid': invitee,
|
'contact_jid': invitee,
|
||||||
'room_jid': self.room_jid}
|
'room_jid': self.room_jid}
|
||||||
self.print_conversation(s)
|
self.print_conversation(s, 'info')
|
||||||
self.clear(self.msg_textview)
|
self.clear(self.msg_textview)
|
||||||
else:
|
else:
|
||||||
#%s is something the user wrote but it is not a jid so we inform
|
#%s is something the user wrote but it is not a jid so we inform
|
||||||
s = _('%s does not appear to be a valid JID') % invitee
|
s = _('%s does not appear to be a valid JID') % invitee
|
||||||
self.print_conversation(s)
|
self.print_conversation(s, 'info')
|
||||||
else:
|
else:
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
return True
|
return True
|
||||||
|
@ -861,7 +867,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
else:
|
else:
|
||||||
#%s is something the user wrote but it is not a jid so we inform
|
#%s is something the user wrote but it is not a jid so we inform
|
||||||
s = _('%s does not appear to be a valid JID') % message_array
|
s = _('%s does not appear to be a valid JID') % message_array
|
||||||
self.print_conversation(s)
|
self.print_conversation(s, 'info')
|
||||||
else:
|
else:
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
return True
|
return True
|
||||||
|
@ -891,7 +897,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
nick, 'outcast', reason)
|
nick, 'outcast', reason)
|
||||||
self.clear(self.msg_textview)
|
self.clear(self.msg_textview)
|
||||||
else:
|
else:
|
||||||
self.print_conversation(_('Nickname not found: %s') % nick)
|
self.print_conversation(_('Nickname not found: %s') % nick,
|
||||||
|
'info')
|
||||||
else:
|
else:
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
return True
|
return True
|
||||||
|
@ -906,7 +913,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
'none', reason)
|
'none', reason)
|
||||||
self.clear(self.msg_textview)
|
self.clear(self.msg_textview)
|
||||||
else:
|
else:
|
||||||
self.print_conversation(_('Nickname not found: %s') % nick)
|
self.print_conversation(_('Nickname not found: %s') % nick,
|
||||||
|
'info')
|
||||||
else:
|
else:
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
return True
|
return True
|
||||||
|
@ -927,8 +935,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.get_command_help(command)
|
self.get_command_help(command)
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
self.print_conversation(_('No such command: /%s (if you want to send this, '
|
self.print_conversation(_('No such command: /%s (if you want to send '
|
||||||
'prefix it with /say)') % command)
|
'this, prefix it with /say)') % command, 'info')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
@ -949,55 +957,59 @@ class GroupchatControl(ChatControlBase):
|
||||||
|
|
||||||
def get_command_help(self, command):
|
def get_command_help(self, command):
|
||||||
if command == 'help':
|
if command == 'help':
|
||||||
self.print_conversation(_('Commands: %s') % self.muc_cmds)
|
self.print_conversation(_('Commands: %s') % self.muc_cmds, 'info')
|
||||||
elif command == 'ban':
|
elif command == 'ban':
|
||||||
s = _('Usage: /%s <nickname|JID> [reason], bans the JID from the room.'
|
s = _('Usage: /%s <nickname|JID> [reason], bans the JID from the room.'
|
||||||
' The nickname of an occupant may be substituted, but not if it contains "@".'
|
' The nickname of an occupant may be substituted, but not if it '
|
||||||
' If the JID is currently in the room, he/she/it will also be kicked.'
|
'contains "@". If the JID is currently in the room, he/she/it will '
|
||||||
' Does NOT support spaces in nickname.') % command
|
'also be kicked. Does NOT support spaces in nickname.') % command
|
||||||
self.print_conversation(s)
|
self.print_conversation(s, 'info')
|
||||||
elif command == 'chat' or command == 'query':
|
elif command == 'chat' or command == 'query':
|
||||||
self.print_conversation(_('Usage: /%s <nickname>, opens a private chat'
|
self.print_conversation(_('Usage: /%s <nickname>, opens a private chat'
|
||||||
'window to the specified occupant.') % command)
|
' window to the specified occupant.') % command, 'info')
|
||||||
elif command == 'clear':
|
elif command == 'clear':
|
||||||
self.print_conversation(_('Usage: /%s, clears the text window.') % command)
|
self.print_conversation(
|
||||||
|
_('Usage: /%s, clears the text window.') % command, 'info')
|
||||||
elif command == 'close' or command == 'leave' or command == 'part':
|
elif command == 'close' or command == 'leave' or command == 'part':
|
||||||
self.print_conversation(_('Usage: /%s [reason], closes the current window '
|
self.print_conversation(_('Usage: /%s [reason], closes the current '
|
||||||
'or tab, displaying reason if specified.') % command)
|
'window or tab, displaying reason if specified.') % command, 'info')
|
||||||
elif command == 'compact':
|
elif command == 'compact':
|
||||||
self.print_conversation(_('Usage: /%s, sets the groupchat window to compact '
|
self.print_conversation(_('Usage: /%s, sets the groupchat window to '
|
||||||
'mode.') % command)
|
'compact mode.') % command, 'info')
|
||||||
elif command == 'invite':
|
elif command == 'invite':
|
||||||
self.print_conversation(_('Usage: /%s <JID> [reason], invites JID to the '
|
self.print_conversation(_('Usage: /%s <JID> [reason], invites JID to '
|
||||||
'current room, optionally providing a reason.') % command)
|
'the current room, optionally providing a reason.') % command,
|
||||||
|
'info')
|
||||||
elif command == 'join':
|
elif command == 'join':
|
||||||
self.print_conversation(_('Usage: /%s <room>@<server>[/nickname], offers to '
|
self.print_conversation(_('Usage: /%s <room>@<server>[/nickname], '
|
||||||
'join room@server optionally using specified '
|
'offers to join room@server optionally using specified nickname.') \
|
||||||
'nickname.') % command)
|
% command, 'info')
|
||||||
elif command == 'kick':
|
elif command == 'kick':
|
||||||
self.print_conversation(_('Usage: /%s <nickname> [reason], removes the occupant '
|
self.print_conversation(_('Usage: /%s <nickname> [reason], removes '
|
||||||
'specified by nickname from the room and optionally '
|
'the occupant specified by nickname from the room and optionally '
|
||||||
'displays a reason. Does NOT support spaces in '
|
'displays a reason. Does NOT support spaces in nickname.') % \
|
||||||
'nickname.') % command)
|
command, 'info')
|
||||||
elif command == 'me':
|
elif command == 'me':
|
||||||
self.print_conversation(_('Usage: /%s <action>, sends action to the current '
|
self.print_conversation(_('Usage: /%s <action>, sends action to the '
|
||||||
'room. Use third person. (e.g. /%s explodes.)') %\
|
'current room. Use third person. (e.g. /%s explodes.)') % \
|
||||||
(command, command))
|
(command, command), 'info')
|
||||||
elif command == 'msg':
|
elif command == 'msg':
|
||||||
s = _('Usage: /%s <nickname> [message], opens a private message window and '
|
s = _('Usage: /%s <nickname> [message], opens a private message window'
|
||||||
'sends message to the occupant specified by nickname.') % command
|
'and sends message to the occupant specified by nickname.') % \
|
||||||
self.print_conversation(s)
|
command
|
||||||
|
self.print_conversation(s, 'info')
|
||||||
elif command == 'nick':
|
elif command == 'nick':
|
||||||
s = _('Usage: /%s <nickname>, changes your nickname in current room.') % command
|
s = _('Usage: /%s <nickname>, changes your nickname in current room.')\
|
||||||
self.print_conversation(s)
|
% command
|
||||||
|
self.print_conversation(s, 'info')
|
||||||
elif command == 'topic':
|
elif command == 'topic':
|
||||||
self.print_conversation(_('Usage: /%s [topic], displays or updates the current '
|
self.print_conversation(_('Usage: /%s [topic], displays or updates the'
|
||||||
'room topic.') % command)
|
'current room topic.') % command, 'info')
|
||||||
elif command == 'say':
|
elif command == 'say':
|
||||||
self.print_conversation(_('Usage: /%s <message>, sends a message without '
|
self.print_conversation(_('Usage: /%s <message>, sends a message '
|
||||||
'looking for other commands.') % command)
|
'without looking for other commands.') % command, 'info')
|
||||||
else:
|
else:
|
||||||
self.print_conversation(_('No help info for /%s') % command)
|
self.print_conversation(_('No help info for /%s') % command, 'info')
|
||||||
|
|
||||||
def get_role(self, nick):
|
def get_role(self, nick):
|
||||||
gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
gc_contact = gajim.contacts.get_gc_contact(self.account, self.room_jid, nick)
|
||||||
|
|
Loading…
Add table
Reference in a new issue