The python script, adds the functionality to use the backspace key to go back to the previous directory.
However, when the browser is enabled, the backspace key is not enabled for text deletion, but still with the functionality to go back to the previous directory. The same happens when creating a new folder and trying to delete within the text field of the new folder name.
It is possible to add a condition that detects if the browser, or new folder is being added. Or, only apply the rollback when over the column.
Can you send me or tell me where I can find the actual documentation, or actual properties of nautilus 47?
import gi
gi.require_version('Nautilus', '4.0')
gi.require_version('Gtk', '4.0')
from gi.repository import GObject, Nautilus, Gtk, GLib, Gdk
class BackspaceNavigation(GObject.GObject, Nautilus.MenuProvider):
def __init__(self):
super().__init__()
app = Gtk.Application.get_default()
if app:
# Asignar la tecla "Retroceso" a la acción "slot.up" para todas las ventanas de Nautilus
app.set_accels_for_action("slot.up", ["BackSpace"])
app.connect("window-added", self.on_window_added)
def on_window_added(self, app, window):
if isinstance(window, Gtk.ApplicationWindow):
window.connect("key-press-event", self.on_key_press)
def on_key_press(self, widget, event):
# Detectar si se presionó la tecla "BackSpace"
if event.keyval == Gdk.KEY_BackSpace:
focus_widget = widget.get_focus()
# Si el foco está en un campo de texto, permitir el comportamiento normal
if isinstance(focus_widget, (Gtk.Entry, Gtk.TextView, Gtk.SearchEntry)):
return False # Permitir el comportamiento estándar de borrado de texto
# Si el foco no está en un campo de texto, manejar el evento y realizar la navegación hacia atrás
return True # Indicar que el evento ha sido manejado para evitar el comportamiento predeterminado
return False # Dejar otros eventos sin modificar
def init():
return BackspaceNavigation()
But not working, how name widget, or entry search in new version?
Don’t think your extension will work without changing the code inside nautilus itself to claim the event because you’re using the app to register the event.