From 92e43b359bda5aa9eb5c33a71263234bc0dc88ac Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sat, 21 Oct 2023 19:00:09 -0500 Subject: [PATCH] added transparancey scale; snippits plugin pre work; search and replace fixes --- plugins/search_replace/replace_mixin.py | 8 +- plugins/snippets/__init__.py | 3 + plugins/snippets/__main__.py | 3 + plugins/snippets/manifest.json | 12 ++ plugins/snippets/plugin.py | 31 +++++ src/core/core_widget.py | 17 ++- src/core/widgets/base/banner_controls.py | 3 + .../widgets/controls/transparency_scale.py | 48 +++++++ src/core/window.py | 7 +- src/utils/settings_manager/manager.py | 4 +- src/utils/settings_manager/options/theming.py | 3 +- user_config/usr/share/newton/settings.json | 1 + user_config/usr/share/newton/stylesheet.css | 125 ++++++++++++++++-- 13 files changed, 241 insertions(+), 24 deletions(-) create mode 100644 plugins/snippets/__init__.py create mode 100644 plugins/snippets/__main__.py create mode 100644 plugins/snippets/manifest.json create mode 100644 plugins/snippets/plugin.py create mode 100644 src/core/widgets/controls/transparency_scale.py diff --git a/plugins/search_replace/replace_mixin.py b/plugins/search_replace/replace_mixin.py index e129e57..9d5a2f0 100644 --- a/plugins/search_replace/replace_mixin.py +++ b/plugins/search_replace/replace_mixin.py @@ -15,15 +15,15 @@ class ReplaceMixin: iter = self._buffer.get_start_iter() search_tag = self._tag_table.lookup(self.search_tag) - iter.forward_to_tag_toggle(replace_text) - self._do_replace(iter, find_text) - self._active_src_view.scroll_to_mark( self._buffer.get_insert(), 0.0, True, 0.0, 0.0 ) + iter.forward_to_tag_toggle(search_tag) + self._do_replace(iter, replace_text) + self._active_src_view.scroll_to_iter( iter, 0.0, True, 0.0, 0.0 ) self._buffer.end_user_action() def replace_all(self, widget): replace_text = self._replace_entry.get_text() - if self.find_text and replace_text: + if self.find_text: self._buffer.begin_user_action() mark = self._buffer.get_insert() diff --git a/plugins/snippets/__init__.py b/plugins/snippets/__init__.py new file mode 100644 index 0000000..d36fa8c --- /dev/null +++ b/plugins/snippets/__init__.py @@ -0,0 +1,3 @@ +""" + Pligin Module +""" diff --git a/plugins/snippets/__main__.py b/plugins/snippets/__main__.py new file mode 100644 index 0000000..a576329 --- /dev/null +++ b/plugins/snippets/__main__.py @@ -0,0 +1,3 @@ +""" + Pligin Package +""" diff --git a/plugins/snippets/manifest.json b/plugins/snippets/manifest.json new file mode 100644 index 0000000..b5ce2b7 --- /dev/null +++ b/plugins/snippets/manifest.json @@ -0,0 +1,12 @@ +{ + "manifest": { + "name": "Snippets", + "author": "ITDominator", + "version": "0.0.1", + "support": "", + "requests": { + "pass_events": "true", + "bind_keys": ["Snippets||show_snippets_ui:f"] + } + } +} \ No newline at end of file diff --git a/plugins/snippets/plugin.py b/plugins/snippets/plugin.py new file mode 100644 index 0000000..1c37437 --- /dev/null +++ b/plugins/snippets/plugin.py @@ -0,0 +1,31 @@ +# Python imports + +# Lib imports +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk + +# Application imports +from plugins.plugin_base import PluginBase + + + +class Plugin(PluginBase): + def __init__(self): + super().__init__() + + self.name = "Snippets" # NOTE: Need to remove after establishing private bidirectional 1-1 message bus + # where self.name should not be needed for message comms + + + def generate_reference_ui_element(self): + button = Gtk.Button(label=self.name) + button.connect("button-release-event", self.send_message) + return button + + def run(self): + ... + + def send_message(self, widget=None, eve=None): + message = "Hello, World!" + event_system.emit("display_message", ("warning", message, None)) \ No newline at end of file diff --git a/src/core/core_widget.py b/src/core/core_widget.py index 391b25b..5f7fd3c 100644 --- a/src/core/core_widget.py +++ b/src/core/core_widget.py @@ -18,23 +18,30 @@ class CoreWidget(Gtk.Box): def __init__(self): super(CoreWidget, self).__init__() - builder = settings_manager.get_builder() + builder = settings_manager.get_builder() + self.ctx = self.get_style_context() builder.expose_object("core_widget", self) + self._setup_styling() self._setup_signals() + self._subscribe_to_events() self._load_widgets() self.show() def _setup_styling(self): + self.ctx.add_class("main-window") self.set_orientation(1) # VERTICAL = 1 - def _setup_signals(self): ... + def _subscribe_to_events(self): + event_system.subscribe("update_transparency", self._update_transparency) + event_system.subscribe("remove_transparency", self._remove_transparency) + def _load_widgets(self): SaveFileDialog() GeneralInfoWidget() @@ -43,3 +50,9 @@ class CoreWidget(Gtk.Box): self.add(Separator("separator_top")) self.add(EditorsContainer()) self.add(Separator("separator_botton")) + + def _update_transparency(self): + self.ctx.add_class(f"mw_transparency_{settings.theming.transparency}") + + def _remove_transparency(self): + self.ctx.remove_class(f"mw_transparency_{settings.theming.transparency}") diff --git a/src/core/widgets/base/banner_controls.py b/src/core/widgets/base/banner_controls.py index b96d54e..3100424 100644 --- a/src/core/widgets/base/banner_controls.py +++ b/src/core/widgets/base/banner_controls.py @@ -11,6 +11,7 @@ from ..controls.save_as_button import SaveAsButton from ..controls.scale_up_button import ScaleUpButton from ..controls.scale_down_button import ScaleDownButton from ..controls.toggle_line_highlight import ToggleLineHighlight +from ..controls.transparency_scale import TransparencyScale from ..controls.theme_button import ThemeButton @@ -47,6 +48,8 @@ class BannerControls(Gtk.Box): center_box.add(ScaleUpButton()) center_box.add(ScaleDownButton()) center_box.add(ToggleLineHighlight()) + center_box.add(TransparencyScale()) + center_box.set_margin_left(15) center_box.set_margin_right(15) self.set_center_widget(center_box) diff --git a/src/core/widgets/controls/transparency_scale.py b/src/core/widgets/controls/transparency_scale.py new file mode 100644 index 0000000..f38ecae --- /dev/null +++ b/src/core/widgets/controls/transparency_scale.py @@ -0,0 +1,48 @@ +# Python imports + +# Lib imports +import gi +gi.require_version('Gtk', '3.0') +from gi.repository import Gtk + +# Application imports + + + +class TransparencyScale(Gtk.Scale): + def __init__(self): + super(TransparencyScale, self).__init__() + + + self._setup_styling() + self._setup_signals() + self._subscribe_to_events() + self._load_widgets() + + self.show_all() + + + def _setup_styling(self): + self.set_digits(0) + self.set_value_pos(Gtk.PositionType.RIGHT) + self.add_mark(50.0, Gtk.PositionType.TOP, "50%") + + + def _setup_signals(self): + self.connect("value-changed", self._update_transparency) + + def _subscribe_to_events(self): + ... + + def _load_widgets(self): + adjust = self.get_adjustment() + adjust.set_lower(0) + adjust.set_upper(99) + adjust.set_value(settings.theming.transparency) + adjust.set_step_increment(1.0) + + def _update_transparency(self, range): + event_system.emit("remove_transparency") + tp = int(range.get_value()) + settings.theming.transparency = tp + event_system.emit("update_transparency") diff --git a/src/core/window.py b/src/core/window.py index 17e98ef..66b374a 100644 --- a/src/core/window.py +++ b/src/core/window.py @@ -26,6 +26,7 @@ class Window(Gtk.ApplicationWindow): def __init__(self, args, unknownargs): super(Window, self).__init__() + settings_manager.set_main_window(self) self._controller = None @@ -34,7 +35,6 @@ class Window(Gtk.ApplicationWindow): self._setup_signals() self._subscribe_to_events() - settings_manager.set_main_window(self) self._load_widgets(args, unknownargs) self._set_size_constraints() @@ -47,6 +47,9 @@ class Window(Gtk.ApplicationWindow): self.set_gravity(5) # 5 = CENTER self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS + ctx = self.get_style_context() + ctx.add_class("main-window") + def _setup_signals(self): self.connect("delete-event", self._tear_down) GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, self._tear_down) @@ -99,7 +102,7 @@ class Window(Gtk.ApplicationWindow): cr.set_operator(cairo.OPERATOR_OVER) - def _tear_down(self, widget=None, eve=None): + def _tear_down(self, widget = None, eve = None): event_system.emit("shutting_down") size = self.get_size() diff --git a/src/utils/settings_manager/manager.py b/src/utils/settings_manager/manager.py index 9f02d5f..b37b78c 100644 --- a/src/utils/settings_manager/manager.py +++ b/src/utils/settings_manager/manager.py @@ -73,13 +73,13 @@ class SettingsManager(StartCheckMixin, Singleton): bindings = json.load(file)["keybindings"] keybindings.configure(bindings) except Exception as e: - print( f"Settings: {self._KEY_BINDINGS_FILE}\n\t\t{repr(e)}" ) + print( f"Settings Manager: {self._KEY_BINDINGS_FILE}\n\t\t{repr(e)}" ) try: with open(self._CONTEXT_MENU) as file: self._context_menu_data = json.load(file) except Exception as e: - print( f"Settings: {self._CONTEXT_MENU}\n\t\t{repr(e)}" ) + print( f"Settings Manager: {self._CONTEXT_MENU}\n\t\t{repr(e)}" ) self.settings: Settings = None diff --git a/src/utils/settings_manager/options/theming.py b/src/utils/settings_manager/options/theming.py index 7a2c587..8a4fdc9 100644 --- a/src/utils/settings_manager/options/theming.py +++ b/src/utils/settings_manager/options/theming.py @@ -8,8 +8,9 @@ from dataclasses import dataclass @dataclass class Theming: + transparency: int = 64 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 + error_color: str = "#ff0000" diff --git a/user_config/usr/share/newton/settings.json b/user_config/usr/share/newton/settings.json index 1515094..44c27c9 100644 --- a/user_config/usr/share/newton/settings.json +++ b/user_config/usr/share/newton/settings.json @@ -110,6 +110,7 @@ ] }, "theming":{ + "transparency":64, "default_zoom":12, "syntax_theme":"solarized-dark", "success_color":"#88cc27", diff --git a/user_config/usr/share/newton/stylesheet.css b/user_config/usr/share/newton/stylesheet.css index 8b0b3a8..ee7c629 100644 --- a/user_config/usr/share/newton/stylesheet.css +++ b/user_config/usr/share/newton/stylesheet.css @@ -1,20 +1,20 @@ /* ---- make most desired things base transparent ---- */ popover, popover > box -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 > * { +.main-window > box, +.main-window > box > box, +.main-window > box > box > paned, +.main-window > box > box > paned > notebook, +.main-window > box > box > paned > notebook > stack, +.main-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, -window > box > box > buttonbox > button { +.main-window > box > box > button, +.main-window > box > box > buttonbox > button { background: rgba(39, 43, 52, 0.64); margin-left: 12px; margin-right: 12px; @@ -22,7 +22,7 @@ window > box > box > buttonbox > button { /* status bar */ -window > box > statusbar { +.main-window > box > statusbar { background: rgba(39, 43, 52, 0.64); padding-left: 96px; padding-right: 96px; @@ -92,7 +92,9 @@ popover { font-size: 1px; } - +.mini-view > text { + background: rgba(39, 43, 52, 0.64); +} /* other properties */ @@ -244,6 +246,103 @@ popover { .px99 { font-size: 99px; } -.mini-view > text { - background: rgba(39, 43, 52, 0.64); -} + +.mw_transparency_1 { background: rgba(39, 43, 52, 0.1); } +.mw_transparency_2 { background: rgba(39, 43, 52, 0.2); } +.mw_transparency_3 { background: rgba(39, 43, 52, 0.3); } +.mw_transparency_4 { background: rgba(39, 43, 52, 0.4); } +.mw_transparency_5 { background: rgba(39, 43, 52, 0.5); } +.mw_transparency_6 { background: rgba(39, 43, 52, 0.6); } +.mw_transparency_7 { background: rgba(39, 43, 52, 0.7); } +.mw_transparency_8 { background: rgba(39, 43, 52, 0.8); } +.mw_transparency_9 { background: rgba(39, 43, 52, 0.9); } +.mw_transparency_10 { background: rgba(39, 43, 52, 0.10); } +.mw_transparency_11 { background: rgba(39, 43, 52, 0.11); } +.mw_transparency_12 { background: rgba(39, 43, 52, 0.12); } +.mw_transparency_13 { background: rgba(39, 43, 52, 0.13); } +.mw_transparency_14 { background: rgba(39, 43, 52, 0.14); } +.mw_transparency_15 { background: rgba(39, 43, 52, 0.15); } +.mw_transparency_16 { background: rgba(39, 43, 52, 0.16); } +.mw_transparency_17 { background: rgba(39, 43, 52, 0.17); } +.mw_transparency_18 { background: rgba(39, 43, 52, 0.18); } +.mw_transparency_19 { background: rgba(39, 43, 52, 0.19); } +.mw_transparency_20 { background: rgba(39, 43, 52, 0.20); } +.mw_transparency_21 { background: rgba(39, 43, 52, 0.21); } +.mw_transparency_22 { background: rgba(39, 43, 52, 0.22); } +.mw_transparency_23 { background: rgba(39, 43, 52, 0.23); } +.mw_transparency_24 { background: rgba(39, 43, 52, 0.24); } +.mw_transparency_25 { background: rgba(39, 43, 52, 0.25); } +.mw_transparency_26 { background: rgba(39, 43, 52, 0.26); } +.mw_transparency_27 { background: rgba(39, 43, 52, 0.27); } +.mw_transparency_28 { background: rgba(39, 43, 52, 0.28); } +.mw_transparency_29 { background: rgba(39, 43, 52, 0.29); } +.mw_transparency_30 { background: rgba(39, 43, 52, 0.30); } +.mw_transparency_31 { background: rgba(39, 43, 52, 0.31); } +.mw_transparency_32 { background: rgba(39, 43, 52, 0.32); } +.mw_transparency_33 { background: rgba(39, 43, 52, 0.33); } +.mw_transparency_34 { background: rgba(39, 43, 52, 0.34); } +.mw_transparency_35 { background: rgba(39, 43, 52, 0.35); } +.mw_transparency_36 { background: rgba(39, 43, 52, 0.36); } +.mw_transparency_37 { background: rgba(39, 43, 52, 0.37); } +.mw_transparency_38 { background: rgba(39, 43, 52, 0.38); } +.mw_transparency_39 { background: rgba(39, 43, 52, 0.39); } +.mw_transparency_40 { background: rgba(39, 43, 52, 0.40); } +.mw_transparency_41 { background: rgba(39, 43, 52, 0.41); } +.mw_transparency_42 { background: rgba(39, 43, 52, 0.42); } +.mw_transparency_43 { background: rgba(39, 43, 52, 0.43); } +.mw_transparency_44 { background: rgba(39, 43, 52, 0.44); } +.mw_transparency_45 { background: rgba(39, 43, 52, 0.45); } +.mw_transparency_46 { background: rgba(39, 43, 52, 0.46); } +.mw_transparency_47 { background: rgba(39, 43, 52, 0.47); } +.mw_transparency_48 { background: rgba(39, 43, 52, 0.48); } +.mw_transparency_49 { background: rgba(39, 43, 52, 0.49); } +.mw_transparency_50 { background: rgba(39, 43, 52, 0.50); } +.mw_transparency_51 { background: rgba(39, 43, 52, 0.51); } +.mw_transparency_52 { background: rgba(39, 43, 52, 0.52); } +.mw_transparency_53 { background: rgba(39, 43, 52, 0.53); } +.mw_transparency_54 { background: rgba(39, 43, 52, 0.54); } +.mw_transparency_55 { background: rgba(39, 43, 52, 0.55); } +.mw_transparency_56 { background: rgba(39, 43, 52, 0.56); } +.mw_transparency_57 { background: rgba(39, 43, 52, 0.57); } +.mw_transparency_58 { background: rgba(39, 43, 52, 0.58); } +.mw_transparency_59 { background: rgba(39, 43, 52, 0.59); } +.mw_transparency_60 { background: rgba(39, 43, 52, 0.60); } +.mw_transparency_61 { background: rgba(39, 43, 52, 0.61); } +.mw_transparency_62 { background: rgba(39, 43, 52, 0.62); } +.mw_transparency_63 { background: rgba(39, 43, 52, 0.63); } +.mw_transparency_64 { background: rgba(39, 43, 52, 0.64); } +.mw_transparency_65 { background: rgba(39, 43, 52, 0.65); } +.mw_transparency_66 { background: rgba(39, 43, 52, 0.66); } +.mw_transparency_67 { background: rgba(39, 43, 52, 0.67); } +.mw_transparency_68 { background: rgba(39, 43, 52, 0.68); } +.mw_transparency_69 { background: rgba(39, 43, 52, 0.69); } +.mw_transparency_70 { background: rgba(39, 43, 52, 0.70); } +.mw_transparency_71 { background: rgba(39, 43, 52, 0.71); } +.mw_transparency_72 { background: rgba(39, 43, 52, 0.72); } +.mw_transparency_73 { background: rgba(39, 43, 52, 0.73); } +.mw_transparency_74 { background: rgba(39, 43, 52, 0.74); } +.mw_transparency_75 { background: rgba(39, 43, 52, 0.75); } +.mw_transparency_76 { background: rgba(39, 43, 52, 0.76); } +.mw_transparency_77 { background: rgba(39, 43, 52, 0.77); } +.mw_transparency_78 { background: rgba(39, 43, 52, 0.78); } +.mw_transparency_79 { background: rgba(39, 43, 52, 0.79); } +.mw_transparency_80 { background: rgba(39, 43, 52, 0.80); } +.mw_transparency_81 { background: rgba(39, 43, 52, 0.81); } +.mw_transparency_82 { background: rgba(39, 43, 52, 0.82); } +.mw_transparency_83 { background: rgba(39, 43, 52, 0.83); } +.mw_transparency_84 { background: rgba(39, 43, 52, 0.84); } +.mw_transparency_85 { background: rgba(39, 43, 52, 0.85); } +.mw_transparency_86 { background: rgba(39, 43, 52, 0.86); } +.mw_transparency_87 { background: rgba(39, 43, 52, 0.87); } +.mw_transparency_88 { background: rgba(39, 43, 52, 0.88); } +.mw_transparency_89 { background: rgba(39, 43, 52, 0.89); } +.mw_transparency_90 { background: rgba(39, 43, 52, 0.90); } +.mw_transparency_91 { background: rgba(39, 43, 52, 0.91); } +.mw_transparency_92 { background: rgba(39, 43, 52, 0.92); } +.mw_transparency_93 { background: rgba(39, 43, 52, 0.93); } +.mw_transparency_94 { background: rgba(39, 43, 52, 0.94); } +.mw_transparency_95 { background: rgba(39, 43, 52, 0.95); } +.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); }