ClientsIconsPlugin. Refactoring

This commit is contained in:
Denis Fomin
2012-11-12 12:15:56 +04:00
parent a601a14820
commit a118658819

View File

@@ -197,7 +197,7 @@ class ClientsIconsPlugin(GajimPlugin):
vertical_fill = gtk.FILL vertical_fill = gtk.FILL
if vcard_table.get_property('n-columns') == 4: if vcard_table.get_property('n-columns') == 4:
vertical_fill |= gtk.EXPAND vertical_fill |= gtk.EXPAND
vcard_current_row = vcard_table.get_property('n-rows')
# put contacts in dict, where key is priority # put contacts in dict, where key is priority
num_resources = 0 num_resources = 0
contacts_dict = {} contacts_dict = {}
@@ -208,14 +208,18 @@ class ClientsIconsPlugin(GajimPlugin):
contacts_dict[contact.priority].append(contact) contacts_dict[contact.priority].append(contact)
else: else:
contacts_dict[contact.priority] = [contact] contacts_dict[contact.priority] = [contact]
# set label
label = gtk.Label() label = gtk.Label()
label.set_alignment(0, 0) label.set_alignment(0, 0)
self.table = gtk.Table(4, 1)
self.table.set_property('column-spacing', 2)
if num_resources > 1: if num_resources > 1:
label.set_markup(_('Clients:')) label.set_markup(_('Clients:'))
else:
if contact.show == 'offline':
return
label.set_markup(_('Client:'))
#fill clients table
self.table = gtk.Table(4, 1)
self.table.set_property('column-spacing', 2)
first_place = vcard_current_row = vcard_table.get_property('n-rows') first_place = vcard_current_row = vcard_table.get_property('n-rows')
vcard_table.attach(label, 1, 2, vcard_current_row, vcard_table.attach(label, 1, 2, vcard_current_row,
vcard_current_row + 1, gtk.FILL, gtk.FILL | gtk.EXPAND, 0, 0) vcard_current_row + 1, gtk.FILL, gtk.FILL | gtk.EXPAND, 0, 0)
@@ -235,28 +239,10 @@ class ClientsIconsPlugin(GajimPlugin):
label.set_markup(client_name) label.set_markup(client_name)
self.table.attach(label, 2, 3, vcard_current_row, self.table.attach(label, 2, 3, vcard_current_row,
vcard_current_row + 1, gtk.FILL | gtk.EXPAND, 0, 0, 0) vcard_current_row + 1, gtk.FILL | gtk.EXPAND, 0, 0, 0)
vcard_current_row = vcard_table.get_property('n-rows') vcard_current_row += 1
vcard_table.attach(self.table, 2, 3, first_place, #set clients table to tooltip
first_place + 1, gtk.FILL, vertical_fill, 0, 0) vcard_table.attach(self.table, 2, 3, first_place, first_place + 1,
else: gtk.FILL, vertical_fill, 0, 0)
if contact.show == 'offline':
return
label.set_markup(_('Client:'))
caps = contact.client_caps._node
vcard_current_row = vcard_table.get_property('n-rows')
vcard_table.attach(label, 1, 2, vcard_current_row,
vcard_current_row + 1, gtk.FILL, gtk.FILL | gtk.EXPAND, 0, 0)
caps_image ,client_name = self.get_icon(caps)
caps_image.set_alignment(0, 0)
self.table.attach(caps_image, 1, 2, vcard_current_row,
vcard_current_row + 1, gtk.FILL, gtk.FILL, 0, 0)
label = gtk.Label()
label.set_alignment(0, 0)
label.set_markup(client_name)
self.table.attach(label, 2, 3, vcard_current_row,
vcard_current_row + 1, gtk.FILL | gtk.EXPAND, 0, 0, 0)
vcard_table.attach(self.table, 2, 3, vcard_current_row,
vcard_current_row + 1, gtk.FILL, vertical_fill, 0, 0)
# rewrite avatar # rewrite avatar
if vcard_table.get_property('n-columns') == 4: if vcard_table.get_property('n-columns') == 4:
@@ -295,6 +281,7 @@ class ClientsIconsPlugin(GajimPlugin):
def disconnect_from_roster_tooltip_populate(self, tooltip, contacts, def disconnect_from_roster_tooltip_populate(self, tooltip, contacts,
vcard_table): vcard_table):
pass pass
@log_calls('ClientsIconsPlugin') @log_calls('ClientsIconsPlugin')
def connect_with_roster_draw_contact(self, roster, jid, account, contact): def connect_with_roster_draw_contact(self, roster, jid, account, contact):
if not self.active: if not self.active:
@@ -470,6 +457,7 @@ class ClientsIconsPlugin(GajimPlugin):
tag = iq_obj.stanza.getTags('c') tag = iq_obj.stanza.getTags('c')
if tag: if tag:
caps = tag[0].getAttr('node') caps = tag[0].getAttr('node')
if caps:
if 'pidgin.im' in caps: if 'pidgin.im' in caps:
caps = 'libpurple' caps = 'libpurple'
for client in libpurple_clients: for client in libpurple_clients: