added config values for background_image and background_alpha

This commit is contained in:
Matt Rose 2020-09-24 16:24:54 -04:00
parent 501e6b3145
commit 415b7653dc
2 changed files with 17 additions and 1 deletions

View File

@ -250,6 +250,8 @@ DEFAULTS = {
'autoclean_groups' : True,
'http_proxy' : '',
'ignore_hosts' : ['localhost','127.0.0.0/8','*.local'],
'background_image' : '',
'background_alpha' : 0.0
},
},
'layouts': {

View File

@ -135,7 +135,14 @@ class Terminal(Gtk.VBox):
self.pending_on_vte_size_allocate = False
self.vte = Vte.Terminal()
self.background_image = GdkPixbuf.Pixbuf.new_from_file("/Users/mattrose/test.jpg")
self.background_image = None
if self.config['background_image'] != '':
try:
self.background_image = GdkPixbuf.Pixbuf.new_from_file(self.config['background_image'])
except Exception:
pass
self.background_alpha = self.config['background_alpha']
self.vte.set_allow_hyperlink(True)
self.vte._draw_data = None
if not hasattr(self.vte, "set_opacity") or \
@ -1128,6 +1135,11 @@ class Terminal(Gtk.VBox):
widget._draw_data = None
def background_draw(self, widget, cr):
if not self.background_image:
return(False)
print("bgcolor obj: %s" % self.bgcolor.alpha)
over = self.bgcolor
over.alpha = self.background_alpha
rect = self.vte.get_allocation()
xratio = float(rect.width) / float(self.background_image.get_width())
yratio = float(rect.height) / float(self.background_image.get_height())
@ -1135,6 +1147,8 @@ class Terminal(Gtk.VBox):
cr.scale(xratio,yratio)
Gdk.cairo_set_source_pixbuf(cr, self.background_image, 0, 0)
cr.paint()
Gdk.cairo_set_source_rgba(cr,over)
cr.paint()
cr.restore()
def on_draw(self, widget, context):