diff options
Diffstat (limited to 'screenbuil.py')
-rw-r--r-- | screenbuil.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/screenbuil.py b/screenbuil.py index 37121ce..59eaa0e 100644 --- a/screenbuil.py +++ b/screenbuil.py @@ -20,42 +20,42 @@ import gi from gi.repository import Gtk +from gi.repository import Gdk import theme class Screen(Gtk.DrawingArea): + def __init__(self): + Gtk.DrawingArea.__init__(self) - self.gc = None # initialized in realize-event handler - self.width = 0 # updated in size-allocate handler - self.height = 0 # idem + self.bgpixbuf = None self.fgpixbuf = None - # FIXME: Re escribir - ''' - self.connect('size-allocate', self.on_size_allocate) - self.connect('expose-event', self.on_expose_event) - self.connect('realize', self.on_realize) - def on_realize(self, widget): - self.gc = widget.window.new_gc() - - def on_size_allocate(self, widget, allocation): - self.height = self.width = min(allocation.width, allocation.height) - - def on_expose_event(self, widget, event): + def do_draw(self, context): # This is where the drawing takes place + + allocation = self.get_allocation() + value = min(allocation.width, allocation.height) + if self.bgpixbuf: pixbuf = self.bgpixbuf - if pixbuf.get_width != self.width: - pixbuf = theme.scale(pixbuf, self.width) - widget.window.draw_pixbuf(self.gc, pixbuf, 0, 0, 0, 0, -1, -1, 0, 0) - + + if pixbuf.get_width != value: + pixbuf = theme.scale(pixbuf, value) + + Gdk.cairo_set_source_pixbuf(context, pixbuf, 0, 0) + context.paint() + if self.fgpixbuf: pixbuf = self.fgpixbuf - if pixbuf.get_width != self.width: - pixbuf = theme.scale(pixbuf, self.width) - widget.window.draw_pixbuf(self.gc, pixbuf, 0, 0, 0, 0, -1, -1, 0, 0) - + + if pixbuf.get_width != value: + pixbuf = theme.scale(pixbuf, value) + + Gdk.cairo_set_source_pixbuf(context, pixbuf, 0, 0) + context.paint() + def draw(self): - self.queue_draw()''' + self.queue_draw() |