|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
Overriding of FXApp's reg member variableHello,
I'd like to make my FOX application "portable" (eg: run from an USB-key), both under Windows and Linux. Therefore, I should store the registry file in the same dir, where the binary resides (not in user's home). Is there any chance to replace FXApp::registry (which is private, and FXRegisty::readFromDir protected, and FXRegistry &operator=(const FXRegistry&); is private, so the FXRegistry secured enough :-)) with my own implementation of (overridden) FXRegistry? If not, why? What do you suggest how to solve this problem? There are serveral usages of getApp()->reg().write*** in the fox code, and there would be rather ugly solution to override or replace all of them with my implementation (including the FXApp class). It would be also useful, when the developer would like to store the app's settings in a database, not in a flat file... Thanks: wwrreecckk |
|
|
Re: Overriding of FXApp's reg member variableOn Saturday 25 July 2009, wwrreecckk wrote:
> > Hello, > > I'd like to make my FOX application "portable" (eg: run from an USB-key), > both under Windows and Linux. > Therefore, I should store the registry file in the same dir, where the > binary resides (not in user's home). Since FXRegistry is derived from FXSettings, you are able to call parseFile() and unparseFile() to read or write the contents to another filename. If its for reading only, then setting FOXDIR environment variable dictates where the system-wide registry settings are found. It also probes directories from $PATH with the suffix /foxrc (e.g. /usr/bin/foxrc, etc). Finally, there is a compile-time override you may set called REGISTRYPATH, if changed, it should contain a list where the system-wide directories are to be searched, in a format similar to $PATH. > Is there any chance to replace FXApp::registry (which is private, and > FXRegisty::readFromDir protected, and FXRegistry &operator=(const > FXRegistry&); is private, so the FXRegistry secured enough :-)) with my own > implementation of (overridden) FXRegistry? > > If not, why? Basically, you're the first one to ask. Users expect their settings to be preserved when applications are started at a later time. For that to work, the settings need to be in a given place; on Windows, FOX uses the WIN32 Registry service, or the ~/.foxrc on *NIX [you may also use the file-based method on Windows if setAsciiMode(true) is used]. > What do you suggest how to solve this problem? There are serveral usages of > getApp()->reg().write*** in the fox code, and there would be rather ugly > solution to override or replace all of them with my implementation > (including the FXApp class). Yes, that would not be nice, most of the library and countless apps assume there is a registry. > It would be also useful, when the developer would like to store the app's > settings in a database, not in a flat file... Its not impossible, to iterate over the settings database and write out each key/value pair to another database. Note that the settings are only getting written if modified, so simply resetting the modified flag to false will cause it to by-pass the normal process in FXApp::exit(). Of course, you could also overload FXApp::exit() and only closeDisplay(), and stop(code) and omit the registry.write() from it. Since the settings database rarely gets really large, a database is not the first thing that comes to mind. In your case it may be sufficient to just call app->reg().unparseFile() with the desired filename. Regards, - Jeroen -- +----------------------------------------------------------------------------+ | Copyright (C) 20:20 07/25/2009 Jeroen van der Zijp. All Rights Reserved. | +----------------------------------------------------------------------------+ ------------------------------------------------------------------------------ _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Overriding of FXApp's reg member variable [solved]Thanks for your fast response.
That's great!
|
|
|
Re: Overriding of FXApp's reg member variableI think it would be handy to be able to override from which file the
settings are read. As a matter of fact, it would be nice if FOX can follow the XDG spec (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) instead. (all application write settings to a common directory under your home account, so it is easy to backup or transfer). The easiest method to override the default reading/writing part in FXRegistry: * override FXApp::init and before calling FXApp::init in the subclass, populate the registry with settings read from your own settings file. Make sure to pass the 'mark' flag as true. * Make sure to have set the application and vendor key to an empty string. This will prevent reading and writing of the settings files, with the exception of "Desktop" file. If you passed the 'mark' flags as false, subsequent reading in FXApp::init won't override the earlier settings you read in. * Implement your own writing of the settings file on shutdown. Cheers, Sander On Sat, Jul 25, 2009 at 9:00 PM, Jeroen van der Zijp <jeroen@...> wrote: > On Saturday 25 July 2009, wwrreecckk wrote: >> >> Hello, >> >> I'd like to make my FOX application "portable" (eg: run from an USB-key), >> both under Windows and Linux. >> Therefore, I should store the registry file in the same dir, where the >> binary resides (not in user's home). > > Since FXRegistry is derived from FXSettings, you are able to call parseFile() > and unparseFile() to read or write the contents to another filename. > > If its for reading only, then setting FOXDIR environment variable dictates > where the system-wide registry settings are found. It also probes directories > from $PATH with the suffix /foxrc (e.g. /usr/bin/foxrc, etc). > Finally, there is a compile-time override you may set called REGISTRYPATH, > if changed, it should contain a list where the system-wide directories are > to be searched, in a format similar to $PATH. > >> Is there any chance to replace FXApp::registry (which is private, and >> FXRegisty::readFromDir protected, and FXRegistry &operator=(const >> FXRegistry&); is private, so the FXRegistry secured enough :-)) with my own >> implementation of (overridden) FXRegistry? >> >> If not, why? > > Basically, you're the first one to ask. Users expect their settings to be > preserved when applications are started at a later time. For that to work, > the settings need to be in a given place; on Windows, FOX uses the WIN32 > Registry service, or the ~/.foxrc on *NIX [you may also use the file-based > method on Windows if setAsciiMode(true) is used]. > >> What do you suggest how to solve this problem? There are serveral usages of >> getApp()->reg().write*** in the fox code, and there would be rather ugly >> solution to override or replace all of them with my implementation >> (including the FXApp class). > > Yes, that would not be nice, most of the library and countless apps assume > there is a registry. > >> It would be also useful, when the developer would like to store the app's >> settings in a database, not in a flat file... > > Its not impossible, to iterate over the settings database and write out > each key/value pair to another database. Note that the settings are only > getting written if modified, so simply resetting the modified flag to > false will cause it to by-pass the normal process in FXApp::exit(). > > Of course, you could also overload FXApp::exit() and only closeDisplay(), > and stop(code) and omit the registry.write() from it. > > Since the settings database rarely gets really large, a database is not > the first thing that comes to mind. > > In your case it may be sufficient to just call app->reg().unparseFile() > with the desired filename. > > > Regards, > > - Jeroen > > > > -- > +----------------------------------------------------------------------------+ > | Copyright (C) 20:20 07/25/2009 Jeroen van der Zijp. All Rights Reserved. | > +----------------------------------------------------------------------------+ > > ------------------------------------------------------------------------------ > _______________________________________________ > Foxgui-users mailing list > Foxgui-users@... > https://lists.sourceforge.net/lists/listinfo/foxgui-users > -- "And any fool knows a dog needs a home A shelter from pigs on the wing" ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Overriding of FXApp's reg member variableOn Wednesday 14 October 2009, Sander Jansen wrote:
> I think it would be handy to be able to override from which file the > settings are read. As a matter of fact, it would be nice if FOX can > follow the XDG spec > (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) > instead. (all application write settings to a common directory under > your home account, so it is easy to backup or transfer). > > The easiest method to override the default reading/writing part in FXRegistry: > > * override FXApp::init and before calling FXApp::init in the subclass, > populate the registry with settings read from your own settings file. > Make sure to pass the 'mark' flag as true. > > * Make sure to have set the application and vendor key to an empty > string. This will prevent reading and writing of the settings files, > with the exception of "Desktop" file. If you passed the 'mark' flags > as false, subsequent reading in FXApp::init won't override the earlier > settings you read in. > > * Implement your own writing of the settings file on shutdown. I have no fundamental problem with the concept per-se. But the first thing I'm asking myself when asked to "Follow the Herd" is, "Is There In Fact a Herd?" Or would we be betting on the wrong horse? Who else is using this, or planning to use this? In what way would we be better off when we used this v.s. our current situation (since obviously this might inconvenience people during the transition). - Jeroen ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
|
|
Re: Overriding of FXApp's reg member variableOn Fri, Oct 16, 2009 at 8:07 AM, Jeroen van der Zijp <jvdzijp@...> wrote:
> On Wednesday 14 October 2009, Sander Jansen wrote: >> I think it would be handy to be able to override from which file the >> settings are read. As a matter of fact, it would be nice if FOX can >> follow the XDG spec >> (http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html) >> instead. (all application write settings to a common directory under >> your home account, so it is easy to backup or transfer). >> >> The easiest method to override the default reading/writing part in FXRegistry: >> >> * override FXApp::init and before calling FXApp::init in the subclass, >> populate the registry with settings read from your own settings file. >> Make sure to pass the 'mark' flag as true. >> >> * Make sure to have set the application and vendor key to an empty >> string. This will prevent reading and writing of the settings files, >> with the exception of "Desktop" file. If you passed the 'mark' flags >> as false, subsequent reading in FXApp::init won't override the earlier >> settings you read in. >> >> * Implement your own writing of the settings file on shutdown. > > I have no fundamental problem with the concept per-se. > > But the first thing I'm asking myself when asked to "Follow the Herd" is, > "Is There In Fact a Herd?" Or would we be betting on the wrong horse? > > Who else is using this, or planning to use this? In what way would we > be better off when we used this v.s. our current situation (since obviously > this might inconvenience people during the transition). Perhaps as a first step, to be able to easily override the FXRegistry in FXApp would be a nice thing to have. The current method is kind of hackerish... > > > - Jeroen > > -- "And any fool knows a dog needs a home A shelter from pigs on the wing" ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Foxgui-users mailing list Foxgui-users@... https://lists.sourceforge.net/lists/listinfo/foxgui-users |
| Free embeddable forum powered by Nabble | Forum Help |