background_draw: organize code

This commit is contained in:
Vulcalien 2021-12-09 23:01:58 +01:00
parent 5a6237cc47
commit 122b0fe3ae
1 changed files with 8 additions and 4 deletions

View File

@ -1131,15 +1131,19 @@ class Terminal(Gtk.VBox):
if self.background_image is None: if self.background_image is None:
return False return False
# save cairo context
cr.save()
# draw background image
rect = self.vte.get_allocation() rect = self.vte.get_allocation()
xratio = float(rect.width) / float(self.background_image.get_width()) xratio = float(rect.width) / float(self.background_image.get_width())
yratio = float(rect.height) / float(self.background_image.get_height()) yratio = float(rect.height) / float(self.background_image.get_height())
cr.save()
cr.scale(xratio, yratio) cr.scale(xratio, yratio)
cr.set_source_surface(self.background_image) cr.set_source_surface(self.background_image)
cr.paint() cr.paint()
# draw transparent monochrome layer
Gdk.cairo_set_source_rgba(cr, self.bgcolor) Gdk.cairo_set_source_rgba(cr, self.bgcolor)
cr.paint() cr.paint()
# restore cairo context
cr.restore() cr.restore()
def on_draw(self, widget, context): def on_draw(self, widget, context):