diff --git a/chatstate/chatstate.py b/chatstate/chatstate.py index 159a627fa3b06e5629bf6028b8d29dbd631e0c4e..274c6b74cc761312d6b5505119d6badb029b204a 100644 --- a/chatstate/chatstate.py +++ b/chatstate/chatstate.py @@ -9,7 +9,23 @@ from common import ged from common import gajim from common import helpers import gtkgui_helpers +import unicodedata +def paragraph_direction_mark(text): + """ + Determine paragraph writing direction according to + http://www.unicode.org/reports/tr9/#The_Paragraph_Level + + Returns either Unicode LTR mark or RTL mark. + """ + for char in text: + bidi = unicodedata.bidirectional(char) + if bidi == 'L': + return u'\u200E' + elif bidi == 'AL' or bidi == 'R': + return u'\u200F' + + return u'\u200E' class ChatstatePlugin(GajimPlugin): @@ -41,12 +57,23 @@ class ChatstatePlugin(GajimPlugin): child_iters = gajim.interface.roster._get_contact_iter(obj.jid, obj.conn.name, contact, self.model) + name = gobject.markup_escape_text(contact.get_shown_name()) + contact_instances = gajim.contacts.get_contacts(obj.conn.name, + contact.jid) + + # Show resource counter + nb_connected_contact = 0 + for c in contact_instances: + if c.show not in ('error', 'offline'): + nb_connected_contact += 1 + if nb_connected_contact > 1: + name += paragraph_direction_mark(unicode(name)) + name += u' (%d)' % nb_connected_contact + for child_iter in child_iters: - name = gobject.markup_escape_text(contact.get_shown_name()) if chatstate != 'gone': color = self.chatstates[chatstate] name = '<span foreground="%s">%s</span>' % (color, name) - if contact.status and gajim.config.get( 'show_status_msgs_in_roster'): status = contact.status.strip() diff --git a/chatstate/manifest.ini b/chatstate/manifest.ini index 3cdc34e16c67e85287780d07345342b9cb561b7a..8250282befaf198ba90b5f25356344acc1055a27 100644 --- a/chatstate/manifest.ini +++ b/chatstate/manifest.ini @@ -1,7 +1,7 @@ [info] name: Chatstate in roster short_name: chatstate -version: 0.4 +version: 0.5 description: Chat State Notifications in roster. Font color of the contact varies depending on the chat state. The plugin does not work if you use custom font color for contacts in roster.