chatstate.Show resource counter
This commit is contained in:
@@ -9,7 +9,23 @@ from common import ged
|
|||||||
from common import gajim
|
from common import gajim
|
||||||
from common import helpers
|
from common import helpers
|
||||||
import gtkgui_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):
|
class ChatstatePlugin(GajimPlugin):
|
||||||
|
|
||||||
@@ -41,12 +57,23 @@ class ChatstatePlugin(GajimPlugin):
|
|||||||
child_iters = gajim.interface.roster._get_contact_iter(obj.jid,
|
child_iters = gajim.interface.roster._get_contact_iter(obj.jid,
|
||||||
obj.conn.name, contact, self.model)
|
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:
|
for child_iter in child_iters:
|
||||||
name = gobject.markup_escape_text(contact.get_shown_name())
|
|
||||||
if chatstate != 'gone':
|
if chatstate != 'gone':
|
||||||
color = self.chatstates[chatstate]
|
color = self.chatstates[chatstate]
|
||||||
name = '<span foreground="%s">%s</span>' % (color, name)
|
name = '<span foreground="%s">%s</span>' % (color, name)
|
||||||
|
|
||||||
if contact.status and gajim.config.get(
|
if contact.status and gajim.config.get(
|
||||||
'show_status_msgs_in_roster'):
|
'show_status_msgs_in_roster'):
|
||||||
status = contact.status.strip()
|
status = contact.status.strip()
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[info]
|
[info]
|
||||||
name: Chatstate in roster
|
name: Chatstate in roster
|
||||||
short_name: chatstate
|
short_name: chatstate
|
||||||
version: 0.4
|
version: 0.5
|
||||||
description: Chat State Notifications in roster.
|
description: Chat State Notifications in roster.
|
||||||
Font color of the contact varies depending on the chat state.
|
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.
|
The plugin does not work if you use custom font color for contacts in roster.
|
||||||
|
|||||||
Reference in New Issue
Block a user