trayicon now displays are status if we have no messages
This commit is contained in:
parent
e88aabcb98
commit
d72a25788a
|
@ -71,8 +71,7 @@ class Systray:
|
||||||
if not list in self.jids:
|
if not list in self.jids:
|
||||||
self.jids.append(list)
|
self.jids.append(list)
|
||||||
self.set_img()
|
self.set_img()
|
||||||
#we look for the number of unread messages
|
#we append to the number of unread messages
|
||||||
#in roster
|
|
||||||
nb = self.plugin.roster.nb_unread
|
nb = self.plugin.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
#in chat / groupchat windows
|
#in chat / groupchat windows
|
||||||
|
@ -81,19 +80,15 @@ class Systray:
|
||||||
for jid in jids:
|
for jid in jids:
|
||||||
if jid != 'tabbed':
|
if jid != 'tabbed':
|
||||||
nb += jids[jid].nb_unread[jid]
|
nb += jids[jid].nb_unread[jid]
|
||||||
if nb > 1:
|
|
||||||
label = _('Gajim - %s unread messages') % nb
|
self.set_tooltip(nb) # update the tooltip
|
||||||
else:
|
|
||||||
label = _('Gajim - 1 unread message')
|
|
||||||
self.tip.set_tip(self.t, label)
|
|
||||||
|
|
||||||
def remove_jid(self, jid, account):
|
def remove_jid(self, jid, account):
|
||||||
list = [account, jid]
|
list = [account, jid]
|
||||||
if list in self.jids:
|
if list in self.jids:
|
||||||
self.jids.remove(list)
|
self.jids.remove(list)
|
||||||
self.set_img()
|
self.set_img()
|
||||||
#we look for the number of unread messages
|
#we remove from the number of unread messages
|
||||||
#in roster
|
|
||||||
nb = self.plugin.roster.nb_unread
|
nb = self.plugin.roster.nb_unread
|
||||||
for acct in gajim.connections:
|
for acct in gajim.connections:
|
||||||
#in chat / groupchat windows
|
#in chat / groupchat windows
|
||||||
|
@ -101,17 +96,13 @@ class Systray:
|
||||||
for jid in self.plugin.windows[acct][kind]:
|
for jid in self.plugin.windows[acct][kind]:
|
||||||
if jid != 'tabbed':
|
if jid != 'tabbed':
|
||||||
nb += self.plugin.windows[acct][kind][jid].nb_unread[jid]
|
nb += self.plugin.windows[acct][kind][jid].nb_unread[jid]
|
||||||
if nb > 1:
|
|
||||||
label = _('Gajim - %s unread messages') % nb
|
self.set_tooltip(nb) # update the tooltip
|
||||||
elif nb == 1:
|
|
||||||
label = _('Gajim - 1 unread message')
|
|
||||||
else:
|
|
||||||
label = 'Gajim'
|
|
||||||
self.tip.set_tip(self.t, label)
|
|
||||||
|
|
||||||
def set_status(self, status):
|
def set_status(self, status):
|
||||||
self.status = status
|
self.status = status
|
||||||
self.set_img()
|
self.set_img()
|
||||||
|
self.set_tooltip()
|
||||||
|
|
||||||
def start_chat(self, widget, account, jid):
|
def start_chat(self, widget, account, jid):
|
||||||
if self.plugin.windows[account]['chats'].has_key(jid):
|
if self.plugin.windows[account]['chats'].has_key(jid):
|
||||||
|
@ -284,13 +275,25 @@ class Systray:
|
||||||
self.t = trayicon.TrayIcon('Gajim')
|
self.t = trayicon.TrayIcon('Gajim')
|
||||||
eb = gtk.EventBox()
|
eb = gtk.EventBox()
|
||||||
eb.connect('button-press-event', self.on_clicked)
|
eb.connect('button-press-event', self.on_clicked)
|
||||||
self.tip.set_tip(self.t, 'Gajim')
|
self.set_tooltip()
|
||||||
self.img_tray = gtk.Image()
|
self.img_tray = gtk.Image()
|
||||||
eb.add(self.img_tray)
|
eb.add(self.img_tray)
|
||||||
self.t.add(eb)
|
self.t.add(eb)
|
||||||
self.set_img()
|
self.set_img()
|
||||||
self.t.show_all()
|
self.t.show_all()
|
||||||
|
|
||||||
|
def set_tooltip(self, unread_messages_no=None):
|
||||||
|
# we look for the number of unread messages
|
||||||
|
# and we set the appropriate tooltip
|
||||||
|
if unread_messages_no > 1:
|
||||||
|
text = _('Gajim - %s unread messages') % unread_messages_no
|
||||||
|
elif unread_messages_no == 1:
|
||||||
|
text = _('Gajim - 1 unread message')
|
||||||
|
else: # it's None or 0
|
||||||
|
uf_show = helpers.get_uf_show(self.status)
|
||||||
|
text = _('Gajim - %s') % uf_show
|
||||||
|
self.tip.set_tip(self.t, text)
|
||||||
|
|
||||||
def hide_icon(self):
|
def hide_icon(self):
|
||||||
if self.t:
|
if self.t:
|
||||||
self.t.destroy()
|
self.t.destroy()
|
||||||
|
|
Loading…
Reference in New Issue