Commit 94b292a2 authored by Dicson's avatar Dicson

Add new plugin. Server Status Icons.

parent f0a7ff64
from server_status_icons import ServerStatusIconsPlugin
<?xml version='1.0' encoding='UTF-8'?>
<icondef>
<version>1.0</version>
<name>Facebook</name>
<description>Facebook Iconset for Vacuum-IM</description>
<creation>2010-05-24</creation>
<author>Artem Rogudeev / [AKI]`Rodent</author>
<icon>
<key>online</key>
<object mime='image/png'>online.png</object>
</icon>
<icon>
<key>offline</key>
<object mime='image/png'>offline.png</object>
</icon>
<icon>
<key>away</key>
<object mime='image/png'>away.png</object>
</icon>
<icon>
<key>xa</key>
<object mime='image/png'>xa.png</object>
</icon>
<icon>
<key>dnd</key>
<object mime='image/png'>dnd.png</object>
</icon>
<icon>
<key>invisible</key>
<object mime='image/png'>invisible.png</object>
</icon>
<icon>
<key>chat</key>
<object mime='image/png'>chatty.png</object>
</icon>
<icon>
<key>ask</key>
<object mime='image/png'>ask.png</object>
</icon>
<icon>
<key>noauth</key>
<object mime='image/png'>noauth.png</object>
</icon>
</icondef>
<?xml version='1.0' encoding='UTF-8'?>
<icondef>
<version>1.0</version>
<name>Google Talk</name>
<description>Google Talk Iconset for Vacuum-IM</description>
<creation>2010-06-12</creation>
<author>Artem Rogudeev / [AKI]`Rodent</author>
<icon>
<key>online</key>
<object mime='image/png'>online.png</object>
</icon>
<icon>
<key>offline</key>
<object mime='image/png'>offline.png</object>
</icon>
<icon>
<key>away</key>
<object mime='image/png'>away.png</object>
</icon>
<icon>
<key>xa</key>
<object mime='image/png'>xa.png</object>
</icon>
<icon>
<key>dnd</key>
<object mime='image/png'>dnd.png</object>
</icon>
<icon>
<key>invisible</key>
<object mime='image/png'>invisible.png</object>
</icon>
<icon>
<key>chat</key>
<object mime='image/png'>chatty.png</object>
</icon>
<icon>
<key>ask</key>
<object mime='image/png'>ask.png</object>
</icon>
<icon>
<key>noauth</key>
<object mime='image/png'>noauth.png</object>
</icon>
</icondef>
<?xml version='1.0' encoding='UTF-8'?>
<icondef>
<version>1.0</version>
<name>LiveJournal</name>
<description>LiveJournal Iconset for Vacuum-IM</description>
<creation>2010-08-15</creation>
<author>Artem Rogudeev / [AKI]`Rodent</author>
<icon>
<key>online</key>
<object mime='image/png'>online.png</object>
</icon>
<icon>
<key>offline</key>
<object mime='image/png'>offline.png</object>
</icon>
<icon>
<key>away</key>
<object mime='image/png'>away.png</object>
</icon>
<icon>
<key>xa</key>
<object mime='image/png'>xa.png</object>
</icon>
<icon>
<key>dnd</key>
<object mime='image/png'>dnd.png</object>
</icon>
<icon>
<key>invisible</key>
<object mime='image/png'>invisible.png</object>
</icon>
<icon>
<key>chat</key>
<object mime='image/png'>chatty.png</object>
</icon>
<icon>
<key>ask</key>
<object mime='image/png'>ask.png</object>
</icon>
<icon>
<key>noauth</key>
<object mime='image/png'>noauth.png</object>
</icon>
</icondef>
[info]
name: Server Status Icons
short_name: server_status_icons
version: 0.1
description: Replace standard Gajim status icons with server
specific for known XMPP server accounts (vk.com, ...)
authors = Denis Fomin <fominde@gmail.com>
Pavel Suslov
homepage = http://trac-plugins.gajim.org/wiki/
# -*- coding: utf-8 -*-
##
import gtk
import os
from plugins.gui import GajimPluginConfigDialog
from plugins import GajimPlugin
from plugins.helpers import log_calls
import gtkgui_helpers
from common import gajim
from common import helpers
from common import ged
class ServerStatusIconsPlugin(GajimPlugin):
@log_calls('ServerStatusIconsPlugin')
def init(self):
self.description = _('Replace standard Gajim status icons with server'
' specific for known XMPP server accounts (vk.com, ...)')
self.pos_list = [_('after statusicon'), _('before avatar')]
self.gui_extension_points = {
'roster_draw_contact': (self.connect_with_roster_draw_contact,
self.disconnect_from_roster_draw_contact)}
self.known_servers = {'chat.facebook.com': 'facebook',
'gmail.com': 'gtalk',
'livejournal.com': 'livejournal',
'odnoklassniki.ru': 'odnoklassniki',
'vk.com': 'vkontakte',
'ya.ru': 'yaonline'}
@log_calls('ServerStatusIconsPlugin')
def connect_with_roster_draw_contact(self, roster, jid, account, contact):
if not self.active:
return
if gajim.jid_is_transport(jid):
return
child_iters = roster._get_contact_iter(jid, account, contact,
roster.model)
if not child_iters:
return
icon_name = helpers.get_icon_name_to_show(contact, account)
if gajim.events.get_events(account, jid) or icon_name == 'requested':
return
host = jid.split('@')[1]
server = self.known_servers.get(host, False)
if not server:
return
if server not in roster.transports_state_images['16']:
# we don't have iconset for this transport loaded yet. Let's do it
self.make_transport_state_images(roster, server)
if server in roster.transports_state_images['16'] and \
icon_name in roster.transports_state_images['16'][server]:
state_images = roster.transports_state_images['16'][server]
img = state_images[icon_name]
for child_iter in child_iters:
roster.model[child_iter][0] = img
def make_transport_state_images(self, roster, transport):
"""
Initialize opened and closed 'transport' iconset dict
"""
folder = os.path.join(self.local_file_path(transport), '16x16')
pixo, pixc = gtkgui_helpers.load_icons_meta()
roster.transports_state_images['opened'][transport] = \
gtkgui_helpers.load_iconset(folder, pixo, transport=True)
roster.transports_state_images['closed'][transport] = \
gtkgui_helpers.load_iconset(folder, pixc, transport=True)
roster.transports_state_images['16'][transport] = \
gtkgui_helpers.load_iconset(folder, transport=True)
folder = os.path.join(self.local_file_path(transport), '32x32')
roster.transports_state_images['32'][transport] = \
gtkgui_helpers.load_iconset(folder, transport=True)
def _nec_our_show(self, obj):
account = obj.conn.name
roster = gajim.interface.roster
status = gajim.connections[account].connected
if account not in gajim.contacts.get_accounts():
return
child_iterA = roster._get_account_iter(account, roster.model)
if not child_iterA:
return
hostname = gajim.config.get_per('accounts', account, 'hostname')
server = self.known_servers.get(hostname, False)
if not server:
return
if not roster.regroup:
show = gajim.SHOW_LIST[status]
else: # accounts merged
show = helpers.get_global_show()
if server not in roster.transports_state_images['16']:
# we don't have iconset for this transport loaded yet. Let's do it
self.make_transport_state_images(roster, server)
if server in roster.transports_state_images['16'] and \
show in roster.transports_state_images['16'][server]:
roster.model[child_iterA][0] = roster.transports_state_images[
'16'][server][show]
@log_calls('ServerStatusIconsPlugin')
def disconnect_from_roster_draw_contact(self, roster, jid, account,
contact):
pass
@log_calls('ServerStatusIconsPlugin')
def activate(self):
self.active = True
gajim.interface.roster.setup_and_draw_roster()
gajim.ged.register_event_handler('our-show', ged.GUI2,
self._nec_our_show)
@log_calls('ServerStatusIconsPlugin')
def deactivate(self):
self.active = None
gajim.ged.remove_event_handler('our-show', ged.GUI2,
self._nec_our_show)
gajim.interface.roster.setup_and_draw_roster()
<?xml version='1.0' encoding='UTF-8'?>
<icondef>
<version>1.0</version>
<name>Vkontakte</name>
<description>Vkontakte Iconset for Vacuum-IM</description>
<creation>2010-05-24</creation>
<author>Artem Rogudeev / [AKI]`Rodent</author>
<icon>
<key>online</key>
<object mime='image/png'>online.png</object>
</icon>
<icon>
<key>offline</key>
<object mime='image/png'>offline.png</object>
</icon>
<icon>
<key>away</key>
<object mime='image/png'>away.png</object>
</icon>
<icon>
<key>xa</key>
<object mime='image/png'>xa.png</object>
</icon>
<icon>
<key>dnd</key>
<object mime='image/png'>dnd.png</object>
</icon>
<icon>
<key>invisible</key>
<object mime='image/png'>invisible.png</object>
</icon>
<icon>
<key>chat</key>
<object mime='image/png'>chatty.png</object>
</icon>
<icon>
<key>ask</key>
<object mime='image/png'>ask.png</object>
</icon>
<icon>
<key>noauth</key>
<object mime='image/png'>noauth.png</object>
</icon>
</icondef>
<?xml version='1.0' encoding='UTF-8'?>
<icondef>
<version>1.0</version>
<name>Ya.Online</name>
<description>Ya.Online Iconset for Vacuum-IM</description>
<creation>2010-09-04</creation>
<author>Artem Rogudeev / [AKI]`Rodent</author>
<icon>
<key>online</key>
<object mime='image/png'>online.png</object>
</icon>
<icon>
<key>offline</key>
<object mime='image/png'>offline.png</object>
</icon>
<icon>
<key>away</key>
<object mime='image/png'>away.png</object>
</icon>
<icon>
<key>xa</key>
<object mime='image/png'>xa.png</object>
</icon>
<icon>
<key>dnd</key>
<object mime='image/png'>dnd.png</object>
</icon>
<icon>
<key>invisible</key>
<object mime='image/png'>invisible.png</object>
</icon>
<icon>
<key>chat</key>
<object mime='image/png'>chatty.png</object>
</icon>
<icon>
<key>ask</key>
<object mime='image/png'>ask.png</object>
</icon>
<icon>
<key>noauth</key>
<object mime='image/png'>noauth.png</object>
</icon>
</icondef>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment