From c3f637b5fdfc404ebe85da9632524844fd7f3951 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 7 Mar 2022 19:18:55 -0600 Subject: [PATCH] Changed keyboard control events --- .../SolarFM/solarfm/__builtins__.py | 2 +- .../SolarFM/solarfm/context/controller.py | 4 +--- .../solarfm/context/controller_data.py | 23 +++++++++---------- .../solarfm/context/mixins/ui/tab_mixin.py | 9 +++++--- .../mixins/ui/widget_file_action_mixin.py | 2 ++ .../solarfm/context/mixins/ui/window_mixin.py | 4 ++-- .../context/signals/keyboard_signals_mixin.py | 14 +---------- .../solarfm/shellfm/windows/controller.py | 4 ++-- .../SolarFM/solarfm/{ => utils}/ipc_server.py | 0 .../usr/share/solarfm/key-bindings.json | 15 +++++++----- 10 files changed, 35 insertions(+), 42 deletions(-) rename src/versions/solarfm-0.0.1/SolarFM/solarfm/{ => utils}/ipc_server.py (100%) diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py index 02c8d57..9f24355 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/__builtins__.py @@ -4,7 +4,7 @@ import builtins # Lib imports # Application imports -from ipc_server import IPCServer +from utils.ipc_server import IPCServer diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller.py index 52285b2..705ae3e 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller.py @@ -28,7 +28,7 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi self.setup_controller_data(_settings) self.window.show() - self.generate_windows(self.state) + self.generate_windows(self.fm_controller_data) self.plugins.launch_plugins() if debug: @@ -140,10 +140,8 @@ class Controller(UIMixin, KeyboardSignalsMixin, IPCSignalsMixin, ExceptionHookMi if action == "rename": self.rename_files() if action == "cut": - self.to_copy_files.clear() self.cut_files() if action == "copy": - self.to_cut_files.clear() self.copy_files() if action == "paste": self.paste_files() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller_data.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller_data.py index 9e06eec..f4a9345 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller_data.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/controller_data.py @@ -22,15 +22,15 @@ class Controller_Data: """ Controller_Data contains most of the state of the app at ay given time. It also has some support methods. """ def setup_controller_data(self, _settings): - self.settings = _settings - self.builder = self.settings.get_builder() - self.logger = self.settings.get_logger() - self.keybindings = self.settings.get_keybindings() + self.settings = _settings + self.builder = self.settings.get_builder() + self.logger = self.settings.get_logger() + self.keybindings = self.settings.get_keybindings() - self.trashman = XDGTrash() - self.fm_controller = WindowController() - self.plugins = Plugins(_settings) - self.state = self.fm_controller.load_state() + self.trashman = XDGTrash() + self.fm_controller = WindowController() + self.plugins = Plugins(_settings) + self.fm_controller_data = self.fm_controller.get_state_from_file() self.trashman.regenerate() self.window = self.settings.get_main_window() @@ -127,11 +127,10 @@ class Controller_Data: Returns: state (obj): State ''' - state = State() - wid, tid = self.fm_controller.get_active_wid_and_tid() + state = State() state.wid, state.tid = self.fm_controller.get_active_wid_and_tid() - state.tab = self.get_fm_window(wid).get_tab_by_id(tid) - state.icon_grid = self.builder.get_object(f"{wid}|{tid}|icon_grid") + 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.store = state.icon_grid.get_model() return state diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/tab_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/tab_mixin.py index 910f3f2..85f8c2c 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/tab_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/tab_mixin.py @@ -15,7 +15,10 @@ from .widget_mixin import WidgetMixin class TabMixin(WidgetMixin): """docstring for TabMixin""" - def create_tab(self, wid, path=None): + def create_tab(self, wid=None, path=None): + if not wid: + wid, _tid = self.fm_controller.get_active_wid_and_tid() + notebook = self.builder.get_object(f"window_{wid}") path_entry = self.builder.get_object(f"path_entry") tab = self.fm_controller.add_tab_for_window_by_nickname(f"window_{wid}") @@ -30,7 +33,7 @@ class TabMixin(WidgetMixin): # scroll, store = self.create_icon_tree_widget(tab, wid) index = notebook.append_page(scroll, tab_widget) - self.fm_controller.set__wid_and_tid(wid, tab.get_id()) + self.fm_controller.set_wid_and_tid(wid, tab.get_id()) path_entry.set_text(tab.get_current_directory()) notebook.show_all() notebook.set_current_page(index) @@ -79,7 +82,7 @@ class TabMixin(WidgetMixin): 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) + self.fm_controller.set_wid_and_tid(wid, tid) self.set_path_text(wid, tid) self.set_window_title() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/widget_file_action_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/widget_file_action_mixin.py index 0a2b8f3..dea712b 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/widget_file_action_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/widget_file_action_mixin.py @@ -191,11 +191,13 @@ class WidgetFileActionMixin: self.selected_files.clear() def cut_files(self): + self.to_copy_files.clear() state = self.get_current_state() uris = self.format_to_uris(state.store, state.wid, state.tid, self.selected_files, True) self.to_cut_files = uris def copy_files(self): + self.to_cut_files.clear() state = self.get_current_state() uris = self.format_to_uris(state.store, state.wid, state.tid, self.selected_files, True) self.to_copy_files = uris diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/window_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/window_mixin.py index 18556b6..5482dd2 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/window_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/mixins/ui/window_mixin.py @@ -165,7 +165,7 @@ class WindowMixin(TabMixin): try: self.path_menu.popdown() wid, tid = icons_grid.get_name().split("|") - self.fm_controller.set__wid_and_tid(wid, tid) + self.fm_controller.set_wid_and_tid(wid, tid) self.set_path_text(wid, tid) self.set_window_title() @@ -235,7 +235,7 @@ class WindowMixin(TabMixin): self.override_drop_dest = uri if isdir(uri) else None if target not in current: - self.fm_controller.set__wid_and_tid(wid, tid) + self.fm_controller.set_wid_and_tid(wid, tid) def grid_on_drag_data_received(self, widget, drag_context, x, y, data, info, time): diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/signals/keyboard_signals_mixin.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/signals/keyboard_signals_mixin.py index c50b848..bc2f762 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/signals/keyboard_signals_mixin.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/context/signals/keyboard_signals_mixin.py @@ -16,7 +16,7 @@ valid_keyvalue_pat = re.compile(r"[a-z0-9A-Z-_\[\]\(\)\| ]") class KeyboardSignalsMixin: """ KeyboardSignalsMixin keyboard hooks controller. """ - # TODO: Need to set methods that use this to somehow check the keybindings state instead. + # TODO: Need to set methods that use this to somehow check the keybindings state instead. def unset_keys_and_data(self, widget=None, eve=None): self.ctrl_down = False self.shift_down = False @@ -72,10 +72,6 @@ class KeyboardSignalsMixin: return True - - def keyboard_create_tab(self, widget=None, eve=None): - self.builder.get_object("create_tab").released() - def keyboard_close_tab(self): wid, tid = self.fm_controller.get_active_wid_and_tid() notebook = self.builder.get_object(f"window_{wid}") @@ -89,11 +85,3 @@ class KeyboardSignalsMixin: notebook.remove_page(page) self.fm_controller.save_state() self.set_window_title() - - def keyboard_copy_files(self, widget=None, eve=None): - self.to_cut_files.clear() - self.copy_files() - - def keyboard_cut_files(self, widget=None, eve=None): - self.to_copy_files.clear() - self.cut_files() diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/shellfm/windows/controller.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/shellfm/windows/controller.py index 60c3379..abec786 100644 --- a/src/versions/solarfm-0.0.1/SolarFM/solarfm/shellfm/windows/controller.py +++ b/src/versions/solarfm-0.0.1/SolarFM/solarfm/shellfm/windows/controller.py @@ -26,7 +26,7 @@ class WindowController: self._windows = [] - def set__wid_and_tid(self, wid, tid): + def set_wid_and_tid(self, wid, tid): self._active_window_id = str(wid) self._active_tab_id = str(tid) @@ -176,7 +176,7 @@ class WindowController: else: raise Exception("Window data corrupted! Can not save session!") - def load_state(self, session_file = None): + def get_state_from_file(self, session_file = None): if not session_file: session_file = self._session_file diff --git a/src/versions/solarfm-0.0.1/SolarFM/solarfm/ipc_server.py b/src/versions/solarfm-0.0.1/SolarFM/solarfm/utils/ipc_server.py similarity index 100% rename from src/versions/solarfm-0.0.1/SolarFM/solarfm/ipc_server.py rename to src/versions/solarfm-0.0.1/SolarFM/solarfm/utils/ipc_server.py diff --git a/user_config/usr/share/solarfm/key-bindings.json b/user_config/usr/share/solarfm/key-bindings.json index 487bc02..a8c6506 100644 --- a/user_config/usr/share/solarfm/key-bindings.json +++ b/user_config/usr/share/solarfm/key-bindings.json @@ -1,10 +1,13 @@ { "keybindings": { "help" : "F1", - "rename_files" : ["F2", "e"], + "rename_files" : ["F2", + "e"], "open_terminal" : "F4", - "refresh_tab" : ["F5", "r"], - "delete_files" : "Delete", + "refresh_tab" : ["F5", + "r"], + "delete_files" : ["Delete", + "d"], "tggl_top_main_menubar" : "", "trash_files" : "t", "tear_down" : "q", @@ -13,10 +16,10 @@ "grab_focus_path_entry" : "l", "open_files" : "o", "show_hide_hidden_files" : "h", - "keyboard_create_tab" : "t", + "create_tab" : "t", "keyboard_close_tab" : "w", - "keyboard_copy_files" : "c", - "keyboard_cut_files" : "x", + "copy_files" : "c", + "cut_files" : "x", "paste_files" : "v", "show_new_file_menu" : "n" }