Port a very simple Nautilus extension to Files 43

Hi guys,

I need help porting the following Nautilus extension to Files 43:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# by Ricardo Lenz, 2016-jun
# riclc@hotmail.com
#

import os, gi
gi.require_version('Nautilus', '3.0')
from gi.repository import GObject, Nautilus, Gtk, Gio, GLib

def ok():
    app = Gtk.Application.get_default()
    app.set_accels_for_action( "view.rename", ["Return"] )


class CustomShortcuts(GObject.GObject, Nautilus.LocationWidgetProvider):
    def __init__(self):
        pass
    
    def get_widget(self, uri, window):
        ok()
        return None

I tried simply bumping the required Nautilus version but that didn’t work.

I was looking at the extension examples in the Nautilus source code repo but didn’t find one showing how a custom shortcut could be set which is the thing I would like to achieve.

Thanks for any input!

There are a couple things here:

  1. you need to use GTK4, that’s what Nautilus 43 uses.
  2. what you’re trying to do will probably work with 43, but is bound to stop working Soon™ as you’re not supposed to access the Nautilus GTK widgets anymore, and it’s likely a future version will move extensions to their own process, where it won’t be possible to access Nautilus’ GtkApplication at all.

Not sure if there are plans to allow properly what you’re trying to do, though, somebody with more insider view might be of more help here.