[Darlan & I]Improved BiDi support for banner text, popup with presence info and more status messages (kick, ban, change nick) fixes #7284 #7192
This commit is contained in:
parent
3bbee5e251
commit
2755dece2e
|
@ -44,6 +44,7 @@ from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import exceptions
|
from common import exceptions
|
||||||
from common import ged
|
from common import ged
|
||||||
|
from common import i18n
|
||||||
from message_control import MessageControl
|
from message_control import MessageControl
|
||||||
from conversation_textview import ConversationTextview
|
from conversation_textview import ConversationTextview
|
||||||
from message_textview import MessageTextView
|
from message_textview import MessageTextView
|
||||||
|
@ -2117,9 +2118,10 @@ class ChatControl(ChatControlBase):
|
||||||
if self.resource:
|
if self.resource:
|
||||||
name += '/' + self.resource
|
name += '/' + self.resource
|
||||||
if self.TYPE_ID == message_control.TYPE_PM:
|
if self.TYPE_ID == message_control.TYPE_PM:
|
||||||
name = _('%(nickname)s from group chat %(room_name)s') %\
|
name = i18n.direction_mark + _(
|
||||||
{'nickname': name, 'room_name': self.room_name}
|
'%(nickname)s from group chat %(room_name)s') % \
|
||||||
name = gobject.markup_escape_text(name)
|
{'nickname': name, 'room_name': self.room_name}
|
||||||
|
name = i18n.direction_mark + gobject.markup_escape_text(name)
|
||||||
|
|
||||||
# We know our contacts nick, but if another contact has the same nick
|
# We know our contacts nick, but if another contact has the same nick
|
||||||
# in another account we need to also display the account.
|
# in another account we need to also display the account.
|
||||||
|
@ -2134,7 +2136,7 @@ class ChatControl(ChatControlBase):
|
||||||
other_contact_ = \
|
other_contact_ = \
|
||||||
gajim.contacts.get_first_contact_from_jid(account, jid)
|
gajim.contacts.get_first_contact_from_jid(account, jid)
|
||||||
if other_contact_.get_shown_name() == self.contact.get_shown_name():
|
if other_contact_.get_shown_name() == self.contact.get_shown_name():
|
||||||
acct_info = ' (%s)' % \
|
acct_info = i18n.direction_mark + ' (%s)' % \
|
||||||
gobject.markup_escape_text(self.account)
|
gobject.markup_escape_text(self.account)
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -2159,16 +2161,16 @@ class ChatControl(ChatControlBase):
|
||||||
chatstate = ''
|
chatstate = ''
|
||||||
|
|
||||||
label_text = '<span %s>%s</span><span %s>%s %s</span>' \
|
label_text = '<span %s>%s</span><span %s>%s %s</span>' \
|
||||||
% (font_attrs, name, font_attrs_small, acct_info, chatstate)
|
% (font_attrs, name, font_attrs_small, acct_info, chatstate)
|
||||||
if acct_info:
|
if acct_info:
|
||||||
acct_info = ' ' + acct_info
|
acct_info = i18n.direction_mark + ' ' + acct_info
|
||||||
label_tooltip = '%s%s %s' % (name, acct_info, chatstate)
|
label_tooltip = '%s%s %s' % (name, acct_info, chatstate)
|
||||||
else:
|
else:
|
||||||
# weight="heavy" size="x-large"
|
# weight="heavy" size="x-large"
|
||||||
label_text = '<span %s>%s</span><span %s>%s</span>' % \
|
label_text = '<span %s>%s</span><span %s>%s</span>' % \
|
||||||
(font_attrs, name, font_attrs_small, acct_info)
|
(font_attrs, name, font_attrs_small, acct_info)
|
||||||
if acct_info:
|
if acct_info:
|
||||||
acct_info = ' ' + acct_info
|
acct_info = i18n.direction_mark + ' ' + acct_info
|
||||||
label_tooltip = '%s%s' % (name, acct_info)
|
label_tooltip = '%s%s' % (name, acct_info)
|
||||||
|
|
||||||
if status_escaped:
|
if status_escaped:
|
||||||
|
|
|
@ -29,6 +29,7 @@ from common import atom
|
||||||
from common import nec
|
from common import nec
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import gajim
|
from common import gajim
|
||||||
|
from common import i18n
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
from common import dataforms
|
from common import dataforms
|
||||||
from common import exceptions
|
from common import exceptions
|
||||||
|
@ -2351,25 +2352,23 @@ class NotificationEvent(nec.NetworkIncomingEvent):
|
||||||
|
|
||||||
self.popup_timeout = gajim.config.get('notification_timeout')
|
self.popup_timeout = gajim.config.get('notification_timeout')
|
||||||
|
|
||||||
|
nick = i18n.direction_mark + gajim.get_name_from_jid(account, self.jid)
|
||||||
if event == 'status_change':
|
if event == 'status_change':
|
||||||
self.popup_title = _('%(nick)s Changed Status') % \
|
self.popup_title = _('%(nick)s Changed Status') % \
|
||||||
{'nick': gajim.get_name_from_jid(account, self.jid)}
|
{'nick': nick}
|
||||||
self.popup_text = _('%(nick)s is now %(status)s') % \
|
self.popup_text = _('%(nick)s is now %(status)s') % \
|
||||||
{'nick': gajim.get_name_from_jid(account, self.jid),\
|
{'nick': nick, 'status': helpers.get_uf_show(pres_obj.show)}
|
||||||
'status': helpers.get_uf_show(pres_obj.show)}
|
|
||||||
if pres_obj.status:
|
if pres_obj.status:
|
||||||
self.popup_text = self.popup_text + " : " + pres_obj.status
|
self.popup_text = self.popup_text + " : " + pres_obj.status
|
||||||
self.popup_event_type = _('Contact Changed Status')
|
self.popup_event_type = _('Contact Changed Status')
|
||||||
elif event == 'contact_connected':
|
elif event == 'contact_connected':
|
||||||
self.popup_title = _('%(nickname)s Signed In') % \
|
self.popup_title = _('%(nickname)s Signed In') % {'nickname': nick}
|
||||||
{'nickname': gajim.get_name_from_jid(account, self.jid)}
|
|
||||||
self.popup_text = ''
|
self.popup_text = ''
|
||||||
if pres_obj.status:
|
if pres_obj.status:
|
||||||
self.popup_text = pres_obj.status
|
self.popup_text = pres_obj.status
|
||||||
self.popup_event_type = _('Contact Signed In')
|
self.popup_event_type = _('Contact Signed In')
|
||||||
elif event == 'contact_disconnected':
|
elif event == 'contact_disconnected':
|
||||||
self.popup_title = _('%(nickname)s Signed Out') % \
|
self.popup_title = _('%(nickname)s Signed Out') % {'nickname': nick}
|
||||||
{'nickname': gajim.get_name_from_jid(account, self.jid)}
|
|
||||||
self.popup_text = ''
|
self.popup_text = ''
|
||||||
if pres_obj.status:
|
if pres_obj.status:
|
||||||
self.popup_text = pres_obj.status
|
self.popup_text = pres_obj.status
|
||||||
|
|
|
@ -26,6 +26,12 @@ import gettext
|
||||||
import os
|
import os
|
||||||
import defs
|
import defs
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
import gtk
|
||||||
|
|
||||||
|
if gtk.widget_get_default_direction() == gtk.TEXT_DIR_LTR:
|
||||||
|
direction_mark = u'\u200E'
|
||||||
|
else:
|
||||||
|
direction_mark = u'\u200F'
|
||||||
|
|
||||||
def paragraph_direction_mark(text):
|
def paragraph_direction_mark(text):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1294,10 +1294,7 @@ class ConversationTextview(gobject.GObject):
|
||||||
direction_mark = i18n.paragraph_direction_mark(unicode(text))
|
direction_mark = i18n.paragraph_direction_mark(unicode(text))
|
||||||
# don't apply direction mark if it's status message
|
# don't apply direction mark if it's status message
|
||||||
if kind == 'status':
|
if kind == 'status':
|
||||||
if gtk.widget_get_default_direction() == gtk.TEXT_DIR_LTR:
|
direction_mark = i18n.direction_mark
|
||||||
direction_mark = u'\u200E'
|
|
||||||
else:
|
|
||||||
direction_mark = u'\u200F'
|
|
||||||
if current_print_time == 'always' and kind != 'info' and not simple:
|
if current_print_time == 'always' and kind != 'info' and not simple:
|
||||||
timestamp_str = self.get_time_to_show(tim)
|
timestamp_str = self.get_time_to_show(tim)
|
||||||
timestamp = time.strftime(timestamp_str, tim)
|
timestamp = time.strftime(timestamp_str, tim)
|
||||||
|
|
|
@ -47,6 +47,7 @@ from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
from common import dataforms
|
from common import dataforms
|
||||||
from common import ged
|
from common import ged
|
||||||
|
from common import i18n
|
||||||
|
|
||||||
from chat_control import ChatControl
|
from chat_control import ChatControl
|
||||||
from chat_control import ChatControlBase
|
from chat_control import ChatControlBase
|
||||||
|
@ -1513,7 +1514,8 @@ class GroupchatControl(ChatControlBase):
|
||||||
affiliation = 'none'
|
affiliation = 'none'
|
||||||
|
|
||||||
newly_created = False
|
newly_created = False
|
||||||
nick_jid = obj.nick
|
nick = i18n.direction_mark + obj.nick
|
||||||
|
nick_jid = nick
|
||||||
|
|
||||||
# Set to true if role or affiliation have changed
|
# Set to true if role or affiliation have changed
|
||||||
right_changed = False
|
right_changed = False
|
||||||
|
@ -1556,10 +1558,10 @@ class GroupchatControl(ChatControlBase):
|
||||||
if '307' in obj.status_code:
|
if '307' in obj.status_code:
|
||||||
if obj.actor is None: # do not print 'kicked by None'
|
if obj.actor is None: # do not print 'kicked by None'
|
||||||
s = _('%(nick)s has been kicked: %(reason)s') % {
|
s = _('%(nick)s has been kicked: %(reason)s') % {
|
||||||
'nick': obj.nick, 'reason': obj.reason}
|
'nick': nick, 'reason': obj.reason}
|
||||||
else:
|
else:
|
||||||
s = _('%(nick)s has been kicked by %(who)s: '
|
s = _('%(nick)s has been kicked by %(who)s: '
|
||||||
'%(reason)s') % {'nick': obj.nick, 'who': obj.actor,
|
'%(reason)s') % {'nick': nick, 'who': obj.actor,
|
||||||
'reason': obj.reason}
|
'reason': obj.reason}
|
||||||
self.print_conversation(s, 'info', graphics=False)
|
self.print_conversation(s, 'info', graphics=False)
|
||||||
if obj.nick == self.nick and not gajim.config.get(
|
if obj.nick == self.nick and not gajim.config.get(
|
||||||
|
@ -1568,10 +1570,10 @@ class GroupchatControl(ChatControlBase):
|
||||||
elif '301' in obj.status_code:
|
elif '301' in obj.status_code:
|
||||||
if obj.actor is None: # do not print 'banned by None'
|
if obj.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') % {
|
||||||
'nick': obj.nick, 'reason': obj.reason}
|
'nick': nick, 'reason': obj.reason}
|
||||||
else:
|
else:
|
||||||
s = _('%(nick)s has been banned by %(who)s: '
|
s = _('%(nick)s has been banned by %(who)s: '
|
||||||
'%(reason)s') % {'nick': obj.nick, 'who': obj.actor,
|
'%(reason)s') % {'nick': nick, 'who': obj.actor,
|
||||||
'reason': obj.reason}
|
'reason': obj.reason}
|
||||||
self.print_conversation(s, 'info', graphics=False)
|
self.print_conversation(s, 'info', graphics=False)
|
||||||
if obj.nick == self.nick:
|
if obj.nick == self.nick:
|
||||||
|
@ -1598,7 +1600,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
ctrl.no_autonegotiation = False
|
ctrl.no_autonegotiation = False
|
||||||
else:
|
else:
|
||||||
s = _('%(nick)s is now known as %(new_nick)s') % {
|
s = _('%(nick)s is now known as %(new_nick)s') % {
|
||||||
'nick': obj.nick, 'new_nick': obj.new_nick}
|
'nick': nick, 'new_nick': obj.new_nick}
|
||||||
tv = self.conv_textview
|
tv = self.conv_textview
|
||||||
if obj.nick in tv.last_received_message_marks:
|
if obj.nick in tv.last_received_message_marks:
|
||||||
tv.last_received_message_marks[obj.new_nick] = \
|
tv.last_received_message_marks[obj.new_nick] = \
|
||||||
|
@ -1652,18 +1654,18 @@ class GroupchatControl(ChatControlBase):
|
||||||
self.print_conversation(s, 'info', graphics=False)
|
self.print_conversation(s, 'info', graphics=False)
|
||||||
elif '321' in obj.status_code:
|
elif '321' in obj.status_code:
|
||||||
s = _('%(nick)s has been removed from the room '
|
s = _('%(nick)s has been removed from the room '
|
||||||
'(%(reason)s)') % { 'nick': obj.nick,
|
'(%(reason)s)') % { 'nick': nick,
|
||||||
'reason': _('affiliation changed') }
|
'reason': _('affiliation changed') }
|
||||||
self.print_conversation(s, 'info', graphics=False)
|
self.print_conversation(s, 'info', graphics=False)
|
||||||
elif '322' in obj.status_code:
|
elif '322' in obj.status_code:
|
||||||
s = _('%(nick)s has been removed from the room '
|
s = _('%(nick)s has been removed from the room '
|
||||||
'(%(reason)s)') % { 'nick': obj.nick,
|
'(%(reason)s)') % { 'nick': nick,
|
||||||
'reason': _('room configuration changed to '
|
'reason': _('room configuration changed to '
|
||||||
'members-only') }
|
'members-only') }
|
||||||
self.print_conversation(s, 'info', graphics=False)
|
self.print_conversation(s, 'info', graphics=False)
|
||||||
elif '332' in obj.status_code:
|
elif '332' in obj.status_code:
|
||||||
s = _('%(nick)s has been removed from the room '
|
s = _('%(nick)s has been removed from the room '
|
||||||
'(%(reason)s)') % {'nick': obj.nick,
|
'(%(reason)s)') % {'nick': nick,
|
||||||
'reason': _('system shutdown') }
|
'reason': _('system shutdown') }
|
||||||
self.print_conversation(s, 'info', graphics=False)
|
self.print_conversation(s, 'info', graphics=False)
|
||||||
# Room has been destroyed.
|
# Room has been destroyed.
|
||||||
|
@ -1697,7 +1699,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
if '210' in obj.status_code:
|
if '210' in obj.status_code:
|
||||||
# Server changed our nick
|
# Server changed our nick
|
||||||
self.nick = obj.nick
|
self.nick = obj.nick
|
||||||
s = _('You are now known as %s') % obj.nick
|
s = _('You are now known as %s') % nick
|
||||||
self.print_conversation(s, 'info', graphics=False)
|
self.print_conversation(s, 'info', graphics=False)
|
||||||
iter_ = self.add_contact_to_roster(obj.nick, obj.show, role,
|
iter_ = self.add_contact_to_roster(obj.nick, obj.show, role,
|
||||||
affiliation, obj.status, obj.real_jid)
|
affiliation, obj.status, obj.real_jid)
|
||||||
|
|
Loading…
Reference in New Issue