Remove a LOT of useless draw_banner()

(stop drawing it 5 times when joining muc, stop reloading banner state icon on ALL
notifications, ...)
roster.py one seems useless because ctrl.update_ui() did it already
This commit is contained in:
Jean-Marie Traissard 2007-01-09 14:23:28 +00:00
parent 0ac904c6be
commit eea2e1c881
3 changed files with 21 additions and 24 deletions

View file

@ -91,15 +91,22 @@ class ChatControlBase(MessageControl):
type_])) type_]))
def draw_banner(self): def draw_banner(self):
self._paint_banner() '''Draw the fat line at the top of the window that
houses the icon, jid, ...
'''
self.draw_banner_text()
self._update_banner_state_image() self._update_banner_state_image()
# Derived types SHOULD implement this # Derived types MAY implement this
def draw_banner_text(self):
pass # Derived types SHOULD implement this
def update_ui(self): def update_ui(self):
self.draw_banner() self.draw_banner()
# Derived types SHOULD implement this # Derived types SHOULD implement this
def repaint_themed_widgets(self): def repaint_themed_widgets(self):
self._paint_banner()
self.draw_banner() self.draw_banner()
# Derived classes MAY implement this # Derived classes MAY implement this
@ -208,6 +215,7 @@ class ChatControlBase(MessageControl):
self.style_event_id = 0 self.style_event_id = 0
self.conv_textview.tv.show() self.conv_textview.tv.show()
self._paint_banner()
# For JEP-0172 # For JEP-0172
self.user_nick = None self.user_nick = None
@ -1011,14 +1019,10 @@ class ChatControl(ChatControlBase):
self._update_gpg() self._update_gpg()
def draw_banner(self, chatstate = None): def draw_banner_text(self):
'''Draw the fat line at the top of the window that '''Draw the text in the fat line at the top of the window that
houses the status icon, name, jid. The chatstate arg should houses the name, jid.
only be used if the control's chatstate member is NOT to be use, such as
composing, paused, etc.
''' '''
ChatControlBase.draw_banner(self)
contact = self.contact contact = self.contact
jid = contact.jid jid = contact.jid
@ -1551,7 +1555,7 @@ class ChatControl(ChatControlBase):
def handle_incoming_chatstate(self): def handle_incoming_chatstate(self):
''' handle incoming chatstate that jid SENT TO us ''' ''' handle incoming chatstate that jid SENT TO us '''
self.draw_banner() self.draw_banner_text()
# update chatstate in tab for this chat # update chatstate in tab for this chat
self.parent_win.redraw_tab(self, self.contact.chatstate) self.parent_win.redraw_tab(self, self.contact.chatstate)

View file

@ -301,8 +301,8 @@ class GroupchatControl(ChatControlBase):
column.set_visible(False) column.set_visible(False)
self.list_treeview.set_expander_column(column) self.list_treeview.set_expander_column(column)
self.draw_banner() gajim.gc_connected[self.account][self.room_jid] = False
self.got_disconnected() # init some variables ChatControlBase.got_disconnected(self)
self.update_ui() self.update_ui()
self.conv_textview.tv.grab_focus() self.conv_textview.tv.grab_focus()
@ -451,12 +451,10 @@ class GroupchatControl(ChatControlBase):
scaled_pix = pix.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR) scaled_pix = pix.scale_simple(32, 32, gtk.gdk.INTERP_BILINEAR)
banner_status_img.set_from_pixbuf(scaled_pix) banner_status_img.set_from_pixbuf(scaled_pix)
def draw_banner(self): def draw_banner_text(self):
'''Draw the fat line at the top of the window that '''Draw the text in the fat line at the top of the window that
houses the muc icon, room jid, subject. houses the room jid, subject.
''' '''
ChatControlBase.draw_banner(self)
self.name_label.set_ellipsize(pango.ELLIPSIZE_END) self.name_label.set_ellipsize(pango.ELLIPSIZE_END)
font_attrs, font_attrs_small = self.get_font_attrs() font_attrs, font_attrs_small = self.get_font_attrs()
text = '<span %s>%s</span>' % (font_attrs, self.room_jid) text = '<span %s>%s</span>' % (font_attrs, self.room_jid)
@ -725,7 +723,7 @@ class GroupchatControl(ChatControlBase):
def set_subject(self, subject): def set_subject(self, subject):
self.subject = subject self.subject = subject
self.draw_banner() self.draw_banner_text()
def got_connected(self): def got_connected(self):
gajim.gc_connected[self.account][self.room_jid] = True gajim.gc_connected[self.account][self.room_jid] = True
@ -740,10 +738,8 @@ class GroupchatControl(ChatControlBase):
nick) nick)
gajim.contacts.remove_gc_contact(self.account, gc_contact) gajim.contacts.remove_gc_contact(self.account, gc_contact)
gajim.gc_connected[self.account][self.room_jid] = False gajim.gc_connected[self.account][self.room_jid] = False
# Note, since this method is called during initialization it is NOT safe
# to call self.parent_win.redraw_tab here
ChatControlBase.got_disconnected(self) ChatControlBase.got_disconnected(self)
self.draw_banner() self._update_banner_state_image()
def draw_roster(self): def draw_roster(self):
self.list_treeview.get_model().clear() self.list_treeview.get_model().clear()

View file

@ -1214,9 +1214,6 @@ class RosterWindow:
else: # No status message else: # No status message
ctrl.print_conversation(_('%s is now %s') % (name, uf_show), ctrl.print_conversation(_('%s is now %s') % (name, uf_show),
'status') 'status')
if contact == gajim.contacts.get_contact_with_highest_priority(
account, contact.jid):
ctrl.draw_banner()
if not contact.groups: if not contact.groups:
self.draw_group(_('General'), account) self.draw_group(_('General'), account)