1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pynotify
import gtk
import cPickle as pickle
import sys
import gettext
gettext.install('gnome-bts-applet', 'po/gen', unicode=True)
import BtsApplet
def quit(*_):
gtk.main_quit()
sys.exit(0)
def main():
old, new, delta, icon_filename = [pickle.load(sys.stdin) for x in range(4)]
pynotify.init('BTS Applet')
def format_commas(it):
if len(it) <= 1:
return ', '.join(it)
else:
return _("%s and %s") % (', '.join(it[:-1]), it[-1])
bug_number = new['bug_number']
title = _("Bug #%d's %s changed") % (bug_number, format_commas(delta))
lines = []
if len(delta) <= 2 and 'summary' not in delta:
lines.append('<span stretch="ultracondensed"><i>%s:</i> %s</span>' % (_("Summary"), new['summary']))
lines.append('')
if len(delta) == 1:
item = delta[0]
lines.append('%s → <b>%s</b>' % (old[item], new[item]))
lines.append('')
else:
for item in delta:
lines.append('<i>%s</i>: %s → <b>%s</b>' % (item.capitalize(), old[item], new[item]))
lines.append('')
n = pynotify.Notification(title, '\n'.join(lines), None)
icon = gtk.gdk.pixbuf_new_from_file_at_size(icon_filename, 32, 32)
n.set_icon_from_pixbuf(icon)
n.set_urgency(pynotify.URGENCY_LOW)
n.add_action('info', _("More info"), lambda *_: BtsApplet.open_url('http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%d' % bug_number))
n.add_action('close', _("Hide"), lambda *_: True)
n.connect('closed', quit)
n.show()
gtk.main()
if __name__ == "__main__":
main()
|