libxfce4util version to try
benedikt.meurer at unix-ag.uni-siegen.de
Sun Mar 14 23:30:59 CET 2004
I finished the work on the xfce-resource stuff and added an RC file parser.
The xfce-resource functions should be ok now (and the trailing slash is
important to distinguish files from directories, cause I don't want to
duplicate the API functions, with every function in _dir() and a _file() version).
I'm thinking about adding two further categories to xfce-resource:
XFCE_RESOURCE_THEMES and XFCE_RESOURCE_PLUGINS. XFCE_RESOURCE_THEMES would
search in the standard themes path (~/.themes:...) and allow for easier
loading of theme (e.g. xfwm4 also uses the theme path, and xfce4-session will
do so soon aswell). For example, checking for themes in xfwm4 mcs module will
then be as easy as:
paths = xfce_resource_match (XFCE_RESOURCE_THEMES, "*/xfwm4/themerc", TRUE);
XFCE_RESOURCE_PLUGINS will allow for easier searching of modules (MCS, Panel),
so you would do:
modules = xfce_resource_match (XFCE_RESOURCE_PLUGINS, "panel/*.so", TRUE);
This would ease programming a lot IMHO, and would make the process of file
lookups transparenter to users, as we get defined locations for resources,
which are easily changeable through environment variables.
The RC parser features a backend system, where one can plug in different
backends. There are currently a "xfce_rc_simple" backend, which takes a file
and parses it and the "xfce_rc_config" backend, which uses the simple backend
to work on various files as specified by a single resource of a given type.
For example, say you have a RC file to customize xfwm4, then the system
default will be located in $sysconfdir/xdg/xfwm4/xfwm4rc and you want the user
to locally override settings. Until now you had to parse first the system
file(s) and after that the user file if any. With the config backend, you
rc = xfce_rc_config_open (XFCE_RESOURCE_DATA, "xfwm4/xfwm4rc", FALSE)
and the RC parse will parse all $XDG_CONFIG_DIRS/xfwm4/xfwm4rc files and make
them accessible through the rc object, where settings from files that appear
earlier in $XDG_CONFIG_DIRS will override other settings.
The xfce-rc module also allows you to open files read-write. If you do so,
it'll load _all_ locales from the file (if you open read-only, it'll only load
entries matching the current locale), so you can save the file later on
without loosing any information.
If you use the xfce_rc_config backend in read-write mode, modified entries
will be saved to the save_location for that type, which is usually a file in
the users home directory.
The RC parser can also be used to parse desktop files. If Jasper agrees, we
could make the XfceDesktopEntry class use the xfce_rc_simple parser. This way
we get write support for the desktop entries (though I doubt we need it).
A few words about performance: The RC parser is quite optimized. It parses
even large RC files from KDE in a very short time. This performance is gained
by using GMemChunks and GStringChunks. Using this two constructs might result
in some memory waste (approx 5% more waste than if using g_malloc and friends
directly), but I think this an acceptable price for better performance (esp.
when thinking of menu generation in xfdesktop with up to hundrets of desktop
files that has to be parsed).
I'd like everyone to have a look at it and give me some feedback about whats
missing or wrong. The stuff should be relatively bug free, but no promises.
Grab it here:
NetBSD Operating system: http://www.NetBSD.org/
pkgsrc "Work in progress": http://pkgsrc-wip.sf.net/
XFce desktop environment: http://www.xfce.org/
German Unix-AG Association: http://www.unix-ag.org/
OpenPGP Key: http://www.home.unix-ag.org/bmeurer/#gpg
More information about the Xfce4-dev