diff options
author | Denis Fomin <fominde@gmail.com> | 2011-09-22 11:12:53 +0400 |
---|---|---|
committer | Denis Fomin <fominde@gmail.com> | 2011-09-22 11:12:53 +0400 |
commit | ea470f898aad2a4ea4667af934531b2854858ae2 (patch) | |
tree | 04d4dc439ca4ccdfdbac2a8735a8c2ac671d9555 | |
parent | 0f3e7d2057830935a8a86e412d72844fe89df0d8 (diff) |
chatstate.Show resource counter
-rw-r--r-- | chatstate/chatstate.py | 31 | ||||
-rw-r--r-- | chatstate/manifest.ini | 2 |
2 files changed, 30 insertions, 3 deletions
diff --git a/chatstate/chatstate.py b/chatstate/chatstate.py index 159a627..274c6b7 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 3cdc34e..8250282 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. |