added transparancey scale; snippits plugin pre work; search and replace fixes

This commit is contained in:
itdominator 2023-10-21 19:00:09 -05:00
parent 7a343e39e8
commit 92e43b359b
13 changed files with 241 additions and 24 deletions

View File

@ -15,15 +15,15 @@ class ReplaceMixin:
iter = self._buffer.get_start_iter() iter = self._buffer.get_start_iter()
search_tag = self._tag_table.lookup(self.search_tag) search_tag = self._tag_table.lookup(self.search_tag)
iter.forward_to_tag_toggle(replace_text) iter.forward_to_tag_toggle(search_tag)
self._do_replace(iter, find_text) self._do_replace(iter, replace_text)
self._active_src_view.scroll_to_mark( self._buffer.get_insert(), 0.0, True, 0.0, 0.0 ) self._active_src_view.scroll_to_iter( iter, 0.0, True, 0.0, 0.0 )
self._buffer.end_user_action() self._buffer.end_user_action()
def replace_all(self, widget): def replace_all(self, widget):
replace_text = self._replace_entry.get_text() replace_text = self._replace_entry.get_text()
if self.find_text and replace_text: if self.find_text:
self._buffer.begin_user_action() self._buffer.begin_user_action()
mark = self._buffer.get_insert() mark = self._buffer.get_insert()

View File

@ -0,0 +1,3 @@
"""
Pligin Module
"""

View File

@ -0,0 +1,3 @@
"""
Pligin Package
"""

View File

@ -0,0 +1,12 @@
{
"manifest": {
"name": "Snippets",
"author": "ITDominator",
"version": "0.0.1",
"support": "",
"requests": {
"pass_events": "true",
"bind_keys": ["Snippets||show_snippets_ui:<Control>f"]
}
}
}

View File

@ -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))

View File

@ -18,23 +18,30 @@ class CoreWidget(Gtk.Box):
def __init__(self): def __init__(self):
super(CoreWidget, self).__init__() 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) builder.expose_object("core_widget", self)
self._setup_styling() self._setup_styling()
self._setup_signals() self._setup_signals()
self._subscribe_to_events()
self._load_widgets() self._load_widgets()
self.show() self.show()
def _setup_styling(self): def _setup_styling(self):
self.ctx.add_class("main-window")
self.set_orientation(1) # VERTICAL = 1 self.set_orientation(1) # VERTICAL = 1
def _setup_signals(self): 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): def _load_widgets(self):
SaveFileDialog() SaveFileDialog()
GeneralInfoWidget() GeneralInfoWidget()
@ -43,3 +50,9 @@ class CoreWidget(Gtk.Box):
self.add(Separator("separator_top")) self.add(Separator("separator_top"))
self.add(EditorsContainer()) self.add(EditorsContainer())
self.add(Separator("separator_botton")) 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}")

View File

@ -11,6 +11,7 @@ from ..controls.save_as_button import SaveAsButton
from ..controls.scale_up_button import ScaleUpButton from ..controls.scale_up_button import ScaleUpButton
from ..controls.scale_down_button import ScaleDownButton from ..controls.scale_down_button import ScaleDownButton
from ..controls.toggle_line_highlight import ToggleLineHighlight from ..controls.toggle_line_highlight import ToggleLineHighlight
from ..controls.transparency_scale import TransparencyScale
from ..controls.theme_button import ThemeButton from ..controls.theme_button import ThemeButton
@ -47,6 +48,8 @@ class BannerControls(Gtk.Box):
center_box.add(ScaleUpButton()) center_box.add(ScaleUpButton())
center_box.add(ScaleDownButton()) center_box.add(ScaleDownButton())
center_box.add(ToggleLineHighlight()) center_box.add(ToggleLineHighlight())
center_box.add(TransparencyScale())
center_box.set_margin_left(15) center_box.set_margin_left(15)
center_box.set_margin_right(15) center_box.set_margin_right(15)
self.set_center_widget(center_box) self.set_center_widget(center_box)

View File

@ -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")

View File

@ -26,6 +26,7 @@ class Window(Gtk.ApplicationWindow):
def __init__(self, args, unknownargs): def __init__(self, args, unknownargs):
super(Window, self).__init__() super(Window, self).__init__()
settings_manager.set_main_window(self)
self._controller = None self._controller = None
@ -34,7 +35,6 @@ class Window(Gtk.ApplicationWindow):
self._setup_signals() self._setup_signals()
self._subscribe_to_events() self._subscribe_to_events()
settings_manager.set_main_window(self)
self._load_widgets(args, unknownargs) self._load_widgets(args, unknownargs)
self._set_size_constraints() self._set_size_constraints()
@ -47,6 +47,9 @@ class Window(Gtk.ApplicationWindow):
self.set_gravity(5) # 5 = CENTER self.set_gravity(5) # 5 = CENTER
self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS self.set_position(1) # 1 = CENTER, 4 = CENTER_ALWAYS
ctx = self.get_style_context()
ctx.add_class("main-window")
def _setup_signals(self): def _setup_signals(self):
self.connect("delete-event", self._tear_down) self.connect("delete-event", self._tear_down)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, 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) 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") event_system.emit("shutting_down")
size = self.get_size() size = self.get_size()

View File

@ -73,13 +73,13 @@ class SettingsManager(StartCheckMixin, Singleton):
bindings = json.load(file)["keybindings"] bindings = json.load(file)["keybindings"]
keybindings.configure(bindings) keybindings.configure(bindings)
except Exception as e: 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: try:
with open(self._CONTEXT_MENU) as file: with open(self._CONTEXT_MENU) as file:
self._context_menu_data = json.load(file) self._context_menu_data = json.load(file)
except Exception as e: 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 self.settings: Settings = None

View File

@ -8,6 +8,7 @@ from dataclasses import dataclass
@dataclass @dataclass
class Theming: class Theming:
transparency: int = 64
default_zoom: int = 12 default_zoom: int = 12
syntax_theme: str = "tango" syntax_theme: str = "tango"
success_color: str = "#88cc27" success_color: str = "#88cc27"

View File

@ -110,6 +110,7 @@
] ]
}, },
"theming":{ "theming":{
"transparency":64,
"default_zoom":12, "default_zoom":12,
"syntax_theme":"solarized-dark", "syntax_theme":"solarized-dark",
"success_color":"#88cc27", "success_color":"#88cc27",

View File

@ -1,20 +1,20 @@
/* ---- make most desired things base transparent ---- */ /* ---- make most desired things base transparent ---- */
popover, popover,
popover > box popover > box
window > box, .main-window > box,
window > box > box, .main-window > box > box,
window > box > box > paned, .main-window > box > box > paned,
window > box > box > paned > notebook, .main-window > box > box > paned > notebook,
window > box > box > paned > notebook > stack, .main-window > box > box > paned > notebook > stack,
window > box > box > paned > notebook > stack > scrolledwindow > textview > * { .main-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 ---- */ /* ---- top controls ---- */
window > box > box > button, .main-window > box > box > button,
window > box > box > buttonbox > button { .main-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;
@ -22,7 +22,7 @@ window > box > box > buttonbox > button {
/* status bar */ /* status bar */
window > box > statusbar { .main-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;
@ -92,7 +92,9 @@ popover {
font-size: 1px; font-size: 1px;
} }
.mini-view > text {
background: rgba(39, 43, 52, 0.64);
}
/* other properties */ /* other properties */
@ -244,6 +246,103 @@ popover {
.px99 { font-size: 99px; } .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); }