Finalized keybinding inferastructure
This commit is contained in:
parent
4aeaffdd44
commit
45ca8abbdd
|
@ -39,8 +39,8 @@ class Plugin:
|
||||||
self._run_timeout()
|
self._run_timeout()
|
||||||
|
|
||||||
if self._message:
|
if self._message:
|
||||||
wid, tid, view, iconview, store = self._message
|
state = self._message
|
||||||
subprocess.Popen([f'{self.SCRIPT_PTH}/download.sh' , view.get_current_directory()])
|
subprocess.Popen([f'{self.SCRIPT_PTH}/download.sh' , state.tab.get_current_directory()])
|
||||||
self._message = None
|
self._message = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,4 +52,4 @@ class Application(EventSystem):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(repr(e))
|
print(repr(e))
|
||||||
|
|
||||||
settings.builder.connect_signals(handlers)
|
settings.get_builder().connect_signals(handlers)
|
||||||
|
|
|
@ -122,7 +122,7 @@ class WindowMixin(TabMixin):
|
||||||
return
|
return
|
||||||
|
|
||||||
# If nothing selected
|
# If nothing selected
|
||||||
if tab.get_hidden():
|
if tab.is_hiding_hidden():
|
||||||
if tab.get_hidden_count() > 0:
|
if tab.get_hidden_count() > 0:
|
||||||
self.bottom_file_count_label.set_label(f"{tab.get_not_hidden_count()} visible ({tab.get_hidden_count()} hidden)")
|
self.bottom_file_count_label.set_label(f"{tab.get_not_hidden_count()} visible ({tab.get_hidden_count()} hidden)")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -53,9 +53,12 @@ class Keybindings:
|
||||||
self._masks = 0
|
self._masks = 0
|
||||||
|
|
||||||
for action, bindings in list(self.keys.items()):
|
for action, bindings in list(self.keys.items()):
|
||||||
if not isinstance(bindings, tuple):
|
if isinstance(bindings, list):
|
||||||
|
bindings = (*bindings,)
|
||||||
|
elif not isinstance(bindings, tuple):
|
||||||
bindings = (bindings,)
|
bindings = (bindings,)
|
||||||
|
|
||||||
|
|
||||||
for binding in bindings:
|
for binding in bindings:
|
||||||
if not binding or binding == "None":
|
if not binding or binding == "None":
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
import os
|
import os, json
|
||||||
from os import path
|
from os import path
|
||||||
|
|
||||||
# Gtk imports
|
# Gtk imports
|
||||||
|
@ -18,36 +18,6 @@ from .keybindings import Keybindings
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
DEFAULTS = {
|
|
||||||
'keybindings': {
|
|
||||||
'help' : 'F1',
|
|
||||||
'rename_files' : 'F2',
|
|
||||||
'open_terminal' : 'F4',
|
|
||||||
'refresh_tab' : 'F5',
|
|
||||||
'delete_files' : 'Delete',
|
|
||||||
# 'tggl_top_main_menubar' : '<Alt>',
|
|
||||||
'trash_files' : '<Shift><Control>t',
|
|
||||||
'tear_down' : '<Control>q',
|
|
||||||
'go_home' : '<Control>slash',
|
|
||||||
'refresh_tab' : '<Control>r',
|
|
||||||
'go_up' : '<Control>Up',
|
|
||||||
'grab_focus_path_entry' : '<Control>l',
|
|
||||||
'open_files' : '<Control>o',
|
|
||||||
'show_hide_hidden_files' : '<Control>h',
|
|
||||||
'rename_files' : '<Control>e',
|
|
||||||
'keyboard_create_tab' : '<Control>t',
|
|
||||||
'keyboard_close_tab' : '<Control>w',
|
|
||||||
'keyboard_copy_files' : '<Control>c',
|
|
||||||
'keyboard_cut_files' : '<Control>x',
|
|
||||||
'paste_files' : '<Control>v',
|
|
||||||
'show_new_file_menu' : '<Control>n',
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Settings:
|
class Settings:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
|
self._SCRIPT_PTH = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
@ -57,7 +27,8 @@ class Settings:
|
||||||
self._USR_SOLARFM = f"/usr/share/{app_name.lower()}"
|
self._USR_SOLARFM = f"/usr/share/{app_name.lower()}"
|
||||||
|
|
||||||
self._CSS_FILE = f"{self._CONFIG_PATH}/stylesheet.css"
|
self._CSS_FILE = f"{self._CONFIG_PATH}/stylesheet.css"
|
||||||
self._WINDOWS_GLADE = f"{self._CONFIG_PATH}/Main_Window.glade"
|
self._GLADE_FILE = f"{self._CONFIG_PATH}/Main_Window.glade"
|
||||||
|
self._KEY_BINDINGS = f"{self._CONFIG_PATH}/key-bindings.json"
|
||||||
self._DEFAULT_ICONS = f"{self._CONFIG_PATH}/icons"
|
self._DEFAULT_ICONS = f"{self._CONFIG_PATH}/icons"
|
||||||
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/{app_name.lower()}.png"
|
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/{app_name.lower()}.png"
|
||||||
|
|
||||||
|
@ -66,8 +37,10 @@ class Settings:
|
||||||
if not os.path.exists(self._PLUGINS_PATH):
|
if not os.path.exists(self._PLUGINS_PATH):
|
||||||
os.mkdir(self._PLUGINS_PATH)
|
os.mkdir(self._PLUGINS_PATH)
|
||||||
|
|
||||||
if not os.path.exists(self._WINDOWS_GLADE):
|
if not os.path.exists(self._GLADE_FILE):
|
||||||
self._WINDOWS_GLADE = f"{self._USR_SOLARFM}/Main_Window.glade"
|
self._GLADE_FILE = f"{self._USR_SOLARFM}/Main_Window.glade"
|
||||||
|
if not os.path.exists(self._KEY_BINDINGS):
|
||||||
|
self._KEY_BINDINGS = f"{self._USR_SOLARFM}/key-bindings.json"
|
||||||
if not os.path.exists(self._CSS_FILE):
|
if not os.path.exists(self._CSS_FILE):
|
||||||
self._CSS_FILE = f"{self._USR_SOLARFM}/stylesheet.css"
|
self._CSS_FILE = f"{self._USR_SOLARFM}/stylesheet.css"
|
||||||
if not os.path.exists(self._WINDOW_ICON):
|
if not os.path.exists(self._WINDOW_ICON):
|
||||||
|
@ -79,29 +52,31 @@ class Settings:
|
||||||
self._warning_color = "#ffa800"
|
self._warning_color = "#ffa800"
|
||||||
self._error_color = "#ff0000"
|
self._error_color = "#ff0000"
|
||||||
|
|
||||||
self.keybindings = Keybindings()
|
self._keybindings = Keybindings()
|
||||||
self.main_window = None
|
with open(self._KEY_BINDINGS) as file:
|
||||||
self.logger = Logger(self._CONFIG_PATH).get_logger()
|
keybindings = json.load(file)["keybindings"]
|
||||||
self.builder = Gtk.Builder()
|
self._keybindings.configure(keybindings)
|
||||||
self.keybindings.configure(DEFAULTS['keybindings'])
|
|
||||||
self.builder.add_from_file(self._WINDOWS_GLADE)
|
|
||||||
|
|
||||||
|
self._main_window = None
|
||||||
|
self._logger = Logger(self._CONFIG_PATH).get_logger()
|
||||||
|
self._builder = Gtk.Builder()
|
||||||
|
self._builder.add_from_file(self._GLADE_FILE)
|
||||||
|
|
||||||
|
|
||||||
def create_window(self):
|
def create_window(self):
|
||||||
# Get window and connect signals
|
# Get window and connect signals
|
||||||
self.main_window = self.builder.get_object("Main_Window")
|
self._main_window = self._builder.get_object("Main_Window")
|
||||||
self._set_window_data()
|
self._set_window_data()
|
||||||
|
|
||||||
def _set_window_data(self):
|
def _set_window_data(self):
|
||||||
self.main_window.set_icon_from_file(self._WINDOW_ICON)
|
self._main_window.set_icon_from_file(self._WINDOW_ICON)
|
||||||
screen = self.main_window.get_screen()
|
screen = self._main_window.get_screen()
|
||||||
visual = screen.get_rgba_visual()
|
visual = screen.get_rgba_visual()
|
||||||
|
|
||||||
if visual != None and screen.is_composited():
|
if visual != None and screen.is_composited():
|
||||||
self.main_window.set_visual(visual)
|
self._main_window.set_visual(visual)
|
||||||
self.main_window.set_app_paintable(True)
|
self._main_window.set_app_paintable(True)
|
||||||
self.main_window.connect("draw", self._area_draw)
|
self._main_window.connect("draw", self._area_draw)
|
||||||
|
|
||||||
# bind css file
|
# bind css file
|
||||||
cssProvider = Gtk.CssProvider()
|
cssProvider = Gtk.CssProvider()
|
||||||
|
@ -117,7 +92,7 @@ class Settings:
|
||||||
cr.set_operator(cairo.OPERATOR_OVER)
|
cr.set_operator(cairo.OPERATOR_OVER)
|
||||||
|
|
||||||
def get_monitor_data(self):
|
def get_monitor_data(self):
|
||||||
screen = self.builder.get_object("Main_Window").get_screen()
|
screen = self._builder.get_object("Main_Window").get_screen()
|
||||||
monitors = []
|
monitors = []
|
||||||
for m in range(screen.get_n_monitors()):
|
for m in range(screen.get_n_monitors()):
|
||||||
monitors.append(screen.get_monitor_geometry(m))
|
monitors.append(screen.get_monitor_geometry(m))
|
||||||
|
@ -127,11 +102,11 @@ class Settings:
|
||||||
|
|
||||||
return monitors
|
return monitors
|
||||||
|
|
||||||
def get_builder(self): return self.builder
|
def get_builder(self): return self._builder
|
||||||
def get_logger(self): return self.logger
|
def get_logger(self): return self._logger
|
||||||
def get_keybindings(self): return self.keybindings
|
def get_keybindings(self): return self._keybindings
|
||||||
def get_main_window(self): return self.main_window
|
def get_main_window(self): return self._main_window
|
||||||
def get_plugins_path(self): return self._PLUGINS_PATH
|
def get_plugins_path(self): return self._PLUGINS_PATH
|
||||||
|
|
||||||
def get_success_color(self): return self._success_color
|
def get_success_color(self): return self._success_color
|
||||||
def get_warning_color(self): return self._warning_color
|
def get_warning_color(self): return self._warning_color
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"keybindings": {
|
||||||
|
"help" : "F1",
|
||||||
|
"rename_files" : ["F2", "<Control>e"],
|
||||||
|
"open_terminal" : "F4",
|
||||||
|
"refresh_tab" : ["F5", "<Control>r"],
|
||||||
|
"delete_files" : "Delete",
|
||||||
|
"tggl_top_main_menubar" : "<Alt>",
|
||||||
|
"trash_files" : "<Shift><Control>t",
|
||||||
|
"tear_down" : "<Control>q",
|
||||||
|
"go_up" : "<Control>Up",
|
||||||
|
"go_home" : "<Control>slash",
|
||||||
|
"grab_focus_path_entry" : "<Control>l",
|
||||||
|
"open_files" : "<Control>o",
|
||||||
|
"show_hide_hidden_files" : "<Control>h",
|
||||||
|
"keyboard_create_tab" : "<Control>t",
|
||||||
|
"keyboard_close_tab" : "<Control>w",
|
||||||
|
"keyboard_copy_files" : "<Control>c",
|
||||||
|
"keyboard_cut_files" : "<Control>x",
|
||||||
|
"paste_files" : "<Control>v",
|
||||||
|
"show_new_file_menu" : "<Control>n"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue