From 3e5a1cefaa92cf6afaef4ae436389e35d08f51b8 Mon Sep 17 00:00:00 2001 From: qmathe Date: Thu, 10 Dec 2009 12:43:35 +0000 Subject: [PATCH] Added NSWindow 'title' binding git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29113 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 7 +++++++ Headers/AppKit/NSKeyValueBinding.h | 1 + Source/NSWindow.m | 26 ++++++++++++++++++++++++++ Source/externs.m | 1 + 4 files changed, 35 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3ef493195..0e28483bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-12-10 Quentin Mathe + + * Headers/AppKit/NSKKeyValueBinding.h: + * Source/externs.m: + * Source/NSWindow.m (+initialize, -bind:toObject:withKeyPath:options:): + Added NSWindow 'title' binding. + 2009-12-08 Quentin Mathe * Source/NSTableColumn.m (-dealloc): Fixed missing release for diff --git a/Headers/AppKit/NSKeyValueBinding.h b/Headers/AppKit/NSKeyValueBinding.h index 8a8c1046c..5c4c988df 100644 --- a/Headers/AppKit/NSKeyValueBinding.h +++ b/Headers/AppKit/NSKeyValueBinding.h @@ -110,6 +110,7 @@ APPKIT_EXPORT NSString *NSFontBinding; APPKIT_EXPORT NSString *NSHiddenBinding; APPKIT_EXPORT NSString *NSSelectedIndexBinding; APPKIT_EXPORT NSString *NSTextColorBinding; +APPKIT_EXPORT NSString *NSTitleBinding; APPKIT_EXPORT NSString *NSToolTipBinding; APPKIT_EXPORT NSString *NSValueBinding; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 56ac074ff..a94c99229 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -66,6 +66,7 @@ #include "AppKit/NSFont.h" #include "AppKit/NSGraphics.h" #include "AppKit/NSHelpManager.h" +#include "AppKit/NSKeyValueBinding.h" #include "AppKit/NSImage.h" #include "AppKit/NSMenu.h" #include "AppKit/NSPasteboard.h" @@ -75,6 +76,7 @@ #include "AppKit/NSView.h" #include "AppKit/NSWindow.h" #include "AppKit/NSWindowController.h" +#include "GSBindingHelpers.h" #include "AppKit/PSOperators.h" #include "GNUstepGUI/GSTrackingRect.h" #include "GNUstepGUI/GSDisplayServer.h" @@ -620,6 +622,8 @@ static NSNotificationCenter *nc = nil; windowmaps = NSCreateMapTable(NSIntMapKeyCallBacks, NSNonRetainedObjectMapValueCallBacks, 20); nc = [NSNotificationCenter defaultCenter]; + + [self exposeBinding: NSTitleBinding]; } } @@ -5179,6 +5183,28 @@ current key view.
return self; } +- (void) bind: (NSString *)binding + toObject: (id)anObject + withKeyPath: (NSString *)keyPath + options: (NSDictionary *)options +{ + if ([binding isEqual: NSTitleBinding]) + { + [self unbind: binding]; + [[GSKeyValueBinding alloc] initWithBinding: @"title" + withName: NSTitleBinding + toObject: anObject + withKeyPath: keyPath + options: options + fromObject: self]; + } + else + { + [super bind: binding toObject: anObject withKeyPath: keyPath + options: options]; + } +} + /** Returns all drawers associated with this window. */ diff --git a/Source/externs.m b/Source/externs.m index f163e4172..3db733196 100644 --- a/Source/externs.m +++ b/Source/externs.m @@ -649,6 +649,7 @@ NSString *NSFontBinding = @"font"; NSString *NSHiddenBinding = @"hidden"; NSString *NSSelectedIndexBinding = @"selectedIndex"; NSString *NSTextColorBinding = @"textColor"; +NSString *NSTitleBinding = @"title"; NSString *NSToolTipBinding = @"toolTip"; NSString *NSValueBinding = @"value";