Improving readability (little) by shifting some boolean checks to a lambda function.

This commit is contained in:
Stephan Erb 2007-12-27 22:28:40 +00:00
parent 14bf5ed62c
commit e25ac90068
2 changed files with 24 additions and 20 deletions

View file

@ -1030,7 +1030,7 @@ class NBSOCKS5PROXYsocket(NonBlockingTcp):
# use the IPv4 address request even if remote resolving was specified. # use the IPv4 address request even if remote resolving was specified.
try: try:
self.ipaddr = socket.inet_aton(self.server[0]) self.ipaddr = socket.inet_aton(self.server[0])
req = req + "\x01" + ipaddr req = req + "\x01" + self.ipaddr
except socket.error: except socket.error:
# Well it's not an IP number, so it's probably a DNS name. # Well it's not an IP number, so it's probably a DNS name.
# if self.__proxy[3]==True: # if self.__proxy[3]==True:

View file

@ -3536,6 +3536,15 @@ class TransformChatToMUC:
self.guests_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE) self.guests_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
# All contacts beside the following can be invited:
# transports, zeroconf contacts, minimized groupchats
invitable = lambda contact, contact_transport = None:\
contact.jid not in self.auto_jids and\
contact.jid != gajim.get_jid_from_account(self.account) and\
contact.jid not in gajim.interface.minimized_controls[account] and\
not contact.is_transport() and\
not contact_transport
# set jabber id and pseudos # set jabber id and pseudos
for account in gajim.contacts.get_accounts(): for account in gajim.contacts.get_accounts():
if gajim.connections[account].is_zeroconf: if gajim.connections[account].is_zeroconf:
@ -3544,24 +3553,20 @@ class TransformChatToMUC:
contact = \ contact = \
gajim.contacts.get_contact_with_highest_priority(account, jid) gajim.contacts.get_contact_with_highest_priority(account, jid)
contact_transport = gajim.get_transport_name_from_jid(jid) contact_transport = gajim.get_transport_name_from_jid(jid)
# do not add transports, zeroconf contacs, minimized groupchats # Add contact if it can be invited
# and selfjid to list of invitable jids if invitable(contact, contact_transport) and \
if contact.jid not in self.auto_jids and contact.jid != \ contact.show not in ('offline', 'error'):
gajim.get_jid_from_account(self.account) and not contact_transport \ img = gajim.interface.roster.jabber_state_images['16'][
and not contact.is_transport() and contact.jid not in \ contact.show]
gajim.interface.minimized_controls[account]: name = contact.name
if contact.show not in ('offline', 'error'): if name == '':
img = gajim.interface.roster.jabber_state_images['16'][ name = jid.split('@')[0]
contact.show] iter = self.store.append([img.get_pixbuf(), name, jid])
name = contact.name # preselect treeview rows
if name == '': if self.preselected_jids and jid in self.preselected_jids:
name = jid.split('@')[0] path = self.store.get_path(iter)
iter = self.store.append([img.get_pixbuf(), name, jid]) self.guests_treeview.get_selection().\
# preselect treeview rows select_path(path)
if self.preselected_jids and jid in self.preselected_jids:
path = self.store.get_path(iter)
self.guests_treeview.get_selection().\
select_path(path)
# show all # show all
self.window.show_all() self.window.show_all()
@ -3579,7 +3584,6 @@ class TransformChatToMUC:
server = self.server_list_comboboxentry.get_active_text() server = self.server_list_comboboxentry.get_active_text()
if server == '': if server == '':
return return
room_id = gajim.nicks[self.account] + str(randrange(9999999))
gajim.connections[self.account].check_unique_room_id_support(server, self) gajim.connections[self.account].check_unique_room_id_support(server, self)
def unique_room_id_supported(self, server, room_id): def unique_room_id_supported(self, server, room_id):