Show offline users only if showOffline=1

This commit is contained in:
Yann Leboulanger 2003-10-22 23:05:36 +00:00
parent ef7952e396
commit e470e520f9
2 changed files with 36 additions and 25 deletions

View File

@ -59,6 +59,10 @@ class GajimCore:
show = 'online' show = 'online'
self.hub.sendPlugin('NOTIFY', \ self.hub.sendPlugin('NOTIFY', \
(prs.getFrom().getBasic(), show, prs.getStatus())) (prs.getFrom().getBasic(), show, prs.getStatus()))
if type == 'unavailable':
self.hub.sendPlugin('NOTIFY', \
(prs.getFrom().getBasic(), 'offline', prs.getStatus()))
# END presenceCB # END presenceCB
def disconnectedCB(self, con): def disconnectedCB(self, con):

View File

@ -104,46 +104,52 @@ class roster:
return self.tree.render_icon(stock, size = gtk.ICON_SIZE_MENU, detail = None) return self.tree.render_icon(stock, size = gtk.ICON_SIZE_MENU, detail = None)
def mkl_group(self): def mkl_group(self):
self.l_group = [] """ {name:iter} """
self.l_group = {}
for u in self.l_contact: for u in self.l_contact:
if u.group in self.l_group: if not self.l_group.has_key(u.group):
pass iterG = self.treestore.append(None, (self.pixbufs['online'], u.group, 'group'))
else: self.l_group[u.group]=iterG
self.l_group.append(u.group)
def mkroster(self): def mkroster(self, tab):
self.treestore.clear()
for g in self.l_group:
iter_g = self.treestore.append(None, (self.pixbufs['online'], g, 'group'))
for c in self.l_contact:
if c.group == g:
# print c.status
self.treestore.append(iter_g, (self.pixbufs[c.show], c.name, c.show))
# if c.status == 'Online':
# self.treestore.append(iter_g, (self.pixbufs['Online'], c.name, 'Online'))
# elif c.status == None:
# self.treestore.append(iter_g, (self.pixbufs['away'], c.name, 'away'))
def mkroster2(self, tab):
self.l_contact = [] self.l_contact = []
for jid in tab.keys(): for jid in tab.keys():
user1 = user(jid, 'general', tab[jid]["Show"], tab[jid]["Status"]) user1 = user(jid, 'general', tab[jid]["Show"], tab[jid]["Status"])
self.l_contact.append(user1) self.l_contact.append(user1)
self.treestore.clear()
self.mkl_group() self.mkl_group()
self.mkroster() for g in self.l_group.keys():
self.tree.collapse_row((0,3)) for c in self.l_contact:
if c.group == g:
if c.show != 'offline' or self.showOffline:
self.treestore.append(self.l_group[g], (self.pixbufs[c.show], c.name, c.show))
def update_iter(self, widget, path, iter, data): def update_iter(self, widget, path, iter, data):
val = self.treestore.get_value(iter, 1) val = self.treestore.get_value(iter, 1)
if val == data[0]: if val == data[0]:
self.treestore.set_value(iter, 0, self.pixbufs[data[1]]) if data[1] == 'offline':
self.treestore.remove(iter)
if not self.showOffline:
self.found=1
else:
self.treestore.set_value(iter, 0, self.pixbufs[data[1]])
self.found=1
return 1
return 0
def chg_status(self, jid, show, status): def chg_status(self, jid, show, status):
for u in self.l_contact: for u in self.l_contact:
if u.name == jid: if u.name == jid:
self.found=0
self.treestore.foreach(self.update_iter, (jid, show))
if self.found==0:
if not self.l_group.has_key(u.group):
iterG = self.treestore.append(None, (self.pixbufs['online'], u.group, 'group'))
self.l_group[u.group]=iterG
self.treestore.append(self.l_group[u.group], (self.pixbufs[show], u.name, show))
u.show = show u.show = show
u.status = status u.status = status
self.treestore.foreach(self.update_iter, (jid, show)) return 1
def mk_menu_c(self, event): def mk_menu_c(self, event):
self.menu_c = gtk.Menu() self.menu_c = gtk.Menu()
@ -219,6 +225,7 @@ class roster:
self.optionmenu = self.xml.get_widget('optionmenu') self.optionmenu = self.xml.get_widget('optionmenu')
self.optionmenu.set_history(6) self.optionmenu.set_history(6)
self.tab_messages = {} self.tab_messages = {}
self.showOffline=1
#colonnes #colonnes
self.col = gtk.TreeViewColumn() self.col = gtk.TreeViewColumn()
@ -246,7 +253,7 @@ class plugin:
ev = self.queueIN.get() ev = self.queueIN.get()
print ev print ev
if ev[0] == 'ROSTER': if ev[0] == 'ROSTER':
self.r.mkroster2(ev[1]) self.r.mkroster(ev[1])
elif ev[0] == 'NOTIFY': elif ev[0] == 'NOTIFY':
self.r.chg_status(ev[1][0], ev[1][1], ev[1][2]) self.r.chg_status(ev[1][0], ev[1][1], ev[1][2])
elif ev[0] == 'MSG': elif ev[0] == 'MSG':
@ -267,4 +274,4 @@ class plugin:
if __name__ == "__main__": if __name__ == "__main__":
plugin(None, None) plugin(None, None)
print "plugin gui loaded" print "plugin gtkgui loaded"