#!/usr/bin/python

import gtk, gobject
w = gtk.Window()

def MyButton (*args, **kwargs):
    layout = gtk.Layout()
    button = gtk.Button(*args, **kwargs)
    button.set_relief(gtk.RELIEF_NONE)
    button.props.xalign = 0
    layout.put(button, 0, 0)
    
    def button_size_allocate(button, balloc):
        arrow_button = gtk.Button()
        arrow_button.set_relief(gtk.RELIEF_NONE)
        arrow_button.add(gtk.Arrow(gtk.ARROW_DOWN, gtk.SHADOW_NONE))
        layout.put(arrow_button,0,0)
        layout.show_all()
        
        def arrow_button_size_allocate(arrow_button, aballoc):
            arrow_button.set_size_request(aballoc.width, balloc.height)
            button.set_size_request(balloc.width+aballoc.width, balloc.height)
            layout.move(arrow_button, balloc.width, 0)
            arrow_button.disconnect(abhid)
        abhid = arrow_button.connect("size-allocate", arrow_button_size_allocate)
        button.disconnect(bhid)
    bhid = button.connect("size-allocate", button_size_allocate)
    return layout

b = MyButton(stock=gtk.STOCK_NEW)

w.add(b)
w.connect("delete-event", gtk.main_quit)
w.set_default_size(200,100)
w.set_border_width(10)
w.show_all()
gtk.main()
