Chatstate and tab redraw fixes
This commit is contained in:
parent
5464701cda
commit
715afc7113
|
@ -359,10 +359,8 @@ class ChatControlBase(MessageControl):
|
|||
if gajim.interface.systray_enabled and\
|
||||
gajim.config.get('trayicon_notification_on_new_messages'):
|
||||
gajim.interface.systray.add_jid(jid, self.account, self.type_id)
|
||||
# FIXME: This is one hairy race condition
|
||||
if self.parent_win.get_active_control():
|
||||
self.parent_win.redraw_tab(self.contact)
|
||||
self.parent_win.show_title(urgent)
|
||||
self.parent_win.redraw_tab(self.contact)
|
||||
self.parent_win.show_title(urgent)
|
||||
|
||||
def toggle_emoticons(self):
|
||||
'''hide show emoticons_button and make sure emoticons_menu is always there
|
||||
|
@ -935,12 +933,7 @@ class ChatControl(ChatControlBase):
|
|||
ChatControlBase.print_conversation_line(self, text, kind, name, tim,
|
||||
subject = subject)
|
||||
|
||||
def markup_tab_label(self, label_str, chatstate):
|
||||
'''Markup the label if necessary. Returns a tuple such as:
|
||||
(new_label_str, color)
|
||||
either of which can be None
|
||||
if chatstate is given that means we have HE SENT US a chatstate'''
|
||||
|
||||
def get_tab_label(self, chatstate):
|
||||
unread = ''
|
||||
num_unread = self.nb_unread
|
||||
if num_unread == 1 and not gajim.config.get('show_unread_tab_icon'):
|
||||
|
@ -981,10 +974,24 @@ class ChatControl(ChatControlBase):
|
|||
color.green = int((color.green * p) + (mask * (1 - p)))
|
||||
color.blue = int((color.blue * p) + (mask * (1 - p)))
|
||||
|
||||
label_str = self.contact.name
|
||||
if num_unread: # if unread, text in the label becomes bold
|
||||
label_str = '<b>' + unread + label_str + '</b>'
|
||||
return (label_str, color)
|
||||
|
||||
def get_tab_image(self):
|
||||
num_unread = self.nb_unread
|
||||
# Set tab image (always 16x16); unread messages show the 'message' image
|
||||
img_16 = gajim.interface.roster.get_appropriate_state_images(self.contact.jid)
|
||||
tab_img = None
|
||||
|
||||
if num_unread and gajim.config.get('show_unread_tab_icon'):
|
||||
tab_img = img_16['message']
|
||||
else:
|
||||
tab_img = img_16[self.contact.show]
|
||||
|
||||
return tab_img
|
||||
|
||||
|
||||
def remove_possible_switch_to_menuitems(self, menu):
|
||||
''' remove duplicate 'Switch to' if they exist and return clean menu'''
|
||||
|
@ -1114,19 +1121,17 @@ class ChatControl(ChatControlBase):
|
|||
|
||||
# prevent going paused if we we were not composing (JEP violation)
|
||||
if state == 'paused' and not contact.our_chatstate == 'composing':
|
||||
MessageControl.send_message(self, jid, None, None,
|
||||
chatstate = 'active') # go active before
|
||||
MessageControl.send_message(self, None, chatstate = 'active') # go active before
|
||||
contact.our_chatstate = 'active'
|
||||
self.reset_kbd_mouse_timeout_vars()
|
||||
|
||||
# if we're inactive prevent composing (JEP violation)
|
||||
if contact.our_chatstate == 'inactive' and state == 'composing':
|
||||
MessageControl.send_message(self, jid, None, None,
|
||||
chatstate = 'active') # go active before
|
||||
MessageControl.send_message(self, None, chatstate = 'active') # go active before
|
||||
contact.our_chatstate = 'active'
|
||||
self.reset_kbd_mouse_timeout_vars()
|
||||
|
||||
MessageControl.send_message(self, jid, None, None, chatstate = state)
|
||||
MessageControl.send_message(self, None, chatstate = state)
|
||||
contact.our_chatstate = state
|
||||
if contact.our_chatstate == 'active':
|
||||
self.reset_kbd_mouse_timeout_vars()
|
||||
|
|
|
@ -88,10 +88,17 @@ class MessageControl:
|
|||
gobject.source_remove(self.print_time_timeout_id)
|
||||
del self.print_time_timeout_id
|
||||
return False
|
||||
def markup_tab_label(self, label_str, chatstate):
|
||||
def get_tab_label(self, chatstate):
|
||||
'''Return a suitable the tab label string. Returns a tuple such as:
|
||||
(label_str, color) either of which can be None
|
||||
if chatstate is given that means we have HE SENT US a chatstate and
|
||||
we want it displayed'''
|
||||
# NOTE: Derived classes SHOULD implement this
|
||||
# Reurn a markup'd label and optional gtk.Color
|
||||
return (label_str, None)
|
||||
def get_tab_image(self):
|
||||
'''Return a suitable tab image for display. None clears any current label.'''
|
||||
return None
|
||||
def prepare_context_menu(self):
|
||||
# NOTE: Derived classes SHOULD implement this
|
||||
return None
|
||||
|
|
|
@ -257,25 +257,13 @@ class MessageWindow:
|
|||
|
||||
# Update nick
|
||||
nick_label.set_max_width_chars(10)
|
||||
(tab_label_str, tab_label_color) = ctl.markup_tab_label(contact.name,
|
||||
chatstate)
|
||||
(tab_label_str, tab_label_color) = ctl.get_tab_label(chatstate)
|
||||
nick_label.set_markup(tab_label_str)
|
||||
if tab_label_color:
|
||||
nick_label.modify_fg(gtk.STATE_NORMAL, tab_label_color)
|
||||
nick_label.modify_fg(gtk.STATE_ACTIVE, tab_label_color)
|
||||
|
||||
num_unread = ctl.nb_unread
|
||||
# Set tab image (always 16x16); unread messages show the 'message' image
|
||||
img_16 = gajim.interface.roster.get_appropriate_state_images(contact.jid)
|
||||
tab_img = None
|
||||
if ctl.type_id == message_control.TYPE_CHAT:
|
||||
if num_unread and gajim.config.get('show_unread_tab_icon'):
|
||||
tab_img = img_16['message']
|
||||
else:
|
||||
tab_img = img_16[contact.show]
|
||||
elif ctl.type_id == message_control.TYPE_GC:
|
||||
# FIXME: muc_active muc_inactive
|
||||
pass
|
||||
tab_img = ctl.get_tab_image()
|
||||
if tab_img:
|
||||
if tab_img.get_storage_type() == gtk.IMAGE_ANIMATION:
|
||||
status_img.set_from_animation(tab_img.get_animation())
|
||||
|
|
|
@ -722,6 +722,7 @@ class RosterWindow:
|
|||
win = gajim.interface.msg_win_mgr.get_window(contact.jid)
|
||||
ctl = win.get_control(jid)
|
||||
ctl.update_state()
|
||||
win.redraw_tab(contact)
|
||||
|
||||
name = contact.name
|
||||
if contact.resource != '':
|
||||
|
|
Loading…
Reference in New Issue