From 5d10d4ccbba979b37f14a79cd641b24a3f10863a Mon Sep 17 00:00:00 2001 From: fedor Date: Tue, 27 May 2003 04:10:20 +0000 Subject: [PATCH] New method to load user bundles git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16804 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Documentation/Gui/DefaultsSummary.gsdoc | 8 ++++++++ Source/NSApplication.m | 27 +++++++++++++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/ChangeLog b/ChangeLog index f88eb9359..bbb4d8361 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-05-26 Adam Fedor + + * Source/NSApplication.m (gsapp_user_bundles): New function + (-_init): Use it. + * Documentation/Gui/DefaultsSummary.gsdoc: Update. + 2003-05-25 Adam Fedor * Version 0.8.6 diff --git a/Documentation/Gui/DefaultsSummary.gsdoc b/Documentation/Gui/DefaultsSummary.gsdoc index a5f7d4a90..be006bc1c 100644 --- a/Documentation/Gui/DefaultsSummary.gsdoc +++ b/Documentation/Gui/DefaultsSummary.gsdoc @@ -55,6 +55,14 @@ Default is Control-g.

+ GSAppKitUserBundles + +

+ An array listing the names of bundles that will be automatically + loaded into every application at startup. Typically these will + be 'theme' bundles that control the look of the application. +

+
GSQuoteKey

diff --git a/Source/NSApplication.m b/Source/NSApplication.m index da1b9fda8..a1d0be8f3 100644 --- a/Source/NSApplication.m +++ b/Source/NSApplication.m @@ -221,6 +221,7 @@ initialize_gnustep_backend(void) _(@"Backend at path %@ doesn't contain the GSBackend class"), path); [backend initializeBackend]; } + #else /* GSBackend will be in a separate library, so use the runtime to find the class and avoid an unresolved reference problem */ @@ -232,6 +233,29 @@ initialize_gnustep_backend(void) return YES; } +void +gsapp_user_bundles() +{ + NSUserDefaults *defs=[NSUserDefaults standardUserDefaults]; + NSArray *a=[defs arrayForKey: @"GSAppKitUserBundles"]; + int i, c; + c = [a count]; + if (a == nil || c == 0) + return; + NSLog(@"Loading %d user defined AppKit bundles", c); + for (i = 0; i < c; i++) + { + NSBundle *b = [NSBundle bundleWithPath: [a objectAtIndex: i]]; + if (!b) + { + NSLog(@"* Unable to load '%@'", [a objectAtIndex: i]); + continue; + } + NSLog(@"Loaded '%@'\n", [a objectAtIndex: i]); + [[[b principalClass] alloc] init]; + } +} + /* * Types */ @@ -588,6 +612,9 @@ static NSCell* tileCell = nil; /* Initialize the backend here. */ initialize_gnustep_backend(); + + /* Load user-defined bundles */ + gsapp_user_bundles(); /* Connect to our window server. */ srv = [GSDisplayServer serverWithAttributes: nil];