do a little less loops

This commit is contained in:
Jean-Marie Traissard 2008-04-06 13:23:10 +00:00
parent 06fdc8367b
commit eb22930361
1 changed files with 4 additions and 5 deletions

View File

@ -1733,21 +1733,20 @@ class GroupchatControl(ChatControlBase):
'nick': self.nick 'nick': self.nick
} }
place_found = False
index = 0
# check for duplicate entry and espect alpha order
for bookmark in gajim.connections[self.account].bookmarks: for bookmark in gajim.connections[self.account].bookmarks:
if bookmark['jid'] == bm['jid']: if bookmark['jid'] == bm['jid']:
dialogs.ErrorDialog( dialogs.ErrorDialog(
_('Bookmark already set'), _('Bookmark already set'),
_('Group Chat "%s" is already in your bookmarks.') % bm['jid']) _('Group Chat "%s" is already in your bookmarks.') % bm['jid'])
return return
place_found = False
index = 0
# Respect alpha order
for bookmark in gajim.connections[self.account].bookmarks:
if bookmark['name'] > bm['name']: if bookmark['name'] > bm['name']:
place_found = True place_found = True
break break
index += 1 index += 1
if place_found: if place_found:
gajim.connections[self.account].bookmarks.insert(index, bm) gajim.connections[self.account].bookmarks.insert(index, bm)
else: else: