#!/usr/bin/python

import os
import sys
 
import gtk
from gtk import gdk
 
# the secret sauce is to get the "window id" out of $XSCREENSAVER_WINDOW

class ScreenSaverWindow(gtk.Window):
 
    def __init__(self):
        gtk.Window.__init__(self)
        pass
 
    def do_realize(self):
        if self.flags() & gtk.REALIZED:
            return
       
        window_xid = os.getenv ("XSCREENSAVER_WINDOW")
 
        if window_xid != None:
            end_index = window_xid.find(" ")
            if end_index > 0:
                window_xid = int(window_xid[:end_index], 0)
            else:
                window_xid = int(window_xid, 0)
 
            if window_xid != 0:
                self.window = gdk.window_foreign_new (window_xid)
 
                if self.window != None:
                    self.window.set_events (gdk.EXPOSURE_MASK | gdk.STRUCTURE_MASK)
 
        if self.window == None:
            self.window = gdk.Window(None, 1024, 768, gdk.WINDOW_TOPLEVEL,
                                     (gdk.EXPOSURE_MASK | gdk.STRUCTURE_MASK),
                                     gdk.INPUT_OUTPUT)
 
        if self.window != None:
            self.window.add_filter(lambda *args: self.filter_event(args))
            self.set_flags(self.flags() | gtk.REALIZED)
 
window = ScreenSaverWindow()
window.set_title('Floaters')
window.connect('delete-event', gtk.main_quit)
#window.set_default_size(1024, 768)
window.realize()
 
window.modify_bg(gtk.STATE_NORMAL, gdk.color_parse("black"))
 
label = gtk.Label()
label.set_markup("<span foreground=\"white\"><big>Hi, how'ya doin'?</big></span>")
label.show()
window.add(label)
 
window.show()
 
gtk.main()


