KService: support for storing Actions defined in .desktop files into ksycoca4

David Faure faure at kde.org
Sat Oct 13 10:24:20 BST 2007


Desktop files can defined Actions (as per the desktop entry standard).
We currently use this feature for individual desktop files when right-clicking on them
(KDesktopFileActions), but also for screensavers (three predefined actions: InWindow, Root, and Setup)
and for konqueror/dolphin servicemenus.
However right now those three places duplicate the parsing of those actions, and worse:
they have to do it using KConfig/KDesktopFile, i.e. they all have to reparse the files every time.
This is simple to fix: letting KService save the information about those actions into ksycoca.
Right now it saves all the contents of the [Desktop Entry] group, but not the actions group.
Implemented with the attached patch.

Also ported KDesktopFileActions to that; changes the API slightly, KDesktopFileActions::Service
is to be ported to KServiceAction, which is good since Service had ugly public members. This part
will wait until Monday obviously.

While writing the unit test for this, I noticed that the binary representation (like, in ksycoca)
of a single KService was 3700 bytes. This is because KConfigGroup::entryMap returns all translated
entries. After filtering those out, the KService is down to 755 bytes; and the whole ksycoca4 went
from 9.0M to 1.5M!
I still have to figure out how this worked in KDE3. From my tests, KConfig::entryMap(group) returned
translated entries as well, and yet they are not seen by kservice nor end up in ksycoca3; confusing.
Seems like KDesktopFile and KConfig behaved a bit differently on this; with KDesktopFile the entryMap
doesn't have the translations... Anyone knows about this? (cf kconfigtest.cpp.kde3.diff)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kdelibs-kserviceactions.diff
Type: text/x-diff
Size: 23297 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071013/8298c3d1/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kconfigtest.cpp.kde3.diff
Type: text/x-diff
Size: 1658 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20071013/8298c3d1/attachment-0001.diff>


More information about the kde-core-devel mailing list