mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Add "show hidden files" checkbox to save dialog
This commit is contained in:
@@ -998,7 +998,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef,
|
||||
|
||||
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
||||
[panel setAllowsMultipleSelection:YES];
|
||||
[panel setAccessoryView:openPanelAccessoryView()];
|
||||
[panel setAccessoryView:showHiddenFilesView()];
|
||||
|
||||
int result = [panel runModalForDirectory:dir file:nil types:nil];
|
||||
if (NSOKButton == result)
|
||||
|
||||
@@ -1252,6 +1252,18 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
afterDelay:0];
|
||||
}
|
||||
|
||||
// NSSavePanel delegate
|
||||
- (void)panel:(id)sender willExpand:(BOOL)expanding
|
||||
{
|
||||
// Show or hide the "show hidden files" button
|
||||
if (expanding) {
|
||||
[sender setAccessoryView:showHiddenFilesView()];
|
||||
} else {
|
||||
[sender setShowsHiddenFiles:NO];
|
||||
[sender setAccessoryView:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)handleBrowseForFile:(NSDictionary *)attr
|
||||
{
|
||||
if (!isInitialized) return;
|
||||
@@ -1269,7 +1281,16 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
}
|
||||
|
||||
if (saving) {
|
||||
[[NSSavePanel savePanel] beginSheetForDirectory:dir file:nil
|
||||
NSSavePanel *panel = [NSSavePanel savePanel];
|
||||
|
||||
// The delegate will be notified when the panel is expanded at which
|
||||
// time we may hide/show the "show hidden files" button (this button is
|
||||
// always visible for the open panel since it is always expanded).
|
||||
[panel setDelegate:self];
|
||||
if ([panel isExpanded])
|
||||
[panel setAccessoryView:showHiddenFilesView()];
|
||||
|
||||
[panel beginSheetForDirectory:dir file:nil
|
||||
modalForWindow:[windowController window]
|
||||
modalDelegate:self
|
||||
didEndSelector:@selector(savePanelDidEnd:code:context:)
|
||||
@@ -1277,7 +1298,7 @@ static BOOL isUnsafeMessage(int msgid);
|
||||
} else {
|
||||
NSOpenPanel *panel = [NSOpenPanel openPanel];
|
||||
[panel setAllowsMultipleSelection:NO];
|
||||
[panel setAccessoryView:openPanelAccessoryView()];
|
||||
[panel setAccessoryView:showHiddenFilesView()];
|
||||
|
||||
[panel beginSheetForDirectory:dir file:nil types:nil
|
||||
modalForWindow:[windowController window]
|
||||
|
||||
@@ -95,7 +95,7 @@ enum {
|
||||
@end
|
||||
|
||||
|
||||
@interface NSOpenPanel (MMExtras)
|
||||
@interface NSSavePanel (MMExtras)
|
||||
- (void)hiddenFilesButtonToggled:(id)sender;
|
||||
- (void)setShowsHiddenFiles:(BOOL)show;
|
||||
@end
|
||||
@@ -130,7 +130,8 @@ enum {
|
||||
|
||||
|
||||
|
||||
// Create a view to be used as accessory for open panel. This function assumes
|
||||
// ownership of the view so do not release it.
|
||||
NSView *openPanelAccessoryView();
|
||||
// Create a view with a "show hidden files" button to be used as accessory for
|
||||
// open/save panels. This function assumes ownership of the view so do not
|
||||
// release it.
|
||||
NSView *showHiddenFilesView();
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ NSString *MMLoadDefaultFontKey = @"MMLoadDefaultFont";
|
||||
|
||||
|
||||
|
||||
@implementation NSOpenPanel (MMExtras)
|
||||
@implementation NSSavePanel (MMExtras)
|
||||
|
||||
- (void)hiddenFilesButtonToggled:(id)sender
|
||||
{
|
||||
@@ -122,7 +122,7 @@ NSString *MMLoadDefaultFontKey = @"MMLoadDefaultFont";
|
||||
[invocation invoke];
|
||||
}
|
||||
|
||||
@end // NSOpenPanel (MMExtras)
|
||||
@end // NSSavePanel (MMExtras)
|
||||
|
||||
|
||||
|
||||
@@ -263,7 +263,7 @@ NSString *MMLoadDefaultFontKey = @"MMLoadDefaultFont";
|
||||
|
||||
|
||||
NSView *
|
||||
openPanelAccessoryView()
|
||||
showHiddenFilesView()
|
||||
{
|
||||
// Return a new button object for each NSOpenPanel -- several of them
|
||||
// could be displayed at once.
|
||||
@@ -272,13 +272,13 @@ openPanelAccessoryView()
|
||||
NSButton *button = [[[NSButton alloc]
|
||||
initWithFrame:NSMakeRect(0, 0, 140, 18)] autorelease];
|
||||
[button setTitle:
|
||||
NSLocalizedString(@"Show Hidden Files", @"Open File Dialog")];
|
||||
NSLocalizedString(@"Show Hidden Files", @"Show Hidden Files Checkbox")];
|
||||
[button setButtonType:NSSwitchButton];
|
||||
|
||||
[button setTarget:nil];
|
||||
[button setAction:@selector(hiddenFilesButtonToggled:)];
|
||||
|
||||
// use the regular control size (checkbox is a bit smaller without this)
|
||||
// Use the regular control size (checkbox is a bit smaller without this)
|
||||
NSControlSize buttonSize = NSRegularControlSize;
|
||||
float fontSize = [NSFont systemFontSizeForControlSize:buttonSize];
|
||||
NSCell *theCell = [button cell];
|
||||
|
||||
Reference in New Issue
Block a user