[sushi] text: install and use builder-dark style



commit f66a197f055fed311a828cc69c893607d5229352
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Aug 26 13:01:42 2019 +0300

    text: install and use builder-dark style
    
    Instead of reading and using the gedit scheme. This is necessary
    since we use the dark theme, and gedit may not, leading to unreadable
    text.
    
    In the future we may tweak this to have two styles (one for light
    and one for dark variants), or something else, but in the meantime
    this provides a big improvement in legibility.
    
    https://gitlab.gnome.org/GNOME/sushi/issues/24

 data/builder-dark.style-scheme.xml | 197 +++++++++++++++++++++++++++++++++++++
 data/meson.build                   |   5 +
 src/viewers/text.js                |  22 ++---
 3 files changed, 208 insertions(+), 16 deletions(-)
---
diff --git a/data/builder-dark.style-scheme.xml b/data/builder-dark.style-scheme.xml
new file mode 100644
index 0000000..3421b4a
--- /dev/null
+++ b/data/builder-dark.style-scheme.xml
@@ -0,0 +1,197 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ This file is part of GtkSourceView
+
+ Copyright (C) 2007 GtkSourceView team
+ Author: Paolo Borelli <pborelli gnome org>
+
+ GtkSourceView is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ GtkSourceView is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+-->
+
+<style-scheme id="builder-dark" name="Builder Dark" version="1.0">
+
+  <author>Paolo Borelli, Christian Hergert</author>
+  <description>Dark color scheme for Builder using the Tango color palette</description>
+
+  <!-- Tango Palette -->
+  <color name="butter1"                     value="#fce94f"/>
+  <color name="butter2"                     value="#edd400"/>
+  <color name="butter3"                     value="#c4a000"/>
+  <color name="chameleon1"                  value="#8ae234"/>
+  <color name="chameleon2"                  value="#73d216"/>
+  <color name="chameleon3"                  value="#4e9a06"/>
+  <color name="orange1"                     value="#fcaf3e"/>
+  <color name="orange2"                     value="#f57900"/>
+  <color name="orange3"                     value="#ce5c00"/>
+  <color name="skyblue1"                    value="#729fcf"/>
+  <color name="skyblue2"                    value="#3465a4"/>
+  <color name="skyblue3"                    value="#204a87"/>
+  <color name="plum1"                       value="#ad7fa8"/>
+  <color name="plum2"                       value="#75507b"/>
+  <color name="plum3"                       value="#5c3566"/>
+  <color name="chocolate1"                  value="#e9b96e"/>
+  <color name="chocolate2"                  value="#c17d11"/>
+  <color name="chocolate3"                  value="#8f5902"/>
+  <color name="scarletred1"                 value="#ef2929"/>
+  <color name="scarletred2"                 value="#cc0000"/>
+  <color name="scarletred3"                 value="#a40000"/>
+  <color name="aluminium1"                  value="#eeeeec"/>
+  <color name="aluminium2"                  value="#d3d7cf"/>
+  <color name="aluminium3"                  value="#babdb6"/>
+  <color name="aluminium4"                  value="#888a85"/>
+  <color name="aluminium5"                  value="#555753"/>
+  <color name="aluminium6"                  value="#2e3436"/>
+  <color name="white"                       value="#ffffff"/>
+  <color name="pink1"                       value="#dd4a68"/>
+  <color name="red1"                        value="#ff0000"/>
+
+  <color name="dark1"                        value="#1e1e1e"/>
+  <color name="dark2"                        value="#303030"/>
+
+  <!-- Global Settings -->
+  <style name="text"                        foreground="aluminium3" background="dark1"/>
+  <style name="selection"                   foreground="aluminium1" background="aluminium4"/>
+  <style name="cursor"                      foreground="aluminium2"/>
+  <style name="current-line"                background="dark2"/>
+  <style name="current-line-number"         background="dark2"/>
+  <style name="line-numbers"                foreground="aluminium5" background="dark1"/>
+  <style name="draw-spaces"                 foreground="aluminium5"/>
+  <style name="background-pattern"          background="#202020"/>
+  <style name="map-overlay"                 background="#rgba(136,138,133,0.25)"/>
+
+  <!-- Diagnostics Underlining -->
+  <style name="diagnostician::deprecated"   underline="error" underline-color="aluminium3"/>
+  <style name="diagnostician::error"        underline="error" underline-color="red1"/>
+  <style name="diagnostician::note"         underline="error" underline-color="skyblue1"/>
+  <style name="diagnostician::warning"      underline="error" underline-color="orange1"/>
+
+  <!-- Snippets -->
+  <style name="snippet::tab-stop"           background="orange3" foreground="aluminium6"/>
+  <style name="snippet::area"               background="#rgba(86,114,151,.5)"/>
+
+  <!-- Debugger -->
+  <style name="debugger::current-breakpoint" foreground="#2e3436" background="#fcaf3e"/>
+  <style name="debugger::breakpoint"         foreground="#ffffff" background="#204a87"/>
+
+  <!-- Hover links -->
+  <style name="action::hover-definition"    background="#41464c" underline="true"/>
+
+  <!-- Bracket Matching -->
+  <style name="bracket-match"               foreground="chocolate2" bold="true"/>
+  <style name="bracket-mismatch"            foreground="aluminium1" background="scarletred2" bold="true"/>
+
+  <!-- Right Margin -->
+  <style name="right-margin"                foreground="#484749" background="#484749"/>
+
+  <!-- Search Matching -->
+  <style name="search-match"                foreground="aluminium1" background="chameleon3"/>
+  <style name="quick-highlight-match"       background="#rgba(78,154,6,.25)"/>
+
+  <!-- Search Shadow -->
+  <style name="search-shadow"               background="#rgba(0,0,0,0.4)"/>
+
+  <!-- Spellchecker Matching -->
+  <style name="misspelled-match"            foreground="#000000" background="#b3d4fc"/>
+
+  <!-- Comments -->
+  <style name="def:comment"                 foreground="aluminium4"/>
+  <style name="def:shebang"                 foreground="aluminium4" bold="true"/>
+  <style name="def:doc-comment-element"     italic="true"/>
+
+  <!-- Constants -->
+  <style name="def:constant"                foreground="butter2"/>
+  <style name="def:string"                  foreground="#0077aa"/>
+  <style name="def:special-char"            foreground="#dd4a68"/>
+  <style name="def:special-constant"        foreground="plum1"/>
+  <style name="def:floating-point"          foreground="orange3"/>
+  <style name="def:function"                foreground="#4186A8"/>
+
+  <!-- Identifiers -->
+  <style name="def:identifier"              foreground="skyblue1"/>
+
+  <!-- Statements -->
+  <style name="def:statement"               foreground="white" bold="true"/>
+
+  <!-- Types -->
+  <style name="def:type"                    foreground="chameleon1" bold="true"/>
+
+  <!-- Others -->
+  <style name="def:preprocessor"            foreground="#dd4a68"/>
+  <style name="def:error"                   foreground="aluminium1" background="scarletred2" bold="true"/>
+  <style name="def:warning"                 foreground="aluminium1" background="plum1"/>
+  <style name="def:note"                    background="butter1" foreground="aluminium4" bold="true"/>
+  <style name="def:underlined"              italic="true" underline="true"/>
+
+  <!-- Heading styles, uncomment to enable -->
+  <!--
+  <style name="def:heading0"                scale="5.0"/>
+  <style name="def:heading1"                scale="2.5"/>
+  <style name="def:heading2"                scale="2.0"/>
+  <style name="def:heading3"                scale="1.7"/>
+  <style name="def:heading4"                scale="1.5"/>
+  <style name="def:heading5"                scale="1.3"/>
+  <style name="def:heading6"                scale="1.2"/>
+  -->
+
+  <!-- Language specific -->
+  <style name="c:comment"                   foreground="#8b9eab"/>
+  <style name="c:preprocessor"              foreground="#8194a6" bold="false"/>
+  <style name="c:boolean"                   foreground="#0077aa"/>
+  <style name="c:keyword"                   foreground="#0077aa" bold="true"/>
+  <style name="c:string"                    foreground="#669900"/>
+  <style name="c:included-file"             foreground="orange3"/>
+  <style name="c:storage-class"             foreground="orange3" bold="true"/>
+  <style name="c:type"                      foreground="#669900" bold="true"/>
+  <style name="c:macro-name"                foreground="#677685" bold="false"/>
+  <style name="c:enum-name"                 foreground="#dd4a68" bold="false"/>
+
+  <style name="diff:added-line"             foreground="chameleon2"/>
+  <style name="diff:removed-line"           foreground="plum1"/>
+  <style name="diff:changed-line"           foreground="blue1"/>
+  <style name="diff:diff-file"              foreground="chameleon1" bold="true"/>
+  <style name="diff:location"               foreground="chameleon1"/>
+  <style name="diff:special-case"           foreground="white" bold="true"/>
+
+  <style name="gutter:added-line"           foreground="chameleon2"/>
+  <style name="gutter:changed-line"         foreground="butter3"/>
+  <style name="gutter:removed-line"         foreground="scarletred3"/>
+
+  <style name="js:object"                   foreground="chameleon3" bold="true"/>
+  <style name="js:constructors"             foreground="pink1"/>
+  <style name="js:keyword"                  foreground="#2b85aa"/>
+  <style name="js:string"                   foreground="#669900"/>
+  <style name="js:function"                 foreground="pink1"/>
+
+  <style name="latex:command"               foreground="chameleon1" bold="true"/>
+  <style name="latex:include"               use-style="def:preprocessor"/>
+
+  <style name="xml:comment"                 foreground="#8b9eab"/>
+  <style name="xml:attribute-name"          foreground="#orange3" bold="false"/>
+  <style name="xml:attribute-value"         foreground="#669900"/>
+  <style name="xml:tag-match"               background="#rgba(114,159,207,.20)"/>
+
+  <!-- Symbol-tree xml-pack coloring -->
+  <style name="symboltree::label"           foreground="#000000" background="#D5E7FC"/>
+  <style name="symboltree::id"              foreground="#000000" background="#D9E7BD"/>
+  <style name="symboltree::style-class"     foreground="#000000" background="#DFCD9B"/>
+  <style name="symboltree::type"            foreground="#000000" background="#F4DAC3"/>
+  <style name="symboltree::parent"          foreground="#000000" background="#DEBECF"/>
+  <style name="symboltree::class"           foreground="#000000" background="#FFEF98"/>
+  <style name="symboltree::attribute"       foreground="#000000" background="#F0E68C"/>
+
+</style-scheme>
+
diff --git a/data/meson.build b/data/meson.build
index 66c6223..3f34d50 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -16,3 +16,8 @@ i18n.merge_file(
   install: true,
   install_dir: join_paths(datadir, 'metainfo')
 )
+
+install_data(
+  'builder-dark.style-scheme.xml',
+  install_dir: join_paths(pkgdatadir, 'gtksourceview-4/styles')
+)
diff --git a/src/viewers/text.js b/src/viewers/text.js
index e29dbef..52d4b17 100644
--- a/src/viewers/text.js
+++ b/src/viewers/text.js
@@ -27,20 +27,6 @@ const {Gdk, Gio, GLib, GObject, Gtk, GtkSource} = imports.gi;
 
 const Renderer = imports.ui.renderer;
 
-function _getGeditScheme() {
-    let geditScheme = 'tango';
-    let schemaName = 'org.gnome.gedit.preferences.editor';
-    let installedSchemas = Gio.Settings.list_schemas();
-    if (installedSchemas.indexOf(schemaName) > -1) {
-        let geditSettings = new Gio.Settings({ schema: schemaName });
-        let geditSchemeName = geditSettings.get_string('scheme');
-        if (geditSchemeName != '')
-            geditScheme = geditSchemeName;
-    }
-
-    return geditScheme;
-}
-
 var Klass = GObject.registerClass({
     Implements: [Renderer.Renderer],
     Properties: {
@@ -77,8 +63,12 @@ var Klass = GObject.registerClass({
     _createBuffer(file, fileInfo) {
         let buffer = new GtkSource.Buffer();
         let styleManager = GtkSource.StyleSchemeManager.get_default();
-        let geditScheme = _getGeditScheme();
-        let scheme = styleManager.get_scheme(geditScheme);
+        let stylePath = GLib.build_filenamev([pkg.pkgdatadir,
+                                              'gtksourceview-4',
+                                              'styles']);
+        styleManager.prepend_search_path(stylePath);
+
+        let scheme = styleManager.get_scheme('builder-dark');
         buffer.set_style_scheme(scheme);
 
         let langManager = GtkSource.LanguageManager.get_default();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]