change var name. type is a reserved word

This commit is contained in:
Yann Leboulanger 2007-01-02 17:43:32 +00:00
parent 4a58db0fca
commit f5108c745f

View file

@ -2471,41 +2471,41 @@ class RosterWindow:
model, list_of_paths = treeselection.get_selected_rows() model, list_of_paths = treeselection.get_selected_rows()
if not len(list_of_paths): if not len(list_of_paths):
return return
type = model[list_of_paths[0]][C_TYPE] type_ = model[list_of_paths[0]][C_TYPE]
account = model[list_of_paths[0]][C_ACCOUNT] account = model[list_of_paths[0]][C_ACCOUNT]
list_ = [] list_ = []
for path in list_of_paths: for path in list_of_paths:
if model[path][C_TYPE] != type: if model[path][C_TYPE] != type_:
return return
jid = model[path][C_JID].decode('utf-8') jid = model[path][C_JID].decode('utf-8')
account = model[path][C_ACCOUNT].decode('utf-8') account = model[path][C_ACCOUNT].decode('utf-8')
contact = gajim.contacts.get_contact_with_highest_priority(account, contact = gajim.contacts.get_contact_with_highest_priority(account,
jid) jid)
list_.append((contact, account)) list_.append((contact, account))
if type in ('account', 'group', 'self_contact') or \ if type_ in ('account', 'group', 'self_contact') or \
account == gajim.ZEROCONF_ACC_NAME: account == gajim.ZEROCONF_ACC_NAME:
return return
if type == 'contact': if type_ == 'contact':
self.on_req_usub(widget, list_) self.on_req_usub(widget, list_)
elif type == 'agent': elif type_ == 'agent':
self.on_remove_agent(widget, list_) self.on_remove_agent(widget, list_)
def show_appropriate_context_menu(self, event, iters): def show_appropriate_context_menu(self, event, iters):
# iters must be all of the same type # iters must be all of the same type
model = self.tree.get_model() model = self.tree.get_model()
type = model[iters[0]][C_TYPE] type_ = model[iters[0]][C_TYPE]
for iter in iters[1:]: for iter in iters[1:]:
if model[iter][C_TYPE] != type: if model[iter][C_TYPE] != type_:
return return
if type == 'group' and len(iters) == 1: if type_ == 'group' and len(iters) == 1:
self.make_group_menu(event, iters[0]) self.make_group_menu(event, iters[0])
elif type == 'agent' and len(iters) == 1: elif type_ == 'agent' and len(iters) == 1:
self.make_transport_menu(event, iters[0]) self.make_transport_menu(event, iters[0])
elif type in ('contact', 'self_contact') and len(iters) == 1: elif type_ in ('contact', 'self_contact') and len(iters) == 1:
self.make_contact_menu(event, iters[0]) self.make_contact_menu(event, iters[0])
elif type == 'contact': elif type_ == 'contact':
self.make_multiple_contact_menu(event, iters) self.make_multiple_contact_menu(event, iters)
elif type == 'account' and len(iters) == 1: elif type_ == 'account' and len(iters) == 1:
self.make_account_menu(event, iters[0]) self.make_account_menu(event, iters[0])
def show_treeview_menu(self, event): def show_treeview_menu(self, event):
@ -2558,10 +2558,10 @@ class RosterWindow:
if list_of_paths != [path]: if list_of_paths != [path]:
self.tree.get_selection().unselect_all() self.tree.get_selection().unselect_all()
self.tree.get_selection().select_path(path) self.tree.get_selection().select_path(path)
type = model[path][C_TYPE] type_ = model[path][C_TYPE]
if type in ('agent', 'contact', 'self_contact'): if type_ in ('agent', 'contact', 'self_contact'):
self.on_roster_treeview_row_activated(widget, path) self.on_roster_treeview_row_activated(widget, path)
elif type == 'account': elif type_ == 'account':
account = model[path][C_ACCOUNT].decode('utf-8') account = model[path][C_ACCOUNT].decode('utf-8')
if account != 'all': if account != 'all':
show = gajim.connections[account].connected show = gajim.connections[account].connected
@ -2585,15 +2585,15 @@ class RosterWindow:
elif event.button == 1: # Left click elif event.button == 1: # Left click
model = self.tree.get_model() model = self.tree.get_model()
type = model[path][C_TYPE] type_ = model[path][C_TYPE]
if type == 'group' and x < 27: if type_ == 'group' and x < 27:
# first cell in 1st column (the arrow SINGLE clicked) # first cell in 1st column (the arrow SINGLE clicked)
if (self.tree.row_expanded(path)): if (self.tree.row_expanded(path)):
self.tree.collapse_row(path) self.tree.collapse_row(path)
else: else:
self.tree.expand_row(path, False) self.tree.expand_row(path, False)
elif type == 'contact' and x < 27: elif type_ == 'contact' and x < 27:
account = model[path][C_ACCOUNT].decode('utf-8') account = model[path][C_ACCOUNT].decode('utf-8')
jid = model[path][C_JID].decode('utf-8') jid = model[path][C_JID].decode('utf-8')
# first cell in 1st column (the arrow SINGLE clicked) # first cell in 1st column (the arrow SINGLE clicked)
@ -2988,16 +2988,16 @@ class RosterWindow:
def new_chat(self, contact, account, private_chat = False, resource = None): def new_chat(self, contact, account, private_chat = False, resource = None):
# Get target window, create a control, and associate it with the window # Get target window, create a control, and associate it with the window
if not private_chat: if not private_chat:
type = message_control.TYPE_CHAT type_ = message_control.TYPE_CHAT
else: else:
type = message_control.TYPE_PM type_ = message_control.TYPE_PM
fjid = contact.jid fjid = contact.jid
if resource: if resource:
fjid += '/' + resource fjid += '/' + resource
mw = gajim.interface.msg_win_mgr.get_window(fjid, account) mw = gajim.interface.msg_win_mgr.get_window(fjid, account)
if not mw: if not mw:
mw = gajim.interface.msg_win_mgr.create_window(contact, account, type) mw = gajim.interface.msg_win_mgr.create_window(contact, account, type_)
if not private_chat: if not private_chat:
chat_control = ChatControl(mw, contact, account, resource) chat_control = ChatControl(mw, contact, account, resource)
@ -3438,11 +3438,11 @@ class RosterWindow:
'''When an iter is double clicked: open the first event window''' '''When an iter is double clicked: open the first event window'''
model = self.tree.get_model() model = self.tree.get_model()
account = model[path][C_ACCOUNT].decode('utf-8') account = model[path][C_ACCOUNT].decode('utf-8')
type = model[path][C_TYPE] type_ = model[path][C_TYPE]
jid = model[path][C_JID].decode('utf-8') jid = model[path][C_JID].decode('utf-8')
resource = None resource = None
iter = model.get_iter(path) iter = model.get_iter(path)
if type in ('group', 'account'): if type_ in ('group', 'account'):
if self.tree.row_expanded(path): if self.tree.row_expanded(path):
self.tree.collapse_row(path) self.tree.collapse_row(path)
else: else:
@ -3486,8 +3486,8 @@ class RosterWindow:
accounts = gajim.connections.keys() accounts = gajim.connections.keys()
else: else:
accounts = [model[iter][C_ACCOUNT].decode('utf-8')] accounts = [model[iter][C_ACCOUNT].decode('utf-8')]
type = model[iter][C_TYPE] type_ = model[iter][C_TYPE]
if type == 'group': if type_ == 'group':
model.set_value(iter, 0, self.jabber_state_images['16']['opened']) model.set_value(iter, 0, self.jabber_state_images['16']['opened'])
jid = model[iter][C_JID].decode('utf-8') jid = model[iter][C_JID].decode('utf-8')
for account in accounts: for account in accounts:
@ -3495,7 +3495,7 @@ class RosterWindow:
gajim.groups[account][jid]['expand'] = True gajim.groups[account][jid]['expand'] = True
if account + jid in self.collapsed_rows: if account + jid in self.collapsed_rows:
self.collapsed_rows.remove(account + jid) self.collapsed_rows.remove(account + jid)
elif type == 'account': elif type_ == 'account':
account = accounts[0] # There is only one cause we don't use merge account = accounts[0] # There is only one cause we don't use merge
if account in self.collapsed_rows: if account in self.collapsed_rows:
self.collapsed_rows.remove(account) self.collapsed_rows.remove(account)
@ -3505,7 +3505,7 @@ class RosterWindow:
pathG = model.get_path(groupIter) pathG = model.get_path(groupIter)
self.tree.expand_row(pathG, False) self.tree.expand_row(pathG, False)
self.draw_account(account) self.draw_account(account)
elif type == 'contact': elif type_ == 'contact':
jid = model[iter][C_JID].decode('utf-8') jid = model[iter][C_JID].decode('utf-8')
account = model[iter][C_ACCOUNT].decode('utf-8') account = model[iter][C_ACCOUNT].decode('utf-8')
self.draw_contact(jid, account) self.draw_contact(jid, account)
@ -3518,8 +3518,8 @@ class RosterWindow:
accounts = gajim.connections.keys() accounts = gajim.connections.keys()
else: else:
accounts = [model[iter][C_ACCOUNT].decode('utf-8')] accounts = [model[iter][C_ACCOUNT].decode('utf-8')]
type = model[iter][C_TYPE] type_ = model[iter][C_TYPE]
if type == 'group': if type_ == 'group':
model.set_value(iter, 0, self.jabber_state_images['16']['closed']) model.set_value(iter, 0, self.jabber_state_images['16']['closed'])
jid = model[iter][C_JID].decode('utf-8') jid = model[iter][C_JID].decode('utf-8')
for account in accounts: for account in accounts:
@ -3527,12 +3527,12 @@ class RosterWindow:
gajim.groups[account][jid]['expand'] = False gajim.groups[account][jid]['expand'] = False
if not account + jid in self.collapsed_rows: if not account + jid in self.collapsed_rows:
self.collapsed_rows.append(account + jid) self.collapsed_rows.append(account + jid)
elif type == 'account': elif type_ == 'account':
account = accounts[0] # There is only one cause we don't use merge account = accounts[0] # There is only one cause we don't use merge
if not account in self.collapsed_rows: if not account in self.collapsed_rows:
self.collapsed_rows.append(account) self.collapsed_rows.append(account)
self.draw_account(account) self.draw_account(account)
elif type == 'contact': elif type_ == 'contact':
jid = model[iter][C_JID].decode('utf-8') jid = model[iter][C_JID].decode('utf-8')
account = model[iter][C_ACCOUNT].decode('utf-8') account = model[iter][C_ACCOUNT].decode('utf-8')
self.draw_contact(jid, account) self.draw_contact(jid, account)