Some random roster cleanups:

* remove unused code
 * use self.model directly when obvious
 * cleanup some FIXME comments
This commit is contained in:
Stephan Erb 2008-05-08 22:09:43 +00:00
parent 708e48a2a7
commit 56da8d7cfb

View file

@ -741,9 +741,11 @@ class RosterWindow:
return True return True
#FIXME: Better never even remove.... #FIXME:
# We need to define a generic way to keep contacts in roster
# as long as they have pending events or as we
# still chat with them
def _readd_contact_to_roster_if_needed(self, contact, account): def _readd_contact_to_roster_if_needed(self, contact, account):
# FIXME What am I REALLY needed for
need_readd = False need_readd = False
if len(gajim.events.get_events(account, contact.jid)): if len(gajim.events.get_events(account, contact.jid)):
need_readd = True need_readd = True
@ -1719,20 +1721,15 @@ class RosterWindow:
_('Now "%s" will always see you as offline.') %jid) _('Now "%s" will always see you as offline.') %jid)
def set_connecting_state(self, account): def set_connecting_state(self, account):
model = self.modelfilter child_iterA = self._get_account_iter(account, self.model)
child_model = model.get_model() if child_iterA:
IterA = self._get_account_iter(account) self.model[child_iterA][0] = \
if IterA:
child_iterA = model.convert_iter_to_child_iter(IterA)
child_model[child_iterA][0] = \
gajim.interface.jabber_state_images['16']['connecting'] gajim.interface.jabber_state_images['16']['connecting']
if gajim.interface.systray_enabled: if gajim.interface.systray_enabled:
gajim.interface.systray.change_status('connecting') gajim.interface.systray.change_status('connecting')
def send_status(self, account, status, txt, auto = False, to = None): def send_status(self, account, status, txt, auto = False, to = None):
model = self.modelfilter child_iterA = self._get_account_iter(account, self.model)
child_model = model.get_model()
iterA = self._get_account_iter(account)
if status != 'offline': if status != 'offline':
if gajim.connections[account].connected < 2: if gajim.connections[account].connected < 2:
self.set_connecting_state(account) self.set_connecting_state(account)
@ -1748,9 +1745,8 @@ class RosterWindow:
_('Save password')) _('Save password'))
passphrase, save = w.run() passphrase, save = w.run()
if passphrase == -1: if passphrase == -1:
if iterA: if child_iterA:
child_iterA = model.convert_iter_to_child_iter(iterA) self.model[child_iterA][0] = gajim.interface.jabber_state_images[
child_model[child_iterA][0] = gajim.interface.jabber_state_images[
'16']['offline'] '16']['offline']
if gajim.interface.systray_enabled: if gajim.interface.systray_enabled:
gajim.interface.systray.change_status('offline') gajim.interface.systray.change_status('offline')
@ -2053,15 +2049,12 @@ class RosterWindow:
show_in_roster=show_in_roster, show_in_systray=show_in_systray) show_in_roster=show_in_roster, show_in_systray=show_in_systray)
gajim.events.add_event(account, fjid, event) gajim.events.add_event(account, fjid, event)
if popup: if popup:
# FIXME: What is happening here.
# What does "OR he is not in the roster at all" mean
if not ctrl: if not ctrl:
gajim.interface.new_chat(contact, account, \ gajim.interface.new_chat(contact, account, \
resource=resource_for_chat) resource=resource_for_chat)
if path and not self.dragging and gajim.config.get( if path and not self.dragging and gajim.config.get(
'scroll_roster_to_last_message'): 'scroll_roster_to_last_message'):
# we curently see contact in our roster OR he # we curently see contact in our roster
# is not in the roster at all.
# show and select his line in roster # show and select his line in roster
# do not change selection while DND'ing # do not change selection while DND'ing
self.tree.expand_row(path[0:1], False) self.tree.expand_row(path[0:1], False)
@ -3023,13 +3016,6 @@ class RosterWindow:
titer = model.get_iter(path) titer = model.get_iter(path)
if x > x_min and x < x_min + 27 and type_ == 'contact' and \ if x > x_min and x < x_min + 27 and type_ == 'contact' and \
model.iter_has_child(titer): model.iter_has_child(titer):
# FIXME: Expand all meta contacts or only the current one?
#account = model[path][C_ACCOUNT].decode('utf-8')
#jid = model[path][C_JID].decode('utf-8')
# first cell in 1st column (the arrow SINGLE clicked)
#iters = self._get_contact_iter(jid, account)
#for titer in iters:
# path = model.get_path(titer)
if (self.tree.row_expanded(path)): if (self.tree.row_expanded(path)):
self.tree.collapse_row(path) self.tree.collapse_row(path)
else: else:
@ -3048,13 +3034,6 @@ class RosterWindow:
self.tree.expand_row(path, False) self.tree.expand_row(path, False)
elif type_ == 'contact' and x > x_min and x < x_min + 27: elif type_ == 'contact' and x > x_min and x < x_min + 27:
# FIXME: Expand all meta contacts or only the current one?
#account = model[path][C_ACCOUNT].decode('utf-8')
#jid = model[path][C_JID].decode('utf-8')
# first cell in 1st column (the arrow SINGLE clicked)
#iters = self._get_contact_iter(jid, account)
#for titer in iters:
# path = model.get_path(titer)
if (self.tree.row_expanded(path)): if (self.tree.row_expanded(path)):
self.tree.collapse_row(path) self.tree.collapse_row(path)
else: else:
@ -3974,17 +3953,14 @@ class RosterWindow:
def set_account_status_icon(self, account): def set_account_status_icon(self, account):
status = gajim.connections[account].connected status = gajim.connections[account].connected
model = self.modelfilter child_iterA = self._get_account_iter(account, self.model)
child_model = model.get_model() if not child_iterA:
iterA = self._get_account_iter(account)
if not iterA:
return return
child_iterA = model.convert_iter_to_child_iter(iterA)
if not self.regroup: if not self.regroup:
show = gajim.SHOW_LIST[status] show = gajim.SHOW_LIST[status]
else: # accounts merged else: # accounts merged
show = helpers.get_global_show() show = helpers.get_global_show()
child_model[child_iterA][C_IMG] = gajim.interface.jabber_state_images['16'][show] self.model[child_iterA][C_IMG] = gajim.interface.jabber_state_images['16'][show]
################################################################################ ################################################################################
### Style and theme related methods ### Style and theme related methods
@ -4025,9 +4001,7 @@ class RosterWindow:
model[titer][C_NAME] = model[titer][C_NAME] model[titer][C_NAME] = model[titer][C_NAME]
def change_roster_style(self, option): def change_roster_style(self, option):
model = self.modelfilter self.model.foreach(self._change_style, option)
child_model = model.get_model()
child_model.foreach(self._change_style, option)
for win in gajim.interface.msg_win_mgr.windows(): for win in gajim.interface.msg_win_mgr.windows():
win.repaint_themed_widgets() win.repaint_themed_widgets()