Externalized some settings; added more css control; added syntax themes

This commit is contained in:
itdominator 2023-10-10 14:51:57 -05:00
parent 0e940aa4f0
commit 2caf381742
9 changed files with 368 additions and 31 deletions

View File

@ -39,7 +39,7 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
self._ignore_internal_change = False self._ignore_internal_change = False
self._buffer = self.get_buffer() self._buffer = self.get_buffer()
self._completion = self.get_completion() self._completion = self.get_completion()
self.px_value = 16 self._px_value = settings.theming.default_zoom
self._multi_insert_marks = [] self._multi_insert_marks = []
self.freeze_multi_line_insert = False self.freeze_multi_line_insert = False
@ -54,6 +54,8 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
def _setup_styling(self): def _setup_styling(self):
ctx = self.get_style_context() ctx = self.get_style_context()
ctx.add_class("source-view") ctx.add_class("source-view")
ctx.add_class(f"px{self._px_value}")
self.set_show_line_marks(True) self.set_show_line_marks(True)
self.set_show_line_numbers(True) self.set_show_line_numbers(True)

View File

@ -19,7 +19,7 @@ class SourceViewEventsMixin:
def set_buffer_language(self, language = "python3"): def set_buffer_language(self, language = "python3"):
self._buffer.set_language( self._language_manager.get_language(language) ) self._buffer.set_language( self._language_manager.get_language(language) )
def set_buffer_style(self, style = "tango"): def set_buffer_style(self, style = settings.theming.syntax_theme):
self._buffer.set_style_scheme( self._style_scheme_manager.get_scheme(style) ) self._buffer.set_style_scheme( self._style_scheme_manager.get_scheme(style) )
def toggle_highlight_line(self, widget = None, eve = None): def toggle_highlight_line(self, widget = None, eve = None):
@ -28,10 +28,9 @@ class SourceViewEventsMixin:
def scale_up_text(self, scale_step = 10): def scale_up_text(self, scale_step = 10):
ctx = self.get_style_context() ctx = self.get_style_context()
if self.px_value < 99: if self._px_value < 99:
self.px_value += 1 self._px_value += 1
ctx.add_class(f"px{self._px_value}")
ctx.add_class(f"px{self.px_value}")
# NOTE: Hope to bring this or similar back after we decouple scaling issues coupled with the miniview. # NOTE: Hope to bring this or similar back after we decouple scaling issues coupled with the miniview.
# tag_table = self._buffer.get_tag_table() # tag_table = self._buffer.get_tag_table()
@ -45,11 +44,10 @@ class SourceViewEventsMixin:
def scale_down_text(self, scale_step = 10): def scale_down_text(self, scale_step = 10):
ctx = self.get_style_context() ctx = self.get_style_context()
ctx.remove_class(f"px{self.px_value}") if self._px_value > 1:
if self.px_value > 1: ctx.remove_class(f"px{self._px_value}")
self.px_value -= 1 self._px_value -= 1
ctx.add_class(f"px{self._px_value}")
ctx.add_class(f"px{self.px_value}")
# NOTE: Hope to bring this or similar back after we decouple scaling issues coupled with the miniview. # NOTE: Hope to bring this or similar back after we decouple scaling issues coupled with the miniview.
# tag_table = self._buffer.get_tag_table() # tag_table = self._buffer.get_tag_table()

View File

@ -44,8 +44,10 @@ class ThemePopover(Gtk.Popover):
self.popup() self.popup()
def _set_theme(self, widget = None, eve = None): def _set_theme(self, widget = None, eve = None):
style_scheme = widget.get_style_scheme() style_scheme = widget.get_style_scheme()
id = style_scheme.get_id() id = style_scheme.get_id()
settings.theming.syntax_theme = id.lower()
event_system.emit('set_buffer_style', ("set_buffer_style", id.lower(),)) event_system.emit('set_buffer_style', ("set_buffer_style", id.lower(),))

View File

@ -8,6 +8,8 @@ from dataclasses import dataclass
@dataclass @dataclass
class Theming: class Theming:
success_color: str = "#88cc27" default_zoom: int = 12
warning_color: str = "#ffa800" syntax_theme: str = "tango"
error_color: str = "#ff0000" success_color: str = "#88cc27"
warning_color: str = "#ffa800"
error_color: str = "#ff0000"

View File

@ -0,0 +1,113 @@
<style-scheme name="Black Leaf" id="blackleaf" version="1.0">
<author>Hamad Al Marri</author>
<description>Color scheme using Black Leaf color palette</description>
<!-- Color Palette -->
<color name="background" value="#172601"/>
<color name="foreground" value="#EDF2C2"/>
<color name="cursor" value="#00DEA4"/>
<!-- Normal Colors-->
<color name="n_black" value="#172601"/>
<color name="n_red" value="#FF636E"/>
<color name="n_green" value="#B1F02A"/>
<color name="n_yellow" value="#ECF22E"/>
<color name="n_blue" value="#46EBE3"/>
<color name="n_magenta" value="#FFC800"/>
<color name="n_cyan" value="#42E1E5"/>
<color name="n_white" value="#7C7C7C"/>
<!-- Bright Colors-->
<!-- <color name="b_black" value="#5E5C64"/>-->
<!-- <color name="b_red" value="#FF636E"/>-->
<color name="b_green" value="#33DA7A"/>
<color name="b_yellow" value="#30F077"/>
<color name="b_blue" value="#608FC8"/>
<color name="b_magenta" value="#FDA954"/>
<color name="b_cyan" value="#C0BBC5"/>
<color name="b_white" value="#FFFFFF"/>
<!-- Extra Colors -->
<color name="extra1" value="#274611"/>
<color name="extra2" value="#000000"/>
<color name="extra3" value="#A09BA5"/>
<color name="extra4" value="#839004"/>
<!-- Global Settings -->
<style name="text" foreground="foreground" background="background" />
<style name="line-numbers" foreground="extra3" background="background" />
<style name="current-line" background="extra1" />
<style name="draw-spaces" foreground="b_white"/>
<style name="background-pattern" background="extra2" />
<style name="selection" foreground="extra2" background="n_green" />
<style name="cursor" foreground="cursor" />
<style name="secondary-cursor" foreground="cursor" />
<style name="right-margin" foreground="extra2" background="n_green" />
<!-- Bracket Matching -->
<style name="bracket-match" foreground="n_magenta" bold="true" />
<style name="bracket-mismatch" foreground="n_red" background="background" bold="true" />
<!-- Search Matching -->
<style name="search-match" foreground="extra2" background="n_green" bold="true" />
<!-- Comments -->
<style name="def:comment" foreground="extra4" />
<style name="def:shebang" bold="true" />
<style name="def:doc-comment-element" italic="true" />
<!-- Constants -->
<style name="def:constant" foreground="n_green" />
<style name="def:special-char" foreground="b_green" />
<!-- Language Syntax -->
<style name="def:identifier" foreground="b_yellow" />
<style name="def:statement" foreground="n_blue" />
<style name="def:type" foreground="b_green" />
<style name="def:operator" foreground="b_magenta" />
<style name="def:arith-operator" foreground="n_yellow" />
<style name="def:preprocessor" foreground="n_magenta" />
<style name="def:error" foreground="n_red" bold="true" />
<style name="def:warning" background="b_yellow"/>
<!-- Others -->
<style name="def:note" foreground="n_white" bold="true" />
<style name="def:underlined" italic="true" underline="true" />
<!-- Markup -->
<style name="def:emphasis" italic="true"/>
<style name="def:strong-emphasis" foreground="n_cyan" bold="true"/>
<style name="def:inline-code" foreground="n_green"/>
<style name="def:insertion" underline="single"/>
<style name="def:deletion" strikethrough="true"/>
<style name="def:link-text" foreground="n_blue"/>
<style name="def:link-symbol" foreground="n_blue" bold="true"/>
<style name="def:link-destination" italic="true" underline="single"/>
<style name="def:heading" foreground="n_magenta" bold="true"/>
<style name="def:thematic-break" foreground="b_magenta" bold="true"/>
<style name="def:preformatted-section" foreground="b_yellow"/>
<style name="def:list-marker" foreground="b_cyan" bold="true"/>
<!-- Language specific -->
<style name="diff:added-line" foreground="n_green"/>
<style name="diff:removed-line" foreground="n_red"/>
<style name="diff:changed-line" use-style="def:preprocessor"/>
<style name="diff:diff-file" use-style="def:type"/>
<style name="diff:location" use-style="def:statement"/>
<style name="diff:special-case" use-style="def:constant"/>
<style name="xml:tags" foreground="n_green"/>
<style name="xml:namespace" bold="true"/>
<style name="js:built-in-constructor" foreground="n_green"/>
<style name="latex:display-math" foreground="b_blue"/>
<style name="latex:command" foreground="n_magenta" bold="true"/>
<style name="latex:include" use-style="def:preprocessor"/>
<style name="latex:special-char" use-style="def:constant"/>
<style name="sh:variable" foreground="n_blue"/>
<style name="sh:variable-definition" foreground="n_magenta"/>
</style-scheme>

View File

@ -0,0 +1,114 @@
<style-scheme name="Chocolate Ice Cream" id="chocolateicecream" version="1.0">
<author>Hamad Al Marri</author>
<description>Color scheme using Chocolate Ice Cream color palette</description>
<!-- Color Palette -->
<color name="background" value="#36292d"/>
<color name="foreground" value="#ffffda"/>
<color name="cursor" value="#ffc400"/>
<!-- Normal Colors-->
<color name="n_black" value="#172601"/>
<color name="n_red" value="#ff1846"/>
<color name="n_green" value="#0DD100"/>
<color name="n_yellow" value="#fef5d7"/>
<color name="n_blue" value="#00b5ff"/>
<color name="n_magenta" value="#ff749b"/>
<color name="n_cyan" value="#60dede"/>
<color name="n_white" value="#7C7C7C"/>
<!-- Bright Colors-->
<!-- <color name="b_black" value="#5E5C64"/>-->
<!-- <color name="b_red" value="#FF636E"/>-->
<color name="b_green" value="#c2ff8e"/>
<color name="b_yellow" value="#eee5c7"/>
<color name="b_blue" value="#cac5ff"/>
<color name="b_magenta" value="#D33682"/>
<color name="b_cyan" value="#00b5ff"/>
<color name="b_white" value="#FFFFFF"/>
<!-- Extra Colors -->
<color name="extra1" value="#4d3436"/>
<color name="extra2" value="#BEB0BE"/>
<color name="extra3" value="#847479"/>
<color name="extra4" value="#839004"/>
<color name="extra5" value="#827082"/>
<!-- Global Settings -->
<style name="text" foreground="foreground" background="background" />
<style name="line-numbers" foreground="extra3" background="background" />
<style name="current-line" background="extra1" />
<style name="draw-spaces" foreground="b_white"/>
<style name="background-pattern" background="extra2" />
<style name="selection" foreground="background" background="b_yellow" />
<style name="cursor" foreground="cursor" />
<style name="secondary-cursor" foreground="cursor" />
<style name="right-margin" foreground="extra2" background="extra5" />
<!-- Bracket Matching -->
<style name="bracket-match" foreground="b_green" bold="true" />
<style name="bracket-mismatch" foreground="b_green" background="n_red" bold="true" />
<!-- Search Matching -->
<style name="search-match" foreground="background" background="b_yellow" bold="true" />
<!-- Comments -->
<style name="def:comment" foreground="extra3" />
<style name="def:shebang" bold="true" />
<style name="def:doc-comment-element" italic="true" />
<!-- Constants -->
<style name="def:constant" foreground="n_cyan" />
<style name="def:special-char" foreground="n_blue" />
<!-- Language Syntax -->
<style name="def:identifier" foreground="b_blue" />
<style name="def:statement" foreground="n_magenta" />
<style name="def:type" foreground="b_blue" />
<style name="def:operator" foreground="n_blue" />
<style name="def:arith-operator" foreground="n_green" />
<style name="def:preprocessor" foreground="n_blue" />
<style name="def:error" foreground="n_red" bold="true" />
<style name="def:warning" background="b_yellow"/>
<!-- Others -->
<style name="def:note" foreground="n_white" bold="true" />
<style name="def:underlined" italic="true" underline="true" />
<!-- Markup -->
<style name="def:emphasis" italic="true"/>
<style name="def:strong-emphasis" foreground="n_cyan" bold="true"/>
<style name="def:inline-code" foreground="n_blue"/>
<style name="def:insertion" underline="single"/>
<style name="def:deletion" strikethrough="true"/>
<style name="def:link-text" foreground="n_blue"/>
<style name="def:link-symbol" foreground="n_blue" bold="true"/>
<style name="def:link-destination" italic="true" underline="single"/>
<style name="def:heading" foreground="n_magenta" bold="true"/>
<style name="def:thematic-break" foreground="b_magenta" bold="true"/>
<style name="def:preformatted-section" foreground="b_blue"/>
<style name="def:list-marker" foreground="n_green" bold="true"/>
<!-- Language specific -->
<style name="diff:added-line" foreground="n_green"/>
<style name="diff:removed-line" foreground="n_magenta"/>
<style name="diff:changed-line" use-style="def:preprocessor"/>
<style name="diff:diff-file" use-style="def:type"/>
<style name="diff:location" use-style="def:operator"/>
<style name="diff:special-case" use-style="def:constant"/>
<style name="xml:tags" foreground="n_magenta"/>
<style name="xml:namespace" bold="true"/>
<style name="js:built-in-constructor" foreground="n_magenta"/>
<style name="latex:display-math" foreground="b_blue"/>
<style name="latex:command" foreground="n_magenta" bold="true"/>
<style name="latex:include" use-style="def:preprocessor"/>
<style name="latex:special-char" use-style="def:constant"/>
<style name="sh:variable" foreground="n_blue"/>
<style name="sh:variable-definition" foreground="n_magenta"/>
</style-scheme>

View File

@ -0,0 +1,67 @@
<style-scheme name="Dark Chocolate Ice Cream" id="darkchocolateicecream" version="1.0">
<author>Hamad Al Marri</author>
<description>Color scheme using Dark Chocolate Ice Cream color palette</description>
<style name="text" foreground="#A87D7D" background="#1b1414" />
<style name="selection" foreground="#A87D7D" background="#443232" />
<style name="cursor" foreground="#ffc400" />
<style name="secondary-cursor" foreground="#f1f0f1" />
<style name="current-line" background="#443232" />
<style name="line-numbers" foreground="#A87D7D" background="#1b1414" />
<style name="background-pattern" background="#201818" />
<style name="bracket-match" bold="true" italic="true" />
<style name="bracket-mismatch" bold="true" italic="true" background="#ff1846" />
<style name="right-margin" foreground="#BEB0BE" background="#827082" />
<style name="search-match" foreground="#A87D7D" background="#FCE94F" bold="true" />
<style name="def:comment" foreground="#847479" />
<style name="def:shebang" bold="true" />
<style name="def:doc-comment-element" italic="true" />
<style name="def:constant" foreground="#999999" />
<style name="def:special-char" foreground="#00b5ff" />
<style name="def:statement" foreground="#A87D7D" bold="true" />
<style name="def:operator" foreground="#af8686" />
<style name="def:arith-operator" foreground="#af8686" />
<style name="def:preprocessor" foreground="#485C69" />
<style name="def:error" foreground="#ff1846" bold="true" />
<style name="def:note" foreground="#D33682" bold="true" />
<style name="def:underlined" italic="true" underline="true" />
<style name="def:identifier" foreground="#af8686" />
<style name="def:type" foreground="#af8686" underline="true" />
<!-- Markup -->
<style name="def:emphasis" italic="true"/>
<style name="def:strong-emphasis" foreground="#D33682" bold="true"/>
<style name="def:inline-code" foreground="#999999"/>
<style name="def:insertion" underline="single"/>
<style name="def:deletion" strikethrough="true"/>
<style name="def:link-text" foreground="#999999"/>
<style name="def:link-symbol" foreground="#777" bold="true"/>
<style name="def:link-destination" italic="true" underline="single"/>
<style name="def:heading" foreground="#999999" bold="true"/>
<style name="def:thematic-break" foreground="#999999" bold="true"/>
<style name="def:preformatted-section" foreground="#999999"/>
<style name="def:list-marker" foreground="#FCE94F" bold="true"/>
<!-- Language specific -->
<style name="diff:added-line" foreground="#0DD100"/>
<style name="diff:removed-line" foreground="#ff749b"/>
<style name="diff:changed-line" use-style="def:preprocessor"/>
<style name="diff:diff-file" use-style="def:type"/>
<style name="diff:location" use-style="def:constant"/>
<style name="diff:special-case" use-style="def:constant"/>
<style name="xml:tags" foreground="#ff749b"/>
<style name="xml:namespace" bold="true"/>
<style name="js:built-in-constructor" foreground="#ff749b"/>
<style name="latex:display-math" foreground="#00b5ff"/>
<style name="latex:command" foreground="#ff749b" bold="true"/>
<style name="latex:include" use-style="def:preprocessor"/>
<style name="latex:special-char" use-style="def:constant"/>
<style name="sh:variable" foreground="#00b5ff"/>
<style name="sh:variable-definition" foreground="#ff749b"/>
</style-scheme>

View File

@ -20,8 +20,8 @@
"terminal_app":"terminator", "terminal_app":"terminator",
"remux_folder_max_disk_usage":"8589934592", "remux_folder_max_disk_usage":"8589934592",
"make_transparent":0, "make_transparent":0,
"main_window_x":721, "main_window_x":800,
"main_window_y":465, "main_window_y":600,
"main_window_min_width":720, "main_window_min_width":720,
"main_window_min_height":480, "main_window_min_height":480,
"main_window_width":800, "main_window_width":800,
@ -110,6 +110,8 @@
] ]
}, },
"theming":{ "theming":{
"default_zoom":12,
"syntax_theme":"solarized-dark",
"success_color":"#88cc27", "success_color":"#88cc27",
"warning_color":"#ffa800", "warning_color":"#ffa800",
"error_color":"#ff0000" "error_color":"#ff0000"
@ -118,4 +120,4 @@
"ch_log_lvl":10, "ch_log_lvl":10,
"fh_log_lvl":20 "fh_log_lvl":20
} }
} }

View File

@ -1,36 +1,77 @@
/* Make most desired things base transparent */ /* ---- make most desired things base transparent ---- */
window > box, window > box,
window > box > box, window > box > box,
window > box > box > paned, window > box > box > paned,
window > box > box > paned > notebook, window > box > box > paned > notebook,
window > box > box > paned > notebook > stack, window > box > box > paned > notebook > stack,
window > box > box > paned > notebook > stack scrolledwindow > textview > * { window > box > box > paned > notebook > stack > scrolledwindow > textview > * {
background: rgba(0, 0, 0, 0.0); background: rgba(0, 0, 0, 0.0);
color: rgba(255, 255, 255, 1); color: rgba(255, 255, 255, 1);
} }
/* Top controls */
window > box > box > button /* ---- top controls ---- */
window > box > box > button,
window > box > box > buttonbox > button { window > box > box > buttonbox > button {
background: rgba(39, 43, 52, 0.64); background: rgba(39, 43, 52, 0.64);
margin-left: 12px; margin-left: 12px;
margin-right: 12px; margin-right: 12px;
} }
/* status bar */
/* status bar */
window > box > statusbar { window > box > statusbar {
background: rgba(39, 43, 52, 0.64); background: rgba(39, 43, 52, 0.64);
padding-left: 96px; padding-left: 96px;
padding-right: 96px; padding-right: 96px;
} }
/* source code notebooks */
window > box > box > paned > notebook > stack scrolledwindow > textview { /* ---- notebook headers ---- */
notebook > header {
background: rgba(39, 43, 52, 0.72);
}
notebook > header > tabs > tab {
color: rgba(255, 255, 255, 1);
}
notebook > header > tabs > tab:active {
background: rgba(39, 43, 52, 0.0);
}
/* ---- notebook tab buttons ---- */
tab > box > button {
background: rgba(116, 0, 0, 0.64);
}
tab > box > button:hover {
background: rgba(256, 0, 0, 0.64);
}
/* ---- source code notebooks ---- */
notebook > stack > scrolledwindow > textview {
background: rgba(39, 43, 52, 0.64); background: rgba(39, 43, 52, 0.64);
color: rgba(255, 255, 255, 1); color: rgba(255, 255, 255, 1);
} }
/* make text selection slightly transparent */ /* ---- miniview properties ---- */
/* the mini view container of text */
.mini-view > text {
background: rgba(39, 43, 52, 0.64);
}
/* draggable overlay of the miniview */
.mini-view > * {
background: rgba(64, 64, 64, 0.32);
color: rgba(255, 255, 255, 1);
}
/* ---- make text selection slightly transparent ---- */
* selection { * selection {
background-color: rgba(0, 115, 115, 0.34); background-color: rgba(0, 115, 115, 0.34);
/* Bergundy */ /* Bergundy */
@ -39,9 +80,6 @@ window > box > box > paned > notebook > stack scrolledwindow > textview {
} }
.source-view, .source-view,
.mini-view { .mini-view {
font-family: Monospace; font-family: Monospace;
@ -85,7 +123,6 @@ window > box > box > paned > notebook > stack scrolledwindow > textview {
.px9 { font-size: 9px; } .px9 { font-size: 9px; }
.px10 { font-size: 10px; } .px10 { font-size: 10px; }
.px11 { font-size: 11px; } .px11 { font-size: 11px; }
.source-view,
.px12 { font-size: 12px; } .px12 { font-size: 12px; }
.px13 { font-size: 13px; } .px13 { font-size: 13px; }
.px14 { font-size: 14px; } .px14 { font-size: 14px; }