Added code load start files command; improved show logic for code widget
This commit is contained in:
@@ -21,7 +21,7 @@ class EditorsContainer(Gtk.Box):
|
|||||||
self._subscribe_to_events()
|
self._subscribe_to_events()
|
||||||
self._load_widgets()
|
self._load_widgets()
|
||||||
|
|
||||||
self.show()
|
self.show_all()
|
||||||
|
|
||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ class PanedEditorsContainer(Gtk.Paned):
|
|||||||
self._subscribe_to_events()
|
self._subscribe_to_events()
|
||||||
self._load_widgets()
|
self._load_widgets()
|
||||||
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
self.ctx = self.get_style_context()
|
self.ctx = self.get_style_context()
|
||||||
@@ -53,9 +51,6 @@ class PanedEditorsContainer(Gtk.Paned):
|
|||||||
self.add1(scrolled_win1)
|
self.add1(scrolled_win1)
|
||||||
self.add2(scrolled_win2)
|
self.add2(scrolled_win2)
|
||||||
|
|
||||||
scrolled_win1.show_all()
|
|
||||||
scrolled_win2.show_all()
|
|
||||||
|
|
||||||
def _init_map(self, view):
|
def _init_map(self, view):
|
||||||
def _first_show_init():
|
def _first_show_init():
|
||||||
self.disconnect(self.map_id)
|
self.disconnect(self.map_id)
|
||||||
@@ -65,8 +60,7 @@ class PanedEditorsContainer(Gtk.Paned):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# GLib.timeout_add(1000, _first_show_init)
|
GLib.timeout_add(200, _first_show_init)
|
||||||
GLib.idle_add(_first_show_init)
|
|
||||||
|
|
||||||
def _handle_first_show(self):
|
def _handle_first_show(self):
|
||||||
self.set_position(
|
self.set_position(
|
||||||
|
|||||||
42
src/core/widgets/code/commands/load_start_files.py
Normal file
42
src/core/widgets/code/commands/load_start_files.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Python imports
|
||||||
|
|
||||||
|
# Lib imports
|
||||||
|
import gi
|
||||||
|
|
||||||
|
gi.require_version('GtkSource', '4')
|
||||||
|
|
||||||
|
from gi.repository import GtkSource
|
||||||
|
from gi.repository import Gio
|
||||||
|
|
||||||
|
# Application imports
|
||||||
|
from ..source_file import SourceFile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def execute(
|
||||||
|
editor: GtkSource.View,
|
||||||
|
):
|
||||||
|
logger.debug("Load Start File(s) Command")
|
||||||
|
|
||||||
|
starting_files = settings_manager.get_starting_files()
|
||||||
|
|
||||||
|
if len(starting_files) == 0: return
|
||||||
|
|
||||||
|
file = starting_files.pop()
|
||||||
|
file = file.replace("FILE|", "")
|
||||||
|
gfile = Gio.File.new_for_path(file)
|
||||||
|
buffer = editor.get_buffer()
|
||||||
|
file = editor.files.get_file(buffer)
|
||||||
|
|
||||||
|
editor.command.exec_with_args(
|
||||||
|
"load_file",
|
||||||
|
(editor, gfile, file)
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(starting_files) == 0: return
|
||||||
|
|
||||||
|
for file in starting_files:
|
||||||
|
file = file.replace("FILE|", "")
|
||||||
|
gfile = Gio.File.new_for_path(file)
|
||||||
|
|
||||||
|
editor.command.exec_with_args("load_file", (editor, gfile))
|
||||||
@@ -19,8 +19,6 @@ class MiniViewWidget(Map):
|
|||||||
self._subscribe_to_events()
|
self._subscribe_to_events()
|
||||||
self._load_widgets()
|
self._load_widgets()
|
||||||
|
|
||||||
self.show_all()
|
|
||||||
|
|
||||||
|
|
||||||
def _setup_styling(self):
|
def _setup_styling(self):
|
||||||
self.set_hexpand(False)
|
self.set_hexpand(False)
|
||||||
|
|||||||
@@ -71,15 +71,10 @@ class SourceView(SourceViewEventsMixin, SourceViewDnDMixin, GtkSource.View):
|
|||||||
self._set_up_dnd()
|
self._set_up_dnd()
|
||||||
|
|
||||||
def _init_map(self, view):
|
def _init_map(self, view):
|
||||||
def _init_first_show():
|
self.disconnect(self.map_id)
|
||||||
self.disconnect(self.map_id)
|
del self.map_id
|
||||||
del self.map_id
|
|
||||||
|
|
||||||
self._init_show()
|
GLib.idle_add(self._init_show)
|
||||||
|
|
||||||
return False
|
|
||||||
|
|
||||||
GLib.idle_add(_init_first_show)
|
|
||||||
|
|
||||||
def _init_show(self):
|
def _init_show(self):
|
||||||
self.language_manager = GtkSource.LanguageManager()
|
self.language_manager = GtkSource.LanguageManager()
|
||||||
@@ -98,12 +93,13 @@ class SourceView(SourceViewEventsMixin, SourceViewDnDMixin, GtkSource.View):
|
|||||||
f"{settings_manager.settings.theming.syntax_theme}"
|
f"{settings_manager.settings.theming.syntax_theme}"
|
||||||
)
|
)
|
||||||
|
|
||||||
def _inner_init():
|
self.connect("focus-in-event", self._focus_in_event)
|
||||||
self.connect("focus-in-event", self._focus_in_event)
|
|
||||||
self.command.exec("new_file")
|
|
||||||
|
|
||||||
if self.sibling_right:
|
self.command.exec("new_file")
|
||||||
self.grab_focus()
|
if not self.sibling_right: return
|
||||||
self._focus_in_event(None, None)
|
|
||||||
|
|
||||||
GLib.idle_add(_inner_init)
|
self.grab_focus()
|
||||||
|
self._focus_in_event(None, None)
|
||||||
|
self.command.exec("load_start_files")
|
||||||
|
|
||||||
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user