[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:
Denis Fomin 2013-07-23 17:55:24 +04:00
parent e24f10bd78
commit c446150a7e
6 changed files with 37 additions and 31 deletions

View File

@ -46,6 +46,7 @@ from common import gajim
from common import helpers
from common import exceptions
from common import ged
from common import i18n
from message_control import MessageControl
from conversation_textview import ConversationTextview
from message_textview import MessageTextView
@ -2154,9 +2155,10 @@ class ChatControl(ChatControlBase):
if self.resource:
name += '/' + self.resource
if self.TYPE_ID == message_control.TYPE_PM:
name = _('%(nickname)s from group chat %(room_name)s') %\
{'nickname': name, 'room_name': self.room_name}
name = GObject.markup_escape_text(name)
name = i18n.direction_mark + _(
'%(nickname)s from group chat %(room_name)s') % \
{'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
# in another account we need to also display the account.
@ -2169,10 +2171,11 @@ class ChatControl(ChatControlBase):
break
for jid in gajim.contacts.get_jid_list(account):
other_contact_ = \
gajim.contacts.get_first_contact_from_jid(account, jid)
if other_contact_.get_shown_name() == self.contact.get_shown_name():
acct_info = ' (%s)' % \
GObject.markup_escape_text(self.account)
gajim.contacts.get_first_contact_from_jid(account, jid)
if other_contact_.get_shown_name() == \
self.contact.get_shown_name():
acct_info = i18n.direction_mark + ' (%s)' % \
GObject.markup_escape_text(self.account)
break
status = contact.status
@ -2196,16 +2199,16 @@ class ChatControl(ChatControlBase):
chatstate = ''
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:
acct_info = ' ' + acct_info
acct_info = i18n.direction_mark + ' ' + acct_info
label_tooltip = '%s%s %s' % (name, acct_info, chatstate)
else:
# weight="heavy" size="x-large"
label_text = '<span %s>%s</span><span %s>%s</span>' % \
(font_attrs, name, font_attrs_small, acct_info)
if acct_info:
acct_info = ' ' + acct_info
acct_info = i18n.direction_mark + ' ' + acct_info
label_tooltip = '%s%s' % (name, acct_info)
if status_escaped:

View File

@ -29,6 +29,7 @@ from common import atom
from common import nec
from common import helpers
from common import gajim
from common import i18n
import nbxmpp
from common import dataforms
from common import exceptions
@ -2368,25 +2369,23 @@ class NotificationEvent(nec.NetworkIncomingEvent):
self.popup_timeout = gajim.config.get('notification_timeout')
nick = i18n.direction_mark + gajim.get_name_from_jid(account, self.jid)
if event == 'status_change':
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') % \
{'nick': gajim.get_name_from_jid(account, self.jid),\
'status': helpers.get_uf_show(pres_obj.show)}
{'nick': nick, 'status': helpers.get_uf_show(pres_obj.show)}
if pres_obj.status:
self.popup_text = self.popup_text + " : " + pres_obj.status
self.popup_event_type = _('Contact Changed Status')
elif event == 'contact_connected':
self.popup_title = _('%(nickname)s Signed In') % \
{'nickname': gajim.get_name_from_jid(account, self.jid)}
self.popup_title = _('%(nickname)s Signed In') % {'nickname': nick}
self.popup_text = ''
if pres_obj.status:
self.popup_text = pres_obj.status
self.popup_event_type = _('Contact Signed In')
elif event == 'contact_disconnected':
self.popup_title = _('%(nickname)s Signed Out') % \
{'nickname': gajim.get_name_from_jid(account, self.jid)}
self.popup_title = _('%(nickname)s Signed Out') % {'nickname': nick}
self.popup_text = ''
if pres_obj.status:
self.popup_text = pres_obj.status

View File

@ -27,6 +27,9 @@ import os
from common import defs
import unicodedata
# May be changed after GTK is imported
direction_mark = u'\u200F'
def paragraph_direction_mark(text):
"""
Determine paragraph writing direction according to

View File

@ -1309,10 +1309,7 @@ class ConversationTextview(GObject.GObject):
direction_mark = i18n.paragraph_direction_mark(text)
# don't apply direction mark if it's status message
if kind == 'status':
if Gtk.Widget.get_default_direction() == gtk.TextDirectionLTR:
direction_mark = u'\u200E'
else:
direction_mark = u'\u200F'
direction_mark = i18n.direction_mark
if current_print_time == 'always' and kind != 'info' and not simple:
timestamp_str = self.get_time_to_show(tim)
timestamp = time.strftime(timestamp_str, tim)

View File

@ -209,6 +209,8 @@ warnings.resetwarnings()
if os.name == 'nt':
warnings.filterwarnings(action='ignore')
if Gtk.Widget.get_default_direction() == Gtk.TextDirection.LTR:
i18n.direction_mark = u'\u200E'
pritext = ''
from common import exceptions

View File

@ -49,6 +49,7 @@ from common import gajim
from common import helpers
from common import dataforms
from common import ged
from common import i18n
from chat_control import ChatControl
from chat_control import ChatControlBase
@ -1523,7 +1524,8 @@ class GroupchatControl(ChatControlBase):
affiliation = 'none'
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
right_changed = False
@ -1566,10 +1568,10 @@ class GroupchatControl(ChatControlBase):
if '307' in obj.status_code:
if obj.actor is None: # do not print 'kicked by None'
s = _('%(nick)s has been kicked: %(reason)s') % {
'nick': obj.nick, 'reason': obj.reason}
'nick': nick, 'reason': obj.reason}
else:
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}
self.print_conversation(s, 'info', graphics=False)
if obj.nick == self.nick and not gajim.config.get(
@ -1578,10 +1580,10 @@ class GroupchatControl(ChatControlBase):
elif '301' in obj.status_code:
if obj.actor is None: # do not print 'banned by None'
s = _('%(nick)s has been banned: %(reason)s') % {
'nick': obj.nick, 'reason': obj.reason}
'nick': nick, 'reason': obj.reason}
else:
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}
self.print_conversation(s, 'info', graphics=False)
if obj.nick == self.nick:
@ -1608,7 +1610,7 @@ class GroupchatControl(ChatControlBase):
ctrl.no_autonegotiation = False
else:
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
if obj.nick in tv.last_received_message_marks:
tv.last_received_message_marks[obj.new_nick] = \
@ -1662,18 +1664,18 @@ class GroupchatControl(ChatControlBase):
self.print_conversation(s, 'info', graphics=False)
elif '321' in obj.status_code:
s = _('%(nick)s has been removed from the room '
'(%(reason)s)') % { 'nick': obj.nick,
'(%(reason)s)') % { 'nick': nick,
'reason': _('affiliation changed') }
self.print_conversation(s, 'info', graphics=False)
elif '322' in obj.status_code:
s = _('%(nick)s has been removed from the room '
'(%(reason)s)') % { 'nick': obj.nick,
'(%(reason)s)') % { 'nick': nick,
'reason': _('room configuration changed to '
'members-only') }
self.print_conversation(s, 'info', graphics=False)
elif '332' in obj.status_code:
s = _('%(nick)s has been removed from the room '
'(%(reason)s)') % {'nick': obj.nick,
'(%(reason)s)') % {'nick': nick,
'reason': _('system shutdown') }
self.print_conversation(s, 'info', graphics=False)
# Room has been destroyed.
@ -1707,7 +1709,7 @@ class GroupchatControl(ChatControlBase):
if '210' in obj.status_code:
# Server changed our 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)
iter_ = self.add_contact_to_roster(obj.nick, obj.show, role,
affiliation, obj.status, obj.real_jid)