Some coding standards.
This commit is contained in:
parent
56598c447b
commit
d82635a55a
1 changed files with 30 additions and 55 deletions
|
@ -919,7 +919,7 @@ class RosterWindow:
|
||||||
|
|
||||||
# FIXME: maybe move to gajim.py
|
# FIXME: maybe move to gajim.py
|
||||||
def remove_to_be_removed(self, jid, account):
|
def remove_to_be_removed(self, jid, account):
|
||||||
if not gajim.interface.instances.has_key(account):
|
if account not in gajim.interface.instances:
|
||||||
# Account has been deleted during the timeout that called us
|
# Account has been deleted during the timeout that called us
|
||||||
return
|
return
|
||||||
if jid in gajim.newly_added[account]:
|
if jid in gajim.newly_added[account]:
|
||||||
|
@ -1073,8 +1073,7 @@ class RosterWindow:
|
||||||
contact = gajim.contacts.get_highest_prio_contact_from_contacts(
|
contact = gajim.contacts.get_highest_prio_contact_from_contacts(
|
||||||
contact_instances)
|
contact_instances)
|
||||||
|
|
||||||
child_iters = self._get_contact_iter(jid, account,
|
child_iters = self._get_contact_iter(jid, account, contact, self.model)
|
||||||
contact, self.model)
|
|
||||||
if not child_iters:
|
if not child_iters:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1099,8 +1098,7 @@ class RosterWindow:
|
||||||
strike = True
|
strike = True
|
||||||
else:
|
else:
|
||||||
for group in contact.get_shown_groups():
|
for group in contact.get_shown_groups():
|
||||||
if group in \
|
if group in gajim.connections[account].blocked_groups:
|
||||||
gajim.connections[account].blocked_groups:
|
|
||||||
strike = True
|
strike = True
|
||||||
break
|
break
|
||||||
if strike:
|
if strike:
|
||||||
|
@ -1123,13 +1121,10 @@ class RosterWindow:
|
||||||
# useless to add account name
|
# useless to add account name
|
||||||
if account_ == account:
|
if account_ == account:
|
||||||
continue
|
continue
|
||||||
for jid_ in \
|
for jid_ in gajim.contacts.get_jid_list(account_):
|
||||||
gajim.contacts.get_jid_list(account_):
|
contact_ = gajim.contacts.get_first_contact_from_jid(
|
||||||
contact_ = gajim.contacts. \
|
|
||||||
get_first_contact_from_jid(
|
|
||||||
account_, jid_)
|
account_, jid_)
|
||||||
if contact_.get_shown_name() == \
|
if contact_.get_shown_name() == contact.get_shown_name() and \
|
||||||
contact.get_shown_name() and \
|
|
||||||
(jid_, account_) != (jid, account):
|
(jid_, account_) != (jid, account):
|
||||||
add_acct = True
|
add_acct = True
|
||||||
break
|
break
|
||||||
|
@ -1142,8 +1137,7 @@ class RosterWindow:
|
||||||
|
|
||||||
# add status msg, if not empty, under contact name in
|
# add status msg, if not empty, under contact name in
|
||||||
# the treeview
|
# the treeview
|
||||||
if contact.status \
|
if contact.status and gajim.config.get('show_status_msgs_in_roster'):
|
||||||
and gajim.config.get('show_status_msgs_in_roster'):
|
|
||||||
status = contact.status.strip()
|
status = contact.status.strip()
|
||||||
if status != '':
|
if status != '':
|
||||||
status = helpers.reduce_chars_newlines(status,
|
status = helpers.reduce_chars_newlines(status,
|
||||||
|
@ -1151,10 +1145,8 @@ class RosterWindow:
|
||||||
# escape markup entities and make them small
|
# escape markup entities and make them small
|
||||||
# italic and fg color color is calcuted to be
|
# italic and fg color color is calcuted to be
|
||||||
# always readable
|
# always readable
|
||||||
color = gtkgui_helpers._get_fade_color(
|
color = gtkgui_helpers._get_fade_color(self.tree, selected, focus)
|
||||||
self.tree, selected, focus)
|
colorstring = '#%04x%04x%04x' % (color.red, color.green, color.blue)
|
||||||
colorstring = '#%04x%04x%04x' % (color.red,
|
|
||||||
color.green, color.blue)
|
|
||||||
name += '\n<span size="small" style="italic" ' \
|
name += '\n<span size="small" style="italic" ' \
|
||||||
'foreground="%s">%s</span>' % (
|
'foreground="%s">%s</span>' % (
|
||||||
colorstring,
|
colorstring,
|
||||||
|
@ -1164,8 +1156,7 @@ class RosterWindow:
|
||||||
# look if another resource has awaiting events
|
# look if another resource has awaiting events
|
||||||
for c in contact_instances:
|
for c in contact_instances:
|
||||||
c_icon_name = helpers.get_icon_name_to_show(c, account)
|
c_icon_name = helpers.get_icon_name_to_show(c, account)
|
||||||
if c_icon_name \
|
if c_icon_name in ('event', 'muc_active', 'muc_inactive'):
|
||||||
in ('event', 'muc_active', 'muc_inactive'):
|
|
||||||
icon_name = c_icon_name
|
icon_name = c_icon_name
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -1175,8 +1166,7 @@ class RosterWindow:
|
||||||
have_visible_children = False
|
have_visible_children = False
|
||||||
if family:
|
if family:
|
||||||
nearby_family, bb_jid, bb_account = \
|
nearby_family, bb_jid, bb_account = \
|
||||||
self._get_nearby_family_and_big_brother(
|
self._get_nearby_family_and_big_brother(family, account)
|
||||||
family, account)
|
|
||||||
is_big_brother = (jid, account) == (bb_jid, bb_account)
|
is_big_brother = (jid, account) == (bb_jid, bb_account)
|
||||||
iters = self._get_contact_iter(jid, account)
|
iters = self._get_contact_iter(jid, account)
|
||||||
have_visible_children = iters \
|
have_visible_children = iters \
|
||||||
|
@ -1186,35 +1176,25 @@ class RosterWindow:
|
||||||
# We are the big brother and have a visible family
|
# We are the big brother and have a visible family
|
||||||
for child_iter in child_iters:
|
for child_iter in child_iters:
|
||||||
child_path = self.model.get_path(child_iter)
|
child_path = self.model.get_path(child_iter)
|
||||||
path = self.modelfilter. \
|
path = self.modelfilter.convert_child_path_to_path(child_path)
|
||||||
convert_child_path_to_path(child_path)
|
|
||||||
|
|
||||||
if not self.tree.row_expanded(path) \
|
if not self.tree.row_expanded(path) and icon_name != 'event':
|
||||||
and icon_name != 'event':
|
iterC = self.model.iter_children(child_iter)
|
||||||
iterC = self.model.iter_children(
|
|
||||||
child_iter)
|
|
||||||
while iterC:
|
while iterC:
|
||||||
# a child has awaiting messages?
|
# a child has awaiting messages?
|
||||||
jidC = self.model[iterC] \
|
jidC = self.model[iterC][C_JID].decode('utf-8')
|
||||||
[C_JID].decode('utf-8')
|
accountC = self.model[iterC][C_ACCOUNT].decode('utf-8')
|
||||||
accountC = self.model \
|
if len(gajim.events.get_events(accountC, jidC)):
|
||||||
[iterC][C_ACCOUNT]. \
|
|
||||||
decode('utf-8')
|
|
||||||
if len(gajim.events.get_events(
|
|
||||||
accountC, jidC)):
|
|
||||||
icon_name = 'event'
|
icon_name = 'event'
|
||||||
break
|
break
|
||||||
iterC = self.model.iter_next(
|
iterC = self.model.iter_next(iterC)
|
||||||
iterC)
|
|
||||||
|
|
||||||
if self.tree.row_expanded(path):
|
if self.tree.row_expanded(path):
|
||||||
state_images = self. \
|
state_images = self.get_appropriate_state_images(
|
||||||
get_appropriate_state_images(
|
|
||||||
jid, size = 'opened',
|
jid, size = 'opened',
|
||||||
icon_name = icon_name)
|
icon_name = icon_name)
|
||||||
else:
|
else:
|
||||||
state_images = self. \
|
state_images = self.get_appropriate_state_images(
|
||||||
get_appropriate_state_images(
|
|
||||||
jid, size = 'closed',
|
jid, size = 'closed',
|
||||||
icon_name = icon_name)
|
icon_name = icon_name)
|
||||||
|
|
||||||
|
@ -1241,12 +1221,10 @@ class RosterWindow:
|
||||||
for group in contact.get_shown_groups():
|
for group in contact.get_shown_groups():
|
||||||
# We need to make sure that _visible_func is called for
|
# We need to make sure that _visible_func is called for
|
||||||
# our groups otherwise we might not be shown
|
# our groups otherwise we might not be shown
|
||||||
iterG = self._get_group_iter(group, account,
|
iterG = self._get_group_iter(group, account, model = self.model)
|
||||||
model = self.model)
|
|
||||||
if iterG:
|
if iterG:
|
||||||
# it's not self contact
|
# it's not self contact
|
||||||
self.model[iterG][C_JID] = \
|
self.model[iterG][C_JID] = self.model[iterG][C_JID]
|
||||||
self.model[iterG][C_JID]
|
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1258,11 +1236,10 @@ class RosterWindow:
|
||||||
jid = self.model[iters[0]][C_JID]
|
jid = self.model[iters[0]][C_JID]
|
||||||
jid = jid.decode('utf-8')
|
jid = jid.decode('utf-8')
|
||||||
contact = gajim.contacts.get_contact(account, jid)
|
contact = gajim.contacts.get_contact(account, jid)
|
||||||
if contact.mood.has_key('mood') \
|
if 'mood' in contact.mood and contact.mood['mood'].strip() in MOODS:
|
||||||
and contact.mood['mood'].strip() in MOODS:
|
|
||||||
pixbuf = gtkgui_helpers.load_mood_icon(
|
pixbuf = gtkgui_helpers.load_mood_icon(
|
||||||
contact.mood['mood'].strip()).get_pixbuf()
|
contact.mood['mood'].strip()).get_pixbuf()
|
||||||
elif contact.mood.has_key('mood'):
|
elif 'mood' in contact.mood:
|
||||||
pixbuf = gtkgui_helpers.load_mood_icon(
|
pixbuf = gtkgui_helpers.load_mood_icon(
|
||||||
'unknown').get_pixbuf()
|
'unknown').get_pixbuf()
|
||||||
else:
|
else:
|
||||||
|
@ -1279,12 +1256,11 @@ class RosterWindow:
|
||||||
jid = self.model[iters[0]][C_JID]
|
jid = self.model[iters[0]][C_JID]
|
||||||
jid = jid.decode('utf-8')
|
jid = jid.decode('utf-8')
|
||||||
contact = gajim.contacts.get_contact(account, jid)
|
contact = gajim.contacts.get_contact(account, jid)
|
||||||
if contact.activity.has_key('activity') \
|
if 'activity' in contact.activity \
|
||||||
and contact.activity['activity'].strip() in ACTIVITIES:
|
and contact.activity['activity'].strip() in ACTIVITIES:
|
||||||
pixbuf = gtkgui_helpers.load_activity_icon(
|
pixbuf = gtkgui_helpers.load_activity_icon(
|
||||||
contact.activity['activity'].strip()). \
|
contact.activity['activity'].strip()).get_pixbuf()
|
||||||
get_pixbuf()
|
elif 'activity' in contact.activity:
|
||||||
elif contact.activity.has_key('activity'):
|
|
||||||
pixbuf = gtkgui_helpers.load_activity_icon(
|
pixbuf = gtkgui_helpers.load_activity_icon(
|
||||||
'unknown').get_pixbuf()
|
'unknown').get_pixbuf()
|
||||||
else:
|
else:
|
||||||
|
@ -1301,8 +1277,7 @@ class RosterWindow:
|
||||||
jid = self.model[iters[0]][C_JID]
|
jid = self.model[iters[0]][C_JID]
|
||||||
jid = jid.decode('utf-8')
|
jid = jid.decode('utf-8')
|
||||||
contact = gajim.contacts.get_contact(account, jid)
|
contact = gajim.contacts.get_contact(account, jid)
|
||||||
if contact.tune.has_key('artist') \
|
if contact.tune.has_key('artist') or contact.tune.has_key('title'):
|
||||||
or contact.tune.has_key('title'):
|
|
||||||
pixbuf = gtk.gdk.pixbuf_new_from_file(
|
pixbuf = gtk.gdk.pixbuf_new_from_file(
|
||||||
'../data/emoticons/static/music.png')
|
'../data/emoticons/static/music.png')
|
||||||
else:
|
else:
|
||||||
|
@ -1680,7 +1655,7 @@ class RosterWindow:
|
||||||
# Most of the logic SHOULD NOT be done at GUI level
|
# Most of the logic SHOULD NOT be done at GUI level
|
||||||
if account not in gajim.contacts.get_accounts():
|
if account not in gajim.contacts.get_accounts():
|
||||||
gajim.contacts.add_account(account)
|
gajim.contacts.add_account(account)
|
||||||
if not gajim.groups.has_key(account):
|
if account not in gajim.groups:
|
||||||
gajim.groups[account] = {}
|
gajim.groups[account] = {}
|
||||||
for jid in array.keys():
|
for jid in array.keys():
|
||||||
# Remove the contact in roster. It might has changed
|
# Remove the contact in roster. It might has changed
|
||||||
|
@ -1724,7 +1699,7 @@ class RosterWindow:
|
||||||
gajim.connections[account].request_vcard(jid_with_resource)
|
gajim.connections[account].request_vcard(jid_with_resource)
|
||||||
else:
|
else:
|
||||||
host = gajim.get_server_from_jid(contact1.jid)
|
host = gajim.get_server_from_jid(contact1.jid)
|
||||||
if not gajim.transport_avatar[account].has_key(host):
|
if host not in gajim.transport_avatar[account]:
|
||||||
gajim.transport_avatar[account][host] = [contact1.jid]
|
gajim.transport_avatar[account][host] = [contact1.jid]
|
||||||
else:
|
else:
|
||||||
gajim.transport_avatar[account][host].append(contact1.jid)
|
gajim.transport_avatar[account][host].append(contact1.jid)
|
||||||
|
|
Loading…
Add table
Reference in a new issue