Riccardo Mottola wrote:

> 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?

I think it would be a better idea to always perform  
  [_listener application: self openFiles: files];
in NSApplication (even if there is only one file).

In GSServicesManager you could then use this code (beware I didn' test this):
- (void) application: (NSApplication*)theApp
           openFiles: (NSArray*)files
{
  id    del = [NSApp delegate];
  
  if ([del respondsToSelector: _cmd])
    {
      [del application: theApp openFiles: files];
    }
  else
    {
       NSString *filePath;
       NSEnumerator *en = [files objectEnumerator];

       while ((filePath = (NSString *)[en nextObject]) != nil)
         {
           [self application: theApp openFile: filePath];
         }
    }
}

Wolfgang



_______________________________________________
Discuss-gnustep mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/discuss-gnustep

Reply via email to