Author: mlytwyn
Date: Wed Oct 5 01:04:37 2016
New Revision: 40122
URL: http://svn.gna.org/viewcvs/gnustep?rev=40122&view=rev
Log:
Merge GUI with trunk revision 40072
Modified:
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSSavePanel.h
libs/gui/branches/gnustep_testplant_branch/Source/NSSavePanel.m
Modified:
libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSSavePanel.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSSavePanel.h?rev=40122&r1=40121&r2=40122&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSSavePanel.h
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Headers/AppKit/NSSavePanel.h
Wed Oct 5 01:04:37 2016
@@ -34,6 +34,7 @@
#ifndef _GNUstep_H_NSSavePanel
#define _GNUstep_H_NSSavePanel
#import <GNUstepBase/GSVersionMacros.h>
+#import <GNUstepBase/GSBlocks.h>
#import <AppKit/NSPanel.h>
@@ -58,7 +59,7 @@
};
@protocol NSOpenSavePanelDelegate <NSObject>
-#ifdef __OBJC2__
+#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST) &&
GS_PROTOCOLS_HAVE_OPTIONAL
@optional
#else
@end
@@ -81,6 +82,7 @@
- (BOOL)panel:(id)sender shouldShowFilename:(NSString*)filename;
@end
+DEFINE_BLOCK_TYPE(GSSavePanelCompletionHandler, void, NSInteger);
@interface NSSavePanel : NSPanel
{
@@ -117,6 +119,7 @@
BOOL _OKButtonPressed;
NSMenu *_showsHiddenFilesMenu;
+ GSSavePanelCompletionHandler _completionHandler;
}
/*
@@ -204,6 +207,12 @@
modalDelegate: (id)delegate
didEndSelector: (SEL)didEndSelector
contextInfo: (void *)contextInfo;
+#endif
+
+#if OS_API_VERSION(MAC_OS_X_VERSION_10_6, GS_API_LATEST)
+- (void) beginSheetModalForWindow:(NSWindow *)window
+ completionHandler:(GSSavePanelCompletionHandler)handler;
+- (void) beginWithCompletionHandler:(GSSavePanelCompletionHandler)handler;
#endif
/*
Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSSavePanel.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSSavePanel.m?rev=40122&r1=40121&r2=40122&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSSavePanel.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSSavePanel.m Wed Oct
5 01:04:37 2016
@@ -55,10 +55,15 @@
#import "AppKit/NSDragging.h"
#import "AppKit/NSSavePanel.h"
#import "AppKit/NSTextField.h"
+#import "AppKit/NSWindowController.h"
#import "AppKit/NSWorkspace.h"
#import "GSGuiPrivate.h"
#import "GNUstepGUI/GSTheme.h"
+
+#if defined(_WIN32)
+#import "objc/blocks_runtime.h"
+#endif
#define _SAVE_PANEL_X_PAD 5
#define _SAVE_PANEL_Y_PAD 4
@@ -858,8 +863,9 @@
*/
- (void) setTitle: (NSString*)title
{
+ // keep the window title in sync with the title field
+ [super setTitle:title];
[_titleField setStringValue: title];
- [super setTitle:title]; // keep the window title in sync with the title field
// TODO: Improve the following by managing
// vertical alignment better.
@@ -1108,7 +1114,22 @@
*/
- (NSInteger) runModal
{
- return [self runModalForDirectory: [self directory] file: [self filename]];
+ return [self runModalForDirectory: [self directory]
+ file: [[self filename] lastPathComponent]];
+}
+
+- (void) beginSheetModalForWindow:(NSWindow *)window
+ completionHandler:(GSSavePanelCompletionHandler)handler
+{
+ NSInteger result = [NSApp runModalForWindow: self
+ relativeToWindow: window];
+ CALL_BLOCK(handler, result);
+}
+
+- (void) beginWithCompletionHandler:(GSSavePanelCompletionHandler)handler
+{
+ self->_completionHandler = Block_copy(handler);
+ [self makeKeyAndOrderFront: self];
}
/**<p> Initializes the panel to the directory specified by path and,
@@ -1187,7 +1208,7 @@
if (_allowedFileTypes == nil ||
[_allowedFileTypes indexOfObject: @""] != NSNotFound)
- return _fullFileName;
+ return AUTORELEASE([_fullFileName copy]);
/* add file type extension if the file name does not have an extension or
the file name's extension is not one of the allowed extensions and the
@@ -1202,7 +1223,7 @@
}
else
{
- return _fullFileName;
+ return AUTORELEASE([_fullFileName copy]);
}
}
@@ -1219,7 +1240,16 @@
{
ASSIGN(_directory, pathToColumn(_browser, [_browser lastColumn]));
[self _updateDefaultDirectory];
+
+ if (self->_completionHandler == NULL)
[NSApp stopModalWithCode: NSCancelButton];
+ else
+ {
+ CALL_BLOCK(self->_completionHandler, NSCancelButton);
+ Block_release(self->_completionHandler);
+ self->_completionHandler = NULL;
+ }
+
[_okButton setEnabled: NO];
[self close];
}
@@ -1390,7 +1420,16 @@
return;
[self _updateDefaultDirectory];
+
+ if (self->_completionHandler == NULL)
[NSApp stopModalWithCode: NSOKButton];
+ else
+ {
+ CALL_BLOCK(self->_completionHandler, NSOKButton);
+ Block_release(self->_completionHandler);
+ self->_completionHandler = NULL;
+ }
+
[_okButton setEnabled: NO];
[self close];
}
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs