#
#
# patch "scribbler.py"
#  from [c82d3a748cfcf7c6256f82dbc7198dfb54867824]
#    to [b12f8e43981b46662740e795a55743d8c2a9728b]
#
============================================================
--- scribbler.py	c82d3a748cfcf7c6256f82dbc7198dfb54867824
+++ scribbler.py	b12f8e43981b46662740e795a55743d8c2a9728b
@@ -1,6 +1,7 @@ import gobject
 #!/usr/bin/env python
 
 import gobject
+import cairo
 import math
 import gtk
 import sys
@@ -9,22 +10,22 @@ def ScribblerFactory(scribble_function):
 def ScribblerFactory(scribble_function):
 	class Scribbler(gobject.GObjectMeta):
 		def __new__(cls, name, bases, dict):
-			def expose_handler(self, widget, event):
+			def expose_handler(widget, event):
 				context = widget.window.cairo_create()
 				context.rectangle(event.area.x, event.area.y, event.area.width, event.area.height)
 				context.clip()
-				scribble_function(context, self.get_allocation())
+				scribble_function(widget, context, widget.get_allocation())
 				return False
 
 			def our_init(self, *args, **kwargs):
 				super(self.__class__, self).__init__(*args, **kwargs)
-				self.connect_after("expose-event", lambda w, e: expose_handler(self, w, e))
+				self.connect_after("expose-event", expose_handler)
 
 			dict['__init__']  = our_init
 			return type.__new__(cls, name, bases, dict)
 	return Scribbler
 
-def draw_circle(context, allocation):
+def draw_circle(widget, context, allocation):
 	x = allocation.x + allocation.width / 2
 	y = allocation.y + allocation.height / 2
 	radius = min(allocation.width / 2, allocation.height / 2) - 5
@@ -32,6 +33,29 @@ def draw_circle(context, allocation):
 	context.set_source_rgb(0, 0, 0)
 	context.stroke()
 
+def draw_flagamo(widget, context, allocation):
+	context.set_source_rgb(1, 0, 0)
+	context.set_line_width(5)
+	context.rectangle(allocation.x + 5, allocation.y+ 5, allocation.width - 10, allocation.height - 10)
+	context.move_to(allocation.x, allocation.y)
+	context.line_to(allocation.x+allocation.width, allocation.y+allocation.height)
+	context.move_to(allocation.x, allocation.y+allocation.height)
+	context.line_to(allocation.x+allocation.width, allocation.y)
+	context.stroke()
+
+def draw_brand(widget, context, allocation):
+	context.set_source_rgba(0.5, 0.5, 1, 0.5)
+	context.select_font_face("Serif", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
+	context.set_font_size(32)
+	brand = '<branded by angry goats>'
+	xb, yb, fw, fh = context.text_extents(brand)[:4]
+	context.move_to(allocation.x + ((allocation.width - fw) / 2 - xb), 
+			allocation.y + ((allocation.height - fh) / 2 - yb))
+	context.show_text(brand)
+
+class BoxedTable(gtk.Table):
+	__metaclass__ = ScribblerFactory(draw_flagamo)
+	
 class WindowCircle(gtk.Window):
 	__metaclass__ = ScribblerFactory(draw_circle)
 
@@ -41,11 +65,14 @@ class LabelCircle(gtk.Label):
 class LabelCircle(gtk.Label):
 	__metaclass__ = ScribblerFactory(draw_circle)
 
+class BrandedWindow(gtk.Window):
+	__metaclass__ = ScribblerFactory(draw_brand)
+
 if __name__ == '__main__':
-	window = WindowCircle()
-	vbox = gtk.VBox()
-	vbox.add(ButtonCircle("This is a Button."))
-	vbox.add(LabelCircle("This is a label."))
+	window = BrandedWindow()
+	vbox = BoxedTable(2, 2)
+	for i in xrange(4):
+		vbox.attach(ButtonCircle("Button %d" % i), (i%2), (i%2)+1, (i/2), (i/2)+1)
 	window.add(vbox)
 	window.show_all()
 	gtk.main()
