develop #12
Binary file not shown.
@ -77,8 +77,7 @@ class Controller(UIMixin, SignalsMixins, Controller_Data):
|
||||
event_system.subscribe("set_clipboard_data", self.set_clipboard_data)
|
||||
|
||||
def _load_glade_file(self):
|
||||
self.builder = Gtk.Builder()
|
||||
self.builder.add_from_file(settings_manager.get_glade_file())
|
||||
self.builder.add_from_file( settings_manager.get_glade_file() )
|
||||
self.builder.expose_object("main_window", self.window)
|
||||
|
||||
self.core_widget = self.builder.get_object("core_widget")
|
||||
|
@ -35,13 +35,39 @@ class State:
|
||||
user_pass_dialog: type = None
|
||||
|
||||
|
||||
|
||||
class SFMBuilder(Gtk.Builder):
|
||||
"""docstring for SFMBuilder."""
|
||||
|
||||
def __init__(self):
|
||||
super(SFMBuilder, self).__init__()
|
||||
|
||||
self.objects = {}
|
||||
|
||||
def get_object(self, id: str, use_gtk: bool = True) -> any:
|
||||
if not use_gtk:
|
||||
return self.objects[id]
|
||||
|
||||
return super(SFMBuilder, self).get_object(id)
|
||||
|
||||
def expose_object(self, id: str, object: any, use_gtk: bool = True) -> None:
|
||||
if not use_gtk:
|
||||
self.objects[id] = object
|
||||
else:
|
||||
super(SFMBuilder, self).expose_object(id, object)
|
||||
|
||||
def dereference_object(self, id: str) -> None:
|
||||
del self.objects[id]
|
||||
|
||||
|
||||
|
||||
class Controller_Data:
|
||||
""" Controller_Data contains most of the state of the app at ay given time. It also has some support methods. """
|
||||
__slots__ = "settings", "builder", "logger", "keybindings", "trashman", "fm_controller", "window", "window1", "window2", "window3", "window4"
|
||||
|
||||
def _setup_controller_data(self) -> None:
|
||||
self.window = settings_manager.get_main_window()
|
||||
self.builder = None
|
||||
self.builder = SFMBuilder()
|
||||
self.core_widget = None
|
||||
|
||||
self._load_glade_file()
|
||||
@ -88,7 +114,7 @@ class Controller_Data:
|
||||
state.notebooks = self.notebooks
|
||||
state.wid, state.tid = self.fm_controller.get_active_wid_and_tid()
|
||||
state.tab = self.get_fm_window(state.wid).get_tab_by_id(state.tid)
|
||||
state.icon_grid = self.builder.get_object(f"{state.wid}|{state.tid}|icon_grid")
|
||||
state.icon_grid = self.builder.get_object(f"{state.wid}|{state.tid}|icon_grid", use_gtk = False)
|
||||
# state.icon_grid = event_system.emit_and_await("get_files_view_icon_grid", (state.wid, state.tid))
|
||||
state.store = state.icon_grid.get_model()
|
||||
state.message_dialog = MessageWidget()
|
||||
@ -110,7 +136,7 @@ class Controller_Data:
|
||||
event_system.emit("update_state_info_plugins", state) # NOTE: Need to remove after we convert plugins to use emit_and_await
|
||||
return state
|
||||
|
||||
def format_to_uris(self, store, wid, tid, treePaths, use_just_path=False):
|
||||
def format_to_uris(self, store, wid, tid, treePaths, use_just_path = False):
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
dir = tab.get_current_directory()
|
||||
uris = []
|
||||
|
@ -35,7 +35,7 @@ class FileActionSignalsMixin:
|
||||
|
||||
# NOTE: Too lazy to impliment a proper update handler and so just regen store and update tab.
|
||||
# Use a lock system to prevent too many update calls for certain instances but user can manually refresh if they have urgency
|
||||
def dir_watch_updates(self, file_monitor, file, other_file=None, eve_type=None, data=None):
|
||||
def dir_watch_updates(self, file_monitor, file, other_file = None, eve_type = None, data = None):
|
||||
if eve_type in [Gio.FileMonitorEvent.CREATED, Gio.FileMonitorEvent.DELETED,
|
||||
Gio.FileMonitorEvent.RENAMED, Gio.FileMonitorEvent.MOVED_IN,
|
||||
Gio.FileMonitorEvent.MOVED_OUT]:
|
||||
@ -68,7 +68,7 @@ class FileActionSignalsMixin:
|
||||
wid, tid = tab_widget.split("|")
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
icon_grid = self.builder.get_object(f"{wid}|{tid}|icon_grid")
|
||||
icon_grid = self.builder.get_object(f"{wid}|{tid}|icon_grid", use_gtk = False)
|
||||
store = icon_grid.get_model()
|
||||
_store, tab_widget_label = self.get_store_and_label_from_notebook(notebook, f"{wid}|{tid}")
|
||||
|
||||
@ -82,7 +82,7 @@ class FileActionSignalsMixin:
|
||||
self.set_bottom_labels(tab)
|
||||
|
||||
|
||||
def do_file_search(self, widget, eve=None):
|
||||
def do_file_search(self, widget, eve = None):
|
||||
if not self.ctrl_down and not self.shift_down and not self.alt_down:
|
||||
target = widget.get_name()
|
||||
notebook = self.builder.get_object(target)
|
||||
|
@ -74,7 +74,7 @@ class KeyboardSignalsMixin:
|
||||
def keyboard_close_tab(self):
|
||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}")
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}", use_gtk = False)
|
||||
page = notebook.page_num(scroll)
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
watcher = tab.get_dir_watcher()
|
||||
|
@ -81,7 +81,7 @@ class GridMixin:
|
||||
def create_tab_widget(self, tab):
|
||||
return TabHeaderWidget(tab, self.close_tab)
|
||||
|
||||
def create_scroll_and_store(self, tab, wid, use_tree_view=False):
|
||||
def create_scroll_and_store(self, tab, wid, use_tree_view = False):
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
|
||||
if not use_tree_view:
|
||||
@ -93,8 +93,8 @@ class GridMixin:
|
||||
scroll.add(grid)
|
||||
scroll.set_name(f"{wid}|{tab.get_id()}")
|
||||
grid.set_name(f"{wid}|{tab.get_id()}")
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}|icon_grid", grid)
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}", scroll)
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}|icon_grid", grid, use_gtk = False)
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}", scroll, use_gtk = False)
|
||||
|
||||
return scroll, grid.get_store()
|
||||
|
||||
|
@ -17,7 +17,7 @@ from .grid_mixin import GridMixin
|
||||
class TabMixin(GridMixin):
|
||||
"""docstring for TabMixin"""
|
||||
|
||||
def create_tab(self, wid=None, tid=None, path=None):
|
||||
def create_tab(self, wid: int = None, tid: int = None, path: str = None):
|
||||
if not wid:
|
||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||
|
||||
@ -60,7 +60,7 @@ class TabMixin(GridMixin):
|
||||
tab_box = button.get_parent()
|
||||
wid = int(notebook.get_name()[-1])
|
||||
tid = self.get_id_from_tab_box(tab_box)
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}")
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}", use_gtk = False)
|
||||
icon_grid = scroll.get_children()[0]
|
||||
store = icon_grid.get_store()
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
@ -69,6 +69,9 @@ class TabMixin(GridMixin):
|
||||
watcher.cancel()
|
||||
self.get_fm_window(wid).delete_tab_by_id(tid)
|
||||
|
||||
self.builder.dereference_object(f"{wid}|{tid}|icon_grid")
|
||||
self.builder.dereference_object(f"{wid}|{tid}")
|
||||
|
||||
store.clear()
|
||||
# store.run_dispose()
|
||||
icon_grid.destroy()
|
||||
@ -112,7 +115,7 @@ class TabMixin(GridMixin):
|
||||
if not settings_manager.is_trace_debug():
|
||||
self.fm_controller.save_state()
|
||||
|
||||
def on_tab_switch_update(self, notebook, content=None, index=None):
|
||||
def on_tab_switch_update(self, notebook, content = None, index = None):
|
||||
self.selected_files.clear()
|
||||
wid, tid = content.get_children()[0].get_name().split("|")
|
||||
self.fm_controller.set_wid_and_tid(wid, tid)
|
||||
@ -131,7 +134,7 @@ class TabMixin(GridMixin):
|
||||
def get_tab_icon_grid_from_notebook(self, notebook):
|
||||
return notebook.get_children()[1].get_children()[0]
|
||||
|
||||
def refresh_tab(data=None):
|
||||
def refresh_tab(data = None):
|
||||
state = self.get_current_state()
|
||||
state.tab.load_directory()
|
||||
self.load_store(state.tab, state.store)
|
||||
@ -148,7 +151,7 @@ class TabMixin(GridMixin):
|
||||
if not settings_manager.is_trace_debug():
|
||||
self.fm_controller.save_state()
|
||||
|
||||
def do_action_from_bar_controls(self, widget, eve=None):
|
||||
def do_action_from_bar_controls(self, widget, eve = None):
|
||||
action = widget.get_name()
|
||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
|
@ -54,7 +54,7 @@ class FilesWidget(FileActionSignalsMixin, WindowMixin):
|
||||
self.files_view.set_group_name("files_widget")
|
||||
self.builder.expose_object(f"{self.NAME}", self.files_view)
|
||||
|
||||
def _load_files_view_state(self, win_name=None, tabs=None):
|
||||
def _load_files_view_state(self, win_name = None, tabs = None):
|
||||
if win_name == self.NAME:
|
||||
if tabs:
|
||||
for tab in tabs:
|
||||
@ -62,9 +62,9 @@ class FilesWidget(FileActionSignalsMixin, WindowMixin):
|
||||
else:
|
||||
self.create_new_tab_notebook(None, self.INDEX, None)
|
||||
|
||||
def _get_files_view_icon_grid(self, win_index=None, tid=None):
|
||||
def _get_files_view_icon_grid(self, win_index = None, tid = None):
|
||||
if win_index == str(self.INDEX):
|
||||
return self.builder.get_object(f"{self.INDEX}|{tid}|icon_grid")
|
||||
return self.builder.get_object(f"{self.INDEX}|{tid}|icon_grid", use_gtk = False)
|
||||
|
||||
|
||||
def set_fm_controller(self, _fm_controller):
|
||||
|
@ -59,7 +59,6 @@ class GridMixin:
|
||||
icon = tab.create_icon(dir, file)
|
||||
itr = store.get_iter(i)
|
||||
store.set_value(itr, 0, icon)
|
||||
return 1
|
||||
|
||||
def create_icons_generator(self, tab, dir, files):
|
||||
for file in files:
|
||||
@ -82,7 +81,7 @@ class GridMixin:
|
||||
def create_tab_widget(self, tab):
|
||||
return TabHeaderWidget(tab, self.close_tab)
|
||||
|
||||
def create_scroll_and_store(self, tab, wid, use_tree_view=False):
|
||||
def create_scroll_and_store(self, tab, wid, use_tree_view = False):
|
||||
scroll = Gtk.ScrolledWindow()
|
||||
|
||||
if not use_tree_view:
|
||||
@ -94,8 +93,8 @@ class GridMixin:
|
||||
scroll.add(grid)
|
||||
scroll.set_name(f"{wid}|{tab.get_id()}")
|
||||
grid.set_name(f"{wid}|{tab.get_id()}")
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}|icon_grid", grid)
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}", scroll)
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}|icon_grid", grid, use_gtk = False)
|
||||
self.builder.expose_object(f"{wid}|{tab.get_id()}", scroll, use_gtk = False)
|
||||
|
||||
return scroll, grid.get_store()
|
||||
|
||||
|
@ -17,7 +17,7 @@ from .grid_mixin import GridMixin
|
||||
class TabMixin(GridMixin):
|
||||
"""docstring for TabMixin"""
|
||||
|
||||
def create_tab(self, wid=None, tid=None, path=None):
|
||||
def create_tab(self, wid: int = None, tid: int = None, path: str = None):
|
||||
if not wid:
|
||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||
|
||||
@ -62,7 +62,7 @@ class TabMixin(GridMixin):
|
||||
tab_box = button.get_parent()
|
||||
wid = int(notebook.get_name()[-1])
|
||||
tid = self.get_id_from_tab_box(tab_box)
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}")
|
||||
scroll = self.builder.get_object(f"{wid}|{tid}", use_gtk = False)
|
||||
icon_grid = scroll.get_children()[0]
|
||||
store = icon_grid.get_model()
|
||||
tab = self.get_fm_window(wid).get_tab_by_id(tid)
|
||||
@ -71,6 +71,9 @@ class TabMixin(GridMixin):
|
||||
watcher.cancel()
|
||||
self.get_fm_window(wid).delete_tab_by_id(tid)
|
||||
|
||||
self.builder.dereference_object(f"{wid}|{tid}|icon_grid")
|
||||
self.builder.dereference_object(f"{wid}|{tid}")
|
||||
|
||||
store.clear()
|
||||
# store.run_dispose()
|
||||
icon_grid.destroy()
|
||||
@ -114,7 +117,7 @@ class TabMixin(GridMixin):
|
||||
if not settings_manager.is_trace_debug():
|
||||
self.fm_controller.save_state()
|
||||
|
||||
def on_tab_switch_update(self, notebook, content=None, index=None):
|
||||
def on_tab_switch_update(self, notebook, content = None, index = None):
|
||||
self.selected_files.clear()
|
||||
wid, tid = content.get_children()[0].get_name().split("|")
|
||||
self.fm_controller.set_wid_and_tid(wid, tid)
|
||||
@ -133,7 +136,7 @@ class TabMixin(GridMixin):
|
||||
def get_tab_icon_grid_from_notebook(self, notebook):
|
||||
return notebook.get_children()[1].get_children()[0]
|
||||
|
||||
def refresh_tab(data=None):
|
||||
def refresh_tab(data = None):
|
||||
state = self.get_current_state()
|
||||
state.tab.load_directory()
|
||||
self.load_store(state.tab, state.store)
|
||||
@ -150,7 +153,7 @@ class TabMixin(GridMixin):
|
||||
if not settings_manager.is_trace_debug():
|
||||
self.fm_controller.save_state()
|
||||
|
||||
def do_action_from_bar_controls(self, widget, eve=None):
|
||||
def do_action_from_bar_controls(self, widget, eve = None):
|
||||
action = widget.get_name()
|
||||
wid, tid = self.fm_controller.get_active_wid_and_tid()
|
||||
notebook = self.builder.get_object(f"window_{wid}")
|
||||
|
Loading…
Reference in New Issue
Block a user