generated from itdominator/Python-With-Gtk-Template
Updated themeing css; temporary fix for zoom + mini view conflicts; cleanup
This commit is contained in:
parent
2aa9d3afd9
commit
0e940aa4f0
@ -25,22 +25,21 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||||||
self._language_manager = GtkSource.LanguageManager()
|
self._language_manager = GtkSource.LanguageManager()
|
||||||
self._style_scheme_manager = GtkSource.StyleSchemeManager()
|
self._style_scheme_manager = GtkSource.StyleSchemeManager()
|
||||||
|
|
||||||
self._general_style_tag = None
|
|
||||||
self._file_loader = None
|
self._file_loader = None
|
||||||
self._file_change_watcher = None
|
self._file_change_watcher = None
|
||||||
self._file_cdr_watcher = None
|
self._file_cdr_watcher = None
|
||||||
self._last_eve_in_queue = None
|
|
||||||
self._current_file: Gio.File = None
|
self._current_file: Gio.File = None
|
||||||
|
|
||||||
self._current_filename: str = ""
|
self._current_filename: str = ""
|
||||||
self._current_filepath: str = None
|
self._current_filepath: str = None
|
||||||
self._current_filetype: str = "buffer"
|
self._current_filetype: str = "buffer"
|
||||||
|
|
||||||
self.skip_file_load = False
|
self._skip_file_load = False
|
||||||
self._is_changed = False
|
self._is_changed = False
|
||||||
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._multi_insert_marks = []
|
self._multi_insert_marks = []
|
||||||
self.freeze_multi_line_insert = False
|
self.freeze_multi_line_insert = False
|
||||||
@ -53,6 +52,9 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||||||
|
|
||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
|
ctx = self.get_style_context()
|
||||||
|
ctx.add_class("source-view")
|
||||||
|
|
||||||
self.set_show_line_marks(True)
|
self.set_show_line_marks(True)
|
||||||
self.set_show_line_numbers(True)
|
self.set_show_line_numbers(True)
|
||||||
self.set_smart_backspace(True)
|
self.set_smart_backspace(True)
|
||||||
@ -71,6 +73,7 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||||||
|
|
||||||
self.set_vexpand(True)
|
self.set_vexpand(True)
|
||||||
|
|
||||||
|
|
||||||
def _setup_signals(self):
|
def _setup_signals(self):
|
||||||
self.connect("focus", self._on_widget_focus)
|
self.connect("focus", self._on_widget_focus)
|
||||||
self.connect("focus-in-event", self._focus_in_event)
|
self.connect("focus-in-event", self._focus_in_event)
|
||||||
@ -108,9 +111,9 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||||||
|
|
||||||
|
|
||||||
def _create_default_tag(self):
|
def _create_default_tag(self):
|
||||||
self._general_style_tag = self._buffer.create_tag('general_style')
|
general_style_tag = self._buffer.create_tag('general_style')
|
||||||
self._general_style_tag.set_property('size', 100)
|
general_style_tag.set_property('size', 100)
|
||||||
self._general_style_tag.set_property('scale', 100)
|
general_style_tag.set_property('scale', 100)
|
||||||
|
|
||||||
def _is_modified(self, *args):
|
def _is_modified(self, *args):
|
||||||
self._is_changed = True
|
self._is_changed = True
|
||||||
@ -148,9 +151,10 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||||||
|
|
||||||
def _on_cursor_move(self, buf, cursor_iter, mark, user_data = None):
|
def _on_cursor_move(self, buf, cursor_iter, mark, user_data = None):
|
||||||
if mark != buf.get_insert(): return
|
if mark != buf.get_insert(): return
|
||||||
|
|
||||||
self.update_cursor_position()
|
self.update_cursor_position()
|
||||||
|
|
||||||
# NOTE: Not sure but this might not be efficient if the map reloads the same view.
|
# NOTE: Not sure but this might not be efficient if the map reloads the same view...
|
||||||
event_system.emit(f"set_source_view", (self,))
|
event_system.emit(f"set_source_view", (self,))
|
||||||
|
|
||||||
def _button_release_event(self, widget = None, eve = None, user_data = None):
|
def _button_release_event(self, widget = None, eve = None, user_data = None):
|
||||||
@ -171,8 +175,7 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||||||
self.drag_dest_set_target_list(targets)
|
self.drag_dest_set_target_list(targets)
|
||||||
|
|
||||||
def _on_drag_data_received(self, widget, drag_context, x, y, data, info, time):
|
def _on_drag_data_received(self, widget, drag_context, x, y, data, info, time):
|
||||||
if info == 70:
|
if info == 70: return
|
||||||
return
|
|
||||||
|
|
||||||
if info == 80:
|
if info == 80:
|
||||||
uris = data.get_uris()
|
uris = data.get_uris()
|
||||||
@ -209,8 +212,7 @@ class SourceView(SourceViewEventsMixin, GtkSource.View):
|
|||||||
self._file_change_watcher.connect("changed", self._file_monitor)
|
self._file_change_watcher.connect("changed", self._file_monitor)
|
||||||
|
|
||||||
def _file_monitor(self, file_monitor, file, other_file = None, eve_type = None, data = None):
|
def _file_monitor(self, file_monitor, file, other_file = None, eve_type = None, data = None):
|
||||||
if not file.get_path() == self._current_file.get_path():
|
if not file.get_path() == self._current_file.get_path(): return
|
||||||
return
|
|
||||||
|
|
||||||
if eve_type in [Gio.FileMonitorEvent.CREATED,
|
if eve_type in [Gio.FileMonitorEvent.CREATED,
|
||||||
Gio.FileMonitorEvent.DELETED,
|
Gio.FileMonitorEvent.DELETED,
|
||||||
|
@ -26,21 +26,39 @@ class SourceViewEventsMixin:
|
|||||||
self.set_highlight_current_line( not self.get_highlight_current_line() )
|
self.set_highlight_current_line( not self.get_highlight_current_line() )
|
||||||
|
|
||||||
def scale_up_text(self, scale_step = 10):
|
def scale_up_text(self, scale_step = 10):
|
||||||
current_scale = self._general_style_tag.get_property('scale')
|
ctx = self.get_style_context()
|
||||||
start_itr = self._buffer.get_start_iter()
|
|
||||||
end_itr = self._buffer.get_end_iter()
|
|
||||||
|
|
||||||
self._general_style_tag.set_property('scale', current_scale + scale_step)
|
if self.px_value < 99:
|
||||||
self._buffer.apply_tag(self._general_style_tag, start_itr, end_itr)
|
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()
|
||||||
|
# start_itr = self._buffer.get_start_iter()
|
||||||
|
# end_itr = self._buffer.get_end_iter()
|
||||||
|
# tag = tag_table.lookup('general_style')
|
||||||
|
#
|
||||||
|
# tag.set_property('scale', tag.get_property('scale') + scale_step)
|
||||||
|
# self._buffer.apply_tag(tag, start_itr, end_itr)
|
||||||
|
|
||||||
def scale_down_text(self, scale_step = 10):
|
def scale_down_text(self, scale_step = 10):
|
||||||
tag_table = self._buffer.get_tag_table()
|
ctx = self.get_style_context()
|
||||||
start_itr = self._buffer.get_start_iter()
|
|
||||||
end_itr = self._buffer.get_end_iter()
|
|
||||||
tag = tag_table.lookup('general_style')
|
|
||||||
|
|
||||||
tag.set_property('scale', tag.get_property('scale') - scale_step)
|
ctx.remove_class(f"px{self.px_value}")
|
||||||
self._buffer.apply_tag(tag, start_itr, end_itr)
|
if self.px_value > 1:
|
||||||
|
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()
|
||||||
|
# start_itr = self._buffer.get_start_iter()
|
||||||
|
# end_itr = self._buffer.get_end_iter()
|
||||||
|
# tag = tag_table.lookup('general_style')
|
||||||
|
#
|
||||||
|
# tag.set_property('scale', tag.get_property('scale') - scale_step)
|
||||||
|
# self._buffer.apply_tag(tag, start_itr, end_itr)
|
||||||
|
|
||||||
def update_cursor_position(self):
|
def update_cursor_position(self):
|
||||||
iter = self._buffer.get_iter_at_mark( self._buffer.get_insert() )
|
iter = self._buffer.get_iter_at_mark( self._buffer.get_insert() )
|
||||||
@ -103,15 +121,15 @@ class SourceViewEventsMixin:
|
|||||||
self._create_file_watcher(gfile)
|
self._create_file_watcher(gfile)
|
||||||
|
|
||||||
def save_file(self):
|
def save_file(self):
|
||||||
self.skip_file_load = True
|
self._skip_file_load = True
|
||||||
gfile = event_system.emit_and_await("save_file_dialog", (self._current_filename, self._current_file)) if not self._current_file else self._current_file
|
gfile = event_system.emit_and_await("save_file_dialog", (self._current_filename, self._current_file)) if not self._current_file else self._current_file
|
||||||
|
|
||||||
if not gfile:
|
if not gfile:
|
||||||
self.skip_file_load = False
|
self._skip_file_load = False
|
||||||
return
|
return
|
||||||
|
|
||||||
self.open_file( self._write_file(gfile) )
|
self.open_file( self._write_file(gfile) )
|
||||||
self.skip_file_load = False
|
self._skip_file_load = False
|
||||||
|
|
||||||
def save_file_as(self):
|
def save_file_as(self):
|
||||||
gfile = event_system.emit_and_await("save_file_dialog", (self._current_filename, self._current_file))
|
gfile = event_system.emit_and_await("save_file_dialog", (self._current_filename, self._current_file))
|
||||||
@ -136,7 +154,7 @@ class SourceViewEventsMixin:
|
|||||||
self._current_filetype = info.get_content_type()
|
self._current_filetype = info.get_content_type()
|
||||||
|
|
||||||
def load_file_async(self, gfile, line: int = 0):
|
def load_file_async(self, gfile, line: int = 0):
|
||||||
if self.skip_file_load:
|
if self._skip_file_load:
|
||||||
self.update_labels(gfile)
|
self.update_labels(gfile)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -24,12 +24,14 @@ class MiniViewWidget(Map):
|
|||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
self.set_hexpand(False)
|
self.set_hexpand(False)
|
||||||
|
ctx = self.get_style_context()
|
||||||
|
ctx.add_class("mini-view")
|
||||||
|
|
||||||
def _setup_signals(self):
|
def _setup_signals(self):
|
||||||
event_system.subscribe(f"set_source_view", self.set_source_view)
|
...
|
||||||
|
|
||||||
def _subscribe_to_events(self):
|
def _subscribe_to_events(self):
|
||||||
...
|
event_system.subscribe(f"set_source_view", self.set_source_view)
|
||||||
|
|
||||||
def _load_widgets(self):
|
def _load_widgets(self):
|
||||||
...
|
...
|
||||||
|
@ -1,8 +1,36 @@
|
|||||||
* {
|
/* Make most desired things base transparent */
|
||||||
background: rgba(39, 43, 52, 0.24);
|
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 > * {
|
||||||
|
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
|
||||||
|
window > box > box > buttonbox > button {
|
||||||
|
background: rgba(39, 43, 52, 0.64);
|
||||||
|
margin-left: 12px;
|
||||||
|
margin-right: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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 {
|
||||||
|
background: rgba(39, 43, 52, 0.64);
|
||||||
|
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 */
|
||||||
@ -11,6 +39,138 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.source-view,
|
||||||
|
.mini-view {
|
||||||
|
font-family: Monospace;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.error_txt { color: rgb(170, 18, 18); }
|
.error_txt { color: rgb(170, 18, 18); }
|
||||||
.warning_txt { color: rgb(255, 168, 0); }
|
.warning_txt { color: rgb(255, 168, 0); }
|
||||||
.success_txt { color: rgb(136, 204, 39); }
|
.success_txt { color: rgb(136, 204, 39); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
.mini-view { font-size: 1px; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
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; }
|
||||||
|
.source-view,
|
||||||
|
.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; }
|
||||||
|
Loading…
Reference in New Issue
Block a user