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):
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
@ -76,4 +76,4 @@ class ControllerData:
proc = subprocess.Popen(['xclip','-selection','clipboard'], stdin=subprocess.PIPE)
proc.stdin.write(data.encode(encoding))
proc.stdin.close()
retcode = proc.wait()
retcode = proc.wait()

View File

@ -35,17 +35,21 @@ class EditorEventsMixin:
source_view.open_file(gfile)
else:
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):
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
page_num = self.page_num(container)
page_num = notebook.page_num(container)
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:
self.hide()
if notebook.NAME == "notebook_2" and notebook.get_n_pages() == 0:
notebook.hide()
event_system.emit("focused_target_changed", ("notebook_1",))
def keyboard_prev_tab(self, page_num):
page_num = self.get_n_pages() - 1 if page_num == 0 else page_num - 1
@ -112,6 +116,4 @@ class EditorEventsMixin:
def set_buffer_style(self, source_view, style = settings.theming.syntax_theme):
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):
self.is_editor_focused = True if target == self.NAME else False
self.grab_focus()
def _add_action_widgets(self):
start_box = Gtk.Box()