Since some data structures are going to be changing for #1421, make more

use of the interators to jide more of the underlying details.
This commit is contained in:
Travis Shirk 2006-01-24 02:57:26 +00:00
parent 96bf76308f
commit b936ff50a0
1 changed files with 14 additions and 14 deletions

View File

@ -112,13 +112,13 @@ class MessageWindow:
def _on_window_delete(self, win, event): def _on_window_delete(self, win, event):
# Make sure all controls are okay with being deleted # Make sure all controls are okay with being deleted
for ctrl in self._controls.values(): for ctrl in self.controls():
if not ctrl.allow_shutdown(): if not ctrl.allow_shutdown():
return True # halt the delete return True # halt the delete
return False return False
def _on_window_destroy(self, win): def _on_window_destroy(self, win):
for ctrl in self._controls.values(): for ctrl in self.controls():
ctrl.shutdown() ctrl.shutdown()
self._controls.clear() self._controls.clear()
@ -180,7 +180,7 @@ class MessageWindow:
def show_title(self, urgent = True, control = None): def show_title(self, urgent = True, control = None):
'''redraw the window's title''' '''redraw the window's title'''
unread = 0 unread = 0
for ctrl in self._controls.values(): for ctrl in self.controls():
if ctrl.type_id == message_control.TYPE_GC and not \ if ctrl.type_id == message_control.TYPE_GC and not \
gajim.config.get('notify_on_all_muc_messages') and not \ gajim.config.get('notify_on_all_muc_messages') and not \
ctrl.attention_flag: ctrl.attention_flag:
@ -280,11 +280,11 @@ class MessageWindow:
def repaint_themed_widgets(self): def repaint_themed_widgets(self):
'''Repaint controls in the window with theme color''' '''Repaint controls in the window with theme color'''
# iterate through controls and repaint # iterate through controls and repaint
for ctrl in self._controls.values(): for ctrl in self.controls():
ctrl.repaint_themed_widgets() ctrl.repaint_themed_widgets()
def _widget_to_control(self, widget): def _widget_to_control(self, widget):
for ctrl in self._controls.values(): for ctrl in self.controls():
if ctrl.widget == widget: if ctrl.widget == widget:
return ctrl return ctrl
return None return None
@ -310,13 +310,13 @@ class MessageWindow:
return self.window.window.get_origin() return self.window.window.get_origin()
def toggle_emoticons(self): def toggle_emoticons(self):
for ctrl in self._controls.values(): for ctrl in self.controls():
ctrl.toggle_emoticons() ctrl.toggle_emoticons()
def update_font(self): def update_font(self):
for ctrl in self._controls.values(): for ctrl in self.controls():
ctrl.update_font() ctrl.update_font()
def update_tags(self): def update_tags(self):
for ctrl in self._controls.values(): for ctrl in self.controls():
ctrl.update_tags() ctrl.update_tags()
def get_control(self, key): def get_control(self, key):
@ -326,7 +326,7 @@ class MessageWindow:
if isinstance(key, unicode): if isinstance(key, unicode):
jid = key jid = key
for ctrl in self._controls.values(): for ctrl in self.controls():
if ctrl.contact.jid == jid: if ctrl.contact.jid == jid:
return ctrl return ctrl
return None return None
@ -394,7 +394,7 @@ class MessageWindow:
# common menuitems (tab switches) # common menuitems (tab switches)
if len(self._controls) > 1: # if there is more than one tab if len(self._controls) > 1: # if there is more than one tab
menu.append(gtk.SeparatorMenuItem()) # seperator menu.append(gtk.SeparatorMenuItem()) # seperator
for ctrl in self._controls.values(): for ctrl in self.controls():
jid = ctrl.contact.jid jid = ctrl.contact.jid
if jid != self.get_active_jid(): if jid != self.get_active_jid():
item = gtk.ImageMenuItem(_('Switch to %s') %\ item = gtk.ImageMenuItem(_('Switch to %s') %\
@ -567,13 +567,13 @@ class MessageWindowMgr:
return win return win
def _gtk_win_to_msg_win(self, gtk_win): def _gtk_win_to_msg_win(self, gtk_win):
for w in self._windows.values(): for w in self.windows():
if w.window == gtk_win: if w.window == gtk_win:
return w return w
return None return None
def get_window(self, jid): def get_window(self, jid):
for win in self._windows.values(): for win in self.windows():
if win.get_control(jid): if win.get_control(jid):
return win return win
return None return None
@ -753,7 +753,7 @@ class MessageWindowMgr:
gajim.config.set(size_height_key, height) gajim.config.set(size_height_key, height)
def reconfig(self): def reconfig(self):
for w in self._windows.values(): for w in self.windows():
self.save_state(w) self.save_state(w)
gajim.interface.save_config() gajim.interface.save_config()
# Map the mode to a int constant for frequent compares # Map the mode to a int constant for frequent compares
@ -764,7 +764,7 @@ class MessageWindowMgr:
self.mode = common.config.opt_one_window_types.index(mode) self.mode = common.config.opt_one_window_types.index(mode)
controls = [] controls = []
for w in self._windows.values(): for w in self.windows():
w.window.hide() w.window.hide()
while w.notebook.get_n_pages(): while w.notebook.get_n_pages():
page = w.notebook.get_nth_page(0) page = w.notebook.get_nth_page(0)