ask C to copy list; respect 80 chars margin; use show and not print when you mean show

This commit is contained in:
Nikos Kouremenos 2006-04-09 16:48:24 +00:00
parent 6f935c5ce0
commit e3c9a07aaa

View file

@ -267,25 +267,27 @@ class Systray:
groups_menu = gtk.Menu() groups_menu = gtk.Menu()
sort_by_show = gajim.config.get('sort_by_show') sort_by_show = gajim.config.get('sort_by_show')
# store contact infos in a table so we can easily sort by group, status and name # store contact infos in a table so we can easily sort by group,
# status and name
# if we sort_by_show : contacts_table = [group, status, name] # if we sort_by_show : contacts_table = [group, status, name]
# else : contacts_table = [group, name, status] # else : contacts_table = [group, name, status]
contacts_table = [] contacts_table = []
show_list = [] show_list = list(gajim.SHOW_LIST) # copy gajim.SHOW_LIST in show_list
for show in gajim.SHOW_LIST: # copy gajim.SHOW_LIST in show_list # not in roster is not in this list but we need it
show_list.append(show) show_list.append('not in roster')
show_list.append('not in roster') # not in roster is not in this list but we need it
for jid in gajim.contacts.get_jid_list(account): for jid in gajim.contacts.get_jid_list(account):
contact = gajim.contacts.get_contact_with_highest_priority(account, contact = gajim.contacts.get_contact_with_highest_priority(account,
jid) jid)
if contact.show not in ('offline', 'error'): if contact.show not in ('offline', 'error'):
if contact.show == 'not in roster': # print user in not in roster group if contact.show == 'not in roster':
# show user in not in roster group
contact_groups = [_('Not in Roster')] contact_groups = [_('Not in Roster')]
elif contact.groups == []: # user has no group, print him in General elif contact.groups == []: # user has no group, print him in General
contact_groups = [_('General')] contact_groups = [_('General')]
else: else:
contact_groups = contact.groups contact_groups = contact.groups
for group in contact_groups: # the user can be in mutiple groups, see in all of them for group in contact_groups:
# the user can be in mutiple groups, see in all of them
if group == _('Transports'): if group == _('Transports'):
continue continue
if sort_by_show: # see comment about contacts_table above if sort_by_show: # see comment about contacts_table above
@ -305,7 +307,8 @@ class Systray:
else: else:
contact_name = contact_item[1] contact_name = contact_item[1]
contact_show = show_list[contact_item[2]] contact_show = show_list[contact_item[2]]
if contact_item[0] != previous_group: #It's a new group, add the submenu if contact_item[0] != previous_group:
# It's a new group, add the submenu
item = gtk.MenuItem(contact_item[0]) item = gtk.MenuItem(contact_item[0])
contacts_menu = gtk.Menu() contacts_menu = gtk.Menu()
self.popup_menus.append(contacts_menu) self.popup_menus.append(contacts_menu)
@ -317,7 +320,8 @@ class Systray:
item_contact = gtk.ImageMenuItem(s) item_contact = gtk.ImageMenuItem(s)
# any given gtk widget can only be used in one place # any given gtk widget can only be used in one place
# (here we use it in status menu too) # (here we use it in status menu too)
# gtk.Image is a widget, it's better we refactor to use gdk.gdk.Pixbuf allover # gtk.Image is a widget, it's better we refactor to use
# gdk.gdk.Pixbuf allover
img = state_images[contact_show] img = state_images[contact_show]
img_copy = gobject.new(gtk.Image, pixbuf=img.get_pixbuf()) img_copy = gobject.new(gtk.Image, pixbuf=img.get_pixbuf())
item_contact.set_image(img_copy) item_contact.set_image(img_copy)