Only set background_image if background_type is 'image'
+ Fixed code duplication
This commit is contained in:
parent
62716872df
commit
25902fd73e
|
@ -140,18 +140,6 @@ 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 = None
|
|
||||||
if self.config['background_image'] != '':
|
|
||||||
try:
|
|
||||||
self.background_image = GdkPixbuf.Pixbuf.new_from_file(self.config['background_image'])
|
|
||||||
self.vte.set_clear_background(False)
|
|
||||||
self.vte.connect("draw",self.background_draw)
|
|
||||||
except Exception as e:
|
|
||||||
self.background_image = None
|
|
||||||
self.vte.set_clear_background(True)
|
|
||||||
err('error loading background image: %s, %s' % (type(e).__name__,e))
|
|
||||||
|
|
||||||
self.background_alpha = self.config['background_darkness']
|
|
||||||
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 \
|
||||||
|
@ -161,7 +149,12 @@ class Terminal(Gtk.VBox):
|
||||||
self.composite_support = True
|
self.composite_support = True
|
||||||
dbg('composite_support: %s' % self.composite_support)
|
dbg('composite_support: %s' % self.composite_support)
|
||||||
|
|
||||||
|
self.background_alpha = self.config['background_darkness']
|
||||||
|
if self.config['background_type'] == 'image' and self.config['background_image'] != '':
|
||||||
|
self.set_background_image(self.config['background_image'])
|
||||||
|
else:
|
||||||
|
self.background_image = None
|
||||||
|
|
||||||
self.vte.show()
|
self.vte.show()
|
||||||
self.update_url_matches()
|
self.update_url_matches()
|
||||||
|
|
||||||
|
@ -1135,7 +1128,7 @@ 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.config['background_type'] == 'image' or not self.background_image:
|
if self.background_image is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
rect = self.vte.get_allocation()
|
rect = self.vte.get_allocation()
|
||||||
|
|
Loading…
Reference in New Issue