added settings, cleaned up keybindings formatting
This commit is contained in:
parent
628bd296c2
commit
4b62747e02
|
@ -83,7 +83,7 @@ class Window(Gtk.ApplicationWindow):
|
||||||
styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
|
||||||
|
|
||||||
def _area_draw(self, widget: Gtk.ApplicationWindow, cr: cairo.Context) -> None:
|
def _area_draw(self, widget: Gtk.ApplicationWindow, cr: cairo.Context) -> None:
|
||||||
cr.set_source_rgba(0, 0, 0, 0.54)
|
cr.set_source_rgba( *settings.get_paint_bg_color() )
|
||||||
cr.set_operator(cairo.OPERATOR_SOURCE)
|
cr.set_operator(cairo.OPERATOR_SOURCE)
|
||||||
cr.paint()
|
cr.paint()
|
||||||
cr.set_operator(cairo.OPERATOR_OVER)
|
cr.set_operator(cairo.OPERATOR_OVER)
|
||||||
|
|
|
@ -12,7 +12,6 @@ from gi.repository import Gdk
|
||||||
|
|
||||||
|
|
||||||
def err(log = ""):
|
def err(log = ""):
|
||||||
"""Print an error message"""
|
|
||||||
print(log)
|
print(log)
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,10 +65,10 @@ class Keybindings:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
keyval, mask = self._parsebinding(binding)
|
keyval, mask = self._parsebinding(binding)
|
||||||
# Does much the same, but with poorer error handling.
|
# Does much the same, but with worse error handling.
|
||||||
# keyval, mask = Gtk.accelerator_parse(binding)
|
# keyval, mask = Gtk.accelerator_parse(binding)
|
||||||
except KeymapError as e:
|
except KeymapError as e:
|
||||||
err ("keybinding reload failed to parse binding '%s': %s" % (binding, e))
|
err(f"Keybinding reload failed to parse binding '{binding}': {e}")
|
||||||
else:
|
else:
|
||||||
if mask & Gdk.ModifierType.SHIFT_MASK:
|
if mask & Gdk.ModifierType.SHIFT_MASK:
|
||||||
if keyval == Gdk.KEY_Tab:
|
if keyval == Gdk.KEY_Tab:
|
||||||
|
@ -103,7 +102,7 @@ class Keybindings:
|
||||||
keyval = Gdk.keyval_from_name(key)
|
keyval = Gdk.keyval_from_name(key)
|
||||||
|
|
||||||
if keyval == 0:
|
if keyval == 0:
|
||||||
raise KeymapError("Key '%s' is unrecognised..." % key)
|
raise KeymapError(f"Key '{key}' is unrecognised...")
|
||||||
return (keyval, mask)
|
return (keyval, mask)
|
||||||
|
|
||||||
def _lookup_modifier(self, modifier):
|
def _lookup_modifier(self, modifier):
|
||||||
|
@ -111,7 +110,7 @@ class Keybindings:
|
||||||
try:
|
try:
|
||||||
return self.modifiers[modifier.lower()]
|
return self.modifiers[modifier.lower()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise KeymapError("Unhandled modifier '<%s>'" % modifier)
|
raise KeymapError(f"Unhandled modifier '<{modifier}>'")
|
||||||
|
|
||||||
def lookup(self, event):
|
def lookup(self, event):
|
||||||
""" Translate a keyboard event into a mapped key """
|
""" Translate a keyboard event into a mapped key """
|
||||||
|
@ -121,7 +120,7 @@ class Keybindings:
|
||||||
Gdk.ModifierType(event.get_state() & ~Gdk.ModifierType.LOCK_MASK),
|
Gdk.ModifierType(event.get_state() & ~Gdk.ModifierType.LOCK_MASK),
|
||||||
event.group)
|
event.group)
|
||||||
except TypeError:
|
except TypeError:
|
||||||
err ("Keybinding lookup failed to translate keyboard event: %s" % dir(event))
|
err(f"Keybinding lookup failed to translate keyboard event: {dir(event)}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
mask = (event.get_state() & ~consumed) & self._masks
|
mask = (event.get_state() & ~consumed) & self._masks
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Settings(StartCheckMixin):
|
||||||
self._CSS_FILE = f"{self._HOME_CONFIG_PATH}/stylesheet.css"
|
self._CSS_FILE = f"{self._HOME_CONFIG_PATH}/stylesheet.css"
|
||||||
self._KEY_BINDINGS_FILE = f"{self._HOME_CONFIG_PATH}/key-bindings.json"
|
self._KEY_BINDINGS_FILE = f"{self._HOME_CONFIG_PATH}/key-bindings.json"
|
||||||
self._PID_FILE = f"{self._HOME_CONFIG_PATH}/{app_name.lower()}.pid"
|
self._PID_FILE = f"{self._HOME_CONFIG_PATH}/{app_name.lower()}.pid"
|
||||||
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/icons/{app_name.lower()}.png"
|
self._WINDOW_ICON = f"{self._DEFAULT_ICONS}/{app_name.lower()}.png"
|
||||||
|
|
||||||
if not os.path.exists(self._HOME_CONFIG_PATH):
|
if not os.path.exists(self._HOME_CONFIG_PATH):
|
||||||
os.mkdir(self._HOME_CONFIG_PATH)
|
os.mkdir(self._HOME_CONFIG_PATH)
|
||||||
|
@ -73,6 +73,7 @@ class Settings(StartCheckMixin):
|
||||||
self._main_window_w = 800
|
self._main_window_w = 800
|
||||||
self._main_window_h = 600
|
self._main_window_h = 600
|
||||||
self._builder = None
|
self._builder = None
|
||||||
|
self.PAINT_BG_COLOR = (0, 0, 0, 0.54)
|
||||||
|
|
||||||
self._trace_debug = False
|
self._trace_debug = False
|
||||||
self._debug = False
|
self._debug = False
|
||||||
|
@ -108,9 +109,10 @@ class Settings(StartCheckMixin):
|
||||||
return monitors
|
return monitors
|
||||||
|
|
||||||
def get_main_window(self) -> any: return self._main_window
|
def get_main_window(self) -> any: return self._main_window
|
||||||
def get_main_window_width(self) -> Gtk.ApplicationWindow: return self._main_window_w
|
def get_main_window_width(self) -> any: return self._main_window_w
|
||||||
def get_main_window_height(self) -> Gtk.ApplicationWindow: return self._main_window_h
|
def get_main_window_height(self) -> any: return self._main_window_h
|
||||||
def get_builder(self) -> any: return self._builder
|
def get_builder(self) -> any: return self._builder
|
||||||
|
def get_paint_bg_color(self) -> any: return self.PAINT_BG_COLOR
|
||||||
def get_glade_file(self) -> str: return self._GLADE_FILE
|
def get_glade_file(self) -> str: return self._GLADE_FILE
|
||||||
|
|
||||||
def get_plugins_path(self) -> str: return self._PLUGINS_PATH
|
def get_plugins_path(self) -> str: return self._PLUGINS_PATH
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
"open_terminal" : "F4",
|
"open_terminal" : "F4",
|
||||||
"refresh_tab" : ["F5", "<Control>r"],
|
"refresh_tab" : ["F5", "<Control>r"],
|
||||||
"delete_files" : "Delete",
|
"delete_files" : "Delete",
|
||||||
"tggl_top_main_menubar" : "<Alt>",
|
"tggl_top_main_menubar" : "Alt",
|
||||||
"trash_files" : "<Shift><Control>t",
|
"trash_files" : "<Shift><Control>t",
|
||||||
"tear_down" : "<Control>q",
|
"tear_down" : "<Control>q",
|
||||||
"go_up" : "<Control>Up",
|
"go_up" : "<Control>Up",
|
||||||
|
|
Loading…
Reference in New Issue