systray.add_jid and systray.remove_jid now have another argument: the typ of message: ('gc' or 'chat' or 'single_chat' or 'pm')

systary now can handle pm messages
This commit is contained in:
Yann Leboulanger 2005-09-24 09:42:10 +00:00
parent 8cc1bd3cea
commit 63c890da2b
6 changed files with 57 additions and 28 deletions

View File

@ -264,6 +264,12 @@ class Chat:
nickname.set_max_width_chars(10)
nickname.set_text(unread + self.names[jid])
def get_type(self, jid):
if self.widget_name == 'groupchat_window':
return 'gc'
if gajim.contacts[self.account].has_key(jid):
return 'chat'
return 'pm'
def on_window_destroy(self, widget, kind): #kind is 'chats' or 'gc'
'''clean self.plugin.windows[self.account][kind]'''
@ -275,7 +281,8 @@ class Chat:
gobject.source_remove(self.possible_paused_timeout_id[jid])
gobject.source_remove(self.possible_inactive_timeout_id[jid])
if self.plugin.systray_enabled and self.nb_unread[jid] > 0:
self.plugin.systray.remove_jid(jid, self.account)
self.plugin.systray.remove_jid(jid, self.account,
self.get_type(jid))
del windows[jid]
if self.print_time_timeout_id.has_key(jid):
gobject.source_remove(self.print_time_timeout_id[jid])
@ -321,7 +328,8 @@ class Chat:
self.nb_unread[jid] = 0 + self.get_specific_unread(jid)
self.show_title()
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
self.plugin.systray.remove_jid(jid, self.account,
self.get_type(jid))
'''TC/GC window received focus, so if we had urgency REMOVE IT
NOTE: we do not have to read the message (it maybe in a bg tab)
@ -485,7 +493,8 @@ class Chat:
self.redraw_tab(new_jid)
self.show_title()
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(new_jid, self.account)
self.plugin.systray.remove_jid(new_jid, self.account,
self.get_type(new_jid))
conversation_textview.grab_focus()
@ -521,7 +530,8 @@ class Chat:
if self.nb_unread[jid] > 0:
self.nb_unread[jid] = 0
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
self.plugin.systray.remove_jid(jid, self.account,
self.get_type(jid))
if self.print_time_timeout_id.has_key(jid):
gobject.source_remove(self.print_time_timeout_id[jid])
del self.print_time_timeout_id[jid]
@ -840,7 +850,8 @@ class Chat:
self.redraw_tab(jid)
self.show_title()
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
self.plugin.systray.remove_jid(jid, self.account,
self.get_type(jid))
def on_conversation_textview_motion_notify_event(self, widget, event):
'''change the cursor to a hand when we are over a mail or an url'''
@ -1307,7 +1318,7 @@ class Chat:
self.nb_unread[jid] += 1
if self.plugin.systray_enabled and gajim.config.get(
'trayicon_notification_on_new_messages'):
self.plugin.systray.add_jid(jid, self.account)
self.plugin.systray.add_jid(jid, self.account, self.get_type(jid))
self.redraw_tab(jid)
self.show_title(urgent)

View File

@ -1259,7 +1259,6 @@ current room topic.') % command, room_jid)
qs[fjid] = []
qs[fjid].append((msg, 'incoming', tim, False)) # False is for encrypted
self.nb_unread[room_jid] += 1
#FIXME: when we scroll to end we set nb_unread to 0
autopopup = gajim.config.get('autopopup')
autopopupaway = gajim.config.get('autopopupaway')
@ -1272,6 +1271,8 @@ current room topic.') % command, room_jid)
state_images = self.plugin.roster.get_appropriate_state_images(room_jid)
image = state_images['message']
model[iter][C_IMG] = image
if self.plugin.systray_enabled:
self.plugin.systray.add_jid(fjid, self.account, 'pm')
self.show_title()
else:
show = gajim.gc_contacts[self.account][room_jid][nick].show

View File

@ -1540,7 +1540,7 @@ _('If "%s" accepts this request you will know his status.') %jid)
model = self.tree.get_model()
self.draw_contact(jid, account)
if self.plugin.systray_enabled:
self.plugin.systray.add_jid(jid, account)
self.plugin.systray.add_jid(jid, account, 'chat')
self.show_title() # we show the * or [n]
if not path:
self.add_contact_to_roster(jid, account)

View File

@ -26,6 +26,7 @@ import os
import tooltips
from gajim import Contact
from common import gajim
from common import helpers
from common import i18n
@ -53,7 +54,7 @@ class Systray:
def __init__(self, plugin):
self.plugin = plugin
self.jids = []
self.jids = [] # Contain things like [account, jid, type_of_msg]
self.new_message_handler_id = None
self.t = None
self.img_tray = gtk.Image()
@ -73,8 +74,8 @@ class Systray:
elif image.get_storage_type() == gtk.IMAGE_PIXBUF:
self.img_tray.set_from_pixbuf(image.get_pixbuf())
def add_jid(self, jid, account):
l = [account, jid]
def add_jid(self, jid, account, typ):
l = [account, jid, typ]
if not l in self.jids:
self.jids.append(l)
self.set_img()
@ -88,8 +89,8 @@ class Systray:
if jid != 'tabbed':
nb += jids[jid].nb_unread[jid]
def remove_jid(self, jid, account):
l = [account, jid]
def remove_jid(self, jid, account, typ):
l = [account, jid, typ]
if l in self.jids:
self.jids.remove(l)
self.set_img()
@ -260,17 +261,31 @@ class Systray:
else:
account = self.jids[0][0]
jid = self.jids[0][1]
acc = self.plugin.windows[account]
typ = self.jids[0][2]
wins = self.plugin.windows[account]
w = None
if acc['gc'].has_key(jid):
w = acc['gc'][jid]
elif acc['chats'].has_key(jid):
w = acc['chats'][jid]
if typ == 'gc':
if wins['gc'].has_key(jid):
w = wins['gc'][jid]
elif typ == 'chat':
if wins['chats'].has_key(jid):
w = wins['chats'][jid]
else:
self.plugin.roster.new_chat(
gajim.contacts[account][jid][0], account)
acc['chats'][jid].set_active_tab(jid)
acc['chats'][jid].window.present()
w = wins['chats'][jid]
elif typ == 'single_chat':
pass
elif typ == 'pm':
if wins['chats'].has_key(jid):
w = wins['chats'][jid]
else:
room_jid, nick = jid.split('/', 1)
show = gajim.gc_contacts[account][room_jid][nick].show
c = Contact(jid = jid, name = nick, groups = ['none'],
show = show, ask = 'none')
self.plugin.roster.new_chat(c, account)
w = wins['chats'][jid]
if w:
w.set_active_tab(jid)
w.window.present()

View File

@ -250,8 +250,8 @@ class SystrayWin32(systray.Systray):
elif lparam == win32con.WM_LBUTTONUP: # Left click
self.on_left_click()
def add_jid(self, jid, account):
l = [account, jid]
def add_jid(self, jid, account, typ):
l = [account, jid, typ]
if not l in self.jids:
self.jids.append(l)
self.set_img()
@ -272,8 +272,8 @@ class SystrayWin32(systray.Systray):
self.systray_winapi.notify_icon.set_tooltip(text)
def remove_jid(self, jid, account):
l = [account, jid]
def remove_jid(self, jid, account, typ):
l = [account, jid, typ]
if l in self.jids:
self.jids.remove(l)
self.set_img()

View File

@ -722,15 +722,17 @@ timestamp, contact):
else:
self.plugin.roster.show_title()
del gajim.awaiting_messages[self.account][jid]
typ = 'chat' # Is it a normal chat or a pm ?
# reset to status image in gc if it is a pm
room_jid = jid.split('/', 1)[0]
gcs = self.plugin.windows[self.account]['gc']
if gcs.has_key(room_jid):
gcs[room_jid].update_state_images()
typ = 'pm'
self.plugin.roster.draw_contact(jid, self.account)
if self.plugin.systray_enabled:
self.plugin.systray.remove_jid(jid, self.account)
self.plugin.systray.remove_jid(jid, self.account, typ)
showOffline = gajim.config.get('showoffline')
if (user.show == 'offline' or user.show == 'error') and \
not showOffline: