Tuesday, November 2, 2010

Improved Service Menus

Dolphin and Konqueror offer so called "services-menus", which are shown when opening a context-menu of a file or directory. For example the context-menu for a JPG-file will show the menu entries "Convert to PNG", "Convert to GIF", ... - those entries are service-menus.

It is very easy to create a service-menu. In a nutshell it is just a text-file that allows to start an application with the selected files as parameters.

But service-menus also have some restrictions: Only the MIME-type is used as criteria to define which entries are shown. So it is not possible to show a service-menu only if e.g. exactly two files are selected or to create dynamic service-menus dependent on some meta-data of the selected files.

Sebastian Trüg has written an interface called KFileItemActionPlugin that bypasses those restrictions. The interface will be available in KDE SC 4.6.0 and is supported by Dolphin and Konqueror.

Some developers might notice the similarity to the KonqPopupMenuPlugin, that has been available since ages, but is not supported by Dolphin. The reason why it is not supported in Dolphin are some interface-issues when using the plugin outside the scope of the Konqueror context-menu. After discussing this with David Faure and Sebastian Trüg we decided to cleanup the interface, call it KFileItemActionPlugin and mark the KonqPopupMenuPlugin as deprecated.

Sadly there are not much applications for KDE 4 that take usage of the KonqPopupMenuPlugin interface. On one hand this is good as this means less efforts to port it to the new KFileItemActionPlugin interface. But on the other hand for the users out there this means a not so tight interaction of the KDE file-managers with applications.

So this is a kind of invitation to all application developers out there: Possibly the KFileItemActionPlugin is also a benefit for your application to get integrated in a better way into the KDE file-managers :-)

13 comments:

Anonymous said...

There is also a graphical editor for making these menus quickly.

http://kde-apps.org/content/show.php/Service+Menu+Editor?content=85062

Anonymous said...

Well if you are looking for applications making use of that, KDiff3 is lacking a context menu extension for some time now :-)

It had a really useful one in KDE 3 days.

toddrme2178 said...

Does this mean it would finally be possible for ark to recognize that you've selected compressed files with different formats?

Chris said...

what is important for app's using this context menu is IMHO,

that it should be an addon, to the specific functionality that the app already provides on those files (e.g pics in digikam, music in amarok).

Perhaps first the app specific functions should appear , then the generic file functions.

Perhaps someone also would like to not provide a specific entry (because it conflicts with the other functions logical wise) but all the others.

Anonymous said...

Note in my todo, write BlueDevil KFileItemActionPlugin to send files, most requested feature :p

great work!

Unknown said...

@Anomymous #1:
> There is also a graphical editor
> for making these menus quickly.
Thanks for the link, I was not aware about this graphical editor.

@Anonymous #2:
> ...KDiff3 is lacking a context
> menu extension for some time now :-)
Yes, KDiff3 is a perfect example, I miss this functionality too.

@toddrme2178:
> Does this mean it would finally
> be possible for ark to recognize
> that you've selected compressed
> files with different formats?
Yes, I think so.

@Chris: I agree. It is also possible for the user to disable services + plugins in case that a generic functionality conflicts with a specific functionality.

@afiestas:
> Note in my todo, write BlueDevil
> KFileItemActionPlugin to send
> files, most requested feature :p
Cool, thanks :-)

Ruben said...

I've made a plugin for Konqueror to send files using KMess. Now Dolphin will finally get this same functionality too.

Exodub said...

I hope this feature will allow me to make a dropbox plugin, which only shows the dropbox context menu on files in the (user defined) dropbox folder.
You couldn't do this with the current implementation.

JaKi143 said...

Will the old servicemenus still work?

Unknown said...

the only thing that I really hate about Dolphin is how selection is so damn slow in it (selecting files using mouse click and drag blue rect)
It's really slow and crappy.
Otherwise it's cool :)

Anonymous said...

"So it is not possible to show a service-menu only if e.g. exactly two files are selected....[...]KFileItemActionPlugin that bypasses those restrictions."

How to implement this?
I don't find example...

Anonymous said...

if you could read this...

i miss feauter that konqueror had :(

http://forum.kde.org/brainstorm.php#idea92269_page1

Anonymous said...

What happened to being able to search by ".file extension"? Konqueror was able to be setup to search for a particular file by name or content, file extension and/or a given modification date/s but Dolphin seems to be general 'Hairy Fairy' and not customizable like I use. Can it be backward revamped to the old system as KFind?

tecmate