Fix focus logic when pane 2 is emptied and pane 1 alerted

This commit is contained in:
itdominator 2023-11-04 14:40:43 -05:00
parent 29b8935ebb
commit 3e883160aa
3 changed files with 14 additions and 11 deletions

View File

@ -28,7 +28,7 @@ class ControllerData:
def set_active_src_view(self, source_view): def set_active_src_view(self, source_view):
if self.active_src_view: if self.active_src_view:
self.active_src_view.get_parent().get_parent().is_editor_focused = False self.active_src_view.get_parent().is_editor_focused = False
self.active_src_view = source_view self.active_src_view = source_view

View File

@ -36,16 +36,20 @@ class EditorEventsMixin:
else: else:
self.create_view(None, None, gfile) self.create_view(None, None, gfile)
# Note: Need to get parent instead given we pass the close_tab method
# from a potentially former notebook.
def close_tab(self, button, container, source_view, eve = None): def close_tab(self, button, container, source_view, eve = None):
if self.NAME == "notebook_1" and self.get_n_pages() == 1: notebook = container.get_parent()
if notebook.NAME == "notebook_1" and notebook.get_n_pages() == 1:
return return
page_num = self.page_num(container) page_num = notebook.page_num(container)
source_view._cancel_current_file_watchers() source_view._cancel_current_file_watchers()
self.remove_page(page_num) notebook.remove_page(page_num)
if self.NAME == "notebook_2" and self.get_n_pages() == 0: if notebook.NAME == "notebook_2" and notebook.get_n_pages() == 0:
self.hide() notebook.hide()
event_system.emit("focused_target_changed", ("notebook_1",))
def keyboard_prev_tab(self, page_num): def keyboard_prev_tab(self, page_num):
page_num = self.get_n_pages() - 1 if page_num == 0 else page_num - 1 page_num = self.get_n_pages() - 1 if page_num == 0 else page_num - 1
@ -113,5 +117,3 @@ class EditorEventsMixin:
def set_buffer_style(self, source_view, style = settings.theming.syntax_theme): def set_buffer_style(self, source_view, style = settings.theming.syntax_theme):
buffer = source_view.get_buffer() buffer = source_view.get_buffer()
source_view.set_buffer_style(buffer, style) source_view.set_buffer_style(buffer, style)

View File

@ -81,6 +81,7 @@ class EditorNotebook(EditorControllerMixin, Gtk.Notebook):
def _focused_target_changed(self, target): def _focused_target_changed(self, target):
self.is_editor_focused = True if target == self.NAME else False self.is_editor_focused = True if target == self.NAME else False
self.grab_focus()
def _add_action_widgets(self): def _add_action_widgets(self):
start_box = Gtk.Box() start_box = Gtk.Box()