discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tool with Resources


From: Nicola Pero
Subject: Re: Tool with Resources
Date: Thu, 26 Sep 2002 02:35:17 +0100 (BST)

Hi Frederic,

> Hello everybody.
> I have a tool (ggelite), not a gui application.  And it needs a lot of
> resources (textures, sounds,....)
> What is the canonical way to deal with this situation?  Should I put
> everything in a bundle? 

A bundle might be a good solution ... but your question has prompted me to
implemented in gnustep-make a quite better solution - of which I've long
been talking about ... I've now finally done it. :-)

Tools can now (optionally) have resource bundles associated with them,
automatically available via [NSBundle +mainBundle], exactly in the same
way as applications have main bundles containing resources associated with
them.

To use it, get the latest gnustep-make from CVS.

Say that you have

include $(GNUSTEP_MAKEFILES)/common.make

TOOL_NAME = Frederic
Frederic_OBJC_FILES = a.m b.m c.m

include $(GNUSTEP_MAKEFILES)/tool.make

Now you need to add

Frederic_HAS_RESOURCE_BUNDLE = yes

with the other Frederic_XXX variables; this will turn on support for tools
main bundles in gnustep-make ... and then you can use all the standard
variables you would normally use for bundles (such as xxx_RESOURCE_FILES,
xxx_RESOURCE_DIRS, xxx_LANGUAGES, xxx_LOCALIZED_RESOURCE_FILES etc), for
example, to include a .txt file in the bundle, just add

Frederic_RESOURCE_FILES = Important.txt

Then, gnustep-make will detect you have requested a bundle for your tool,
and will automatically create a ./Resources/Frederic directory, and build
the bundle there by copying stuff into it with the usual bundle rules.

When you install the tool, say that's installed into

xxx/Tools/ix86/linux-gnu/gnu-gnu-gnu/Frederic

then its associated bundle will automatically be installed into

xxx/Tools/Resources/Frederic/

gnustep-base can move backwards from the tool executable location to the
tool resource bundle dir and find it - it does so when you ask for
[NSBundle +mainBundle].

So basically you can access your bundle using gnustep-base's [NSBundle
+mainBundle] method.  For an application, it returns the applciation main
bundle; for a tool, by extension it returns the 'tool main bundle', which
is the bundle we've been talking about.  NB: the gnustep-base code should
find the bundle both before you install the tool (it will then find the
non-installed ./Resources/Frederic dir; of course it will find it assuming
you've not moved the tool around :-), and after you install the tool (it
will then find the installed xxx/Tools/Resources/Frederic dir).

It's experimental, but it works quite nicely on my machine.  If you try it
out (if anyone tries it out!), let me know if you have any problems or
comments or how it goes :-)

Btw, this stuff is basic as it will allow tools not only to have resources
(and they normally do have resources), but also to have localized
messages.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]