- self.set_flags(self.flags() | gtk.REALIZED)
- alloc = self.allocation
- self.window = gtk.gdk.Window(self.get_parent_window(),
- width=alloc.width, height=alloc.height,
- window_type = gtk.gdk.WINDOW_CHILD,
- wclass = gtk.gdk.INPUT_OUTPUT,
- event_mask = self.get_events() | gtk.gdk.EXPOSURE_MASK
- )
- self.window.set_user_data(self)
- self.style.attach(self.window)
- self.style.set_background(self.window, gtk.STATE_NORMAL)
- self.window.move_resize(*alloc)
-
- def do_unrealize(self):
- self.window.set_user_data(None)
-
- def do_size_request(self, req):
- w, h = self.get_osize()
- req.width, req.height = max(min(w, 4096), 0), max(min(h, 4096), 0)
+ alloc = self.get_allocation()
+ attr = gdk.WindowAttr()
+ attr.window_type = gdk.WindowType.CHILD
+ attr.x = alloc.x
+ attr.y = alloc.y
+ attr.width = alloc.width
+ attr.height = alloc.height
+ attr.visual = self.get_visual()
+ attr.event_mask = self.get_events() | gdk.EventMask.EXPOSURE_MASK
+ a = gdk.WindowAttributesType
+ wnd = gdk.Window(self.get_parent_window(), attr, a.X | a.Y | a.VISUAL)
+ wnd.set_background_pattern(None)
+ self.set_window(wnd)
+ self.register_window(wnd)
+ self.set_realized(True)
+
+ # XXX: Why don't these actually get called?
+ def get_preferred_width(self):
+ return 0, max(min(self.get_osize()[0], 4096), 0)
+ def get_preferred_height(self):
+ return 0, max(min(self.get_osize()[1], 4096), 0)