Hi,
Fred Kiefer wrote:
GNUstep has these methods mainly on the class GSServicesManager. This
is somethign that I always wondered about. It would feel more natural
to me to have these methods on NSApplication, and have
GSServicesManager call that implementation. We could then dispatch the
calls in NSApplication either to the delegate or to the corresponding
methods on NSDocumentController, if the delegate wont handle them.
Adding "application:openFiles:"would be very simple then.
For your specific requirement even with the current code it would be
simple to add that method and all you would have to do then is
implement it on the application delegate.
That is what I did, I attach a preliminary patch that shows where I am
heading to. It works: for N files the delegate gets called, else with a
single file it works as before. Fine.
However, previously if N files were passed, openFile was called iteratively.
I think this behaviour should be preserved if ther eis no delegate for
openFiles, what do you think? But how? The chekds are done in the
GSServiceManager, but there this method returns (void) so in
NSApplication I don't know to handle the fallback. Inside NSApplication
how can I check if the delegate implements the openFiles method?
Riccardo
Index: Source/NSApplication.m
===================================================================
--- Source/NSApplication.m (revision 35352)
+++ Source/NSApplication.m (working copy)
@@ -1122,10 +1122,17 @@
{
NSEnumerator *en = [files objectEnumerator];
- while ((filePath = (NSString *)[en nextObject]) != nil)
+ if ([files count] > 1)
{
- [_listener application: self openFile: filePath];
+ [_listener application: self openFiles: files];
}
+ else
+ {
+ while ((filePath = (NSString *)[en nextObject]) != nil)
+ {
+ [_listener application: self openFile: filePath];
+ }
+ }
}
else if ((filePath = [defs stringForKey: @"GSFilePath"]) != nil
|| (filePath = [defs stringForKey: @"NSOpen"]) != nil)
@@ -3555,6 +3562,7 @@
* <item>application:shouldTerminateAfterLastWindowClosed:</item>
* <item>application:shouldOpenUntitledFile:</item>
* <item>application:openFile:</item>
+ * <item>application:openFiles:</item>
* <item>application:openFileWithoutUI:</item>
* <item>application:openTempFile:</item>
* <item>application:openUntitledFile:</item>
Index: Source/GSServicesManager.m
===================================================================
--- Source/GSServicesManager.m (revision 35352)
+++ Source/GSServicesManager.m (working copy)
@@ -591,6 +591,18 @@
return result;
}
+- (void) application: (NSApplication*)theApp
+ openFiles: (NSArray*)files
+{
+ id del = [NSApp delegate];
+
+ if ([del respondsToSelector: _cmd])
+ {
+ [del application: theApp openFiles: files];
+ }
+}
+
+
- (BOOL) application: (NSApplication*)theApp
openFileWithoutUI: (NSString*)file
{
_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep