From f02f38389c8fd94136a3fafc22d7066b4ce652e2 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sun, 11 Dec 2016 05:46:02 +0100 Subject: [PATCH] Fixes the transparent scrollbars for Ambiance. --- terminatorlib/terminal.py | 10 +++++++ terminatorlib/terminator.py | 28 ++++++++++++++++++- .../Ambiance/gtk-3.0/apps/terminator.css | 6 ++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 terminatorlib/themes/Ambiance/gtk-3.0/apps/terminator.css diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 0ee4851d..fa8d7a1b 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -734,6 +734,16 @@ class Terminal(Gtk.VBox): else: self.vte.set_colors(self.fgcolor_inactive, self.bgcolor, self.palette_inactive) + profiles = self.config.base.profiles + terminal_box_style_context = self.terminalbox.get_style_context() + for profile in profiles.keys(): + munged_profile = "terminator-profile-%s" % ( + "".join([c if c.isalnum() else "-" for c in profile])) + if terminal_box_style_context.has_class(munged_profile): + terminal_box_style_context.remove_class(munged_profile) + munged_profile = "".join([c if c.isalnum() else "-" for c in self.get_profile()]) + css_class_name = "terminator-profile-%s" % (munged_profile) + terminal_box_style_context.add_class(css_class_name) self.set_cursor_color() self.vte.set_cursor_shape(getattr(Vte.CursorShape, self.config['cursor_shape'].upper())); diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 2fc045a3..a728c0a2 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -5,7 +5,9 @@ import copy import os -from gi.repository import Gtk, Gdk +import gi +gi.require_version('Vte', '2.91') +from gi.repository import Gtk, Gdk, Vte import borg from borg import Borg @@ -404,6 +406,30 @@ class Terminator(Borg): background-color: transparent; } """ + # Add per profile snippets for setting the background of the HBox + template = """ + .terminator-profile-%s { + background-color: alpha(%s, %s); } + """ + profiles = self.config.base.profiles + for profile in profiles.keys(): + if profiles[profile]['use_theme_colors']: + # FIXME: This dummy vte has different system colors to the real ones + bgcolor = Vte.Terminal().get_style_context().get_background_color(Gtk.StateType.NORMAL) + bgcolor = "#{0:02x}{1:02x}{2:02x}".format(int(bgcolor.red * 255), + int(bgcolor.green * 255), + int(bgcolor.blue * 255)) + else: + bgcolor = Gdk.RGBA() + bgcolor = profiles[profile]['background_color'] + if profiles[profile]['background_type'] == 'transparent': + bgalpha = profiles[profile]['background_darkness'] + else: + bgalpha = "1" + + munged_profile = "".join([c if c.isalnum() else "-" for c in profile]) + css += template % (munged_profile, bgcolor, bgalpha) + style_provider = Gtk.CssProvider() style_provider.load_from_data(css) self.style_providers.append(style_provider) diff --git a/terminatorlib/themes/Ambiance/gtk-3.0/apps/terminator.css b/terminatorlib/themes/Ambiance/gtk-3.0/apps/terminator.css new file mode 100644 index 00000000..36520d33 --- /dev/null +++ b/terminatorlib/themes/Ambiance/gtk-3.0/apps/terminator.css @@ -0,0 +1,6 @@ +.terminator-terminal-window .scrollbar.dragging:not(.slider), +.terminator-terminal-window .scrollbar:hover:not(.slider), +.terminator-terminal-window .scrollbar:not(.slider) { + background-color: alpha(@dark_bg_color,0); +} +