Here is the code that I have so far to define the icon:
icon_bg = gtk.gdk.pixbuf_new_from_file('gmail.png')
w, h = icon_bg.get_width(), icon_bg.get_height()
cmap = gtk.gdk.Colormap(gtk.gdk.visual_get_system(), False)
drawable = gtk.gdk.Pixmap(None, w, h, 24)
drawable.set_colormap = cmap
gc = drawable.new_gc()
drawable.draw_pixbuf(gc, icon_bg, 0, 0, 0, 0, w, h)
drawn_icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, w, h)
drawn_icon.get_from_drawable(drawable, cmap, 0, 0, 0, 0, w, h)
icon = gtk.status_icon_new_from_pixbuf(drawn_icon)
This works to get the png into the icon, but falls short in two areas. First, transparency is not working. If I use a 22x22 png with transparent background and the image centered, I end up with sections of other active icons showing up inside of mine, like this:
http://i237.photobucket.com/albums/ff311/Raugturi/22x22_image_with_transparency.png
The icon it choose to steal from is somewhat random. Sometimes it's part of the dropbox icon, others the NetworkManager Applet.
If I instead use this code:
icon_bg = gtk.gdk.pixbuf_new_from_file('gmail.png')
w, h = icon_bg.get_width(), icon_bg.get_height()
cmap = gtk.gdk.Colormap(gtk.gdk.visual_get_system(), False)
drawable = gtk.gdk.Pixmap(None, w, h, 24)
drawable.set_colormap = cmap
gc = drawable.new_gc()
drawable.draw_pixbuf(gc, icon_bg, 0, 0, 0, 0, w, h)
drawn_icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, 22, 22)
drawn_icon.get_from_drawable(drawable, cmap, 0, 0, 3, 6, w, h)
icon = gtk.status_icon_new_from_pixbuf(drawn_icon)
And an image that is only 16x11 with the transparent edges removed, what I end up with is this:
Same URL but file is 16x11_image_positioned_in_middle.png
So how do I end up with a transparent block like the 1st one that doesn't pull in stuff from other icons?
As for the second problem, I need the ability to write on the image before converting it to the icon. I tried using draw_glyphs and it told me I should be using Pango layout/context instead. Unfortunately all the Pango tutorials I could find deal with actual windows, not the status icon. Is there a good tutorial out there for Pango that would apply to this issue (and also maybe have at least some explanation of how to tell it what font to use as all of them that I found seem to lack this and it won't write anything without it).
Note: Sorry for the lack of actual images and only one working link, apparently this is a spam prevention feature due to my lack of reputation.