6 Oct 2004 lgs   » (Master)

GMail Applet

Some weeks ago I got a gmail account and I realized that they don't have pop3/imap support so you need to log into the webmail to see if you have something new. I understand they want you to see the ads but that's too much for a email compulsive user as me.

So I hacked up a 50 lines gnome systray icon to alert me when you have mail:

#!/bin/env python

import pygtk pygtk.require('2.0') import gtk import gnome import eggtrayicon

import libgmail

ACCOUNT = 'your.name@gmail.com' PASSWORD = 'yourpassword' REFRESH_INTERVAL = 1000 * 60 * 5 # this is in milliseconds (5 minutes)

class GMailApplet(object): def __init__(self): gnome.program_init('gmail-applet', '0.0.1') self.applet_window = eggtrayicon.create_window('gmail-applet') self.applet_window.connect('destroy', gtk.main_quit)

self.event_box = gtk.EventBox() self.image_widget = gtk.Image() self.image_widget.set_from_file('gmail.png') self.event_box.add(self.image_widget)

self.image_widget.show() self.applet_window.add(self.event_box) self.applet_window.show_all()

self.account = libgmail.GmailAccount(ACCOUNT, PASSWORD) self.account.login() gtk.timeout_add(REFRESH_INTERVAL, self.refresh_handler) def run(self): gtk.main()

def refresh_handler(self): # handle gtk events while gtk.events_pending(): gtk.main_iteration(gtk.FALSE)

unreadMsgCount = self.account.getUnreadMsgCount()

if unreadMsgCount > 0: self.image_widget.set_from_file('gmail_notice.png') else: self.image_widget.set_from_file('gmail.png') return gtk.TRUE if __name__ == '__main__': g = GMailApplet() g.run()

You need libgmail and eggtrayicon.

There are some screenshots

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!