show unread pm in tab and in chat window title. fixes #2645
This commit is contained in:
		
							parent
							
								
									f4a3bf3ee4
								
							
						
					
					
						commit
						0e092980fd
					
				
					 2 changed files with 12 additions and 6 deletions
				
			
		| 
						 | 
					@ -395,9 +395,7 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		# count waiting highlighted messages
 | 
							# count waiting highlighted messages
 | 
				
			||||||
		unread = ''
 | 
							unread = ''
 | 
				
			||||||
		jid = self.contact.jid
 | 
							num_unread = self.get_nb_unread()
 | 
				
			||||||
		num_unread = len(gajim.events.get_events(self.account, jid,
 | 
					 | 
				
			||||||
			['printed_gc_msg']))
 | 
					 | 
				
			||||||
		if num_unread == 1:
 | 
							if num_unread == 1:
 | 
				
			||||||
			unread = '*'
 | 
								unread = '*'
 | 
				
			||||||
		elif num_unread > 1:
 | 
							elif num_unread > 1:
 | 
				
			||||||
| 
						 | 
					@ -469,7 +467,7 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
		iter = self.get_contact_iter(nick)
 | 
							iter = self.get_contact_iter(nick)
 | 
				
			||||||
		path = self.list_treeview.get_model().get_path(iter)
 | 
							path = self.list_treeview.get_model().get_path(iter)
 | 
				
			||||||
		if not autopopup or (not autopopupaway and \
 | 
							if not autopopup or (not autopopupaway and \
 | 
				
			||||||
					gajim.connections[self.account].connected > 2):
 | 
							gajim.connections[self.account].connected > 2):
 | 
				
			||||||
			if no_queue: # We didn't have a queue: we change icons
 | 
								if no_queue: # We didn't have a queue: we change icons
 | 
				
			||||||
				model = self.list_treeview.get_model()
 | 
									model = self.list_treeview.get_model()
 | 
				
			||||||
				state_images =\
 | 
									state_images =\
 | 
				
			||||||
| 
						 | 
					@ -478,6 +476,7 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
				image = state_images['message']
 | 
									image = state_images['message']
 | 
				
			||||||
				model[iter][C_IMG] = image
 | 
									model[iter][C_IMG] = image
 | 
				
			||||||
			self.parent_win.show_title()
 | 
								self.parent_win.show_title()
 | 
				
			||||||
 | 
								self.parent_win.redraw_tab(self)
 | 
				
			||||||
		else:
 | 
							else:
 | 
				
			||||||
			self._start_private_message(nick)
 | 
								self._start_private_message(nick)
 | 
				
			||||||
		# Scroll to line
 | 
							# Scroll to line
 | 
				
			||||||
| 
						 | 
					@ -588,6 +587,11 @@ class GroupchatControl(ChatControlBase):
 | 
				
			||||||
	def get_nb_unread(self):
 | 
						def get_nb_unread(self):
 | 
				
			||||||
		nb = len(gajim.events.get_events(self.account, self.room_jid,
 | 
							nb = len(gajim.events.get_events(self.account, self.room_jid,
 | 
				
			||||||
			['printed_gc_msg']))
 | 
								['printed_gc_msg']))
 | 
				
			||||||
 | 
							nb += self.get_nb_unread_pm()
 | 
				
			||||||
 | 
							return nb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						def get_nb_unread_pm(self):
 | 
				
			||||||
 | 
							nb = 0
 | 
				
			||||||
		for nick in gajim.contacts.get_nick_list(self.account, self.room_jid):
 | 
							for nick in gajim.contacts.get_nick_list(self.account, self.room_jid):
 | 
				
			||||||
			nb += len(gajim.events.get_events(self.account, self.room_jid + '/' + \
 | 
								nb += len(gajim.events.get_events(self.account, self.room_jid + '/' + \
 | 
				
			||||||
				nick, ['pm']))
 | 
									nick, ['pm']))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -238,8 +238,10 @@ class MessageWindow:
 | 
				
			||||||
		unread = 0
 | 
							unread = 0
 | 
				
			||||||
		for ctrl in self.controls():
 | 
							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:
 | 
				
			||||||
 | 
									# count only pm messages
 | 
				
			||||||
 | 
									unread += ctrl.get_nb_unread_pm()
 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			unread += ctrl.get_nb_unread()
 | 
								unread += ctrl.get_nb_unread()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue