Changed keyboard control events
This commit is contained in:
parent
45ca8abbdd
commit
c3f637b5fd
@ -4,7 +4,7 @@ import builtins
|
||||
# Lib imports
|
||||
|
||||
# Application imports
|
||||
from ipc_server import IPCServer
|
||||
from utils.ipc_server import IPCServer
|
||||
|
||||
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
{
|
||||
"keybindings": {
|
||||
"help" : "F1",
|
||||
"rename_files" : ["F2", "<Control>e"],
|
||||
"rename_files" : ["F2",
|
||||
"<Control>e"],
|
||||
"open_terminal" : "F4",
|
||||
"refresh_tab" : ["F5", "<Control>r"],
|
||||
"delete_files" : "Delete",
|
||||
"refresh_tab" : ["F5",
|
||||
"<Control>r"],
|
||||
"delete_files" : ["Delete",
|
||||
"<Shift><Control>d"],
|
||||
"tggl_top_main_menubar" : "<Alt>",
|
||||
"trash_files" : "<Shift><Control>t",
|
||||
"tear_down" : "<Control>q",
|
||||
@ -13,10 +16,10 @@
|
||||
"grab_focus_path_entry" : "<Control>l",
|
||||
"open_files" : "<Control>o",
|
||||
"show_hide_hidden_files" : "<Control>h",
|
||||
"keyboard_create_tab" : "<Control>t",
|
||||
"create_tab" : "<Control>t",
|
||||
"keyboard_close_tab" : "<Control>w",
|
||||
"keyboard_copy_files" : "<Control>c",
|
||||
"keyboard_cut_files" : "<Control>x",
|
||||
"copy_files" : "<Control>c",
|
||||
"cut_files" : "<Control>x",
|
||||
"paste_files" : "<Control>v",
|
||||
"show_new_file_menu" : "<Control>n"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user