[change window icon according to the content (muc, chat). Fixes #4300
This commit is contained in:
parent
f6136a7058
commit
503aebd919
|
@ -2045,13 +2045,16 @@ class ChatControl(ChatControlBase):
|
||||||
label_str = '<b>' + unread + label_str + '</b>'
|
label_str = '<b>' + unread + label_str + '</b>'
|
||||||
return (label_str, color)
|
return (label_str, color)
|
||||||
|
|
||||||
def get_tab_image(self):
|
def get_tab_image(self, count_unread=True):
|
||||||
if self.resource:
|
if self.resource:
|
||||||
jid = self.contact.get_full_jid()
|
jid = self.contact.get_full_jid()
|
||||||
else:
|
else:
|
||||||
jid = self.contact.jid
|
jid = self.contact.jid
|
||||||
num_unread = len(gajim.events.get_events(self.account, jid,
|
if count_unread:
|
||||||
['printed_' + self.type_id, self.type_id]))
|
num_unread = len(gajim.events.get_events(self.account, jid,
|
||||||
|
['printed_' + self.type_id, self.type_id]))
|
||||||
|
else:
|
||||||
|
num_unread = 0
|
||||||
# Set tab image (always 16x16); unread messages show the 'event' image
|
# Set tab image (always 16x16); unread messages show the 'event' image
|
||||||
tab_img = None
|
tab_img = None
|
||||||
|
|
||||||
|
@ -2066,7 +2069,7 @@ class ChatControl(ChatControlBase):
|
||||||
# For transient contacts
|
# For transient contacts
|
||||||
contact = self.contact
|
contact = self.contact
|
||||||
img_16 = gajim.interface.roster.get_appropriate_state_images(
|
img_16 = gajim.interface.roster.get_appropriate_state_images(
|
||||||
self.contact.jid, icon_name = contact.show)
|
self.contact.jid, icon_name=contact.show)
|
||||||
tab_img = img_16[contact.show]
|
tab_img = img_16[contact.show]
|
||||||
|
|
||||||
return tab_img
|
return tab_img
|
||||||
|
|
|
@ -535,7 +535,7 @@ class GroupchatControl(ChatControlBase):
|
||||||
label_str = unread + label_str
|
label_str = unread + label_str
|
||||||
return (label_str, color)
|
return (label_str, color)
|
||||||
|
|
||||||
def get_tab_image(self):
|
def get_tab_image(self, count_unread=True):
|
||||||
# Set tab image (always 16x16)
|
# Set tab image (always 16x16)
|
||||||
tab_image = None
|
tab_image = None
|
||||||
if gajim.gc_connected[self.account][self.room_jid]:
|
if gajim.gc_connected[self.account][self.room_jid]:
|
||||||
|
|
|
@ -120,7 +120,7 @@ class MessageControl:
|
||||||
#return (label_str, None)
|
#return (label_str, None)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_tab_image(self):
|
def get_tab_image(self, count_unread=True):
|
||||||
# Return a suitable tab image for display.
|
# Return a suitable tab image for display.
|
||||||
# None clears any current label.
|
# None clears any current label.
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -146,6 +146,7 @@ class MessageWindow(object):
|
||||||
else:
|
else:
|
||||||
self.notebook.set_show_tabs(False)
|
self.notebook.set_show_tabs(False)
|
||||||
self.notebook.set_show_border(gajim.config.get('tabs_border'))
|
self.notebook.set_show_border(gajim.config.get('tabs_border'))
|
||||||
|
self.show_icon()
|
||||||
|
|
||||||
def change_account_name(self, old_name, new_name):
|
def change_account_name(self, old_name, new_name):
|
||||||
if old_name in self._controls:
|
if old_name in self._controls:
|
||||||
|
@ -417,6 +418,29 @@ class MessageWindow(object):
|
||||||
'''When close button is pressed: close a tab'''
|
'''When close button is pressed: close a tab'''
|
||||||
self.remove_tab(control, self.CLOSE_CLOSE_BUTTON)
|
self.remove_tab(control, self.CLOSE_CLOSE_BUTTON)
|
||||||
|
|
||||||
|
def show_icon(self):
|
||||||
|
window_mode = gajim.interface.msg_win_mgr.mode
|
||||||
|
icon = None
|
||||||
|
if window_mode == MessageWindowMgr.ONE_MSG_WINDOW_NEVER:
|
||||||
|
ctrl = self.get_active_control()
|
||||||
|
if not ctrl:
|
||||||
|
return
|
||||||
|
icon = ctrl.get_tab_image(count_unread=False)
|
||||||
|
elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS:
|
||||||
|
pass # keep default icon
|
||||||
|
elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_ALWAYS_WITH_ROSTER:
|
||||||
|
pass # keep default icon
|
||||||
|
elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_PERACCT:
|
||||||
|
pass # keep default icon
|
||||||
|
elif window_mode == MessageWindowMgr.ONE_MSG_WINDOW_PERTYPE:
|
||||||
|
if self.type_ == 'gc':
|
||||||
|
icon = gtkgui_helpers.load_icon('muc_active')
|
||||||
|
else:
|
||||||
|
# chat, pm
|
||||||
|
icon = gtkgui_helpers.load_icon('online')
|
||||||
|
if icon:
|
||||||
|
self.window.set_icon(icon.get_pixbuf())
|
||||||
|
|
||||||
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'''
|
||||||
if not control:
|
if not control:
|
||||||
|
@ -587,6 +611,8 @@ class MessageWindow(object):
|
||||||
else:
|
else:
|
||||||
status_img.set_from_pixbuf(tab_img.get_pixbuf())
|
status_img.set_from_pixbuf(tab_img.get_pixbuf())
|
||||||
|
|
||||||
|
self.show_icon()
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in New Issue