Very rough preliminary css styling work, showing the general principles

This commit is contained in:
Stephen Boddy 2016-12-08 03:22:59 +01:00
parent d9c6c9c496
commit b2e81d8f38
3 changed files with 160 additions and 17 deletions

View File

@ -39,6 +39,8 @@ class Searchbar(Gtk.HBox):
self.config = Config()
self.get_style_context().add_class("terminator-terminal-searchbar")
# Search text
self.entry = Gtk.Entry()
self.entry.set_activates_default(True)

View File

@ -0,0 +1,110 @@
/*
Some basic playing copying out the GNOME-Terminal style tab headers.
Might want to have a seperate option for "shrinking" the tabs, by
nuking the padding/borders in the tabs.
*/
/*
GtkNotebook.header {
background-color: rgba(90%,20%,30%,1);
border: none;
}
.notebook.header {
background-color: rgba(90%,20%,30%,1);
border: none;
}
*/
.notebook tab.top { padding: 4px 6px 2px 6px; }
.notebook tab.top:active { padding-bottom: 3px; }
.notebook tab.bottom { padding: 2px 6px 4px 6px; }
.notebook tab.bottom:active { padding-top: 3px; }
.notebook tab.left { padding: 2px 4px 2px 6px; }
.notebook tab.left:active { padding-right: 5px; }
.notebook tab.right { padding: 2px 6px 2px 4px; }
.notebook tab.right:active { padding-left: 5px; }
/* give active tab a background, as it might be dragged across of others when reordering */
.notebook tab:active {
background-color: @bg_color;
}
.notebook.header {
border-width: 0; /* set below depending on position of tab bar */
border-color: shade (@bg_color, 0.82);
border-style: solid;
/* background-color: rgba(90%,20%,30%,1); */
background-color: @dark_bg_color;
}
/* Draw a border between tabs and content ... */
.notebook.header.top { border-bottom-width: 1px; }
.notebook.header.right { border-left-width: 1px; }
.notebook.header.left { border-right-width: 1px; }
.notebook.header.bottom { border-top-width: 1px; }
/* ... unless the content is in a frame (thus having a border itself */
.notebook.header.frame.top { border: none; }
.notebook.header.frame.right { border: none; }
.notebook.header.frame.right { border: none; }
.notebook.header.frame.bottom { border: none; }
.notebook tab.top {
background-color: shade(@bg_color, 0.7);
border-width: 1px 1px 0px 1px;
border-radius: 8px 8px 0px 0px;
border-image: none;
border-style: solid;
border-color: @dark_bg_color;
}
.notebook tab.top:active {
background-color: @bg_color;
border-image: none;
}
.notebook tab .button {
background-color: transparent;
padding: 1px;
}
.notebook tab.right {
border-image: -gtk-gradient (linear, right top, left top,
from (alpha (shade (@bg_color, 0.9), 0.0)),
to (shade (@bg_color, 0.9))) 1;
border-image-width: 1px 0;
}
.notebook tab.left {
border-image: -gtk-gradient (linear, left top, right top,
from (alpha (shade (@bg_color, 0.9), 0.0)),
to (shade (@bg_color, 0.9))) 1;
border-image-width: 1px 0;
}
.notebook tab.bottom {
border-image: -gtk-gradient (linear, left bottom, left top,
from (alpha (shade (@bg_color, 0.9), 0.0)),
to (shade (@bg_color, 0.9))) 1;
border-image-width: 0 1px;
}
/* Draw a focus ring around labels in tabs */
.notebook tab GtkLabel {
border: 1px solid transparent;
border-radius: 5px;
}
.notebook:focus tab GtkLabel.active-page {
border-color: @focus_color;
background-color: @focus_bg_color;
}
.notebook GtkDrawingArea {
background-color: shade (@bg_color, 1.02);
}

View File

@ -39,7 +39,7 @@ class Terminator(Borg):
groups = None
config = None
keybindings = None
style_provider = None
style_providers = None
last_focused_term = None
origcwd = None
@ -81,6 +81,8 @@ class Terminator(Borg):
if not self.keybindings:
self.keybindings = Keybindings()
self.keybindings.configure(self.config['keybindings'])
if not self.style_providers:
self.style_providers = []
if not self.doing_layout:
self.doing_layout = False
if not self.pid_cwd:
@ -368,30 +370,59 @@ class Terminator(Borg):
def reconfigure(self):
"""Update configuration for the whole application"""
if self.style_provider is not None:
if self.style_providers != []:
for style_provider in self.style_providers:
Gtk.StyleContext.remove_provider_for_screen(
Gdk.Screen.get_default(),
self.style_provider)
style_provider)
self.style_providers = []
# Force the window background to be transparent for newer versions of
# GTK3. We then have to fix all the widget backgrounds because the
# widgets theming may not render it's own background.
css = """
.terminator-terminal-window {
background-color: rgba(0,0,0,0);
}
background-color: rgba(0,0,0,0); }
.notebook.header {
background-color: @bg_color; }
.pane-separator {
background-color: @bg_color; }
.terminator-terminal-searchbar {
background-color: @bg_color; }
"""
style_provider = Gtk.CssProvider()
style_provider.load_from_data(css)
self.style_providers.append(style_provider)
if self.config['handle_size'] in xrange(0, 6):
css += """
# Attempt to load some theme specific stylistic tweaks for appearances
# Shamelessly cribbed from GNOME-Terminal
style_provider = Gtk.CssProvider()
style_provider.load_from_path('terminatorlib/terminator.css')
self.style_providers.append(style_provider)
# Size the GtkPaned splitter handle size and fix Adwaita dumb-ass
# oversized hover on handle.
if self.config['handle_size'] in xrange(0, 21):
css = """
GtkPaned {
-GtkPaned-handle-size: %s
}
-GtkPaned-handle-size: %s;
margin: 0 0 0 0;
padding: 0 0 0 0; }
""" % self.config['handle_size']
style_provider = Gtk.CssProvider()
style_provider.load_from_data(css)
self.style_providers.append(style_provider)
self.style_provider = Gtk.CssProvider()
self.style_provider.load_from_data(css)
# Apply the providers, incrementing priority so they don't cancel out
# each other
for idx in xrange(0, len(self.style_providers)):
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
self.style_provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
self.style_providers[idx],
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION+idx)
# Cause all the terminals to reconfigure
for terminal in self.terminals: