discuss-gnustep
[Top][All Lists]
Advanced

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

Re: porting cocoafibs, trouble with nibs


From: Fred Kiefer
Subject: Re: porting cocoafibs, trouble with nibs
Date: Sun, 17 Sep 2006 21:45:53 +0200
User-agent: Thunderbird 1.5.0.5 (X11/20060725)

Paddy Smith schrieb:
> On 9/16/06, Fred Kiefer <fredkiefer@gmx.de> wrote:
>> Nice thing that you are doing here. Your main problem seems to be that
>> GNUstep currently does not support NSController and its subclasses (in
>> your case NSUserDefaultsController). With that missing your NIB file
>> will never work, which ever way you convert it.
>> I see two ways to proceed: Either you manage to remove the need for that
>> class from the original NIB file or we need to add that class somewhere.
>> I have some basic implementation for some of the controller classes
>> lying around here, but I never committed them to GNUstep as not to bloat
>> our code with unused classes.
> 
> okay, so it sounds like I need to get a handle on
> 
> 1) how far gnustep is away from having NSController support that would
> solve this problem for this case.
> 
> and
> 
> 2) how much work we would need to do to rip the NSController stuff
> out, and replace it.
> 
> For preference I would rather work on the NSController stuff, which
> should be of use to others, rather than on the hand-coding replacement
> bits.
> 
> any chance of getting my hands on your code ? ;-)
> 

Attached you will find the starting point for an implementation of the
needed controller classes. I also have some basic code for the array and
object control. But all of this is currently without real functionality.
We first need to decide if it is ok to add these classes to GNUstep gui.
Then somebody with understanding of key value binding needs to add the
actual code.

But even in the current state it should help to load your NIB file, or
at least get on to the next error. :-)

Cheers
Fred
/** <title>NSController</title>

   <abstract>abstract base class for controllers</abstract>

   Copyright <copy>(C) 2006 Free Software Foundation, Inc.</copy>

   Author: Fred Kiefer <fredkiefer@gmx.de>
   Date: June 2006

   This file is part of the GNUstep GUI Library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef _GNUstep_H_NSController
#define _GNUstep_H_NSController

#include <Foundation/NSObject.h>

#if OS_API_VERSION(100300,GS_API_LATEST)

@class NSMutableArray;

@interface NSController : NSObject <NSCoding>
{
  NSMutableArray *_editors;
}

// NSEditor protocol
- (BOOL) commitEditing;
- (void) discardEditing;

- (BOOL) isEditing;

// NSEditorRegistration protocol
- (void) objectDidBeginEditing: (id)editor;
- (void) objectDidEndEditing: (id)editor;

@end

#endif // OS_API_VERSION

#endif // _GNUstep_H_NSController
/** <title>NSUserDefaultsController</title>

   <abstract>Controller class for user defaults</abstract>

   Copyright <copy>(C) 2006 Free Software Foundation, Inc.</copy>

   Author: Fred Kiefer <fredkiefer@gmx.de>
   Date: September 2006

   This file is part of the GNUstep GUI Library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#ifndef _GNUstep_H_NSUserDefaultsController
#define _GNUstep_H_NSUserDefaultsController

#include <AppKit/NSController.h>

#if OS_API_VERSION(100300,GS_API_LATEST)

@class NSUserDefaults;
@class NSDictionary;
@class NSMutableDictionary;

@interface NSUserDefaultsController : NSController
{
  NSUserDefaults* _defaults;
  NSDictionary* _initial_values;
  BOOL _applies_immediately;
}

+ (id) sharedUserDefaultsController;

- (id) initWithDefaults: (NSUserDefaults*)defaults
          initialValues: (NSDictionary*)initialValues;

- (NSUserDefaults*) defaults;
- (id) values;
- (NSDictionary*) initialValues;
- (void) setInitialValues: (NSDictionary*)values;
- (BOOL) appliesImmediately;
- (void) setAppliesImmediately: (BOOL)flag;
- (void) revert: (id)sender;
- (void) revertToInitialValues: (id)sender;
- (void) save: (id)sender;

@end

#endif // OS_API_VERSION

#endif // _GNUstep_H_NSUserDefaultsController
/** <title>NSController</title>

   <abstract>abstract base class for controllers</abstract>

   Copyright <copy>(C) 2006 Free Software Foundation, Inc.</copy>

   Author: Fred Kiefer <fredkiefer@gmx.de>
   Date: June 2006

   This file is part of the GNUstep GUI Library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <Foundation/NSArray.h>
#include <AppKit/NSController.h>

@implementation NSController

- (id) init
{
  _editors = [[NSMutableArray alloc] init];

  return self;
}

- (void) dealloc
{
  RELEASE(_editors);
  [super dealloc];
}

- (void) encodeWithCoder: (NSCoder *)aCoder
{ 
  // TODO
}

- (id) initWithCoder: (NSCoder *)aDecoder
{ 
  // TODO
  return self; 
}

- (BOOL) isEditing
{
  return [_editors count] > 0;
}

- (BOOL) commitEditing
{
  unsigned c = [_editors count];
  unsigned i;

  for (i = 0; i < c; i++)
    {
      if (![[_editors objectAtIndex: i] commitEditing])
        {
          return NO;
        }
    }

  return YES;
}

- (void) discardEditing
{
  [_editors makeObjectsPerformSelector: @selector(discardEditing)];
}

- (void) objectDidBeginEditing: (id)editor
{
  [_editors addObject: editor];
}

- (void) objectDidEndEditing: (id)editor
{
  [_editors removeObject: editor];
}

@end
/** <title>NSUserDefaultsController</title>

   <abstract>Controller class for user defaults</abstract>

   Copyright <copy>(C) 2006 Free Software Foundation, Inc.</copy>

   Author: Fred Kiefer <fredkiefer@gmx.de>
   Date: September 2006

   This file is part of the GNUstep GUI Library.

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; either
   version 2 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this library; see the file COPYING.LIB.
   If not, write to the Free Software Foundation,
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#include <Foundation/NSDictionary.h>
#include <Foundation/NSUserDefaults.h>
#include <AppKit/NSUserDefaultsController.h>

static id shared = nil;

@implementation NSUserDefaultsController

+ (id) sharedUserDefaultsController
{
  if (shared == nil)
    {
        shared = [[NSUserDefaultsController alloc] 
                     initWithDefaults: nil
                     initialValues: nil];    
    }
  return shared;
}

- (id) initWithDefaults: (NSUserDefaults*)defaults
          initialValues: (NSDictionary*)initialValues
{
  if ((self = [super init]) != nil)
    {
      if (defaults == nil)
        {
          defaults = [NSUserDefaults standardUserDefaults];
        }
        
      ASSIGN(_defaults, defaults);
      [self setInitialValues: initialValues];
    }

  return self;
}

- (NSUserDefaults*) defaults
{
  return _defaults;
}

- (id) values
{
  // TODO
  return nil;  
}

- (NSDictionary*) initialValues
{
  return _initial_values;
}

- (void) setInitialValues: (NSDictionary*)values
{
  ASSIGN(_initial_values, values);
}

- (BOOL) appliesImmediately
{
  return _applies_immediately;
}

- (void) setAppliesImmediately: (BOOL)flag
{
  _applies_immediately = flag; 
}

- (void) revert: (id)sender
{
  [self discardEditing];
  if (![self appliesImmediately])
    {
      // TODO
    } 
}

- (void) revertToInitialValues: (id)sender
{
  // TODO
}

- (void) save: (id)sender
{
  // TODO
}

@end

reply via email to

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