Re: Resource Files (Was: Re: [GUI] More points for the technical discussion)

On Monday, February 17, 2003, at 02:40 AM, Seth Kurtzberg wrote:
I would phrase it slightly differently. We should have a platform-independent API related to resources, which in some cases may use underlying capabilities of the target O/S.
On Monday, February 17, 2003, at 11:03 AM, Axel Simon wrote:
I definitely agree to that. IMHO it is very important to use the toolkit's capability to custumize and internationalize the application. Every platform has it, Windows has .rc files, Gtk has style files and Apple has its functionality. If we don't make use of these facilities we wind up writing a toy (educational) API where you have 6 color constants and 3 font constants and use them blindly.
Are you sure we're talking about the same resource files here? Resources on MacOS, and, as far as I know, on Windows, have nothing to do with customization - whereas IIRC customization and "theming" are the main purpose of X11 resources and GTK style files. I was responding to Glynn Clements' statement that "User-visible text doesn't belong in the source code". For Mac OS apps, it belongs in the dialog templates (the "nib" file, a binary format editable only with Apple's Interface Builder application) and in string tables (nowadays, XML files). We don't want to end up having to draw all dialogs three times with three different (and possibly proprietary and single-platform) tools, or having to write down all user-visible text in three different file formats. On the other hand, it would be great to be able to store bitmaps and other data in the .EXE file's resources on Windows, and in the appropriate application wrapper on Mac OS, rather than cluttering the application directory with many files. As far as X-style customization is concerned, are there any features that you would expect that don't come for free? As a MacOS developer, I'd just expect some library to provide me with a way to say "store this data in the preferences/settings/defaults file" (which should be put in the standard location for preferences files). Do I have to use a particular resource format in order to be a "good citizen" on X11? Cheers, Wolfgang

I definitely agree to that. IMHO it is very important to use the toolkit's capability to custumize and internationalize the application. Every platform has it, Windows has .rc files, Gtk has style files and Apple has its functionality. If we don't make use of these facilities we wind up writing a toy (educational) API where you have 6 color constants and 3 font constants and use them blindly.
Are you sure we're talking about the same resource files here? Well, resource files are some sort of abstraction (separation of functionality and content). As such, there should be an advantage of going
On Mon, Feb 17, 2003 at 01:51:38PM +0100, Wolfgang Thaller wrote: through all this hassle, i.e. the possibility of changing resources must have benefits (internationalization, or just the fact that you don't hard-code any values in you program). In an old "Programming Windows" Petzold (3.1) I read something about "you can change the resource strings to a different language to get a foreign language version of you application".
Resources on MacOS, and, as far as I know, on Windows, have nothing to do with customization - whereas IIRC customization and "theming" are the main purpose of X11 resources and GTK style files. True, themes are the real reason of haveing these resource files. But you can (and should) use these files as normal resource files in the Windows/Aqua sense.
I was responding to Glynn Clements' statement that "User-visible text doesn't belong in the source code". For Mac OS apps, it belongs in the dialog templates (the "nib" file, a binary format editable only with Apple's Interface Builder application) and in string tables (nowadays, XML files). We don't want to end up having to draw all dialogs three times with three different (and possibly proprietary and single-platform) tools, or having to write down all user-visible text in three different file formats. ...but we would like to have a common API to look up these resources, right? I feel there is a problem.
On the other hand, it would be great to be able to store bitmaps and other data in the .EXE file's resources on Windows, and in the appropriate application wrapper on Mac OS, rather than cluttering the application directory with many files. Supporting the native way of storing data would be very nice and I would prefer that. Maybe this requires adopting one approach and build a compiler to resource formats on other platforms. Or we choose one format and use it on all platforms. This wouldn't affect native-look-and-feel but would make it harder using native backend functionality with this foreign resource files.
As far as X-style customization is concerned, are there any features that you would expect that don't come for free? No, I think theming and the like is not an issue in the sense that it would still be possible and is totally transparent for the programmer.
As a MacOS developer, I'd just expect some library to provide me with a way to say "store this data in the preferences/settings/defaults file" (which should be put in the standard location for preferences files). Do I have to use a particular resource format in order to be a "good citizen" on X11? I guess most applications still store their data in a proprietary format in a .blah file in the user's home directory. Gtk knows something about "Settings" which allows to store texts, number, colors and the like. This format is definitely proprietary. I think Gnome provides some Registry equivalent.
I would like to see this covered by the Common API, since it takes a big burden from the programmer. I could imagine a function like col <- lookupColor "automaton-state-color" black which looks up the entry "automaton-state-color" in your local resource files and returns that. If the entry is not found, black is returned as a default (and maybe this entry is created). Axel.

Axel Simon wrote:
I was responding to Glynn Clements' statement that "User-visible text doesn't belong in the source code". For Mac OS apps, it belongs in the dialog templates (the "nib" file, a binary format editable only with Apple's Interface Builder application) and in string tables (nowadays, XML files). We don't want to end up having to draw all dialogs three times with three different (and possibly proprietary and single-platform) tools, or having to write down all user-visible text in three different file formats.
...but we would like to have a common API to look up these resources, right? I feel there is a problem.
Xt applications don't read the resource database explicitly. The application creates a widget of a particular class with a specific name. Xt retrieves all of the widget's properties from the resource database automatically. The key point is that the details of the UI's appearance are separated from the application logic. The program just creates the widget and notes its "handle". Motif takes this approach a step further via the MRM library. This allows an entire UI hierarchy to be loaded from a UID file with a couple of function calls. The application can then retrieve widget handles by name or index. This allows the UI to be constructed using an interface builder, possibly by someone without programming skills.
As a MacOS developer, I'd just expect some library to provide me with a way to say "store this data in the preferences/settings/defaults file" (which should be put in the standard location for preferences files). Do I have to use a particular resource format in order to be a "good citizen" on X11?
I guess most applications still store their data in a proprietary format in a .blah file in the user's home directory. Gtk knows something about "Settings" which allows to store texts, number, colors and the like. This format is definitely proprietary. I think Gnome provides some Registry equivalent.
I would like to see this covered by the Common API, since it takes a big burden from the programmer. I could imagine a function like
col <- lookupColor "automaton-state-color" black
which looks up the entry "automaton-state-color" in your local resource files and returns that. If the entry is not found, black is returned as a default (and maybe this entry is created).
This has some similarities to XtGetApplicationResources(). However,
all X resources have both a name and a class; e.g. you might have
several font resources, each with a distinct name but all with the
class "Font". To retrieve a value, you specify both the name and the
class (as well as the type, size, result location and a default
value).
Also, Xt doesn't have type-specific get/set functions; the type is
passed in as argument, and the set of types is extensible. A
polymorphic function might be preferable.
--
Glynn Clements

--- Wolfgang Thaller
On the other hand, it would be great to be able to store bitmaps and other data in the .EXE file's resources on Windows, and in the appropriate application wrapper on Mac OS, rather than cluttering the application directory with many files.
I was recently planed to do this with Port. The Port library has readBitmap function which takes the FilePath and returns the Bitmap data type. My idea is to use paths like "res://MyBitmap.bmp" for bitmaps which are contained in the resource section of the .EXE file. Under Linux/Unix the "res://" prefix can be mapped to "/usr/shared/AppName/" or some similar predefined path. Krasimir __________________________________________________ Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day http://shopping.yahoo.com

Wolfgang, There is a standard format used with X for application specific configuration. However, X is agnostic about whether this information is in one file, a separate file for each app, or some combination. .Xdefaults in the home directory is a typical place. You would not want to bundle the configuration information into the same file as the program itself in an X environment. I don't know if I would agree that customization and theming are the primary reason that resource-type files are used in X. It is true that such information can be included in these files, but other types of info are also included there. It is more of a general mechanism to fetch something that can be specified without rebuilding the application. So it is relevant here, even though it also has other uses in X. On Monday 17 February 2003 05:51 am, Wolfgang Thaller wrote:
On Monday, February 17, 2003, at 02:40 AM, Seth Kurtzberg wrote:
I would phrase it slightly differently. We should have a platform-independent API related to resources, which in some cases may use underlying capabilities of the target O/S.
On Monday, February 17, 2003, at 11:03 AM, Axel Simon wrote:
I definitely agree to that. IMHO it is very important to use the toolkit's capability to custumize and internationalize the application. Every platform has it, Windows has .rc files, Gtk has style files and Apple has its functionality. If we don't make use of these facilities we wind up writing a toy (educational) API where you have 6 color constants and 3 font constants and use them blindly.
Are you sure we're talking about the same resource files here? Resources on MacOS, and, as far as I know, on Windows, have nothing to do with customization - whereas IIRC customization and "theming" are the main purpose of X11 resources and GTK style files.
I was responding to Glynn Clements' statement that "User-visible text doesn't belong in the source code". For Mac OS apps, it belongs in the dialog templates (the "nib" file, a binary format editable only with Apple's Interface Builder application) and in string tables (nowadays, XML files). We don't want to end up having to draw all dialogs three times with three different (and possibly proprietary and single-platform) tools, or having to write down all user-visible text in three different file formats.
On the other hand, it would be great to be able to store bitmaps and other data in the .EXE file's resources on Windows, and in the appropriate application wrapper on Mac OS, rather than cluttering the application directory with many files.
As far as X-style customization is concerned, are there any features that you would expect that don't come for free? As a MacOS developer, I'd just expect some library to provide me with a way to say "store this data in the preferences/settings/defaults file" (which should be put in the standard location for preferences files). Do I have to use a particular resource format in order to be a "good citizen" on X11?
Cheers,
Wolfgang
_______________________________________________ GUI mailing list GUI@haskell.org http://www.haskell.org/mailman/listinfo/gui
-- Seth Kurtzberg M. I. S. Corp. 480-661-1849 seth@cql.com
participants (5)
-
Axel Simon
-
Glynn Clements
-
Krasimir Angelov
-
Seth Kurtzberg
-
Wolfgang Thaller