From 2caf38174220b58bb0b662cb9797aff9fd11d601 Mon Sep 17 00:00:00 2001
From: itdominator <1itdominator@gmail.com>
Date: Tue, 10 Oct 2023 14:51:57 -0500
Subject: [PATCH] Externalized some settings; added more css control; added
syntax themes
---
.../widgets/base/sourceview/source_view.py | 4 +-
.../base/sourceview/source_view_events.py | 18 ++-
src/core/widgets/controls/theme_button.py | 6 +-
src/utils/settings_manager/options/theming.py | 8 +-
.../gtksourceview-4/styles/blackleaf.xml | 113 +++++++++++++++++
.../styles/chocolateicecream.xml | 114 ++++++++++++++++++
.../styles/darkchocolateicecream.xml | 67 ++++++++++
user_config/usr/share/newton/settings.json | 8 +-
user_config/usr/share/newton/stylesheet.css | 61 ++++++++--
9 files changed, 368 insertions(+), 31 deletions(-)
create mode 100644 user_config/local/share/gtksourceview-4/styles/blackleaf.xml
create mode 100755 user_config/local/share/gtksourceview-4/styles/chocolateicecream.xml
create mode 100755 user_config/local/share/gtksourceview-4/styles/darkchocolateicecream.xml
diff --git a/src/core/widgets/base/sourceview/source_view.py b/src/core/widgets/base/sourceview/source_view.py
index e9f3896..689e942 100644
--- a/src/core/widgets/base/sourceview/source_view.py
+++ b/src/core/widgets/base/sourceview/source_view.py
@@ -39,7 +39,7 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
self._ignore_internal_change = False
self._buffer = self.get_buffer()
self._completion = self.get_completion()
- self.px_value = 16
+ self._px_value = settings.theming.default_zoom
self._multi_insert_marks = []
self.freeze_multi_line_insert = False
@@ -54,6 +54,8 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
def _setup_styling(self):
ctx = self.get_style_context()
ctx.add_class("source-view")
+ ctx.add_class(f"px{self._px_value}")
+
self.set_show_line_marks(True)
self.set_show_line_numbers(True)
diff --git a/src/core/widgets/base/sourceview/source_view_events.py b/src/core/widgets/base/sourceview/source_view_events.py
index f8d5638..5bac8e0 100644
--- a/src/core/widgets/base/sourceview/source_view_events.py
+++ b/src/core/widgets/base/sourceview/source_view_events.py
@@ -19,7 +19,7 @@ class SourceViewEventsMixin:
def set_buffer_language(self, language = "python3"):
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) )
def toggle_highlight_line(self, widget = None, eve = None):
@@ -28,10 +28,9 @@ class SourceViewEventsMixin:
def scale_up_text(self, scale_step = 10):
ctx = self.get_style_context()
- if self.px_value < 99:
- self.px_value += 1
-
- ctx.add_class(f"px{self.px_value}")
+ if self._px_value < 99:
+ self._px_value += 1
+ 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.
# tag_table = self._buffer.get_tag_table()
@@ -45,11 +44,10 @@ class SourceViewEventsMixin:
def scale_down_text(self, scale_step = 10):
ctx = self.get_style_context()
- ctx.remove_class(f"px{self.px_value}")
- if self.px_value > 1:
- self.px_value -= 1
-
- ctx.add_class(f"px{self.px_value}")
+ if self._px_value > 1:
+ ctx.remove_class(f"px{self._px_value}")
+ self._px_value -= 1
+ 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.
# tag_table = self._buffer.get_tag_table()
diff --git a/src/core/widgets/controls/theme_button.py b/src/core/widgets/controls/theme_button.py
index 3dd8bb0..2add82a 100644
--- a/src/core/widgets/controls/theme_button.py
+++ b/src/core/widgets/controls/theme_button.py
@@ -44,8 +44,10 @@ class ThemePopover(Gtk.Popover):
self.popup()
def _set_theme(self, widget = None, eve = None):
- style_scheme = widget.get_style_scheme()
- id = style_scheme.get_id()
+ style_scheme = widget.get_style_scheme()
+ id = style_scheme.get_id()
+ settings.theming.syntax_theme = id.lower()
+
event_system.emit('set_buffer_style', ("set_buffer_style", id.lower(),))
diff --git a/src/utils/settings_manager/options/theming.py b/src/utils/settings_manager/options/theming.py
index 034f7bd..7a2c587 100644
--- a/src/utils/settings_manager/options/theming.py
+++ b/src/utils/settings_manager/options/theming.py
@@ -8,6 +8,8 @@ from dataclasses import dataclass
@dataclass
class Theming:
- success_color: str = "#88cc27"
- warning_color: str = "#ffa800"
- error_color: str = "#ff0000"
+ default_zoom: int = 12
+ syntax_theme: str = "tango"
+ success_color: str = "#88cc27"
+ warning_color: str = "#ffa800"
+ error_color: str = "#ff0000"
\ No newline at end of file
diff --git a/user_config/local/share/gtksourceview-4/styles/blackleaf.xml b/user_config/local/share/gtksourceview-4/styles/blackleaf.xml
new file mode 100644
index 0000000..1bd4aaf
--- /dev/null
+++ b/user_config/local/share/gtksourceview-4/styles/blackleaf.xml
@@ -0,0 +1,113 @@
+
+ Hamad Al Marri
+ Color scheme using Black Leaf color palette
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/user_config/local/share/gtksourceview-4/styles/chocolateicecream.xml b/user_config/local/share/gtksourceview-4/styles/chocolateicecream.xml
new file mode 100755
index 0000000..ac5b1a8
--- /dev/null
+++ b/user_config/local/share/gtksourceview-4/styles/chocolateicecream.xml
@@ -0,0 +1,114 @@
+
+ Hamad Al Marri
+ Color scheme using Chocolate Ice Cream color palette
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/user_config/local/share/gtksourceview-4/styles/darkchocolateicecream.xml b/user_config/local/share/gtksourceview-4/styles/darkchocolateicecream.xml
new file mode 100755
index 0000000..1eed0ea
--- /dev/null
+++ b/user_config/local/share/gtksourceview-4/styles/darkchocolateicecream.xml
@@ -0,0 +1,67 @@
+
+ Hamad Al Marri
+ Color scheme using Dark Chocolate Ice Cream color palette
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/user_config/usr/share/newton/settings.json b/user_config/usr/share/newton/settings.json
index 08e920f..c6112e3 100644
--- a/user_config/usr/share/newton/settings.json
+++ b/user_config/usr/share/newton/settings.json
@@ -20,8 +20,8 @@
"terminal_app":"terminator",
"remux_folder_max_disk_usage":"8589934592",
"make_transparent":0,
- "main_window_x":721,
- "main_window_y":465,
+ "main_window_x":800,
+ "main_window_y":600,
"main_window_min_width":720,
"main_window_min_height":480,
"main_window_width":800,
@@ -110,6 +110,8 @@
]
},
"theming":{
+ "default_zoom":12,
+ "syntax_theme":"solarized-dark",
"success_color":"#88cc27",
"warning_color":"#ffa800",
"error_color":"#ff0000"
@@ -118,4 +120,4 @@
"ch_log_lvl":10,
"fh_log_lvl":20
}
-}
+}
\ No newline at end of file
diff --git a/user_config/usr/share/newton/stylesheet.css b/user_config/usr/share/newton/stylesheet.css
index f4b05a9..24624db 100644
--- a/user_config/usr/share/newton/stylesheet.css
+++ b/user_config/usr/share/newton/stylesheet.css
@@ -1,36 +1,77 @@
-/* Make most desired things base transparent */
+/* ---- make most desired things base transparent ---- */
window > box,
window > box > box,
window > box > box > paned,
window > box > box > paned > notebook,
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);
color: rgba(255, 255, 255, 1);
}
-/* Top controls */
-window > box > box > button
+
+/* ---- top controls ---- */
+window > box > box > button,
window > box > box > buttonbox > button {
background: rgba(39, 43, 52, 0.64);
margin-left: 12px;
margin-right: 12px;
}
-/* status bar */
+
+/* status bar */
window > box > statusbar {
background: rgba(39, 43, 52, 0.64);
padding-left: 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);
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 {
background-color: rgba(0, 115, 115, 0.34);
/* Bergundy */
@@ -39,9 +80,6 @@ window > box > box > paned > notebook > stack scrolledwindow > textview {
}
-
-
-
.source-view,
.mini-view {
font-family: Monospace;
@@ -85,7 +123,6 @@ window > box > box > paned > notebook > stack scrolledwindow > textview {
.px9 { font-size: 9px; }
.px10 { font-size: 10px; }
.px11 { font-size: 11px; }
-.source-view,
.px12 { font-size: 12px; }
.px13 { font-size: 13px; }
.px14 { font-size: 14px; }