Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows-like shell extension on Mac & Linux

I'm making an application (Initially for Windows, but extending to Mac & Linux asap), and I'll be needing to extend the shell on both platforms, to achieve the best usability. So how would I go about making a shell extension for Mac OS X, as well as Linux (GNOME based), in C#?

On Windows there's a library called SharpShell that handles pretty much all of this for you, so that's great. But no such luck for Mac or Linux (As far as I can tell).

The main aspects of the Shell I'm looking to integrate with, is the option of right-clicking on a file, and having it show a context menu with different options for my application. (Like 7-Zip on Windows)

When I'm using the term Shell, I'm deriving it from Windows. So when I say I'm looking to integrate with the Shell, I mean creating context menus upon right-clicking, and similar features. All UI based.

like image 815
Falgantil Avatar asked Nov 21 '22 22:11

Falgantil


1 Answers

You're trying to apply a concept specific in Windows environments (contextual menu) in a totally different *NIX Environment. Is a hard task, and very difficult because *NIX doesn't provide a friendly API to modify environment because Desktop/Shells fragmentation (Gnome, KDE, etc). The Windows Shell is explorer.exe and provides shell and desktop experience, explorer.exe shows to you the desktop, the start button bar, and the explorer window (to navigate across files, devices and directories), so in Windows we have a only program to do this, Linux or OSX follow another design, in Linux, we have a Desktop Manager (Gnome, KDE, LXDE), it shows to you the desktop, but for file interaction we have a different program called File Manager (Nautilus, Dolphin, etc). But, I need to say is hard but not imposible.

For accomplish that you need to write an abstraction layer (AL). Your program needs to call this layer only, and you need to port the AL to every platform / desktop manager you have.

Example:

Let's say we have a function called AddContextualItem(...) in our AL, to add a new item to Shell Context Menu, your code needs to call this function, but for Windows environments this function surely calls some WIN32 API's to accomplish the goal, but in OSX Environment or Linux this function AddContextualItem should be replaced by another implementation compatible with unix desktop environment (like Gnome, KDE, etc) or specific file manager (Nautilus, Dolphin, etc).

Ultimately, C# does't seems to be the better language for accomplish task like that, Xamarin are doing a good job with Mono Framework, but isn't sufficient. C or C++ is more powerful language to do this.

How To add right click menu to Nautilus (Gnome) File Manager

Source code of nautilus-actions

How to add right click menu to Dolphin (KDE) File Manager

Apple Official Documentation for Building a service (like right-click item menu) in OS X

like image 137
Mr Rivero Avatar answered Nov 24 '22 12:11

Mr Rivero