Difference between revisions of "Standard Resources (KDE3 Architecture)"
imported>Eliddell (Created page with "== Overview == <!--T:2--> <!--T:3--> KDE offers several ways to access the files that your application installed on your user's hard disc while making it transparent to you w...") |
m (Added a header) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
− | == Overview == <!--T:2--> |
||
− | |||
− | <!--T:3--> |
||
⚫ | |||
installed on your user's hard disc while making it transparent |
installed on your user's hard disc while making it transparent |
||
to you where the data really are. To allow the user (or adminstrator |
to you where the data really are. To allow the user (or adminstrator |
||
− | in most cases) to move files where |
+ | in most cases) to move files where they see them fit best, TDE offers |
a list of different resource types for which a different search path |
a list of different resource types for which a different search path |
||
is assigned to. You may have heard of the environment variable <tt>PATH</tt> |
is assigned to. You may have heard of the environment variable <tt>PATH</tt> |
||
Line 12: | Line 9: | ||
<!--T:4--> |
<!--T:4--> |
||
− | Similiar to that concept |
+ | Similiar to that concept, TDE separates search paths for different |
things to make it simpler to add paths for a specific resource without |
things to make it simpler to add paths for a specific resource without |
||
making a lookup for another resource unnecessary slower and without |
making a lookup for another resource unnecessary slower and without |
||
requiring you to put everything into one directory. |
requiring you to put everything into one directory. |
||
+ | = Resource types = |
||
<!--T:5--> |
<!--T:5--> |
||
+ | {{Outdated|2022|04|21|reason=Might need to be updated according to docs.}} |
||
− | The types of resources |
+ | The types of resources TDE offers are |
<!--T:6--> |
<!--T:6--> |
||
Line 27: | Line 26: | ||
* data - where applications store data |
* data - where applications store data |
||
<!--T:8--> |
<!--T:8--> |
||
− | * exe - executables installed privatly for |
+ | * exe - executables installed privatly for use by the desktop environment |
* html - HTML documentation |
* html - HTML documentation |
||
<!--T:9--> |
<!--T:9--> |
||
* icon - application icons to appear in the window manager or the panel |
* icon - application icons to appear in the window manager or the panel |
||
− | * lib - libraries and to be |
+ | * lib - libraries and to be <code>dlopen</code>ed modules |
<!--T:10--> |
<!--T:10--> |
||
− | * locale - translation files for |
+ | * locale - translation files for TDELocale |
* mime - mime types |
* mime - mime types |
||
<!--T:11--> |
<!--T:11--> |
||
Line 41: | Line 40: | ||
<!--T:12--> |
<!--T:12--> |
||
− | For all of them exist also Makefile aliases that configures created by the development |
+ | <!-- For all of them exist also Makefile aliases that configures created by the development |
− | tools provided for |
+ | tools provided for TDE (e.g. tdevelop) will know about. --> |
− | + | = TDEStandardDirs = <!--T:13--> |
|
<!--T:14--> |
<!--T:14--> |
||
− | This is one of the most central classes in |
+ | This is one of the most central classes in tdelibs as |
it provides a basic service: it knows where the files |
it provides a basic service: it knows where the files |
||
− | reside on the user's |
+ | reside on the user's hard disk. And it's meant to be the |
only one that knows - to make the real location as |
only one that knows - to make the real location as |
||
transparent as possible to both the user and the applications. |
transparent as possible to both the user and the applications. |
||
Line 58: | Line 57: | ||
(e.g. apps) and a filename (e.g. Home.desktop). In an ideal world |
(e.g. apps) and a filename (e.g. Home.desktop). In an ideal world |
||
the application would make no assumption where this file is and |
the application would make no assumption where this file is and |
||
− | leaves it up to < |
+ | leaves it up to <code>TDEStandardDirs::findResource("apps", "Home.desktop")</code> |
to apply this knowledge. |
to apply this knowledge. |
||
<!--T:16--> |
<!--T:16--> |
||
− | The main idea behind |
+ | The main idea behind TDEStandardDirs is that there are several |
toplevel prefixes where files are below. One of this prefixes is |
toplevel prefixes where files are below. One of this prefixes is |
||
− | the one where the user installed |
+ | the one where the user installed tdelibs into, one where the |
− | application has been installed to and one is $HOME/. |
+ | application has been installed to and one is <tt>$HOME/.trinity</tt>, but there |
may be even more. Under these prefixes there are several well |
may be even more. Under these prefixes there are several well |
||
defined suffixes where specific resource types are to be found. |
defined suffixes where specific resource types are to be found. |
||
− | For example for toolbar icons that is share/toolbar and |
+ | For example for toolbar icons that is <tt>share/toolbar</tt> and |
− | share/apps/<appname>/pics. |
+ | <tt>share/apps/<appname>/pics</tt>. |
<!--T:17--> |
<!--T:17--> |
||
− | So the search algorithm |
+ | So the search algorithm basically appends to each prefix each registered |
suffix and tries to locate the file there. |
suffix and tries to locate the file there. |
||
To make the thing even more complex, it's also possible to register |
To make the thing even more complex, it's also possible to register |
||
− | absolute paths that |
+ | absolute paths that TDEStandardDirs looks up after not finding anything |
in the former steps. They can be useful if the user wants to provide |
in the former steps. They can be useful if the user wants to provide |
||
− | specific directories that aren't in |
+ | specific directories that aren't in their $HOME/.kde directory as |
example for icons. |
example for icons. |
||
− | + | == On the usage of <code>locate</code> and <code>locateLocal</code> == <!--T:18--> |
|
<!--T:19--> |
<!--T:19--> |
||
− | locate and locateLocal are both convenient functions that make the use of |
+ | <code>locate</code> and <code>locateLocal</code> are both convenient functions that make the use of |
− | + | TDEStandardDirs as simple as possible. You have however the possibility to |
|
− | use the full power of |
+ | use the full power of TDEStandardDirs without them. |
<!--T:20--> |
<!--T:20--> |
||
− | Typical |
+ | Typical TDE applications use resource files in one out of three ways: |
<!--T:21--> |
<!--T:21--> |
||
− | * A resource file is read but is never written. A system default is supplied but the user can override this default in |
+ | * A resource file is read but is never written. A system default is supplied but the user can override this default in their local .trinity directory: |
<!--T:22--> |
<!--T:22--> |
||
Line 101: | Line 100: | ||
<!--T:23--> |
<!--T:23--> |
||
− | * A resource file is read and written. If the user has no local version of the file the system default is used. The resource file is always written to the users local . |
+ | * A resource file is read and written. If the user has no local version of the file the system default is used. The resource file is always written to the users local <tt>.trinity</tt> directory. |
<!--T:24--> |
<!--T:24--> |
||
Line 116: | Line 115: | ||
<!--T:25--> |
<!--T:25--> |
||
− | * A resource file is read and written. No system default is used if the user has no local version of the file. The resource file is always written to the users local . |
+ | * A resource file is read and written. No system default is used if the user has no local version of the file. The resource file is always written to the users local <tt>.trinity</tt> directory. |
<!--T:26--> |
<!--T:26--> |
Latest revision as of 16:37, 21 April 2022
Trinity offers several ways to access the files that your application installed on your user's hard disc while making it transparent to you where the data really are. To allow the user (or adminstrator in most cases) to move files where they see them fit best, TDE offers a list of different resource types for which a different search path is assigned to. You may have heard of the environment variable PATH to lookup executables or MANPATH for looking up man pages. You wouldn't expect man to lookup man pages in PATH.
Similiar to that concept, TDE separates search paths for different things to make it simpler to add paths for a specific resource without making a lookup for another resource unnecessary slower and without requiring you to put everything into one directory.
Resource types
This warning was placed on 2022/04/21. (Reason: Might need to be updated according to docs.)
The types of resources TDE offers are
- apps - applications menu (.desktop files)
- cgi - CGIs to run from khelpcenter
- config - configuration files
- data - where applications store data
- exe - executables installed privatly for use by the desktop environment
- html - HTML documentation
- icon - application icons to appear in the window manager or the panel
- lib - libraries and to be
dlopen
ed modules - locale - translation files for TDELocale
- mime - mime types
- sound - application sounds
- toolbar - toolbar pictures
- wallpaper - wallpapers
TDEStandardDirs
This is one of the most central classes in tdelibs as it provides a basic service: it knows where the files reside on the user's hard disk. And it's meant to be the only one that knows - to make the real location as transparent as possible to both the user and the applications.
For this it encapsulates all informations from the application
and applications always refer to a file with a resource type
(e.g. apps) and a filename (e.g. Home.desktop). In an ideal world
the application would make no assumption where this file is and
leaves it up to TDEStandardDirs::findResource("apps", "Home.desktop")
to apply this knowledge.
The main idea behind TDEStandardDirs is that there are several toplevel prefixes where files are below. One of this prefixes is the one where the user installed tdelibs into, one where the application has been installed to and one is $HOME/.trinity, but there may be even more. Under these prefixes there are several well defined suffixes where specific resource types are to be found. For example for toolbar icons that is share/toolbar and share/apps/<appname>/pics.
So the search algorithm basically appends to each prefix each registered suffix and tries to locate the file there. To make the thing even more complex, it's also possible to register absolute paths that TDEStandardDirs looks up after not finding anything in the former steps. They can be useful if the user wants to provide specific directories that aren't in their $HOME/.kde directory as example for icons.
On the usage of locate
and locateLocal
locate
and locateLocal
are both convenient functions that make the use of
TDEStandardDirs as simple as possible. You have however the possibility to
use the full power of TDEStandardDirs without them.
Typical TDE applications use resource files in one out of three ways:
- A resource file is read but is never written. A system default is supplied but the user can override this default in their local .trinity directory:
// Code example
myFile = locate("appdata", "groups.lst")
myData = myReadGroups(myFile);
- A resource file is read and written. If the user has no local version of the file the system default is used. The resource file is always written to the users local .trinity directory.
// Code example
myFile = locate("appdata", "groups.lst")
myData = myReadGroups(myFile);
...
doSomething(myData);
...
myFile = locateLocal("appdata", "groups.lst");
myWriteGroups(myFile, myData);
- A resource file is read and written. No system default is used if the user has no local version of the file. The resource file is always written to the users local .trinity directory.
// Code example
myFile = locateLocal("appdata", "groups.lst");
myData = myReadGroups(myFile);
...
doSomething(myData);
...
myFile = locateLocal("appdata", "groups.lst");
myWriteGroups(myFile, myData);
Initial Author: Stephan Kulow (coolo@kde.org)