From 55d2d99d684370ff92503de07ad776ee046f73f1 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 21 Feb 2026 00:38:27 -0600 Subject: [PATCH] refactor: use Pango for font scaling instead of CSS classes - Replace CSS-based zoom (px1-px99 classes) with Pango.FontDescription - Fix bug in multi-insert: insert at start_itr instead of end_itr - Add Pango-based font setup for mini-view widget - Revamp stylesheet with Light Blue-Grey Glass theme --- src/core/containers/center_container.py | 5 +- .../code/command_system/commands/zoom_in.py | 8 +- .../code/command_system/commands/zoom_out.py | 8 +- .../provider_response_cache_base.py | 9 +- .../code/controllers/completion_controller.py | 2 + .../states/source_view_multi_insert_state.py | 2 +- src/core/widgets/code/mini_view_widget.py | 11 +- src/core/widgets/code/source_file.py | 7 +- src/core/widgets/code/source_view.py | 1 - user_config/usr/share/app_name/stylesheet.css | 287 ++++++------------ 10 files changed, 131 insertions(+), 209 deletions(-) diff --git a/src/core/containers/center_container.py b/src/core/containers/center_container.py index 9546af3..7900535 100644 --- a/src/core/containers/center_container.py +++ b/src/core/containers/center_container.py @@ -42,6 +42,9 @@ class CenterContainer(Gtk.Box): glade_box = widget_registery.get_object("glade_box") button = Gtk.Button(label = "Click Me!") + webkit_ui = WebkitUI() + + webkit_ui.load_context_base_path() button.connect("clicked", self._hello_world) @@ -50,7 +53,7 @@ class CenterContainer(Gtk.Box): self.add(button) self.add(glade_box) - self.add( WebkitUI() ) + self.add(webkit_ui) def _hello_world(self, widget = None, eve = None): logger.debug("Hello, World!") \ No newline at end of file diff --git a/src/core/widgets/code/command_system/commands/zoom_in.py b/src/core/widgets/code/command_system/commands/zoom_in.py index 1151656..a4038ea 100644 --- a/src/core/widgets/code/command_system/commands/zoom_in.py +++ b/src/core/widgets/code/command_system/commands/zoom_in.py @@ -6,6 +6,7 @@ import gi gi.require_version('GtkSource', '4') from gi.repository import GtkSource +from gi.repository import Pango # Application imports @@ -18,6 +19,9 @@ def execute( ctx = view.get_style_context() if view.zoom_level < 99: - ctx.remove_class(f"px{view.zoom_level}") view.zoom_level += 1 - ctx.add_class(f"px{view.zoom_level}") \ No newline at end of file + + font_desc = \ + Pango.FontDescription(f"Monospace {view.zoom_level}") + + view.modify_font(font_desc) diff --git a/src/core/widgets/code/command_system/commands/zoom_out.py b/src/core/widgets/code/command_system/commands/zoom_out.py index f03485f..e17c37e 100644 --- a/src/core/widgets/code/command_system/commands/zoom_out.py +++ b/src/core/widgets/code/command_system/commands/zoom_out.py @@ -6,6 +6,7 @@ import gi gi.require_version('GtkSource', '4') from gi.repository import GtkSource +from gi.repository import Pango # Application imports @@ -18,6 +19,9 @@ def execute( ctx = view.get_style_context() if view.zoom_level > 1: - ctx.remove_class(f"px{view.zoom_level}") view.zoom_level -= 1 - ctx.add_class(f"px{view.zoom_level}") \ No newline at end of file + + font_desc = \ + Pango.FontDescription(f"Monospace {view.zoom_level}") + + view.modify_font(font_desc) diff --git a/src/core/widgets/code/completion_providers/provider_response_cache_base.py b/src/core/widgets/code/completion_providers/provider_response_cache_base.py index 4dbbbad..1c17f64 100644 --- a/src/core/widgets/code/completion_providers/provider_response_cache_base.py +++ b/src/core/widgets/code/completion_providers/provider_response_cache_base.py @@ -11,6 +11,7 @@ from gi.repository import Gtk from gi.repository import GtkSource # Application imports +from libs.event_factory import Code_Event_Types @@ -26,16 +27,16 @@ class ProviderResponseCacheBase: self._icon_theme = Gtk.IconTheme.get_default() - def process_file_load(self, buffer: GtkSource.Buffer): + def process_file_load(self, event: Code_Event_Types.AddedNewFileEvent): raise ProviderResponseCacheException("ProviderResponseCacheBase 'process_file_load' not implemented...") - def process_file_close(self, buffer: GtkSource.Buffer): + def process_file_close(self, event: Code_Event_Types.RemovedFileEvent): raise ProviderResponseCacheException("ProviderResponseCacheBase 'process_file_close' not implemented...") - def process_file_save(self, buffer: GtkSource.Buffer): + def process_file_save(self, event: Code_Event_Types.SavedFileEvent): raise ProviderResponseCacheException("ProviderResponseCacheBase 'process_file_save' not implemented...") - def process_file_change(self, buffer: GtkSource.Buffer): + def process_file_change(self, event: Code_Event_Types.TextChangedEvent): raise ProviderResponseCacheException("ProviderResponseCacheBase 'process_change' not implemented...") def filter(self, word: str) -> list[dict]: diff --git a/src/core/widgets/code/controllers/completion_controller.py b/src/core/widgets/code/controllers/completion_controller.py index 647a18b..4102ddd 100644 --- a/src/core/widgets/code/controllers/completion_controller.py +++ b/src/core/widgets/code/controllers/completion_controller.py @@ -68,6 +68,8 @@ class CompletionController(ControllerBase): def provider_process_file_load(self, event: Code_Event_Types.AddedNewFileEvent): for provider in self._providers.values(): + # if provider.get_name() == "Words Completion": + # provider.register(event.file.buffer) provider.response_cache.process_file_load(event) def provider_process_file_close(self, event: Code_Event_Types.RemovedFileEvent): diff --git a/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py b/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py index 3fab3e5..2429fb9 100644 --- a/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py +++ b/src/core/widgets/code/controllers/views/states/source_view_multi_insert_state.py @@ -71,7 +71,7 @@ class SourceViewsMultiInsertState(MarkEventsMixin): end_itr.forward_word_end() buffer.delete(start_itr, end_itr) - buffer.insert(end_itr, text, -1) + buffer.insert(start_itr, text, -1) buffer.end_user_action() buffer.unblock_insert_after_signal() diff --git a/src/core/widgets/code/mini_view_widget.py b/src/core/widgets/code/mini_view_widget.py index 789f475..da77c6a 100644 --- a/src/core/widgets/code/mini_view_widget.py +++ b/src/core/widgets/code/mini_view_widget.py @@ -4,7 +4,7 @@ import gi gi.require_version('GtkSource', '4') from gi.repository.GtkSource import Map - +from gi.repository import Pango # Application imports @@ -25,6 +25,7 @@ class MiniViewWidget(Map): ctx.add_class("mini-view") self.set_hexpand(False) + self._set_font_desc() def _setup_signals(self): ... @@ -35,5 +36,13 @@ class MiniViewWidget(Map): def _load_widgets(self): ... + def _set_font_desc(self): + default_font = 'Monospace 1' + desc = Pango.FontDescription(default_font) + + desc.set_size(Pango.SCALE) # Set size to 1pt + desc.set_family('BuilderBlocks,' + desc.get_family()) + self.set_property('font-desc', desc) + def set_smini_view(self, source_view): self.set_view(source_view) \ No newline at end of file diff --git a/src/core/widgets/code/source_file.py b/src/core/widgets/code/source_file.py index 216b33f..f7f8e54 100644 --- a/src/core/widgets/code/source_file.py +++ b/src/core/widgets/code/source_file.py @@ -45,8 +45,11 @@ class SourceFile(GtkSource.File): def _changed(self, buffer: SourceBuffer): self.check_file_on_disk() - event = Event_Factory.create_event("text_changed", buffer = buffer) - event.file = self + event = Event_Factory.create_event( + "text_changed", + file = self, + buffer = buffer + ) self.emit(event) if self.is_deleted(): diff --git a/src/core/widgets/code/source_view.py b/src/core/widgets/code/source_view.py index 462f3f5..ce751f6 100644 --- a/src/core/widgets/code/source_view.py +++ b/src/core/widgets/code/source_view.py @@ -39,7 +39,6 @@ class SourceView(GtkSource.View, SourceViewDnDMixin): ctx = self.get_style_context() ctx.add_class("source-view") - ctx.add_class(f"px{self.zoom_level}") self.set_vexpand(True) self.set_bottom_margin(800) diff --git a/user_config/usr/share/app_name/stylesheet.css b/user_config/usr/share/app_name/stylesheet.css index fef2246..0f295ee 100644 --- a/user_config/usr/share/app_name/stylesheet.css +++ b/user_config/usr/share/app_name/stylesheet.css @@ -1,21 +1,47 @@ -/* ---- Overrides ---- */ +/* ============================== + Light Blue-Grey Glass Theme + ============================== */ + +/* -------- Color Variables -------- */ +@define-color bg_glass rgba(30, 36, 46, 0.65); +@define-color bg_soft rgba(45, 52, 64, 0.55); +@define-color accent_blue #6fa8dc; +@define-color accent_blue_transparent rgba(111, 168, 220, 0.64); +@define-color accent_orange #ffa500; +@define-color accent_red #c84646; +@define-color accent_green #88cc27; +@define-color text_primary #e6edf3; +@define-color text_dim rgba(230, 237, 243, 0.7); +@define-color border_soft rgba(255, 255, 255, 0.08); + + +/* -------- Text Selection -------- */ text selection { - background-color: #44475a; - color: #FFA500; + background-color: @accent_blue_transparent; + color: #ffffff; } -/* ---- Make most desired things base transparent ---- */ + +/* -------- Transparent Base Areas -------- */ popover, popover > box, notebook, header, -stack { - background: rgba(0, 0, 0, 0.0); - color: rgba(255, 255, 255, 1); +stack, +.main-window, +.base-container, +.body-container, +.center-container, +.header-container, +.footer-container, +.left-container, +.right-container { + background: transparent; + color: @text_primary; } -/* The scrolled window itself */ +/* -------- Scrollable Areas -------- */ scrolledwindow, scrolledwindow viewport, textview, @@ -23,249 +49,120 @@ textview text { background-color: transparent; } -scrollbar { - background-color: #2a2a2a; + +/* -------- Borders -------- */ +border { + background: @bg_glass; +} + + +/* -------- Scrollbar Styling -------- */ +scrollbar { + background-color: transparent; } -/* The track */ scrollbar trough { background-color: transparent; - /*background-color: #2a2a2a;*/ - border-radius: 6px; + border-radius: 8px; } -/* The draggable handle */ scrollbar slider { - background-color: #555; - border-radius: 6px; + background-color: rgba(255, 255, 255, 0.18); + border-radius: 8px; min-width: 10px; min-height: 10px; + transition: 120ms ease-in-out; } scrollbar slider:hover { - background-color: #777; + background-color: rgba(255, 255, 255, 0.30); } scrollbar slider:active { - background-color: #999; + background-color: @accent_blue; } -border { - background: rgba(39, 43, 52, 0.84); -} - -tab { - color: rgba(255, 255, 255, 1); -} - -tab:checked { - border-bottom-color: rgba(125, 125, 125, 1); -} - - -.main-window, -.base-container, -.body-container, -.center-container, -.header-container, -.footer-container, -.left-containerm, -.right-container { - background: rgba(0, 0, 0, 0.0); - color: rgba(255, 255, 255, 1); -} - - -/* the mini view container of text */ +/* -------- Mini View -------- */ .mini-view > text { - background: rgba(39, 43, 52, 0.64); + background: @bg_soft; } -/* draggable overlay of the miniview */ .mini-view > * { - background-color: rgba(124, 124, 124, 0.34); - color: rgba(255, 255, 255, 1); + background-color: rgba(255, 255, 255, 0.08); + color: @text_primary; font-size: 1px; } +/* -------- Layout Adjustments -------- */ .base-container { margin: 10px; } +/* -------- Focus State -------- */ .source-view-focused { - border-style: solid; - border-color: white; - border-width: 0.05em; + border: 1px solid @accent_blue; } -.tab-widget { - padding-left: 0.2em; - padding-right: 0.2em; - margin-right: 0.8em; - - border-top-style: solid; - border-top-color: rgba(255, 255, 255, 0.64); - border-top-width: 2px; - - border-left-style: solid; - border-left-color: rgba(255, 255, 255, 0.64); - border-left-width: 2px; - - border-right-style: solid; - border-right-color: rgba(255, 255, 255, 0.64); - border-right-width: 2px; -} +/* -------- Tabs -------- */ .tab-label { margin-left: 2em; margin-right: 2em; } .tab-close-bttn { - background: rgba(116, 0, 0, 0.64); - border-color: rgba(0, 0, 0, 0.64); - color: rgba(255, 255, 255, 0.64); - border-style: solid; - border-width: 1px; + background: rgba(200, 70, 70, 0.35); + border: 1px solid rgba(0, 0, 0, 0.4); + color: #ffffff; + transition: 120ms ease-in-out; } .tab-close-bttn:hover { - background: rgba(256, 0, 0, 0.64); + background: @accent_red; } +/* -------- File States -------- */ .file-changed { - color: rgba(255, 168, 0, 0.64); + color: @accent_orange; } .file-deleted { - color: rgba(255, 0, 0, 0.64); + color: @accent_red; } -.error-txt { color: rgb(170, 18, 18); } -.warning-txt { color: rgb(255, 168, 0); } -.success-txt { color: rgb(136, 204, 39); } + +/* -------- Search States -------- */ +.searching, +.search-success, +.search-fail { + border: 1px solid; +} + +.searching { + border-color: @accent_blue; +} + +.search-success { + background: rgba(136, 204, 39, 0.15); + border-color: @accent_green; +} + +.search-fail { + background: rgba(200, 70, 70, 0.15); + border-color: @accent_red; +} +/* -------- Message Colors -------- */ +.error-txt { color: @accent_red; } +.warning-txt { color: @accent_orange; } +.success-txt { color: @accent_green; } -/* - Need these because updating buffer with get_tag_table and tags updates minimap to the same size due to its mapping structure... - I've tried initial looks at: - https://github.com/johnfactotum/gedit-restore-minimap - which is re-adding minimap to gedit and they just used the below code snippit which still didn't work for me. - - desc = Pango.FontDescription(default_font) - desc.set_size(Pango.SCALE) # set size to 1pt - desc.set_family('BuilderBlocks,' + desc.get_family()) - self.source_map.set_property('font-desc', desc) - - So now we do this monstrocity until I can figure out what is needed to make something better work. - -*/ -.px1 { font-size: 1px; } -.px2 { font-size: 2px; } -.px3 { font-size: 3px; } -.px4 { font-size: 4px; } -.px5 { font-size: 5px; } -.px6 { font-size: 6px; } -.px7 { font-size: 7px; } -.px8 { font-size: 8px; } -.px9 { font-size: 9px; } -.px10 { font-size: 10px; } -.px11 { font-size: 11px; } -.px12 { font-size: 12px; } -.px13 { font-size: 13px; } -.px14 { font-size: 14px; } -.px15 { font-size: 15px; } -.px16 { font-size: 16px; } -.px17 { font-size: 17px; } -.px18 { font-size: 18px; } -.px19 { font-size: 19px; } -.px20 { font-size: 20px; } -.px21 { font-size: 21px; } -.px22 { font-size: 22px; } -.px23 { font-size: 23px; } -.px24 { font-size: 24px; } -.px25 { font-size: 25px; } -.px26 { font-size: 26px; } -.px27 { font-size: 27px; } -.px28 { font-size: 28px; } -.px29 { font-size: 29px; } -.px30 { font-size: 30px; } -.px31 { font-size: 31px; } -.px32 { font-size: 32px; } -.px33 { font-size: 33px; } -.px34 { font-size: 34px; } -.px35 { font-size: 35px; } -.px36 { font-size: 36px; } -.px37 { font-size: 37px; } -.px38 { font-size: 38px; } -.px39 { font-size: 39px; } -.px40 { font-size: 40px; } -.px41 { font-size: 41px; } -.px42 { font-size: 42px; } -.px43 { font-size: 43px; } -.px44 { font-size: 44px; } -.px45 { font-size: 45px; } -.px46 { font-size: 46px; } -.px47 { font-size: 47px; } -.px48 { font-size: 48px; } -.px49 { font-size: 49px; } -.px50 { font-size: 50px; } -.px51 { font-size: 51px; } -.px52 { font-size: 52px; } -.px53 { font-size: 53px; } -.px54 { font-size: 54px; } -.px55 { font-size: 55px; } -.px56 { font-size: 56px; } -.px57 { font-size: 57px; } -.px58 { font-size: 58px; } -.px59 { font-size: 59px; } -.px60 { font-size: 60px; } -.px61 { font-size: 61px; } -.px62 { font-size: 62px; } -.px63 { font-size: 63px; } -.px64 { font-size: 64px; } -.px65 { font-size: 65px; } -.px66 { font-size: 66px; } -.px67 { font-size: 67px; } -.px68 { font-size: 68px; } -.px69 { font-size: 69px; } -.px70 { font-size: 70px; } -.px71 { font-size: 71px; } -.px72 { font-size: 72px; } -.px73 { font-size: 73px; } -.px74 { font-size: 74px; } -.px75 { font-size: 75px; } -.px76 { font-size: 76px; } -.px77 { font-size: 77px; } -.px78 { font-size: 78px; } -.px79 { font-size: 79px; } -.px80 { font-size: 80px; } -.px81 { font-size: 81px; } -.px82 { font-size: 82px; } -.px83 { font-size: 83px; } -.px84 { font-size: 84px; } -.px85 { font-size: 85px; } -.px86 { font-size: 86px; } -.px87 { font-size: 87px; } -.px88 { font-size: 88px; } -.px89 { font-size: 89px; } -.px90 { font-size: 90px; } -.px91 { font-size: 91px; } -.px92 { font-size: 92px; } -.px93 { font-size: 93px; } -.px94 { font-size: 94px; } -.px95 { font-size: 95px; } -.px96 { font-size: 96px; } -.px97 { font-size: 97px; } -.px98 { font-size: 98px; } -.px99 { font-size: 99px; } - .mw_transparency_1 { background: rgba(39, 43, 52, 0.1); } @@ -366,4 +263,4 @@ tab:checked { .mw_transparency_96 { background: rgba(39, 43, 52, 0.96); } .mw_transparency_97 { background: rgba(39, 43, 52, 0.97); } .mw_transparency_98 { background: rgba(39, 43, 52, 0.98); } -.mw_transparency_99 { background: rgba(39, 43, 52, 0.99); } \ No newline at end of file +.mw_transparency_99 { background: rgba(39, 43, 52, 0.99); }