show newly connected contacts in green and contacts that have just disconnected in red before removing them. Presentation/colors have to be improved, but the principle is there (to be tested).
This commit is contained in:
parent
923f10d57a
commit
c797d737b0
|
@ -1147,6 +1147,10 @@ class Account_modification_window:
|
||||||
self.plugin.roster.groups[self.account]
|
self.plugin.roster.groups[self.account]
|
||||||
self.plugin.roster.contacts[name] = \
|
self.plugin.roster.contacts[name] = \
|
||||||
self.plugin.roster.contacts[self.account]
|
self.plugin.roster.contacts[self.account]
|
||||||
|
self.plugin.roster.newly_added[name] = \
|
||||||
|
self.plugin.roster.newly_added[self.account]
|
||||||
|
self.plugin.roster.to_be_removed[name] = \
|
||||||
|
self.plugin.roster.to_be_removed[self.account]
|
||||||
self.plugin.sleeper_state[name] = \
|
self.plugin.sleeper_state[name] = \
|
||||||
self.plugin.sleeper_state[self.account]
|
self.plugin.sleeper_state[self.account]
|
||||||
#upgrade account variable in opened windows
|
#upgrade account variable in opened windows
|
||||||
|
@ -1211,6 +1215,8 @@ class Account_modification_window:
|
||||||
self.plugin.connected[name] = 0
|
self.plugin.connected[name] = 0
|
||||||
self.plugin.roster.groups[name] = {}
|
self.plugin.roster.groups[name] = {}
|
||||||
self.plugin.roster.contacts[name] = {}
|
self.plugin.roster.contacts[name] = {}
|
||||||
|
self.plugin.roster.newly_added[name] = []
|
||||||
|
self.plugin.roster.to_be_removed[name] = []
|
||||||
self.plugin.nicks[name] = login
|
self.plugin.nicks[name] = login
|
||||||
self.plugin.sleeper_state[name] = 0
|
self.plugin.sleeper_state[name] = 0
|
||||||
#refresh accounts window
|
#refresh accounts window
|
||||||
|
|
|
@ -370,6 +370,18 @@ class plugin:
|
||||||
user1.priority, user1.keyID)
|
user1.priority, user1.keyID)
|
||||||
luser.append(user1)
|
luser.append(user1)
|
||||||
user1.resource = resource
|
user1.resource = resource
|
||||||
|
if old_show == 0 and statuss.index(array[1]) > 1:
|
||||||
|
if not user1.jid in self.roster.newly_added[account]:
|
||||||
|
self.roster.newly_added[account].append(user1.jid)
|
||||||
|
if user1.jid in self.roster.to_be_removed[account]:
|
||||||
|
self.roster.to_be_removed[account].remove(user1.jid)
|
||||||
|
gobject.timeout_add(5000, self.roster.remove_newly_added, user1.jid, account)
|
||||||
|
if old_show > 1 and statuss.index(array[1]) == 0 and self.connected[account] > 1:
|
||||||
|
if not user1.jid in self.roster.to_be_removed[account]:
|
||||||
|
self.roster.to_be_removed[account].append(user1.jid)
|
||||||
|
if user1.jid in self.roster.newly_added[account]:
|
||||||
|
self.roster.newly_added[account].remove(user1.jid)
|
||||||
|
gobject.timeout_add(5000, self.roster.really_remove_user, user1, account)
|
||||||
user1.show = array[1]
|
user1.show = array[1]
|
||||||
user1.status = array[2]
|
user1.status = array[2]
|
||||||
user1.priority = priority
|
user1.priority = priority
|
||||||
|
|
|
@ -113,6 +113,11 @@ class Roster_window:
|
||||||
model.append(None, (self.pixbufs[status], account, 'account', account,\
|
model.append(None, (self.pixbufs[status], account, 'account', account,\
|
||||||
account, False))
|
account, False))
|
||||||
|
|
||||||
|
def remove_newly_added(self, jid, account):
|
||||||
|
if jid in self.newly_added[account]:
|
||||||
|
self.newly_added[account].remove(jid)
|
||||||
|
self.redraw_jid(jid, account)
|
||||||
|
|
||||||
def add_user_to_roster(self, jid, account):
|
def add_user_to_roster(self, jid, account):
|
||||||
"""Add a user to the roster and add groups if they aren't in roster"""
|
"""Add a user to the roster and add groups if they aren't in roster"""
|
||||||
showOffline = self.plugin.config['showoffline']
|
showOffline = self.plugin.config['showoffline']
|
||||||
|
@ -157,8 +162,15 @@ class Roster_window:
|
||||||
self.tree.expand_row(model.get_path(iterG), False)
|
self.tree.expand_row(model.get_path(iterG), False)
|
||||||
self.redraw_jid(jid, account)
|
self.redraw_jid(jid, account)
|
||||||
|
|
||||||
|
def really_remove_user(self, user, account):
|
||||||
|
if user.jid in self.to_be_removed[account]:
|
||||||
|
self.to_be_removed[account].remove(user.jid)
|
||||||
|
self.remove_user(user, account)
|
||||||
|
|
||||||
def remove_user(self, user, account):
|
def remove_user(self, user, account):
|
||||||
"""Remove a user from the roster"""
|
"""Remove a user from the roster"""
|
||||||
|
if user.jid in self.to_be_removed[account]:
|
||||||
|
return
|
||||||
model = self.tree.get_model()
|
model = self.tree.get_model()
|
||||||
for i in self.get_user_iter(user.jid, account):
|
for i in self.get_user_iter(user.jid, account):
|
||||||
parent_i = model.iter_parent(i)
|
parent_i = model.iter_parent(i)
|
||||||
|
@ -1181,8 +1193,15 @@ class Roster_window:
|
||||||
renderer.set_property('font', self.plugin.config['groupfont'])
|
renderer.set_property('font', self.plugin.config['groupfont'])
|
||||||
renderer.set_property('xpad', 4)
|
renderer.set_property('xpad', 4)
|
||||||
else:
|
else:
|
||||||
renderer.set_property('foreground', \
|
jid = model.get_value(iter, 3)
|
||||||
self.plugin.config['usertextcolor'])
|
account = model.get_value(iter, 4)
|
||||||
|
if jid in self.newly_added[account]:
|
||||||
|
renderer.set_property('foreground', 'green')
|
||||||
|
elif jid in self.to_be_removed[account]:
|
||||||
|
renderer.set_property('foreground', 'red')
|
||||||
|
else:
|
||||||
|
renderer.set_property('foreground', \
|
||||||
|
self.plugin.config['usertextcolor'])
|
||||||
renderer.set_property('cell-background', \
|
renderer.set_property('cell-background', \
|
||||||
self.plugin.config['userbgcolor'])
|
self.plugin.config['userbgcolor'])
|
||||||
renderer.set_property('font', self.plugin.config['userfont'])
|
renderer.set_property('font', self.plugin.config['userfont'])
|
||||||
|
@ -1307,10 +1326,14 @@ class Roster_window:
|
||||||
self.window.show_all()
|
self.window.show_all()
|
||||||
self.groups = {}
|
self.groups = {}
|
||||||
self.contacts = {}
|
self.contacts = {}
|
||||||
|
self.newly_added = {}
|
||||||
|
self.to_be_removed = {}
|
||||||
self.popups_height = 0
|
self.popups_height = 0
|
||||||
for a in self.plugin.accounts.keys():
|
for a in self.plugin.accounts.keys():
|
||||||
self.contacts[a] = {}
|
self.contacts[a] = {}
|
||||||
self.groups[a] = {}
|
self.groups[a] = {}
|
||||||
|
self.newly_added[a] = []
|
||||||
|
self.to_be_removed[a] = []
|
||||||
#(icon, name, type, jid, account, editable)
|
#(icon, name, type, jid, account, editable)
|
||||||
model = gtk.TreeStore(gtk.Image, str, str, str, str, gobject.TYPE_BOOLEAN)
|
model = gtk.TreeStore(gtk.Image, str, str, str, str, gobject.TYPE_BOOLEAN)
|
||||||
model.set_sort_func(1, self.compareIters)
|
model.set_sort_func(1, self.compareIters)
|
||||||
|
|
Loading…
Reference in New Issue