-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #239, support theme specific CSS
- Loading branch information
Showing
14 changed files
with
316 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* GTK 3.20 */ | ||
scrollbar { | ||
background: $TERMINAL_BG; | ||
opacity: $TERMINAL_OPACITY; | ||
} | ||
/* GTK 3.18 */ | ||
.scrollbar:not(.slider) { | ||
background: $TERMINAL_BG; | ||
opacity: $TERMINAL_OPACITY; | ||
border-left: 0px; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.scrollbar:not(.slider) { | ||
background: $TERMINAL_BG; | ||
opacity: $TERMINAL_OPACITY; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* GTK 3.20 */ | ||
scrollbar { | ||
background: $TERMINAL_BG; | ||
opacity: $TERMINAL_OPACITY; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** Ambiance specific CSS to fix Ubuntu problems so the rest of us can have nice things **/ | ||
|
||
/* Fix Ubuntu Popover label borders, see #217 */ | ||
GtkBox > .label.separator { | ||
border: 0px; | ||
color: @theme_fg_color; | ||
opacity: 0.4; | ||
} | ||
|
||
/* Add background to pane-separator */ | ||
.pane-separator { | ||
background-color: @theme_bg_color; | ||
} | ||
|
||
/* Attempt to improve scrollbars */ | ||
.terminix-terminal-scrollbar:hover:not(.slider), | ||
.terminix-terminal-scrollbar.dragging:not(.slider) { | ||
background-color: alpha(@scrollbar_track_color, 0.4); | ||
} | ||
|
||
/* Since .hovering class is not working here, we always use the same radius */ | ||
.terminix-terminal-scrollbar.slider.hovering, | ||
.terminix-terminal-scrollbar.slider.dragging { | ||
/*border-radius: 1px;*/ | ||
border-left: 0px; | ||
} | ||
|
||
.terminix-terminal-scrollbar.vertical:hover:dir(ltr), | ||
.terminix-terminal-scrollbar.vertical.dragging:dir(ltr) { | ||
margin-left: 0px; | ||
} | ||
|
||
.terminix-terminal-scrollbar.vertical:hover:dir(rtl), | ||
.terminix-terminal-scrollbar.vertical.dragging:dir(rtl) { | ||
margin-right: 0px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.scrollbar:not(.slider) { | ||
background: $TERMINAL_BG; | ||
opacity: $TERMINAL_OPACITY; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not | ||
* distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
module gx.gtk.resource; | ||
|
||
import std.array; | ||
import std.conv; | ||
import std.experimental.logger; | ||
import std.file; | ||
import std.format; | ||
import std.path; | ||
|
||
import gdk.Screen; | ||
|
||
import glib.Bytes; | ||
import glib.GException; | ||
import glib.Util; | ||
|
||
import gio.Resource; | ||
|
||
import gtk.CssProvider; | ||
import gtk.StyleContext; | ||
|
||
import gtkc.giotypes; | ||
|
||
/** | ||
* Defined here since not defined in GtkD | ||
*/ | ||
enum ProviderPriority : uint { | ||
FALLBACK = 1, | ||
THEME = 200, | ||
SETTINGS = 400, | ||
APPLICATION = 600, | ||
USER = 800 | ||
} | ||
|
||
/** | ||
* Find and optionally register a resource | ||
*/ | ||
Resource findResource(string resourcePath, bool register = true) { | ||
foreach (path; Util.getSystemDataDirs()) { | ||
auto fullpath = buildPath(path, resourcePath); | ||
trace("looking for resource " ~ fullpath); | ||
if (exists(fullpath)) { | ||
Resource resource = Resource.load(fullpath); | ||
if (register && resource) { | ||
trace("Resource found and registered " ~ fullpath); | ||
Resource.register(resource); | ||
} | ||
return resource; | ||
} | ||
} | ||
error(format("Resource %s could not be found", resourcePath)); | ||
return null; | ||
} | ||
|
||
CssProvider createCssProvider(string filename, string[string] variables = null) { | ||
try { | ||
CssProvider provider = new CssProvider(); | ||
string css = getResource(filename, variables); | ||
if (css.length > 0) { | ||
if (provider.loadFromData(css)) { | ||
return provider; | ||
} | ||
} | ||
} catch (GException ge) { | ||
trace("Unexpected error loading css provider " ~ filename); | ||
trace("Error: " ~ ge.msg); | ||
} | ||
return null; | ||
} | ||
|
||
/** | ||
* Adds a CSSProvider to the default screen, if no provider is found it | ||
* returns null | ||
*/ | ||
CssProvider addCssProvider(string filename, ProviderPriority priority, string[string] variables = null) { | ||
try { | ||
CssProvider provider = createCssProvider(filename, variables); | ||
if (provider !is null) { | ||
StyleContext.addProviderForScreen(Screen.getDefault(), provider, priority); | ||
return provider; | ||
} | ||
} catch (GException ge) { | ||
trace("Unexpected error loading css provider " ~ filename); | ||
trace("Error: " ~ ge.msg); | ||
} | ||
return null; | ||
} | ||
|
||
private: | ||
|
||
/** | ||
* Loads a textual resource and performs string subsitution based on key-value pairs | ||
*/ | ||
string getResource(string filename, string[string] variables = null) { | ||
Bytes bytes; | ||
try { | ||
bytes = Resource.resourcesLookupData(filename, GResourceLookupFlags.NONE); | ||
} catch (GException ge) { | ||
error("Unexpected error loading resource " ~ filename); | ||
error("Error: " ~ ge.msg); | ||
} | ||
if (bytes is null || bytes.getSize() == 0) return null; | ||
else { | ||
string contents = to!string(cast(char*)bytes.getData()); | ||
if (variables !is null) { | ||
foreach(variable; variables.byKeyValue()) { | ||
contents = contents.replace(variable.key, variable.value); | ||
} | ||
} | ||
return contents; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.