How to add an entry to context menus in Nautilus?

243 Views Asked by At

I have a tool that works on Pharo packages (RPackages).

To make it accessible i want to add a menu entry to the Nautilus package context menu, so one can open my tool on selected packages from within Nautilus. Is this possible?

1

There are 1 best solutions below

0
On BEST ANSWER

To add entries to the Nautilus context menus you can use one of the menu pragmas that are defined in the AbstractNautilusUI menu pragmas protocol.

Just define a class side method with one of the pragmas on any class you desire. For example:

MyClass class >> myMenuEntry: aBuilder
   <nautilusGlobalPackageMenu>
   | target packages |

   target := aBuilder model.

   (packages := target selectedPackages) ifNil: [ ^ target ].

   (aBuilder item: #'Show my selection')
        action: [ self inform: packages ]

In the case of the Nautilus package menu you obtain the selection via

aBuilder model selectedPackages

Use the Finder’s pragma search option to look at examples.

(Thanks to Benjamin Van Ryseghem)