added config values for background_image and background_alpha
This commit is contained in:
parent
501e6b3145
commit
415b7653dc
|
@ -250,6 +250,8 @@ DEFAULTS = {
|
||||||
'autoclean_groups' : True,
|
'autoclean_groups' : True,
|
||||||
'http_proxy' : '',
|
'http_proxy' : '',
|
||||||
'ignore_hosts' : ['localhost','127.0.0.0/8','*.local'],
|
'ignore_hosts' : ['localhost','127.0.0.0/8','*.local'],
|
||||||
|
'background_image' : '',
|
||||||
|
'background_alpha' : 0.0
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'layouts': {
|
'layouts': {
|
||||||
|
|
|
@ -135,7 +135,14 @@ class Terminal(Gtk.VBox):
|
||||||
self.pending_on_vte_size_allocate = False
|
self.pending_on_vte_size_allocate = False
|
||||||
|
|
||||||
self.vte = Vte.Terminal()
|
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.set_allow_hyperlink(True)
|
||||||
self.vte._draw_data = None
|
self.vte._draw_data = None
|
||||||
if not hasattr(self.vte, "set_opacity") or \
|
if not hasattr(self.vte, "set_opacity") or \
|
||||||
|
@ -1128,6 +1135,11 @@ class Terminal(Gtk.VBox):
|
||||||
widget._draw_data = None
|
widget._draw_data = None
|
||||||
|
|
||||||
def background_draw(self, widget, cr):
|
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()
|
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())
|
||||||
|
@ -1135,6 +1147,8 @@ class Terminal(Gtk.VBox):
|
||||||
cr.scale(xratio,yratio)
|
cr.scale(xratio,yratio)
|
||||||
Gdk.cairo_set_source_pixbuf(cr, self.background_image, 0, 0)
|
Gdk.cairo_set_source_pixbuf(cr, self.background_image, 0, 0)
|
||||||
cr.paint()
|
cr.paint()
|
||||||
|
Gdk.cairo_set_source_rgba(cr,over)
|
||||||
|
cr.paint()
|
||||||
cr.restore()
|
cr.restore()
|
||||||
|
|
||||||
def on_draw(self, widget, context):
|
def on_draw(self, widget, context):
|
||||||
|
|
Loading…
Reference in New Issue