Remove "not writable" alert

Since in the last sytems, such dialogs are automatically displayed first when user make change to the file. So, it is no more imporetant to have it by own.
This commit is contained in:
1024jp 2016-05-15 08:13:49 +09:00
parent fe806a9bc2
commit 32b71fcd2c
10 changed files with 9 additions and 77 deletions

View File

@ -2,6 +2,14 @@
Change Log
==========================
2.6.0
--------------------------
### Improvements
- Remove “Not writable” alert which displayed on file opening.
develop
--------------------------

View File

@ -218,7 +218,6 @@
CEDefaultTextContainerInsetHeightBottomKey: @16.0f,
CEDefaultShowColoringIndicatorTextLengthKey: @75000U,
CEDefaultRunAppleScriptInLaunchingKey: @YES,
CEDefaultShowAlertForNotWritableKey: @YES,
CEDefaultNotifyEditByAnotherKey: @YES,
CEDefaultColoringRangeBufferLengthKey: @5000,
CEDefaultLargeFileAlertThresholdKey: @(50 * pow(1024, 2)), // 50 MB

View File

@ -165,7 +165,6 @@ extern NSString *_Nonnull const CEDefaultTextContainerInsetHeightTopKey;
extern NSString *_Nonnull const CEDefaultTextContainerInsetHeightBottomKey;
extern NSString *_Nonnull const CEDefaultShowColoringIndicatorTextLengthKey;
extern NSString *_Nonnull const CEDefaultRunAppleScriptInLaunchingKey;
extern NSString *_Nonnull const CEDefaultShowAlertForNotWritableKey;
extern NSString *_Nonnull const CEDefaultNotifyEditByAnotherKey;
extern NSString *_Nonnull const CEDefaultColoringRangeBufferLengthKey;
extern NSString *_Nonnull const CEDefaultLargeFileAlertThresholdKey;

View File

@ -165,7 +165,6 @@ NSString *_Nonnull const CEDefaultTextContainerInsetHeightTopKey = @"textContain
NSString *_Nonnull const CEDefaultTextContainerInsetHeightBottomKey = @"textContainerInsetHeightBottom";
NSString *_Nonnull const CEDefaultShowColoringIndicatorTextLengthKey = @"showColoringIndicatorTextLength";
NSString *_Nonnull const CEDefaultRunAppleScriptInLaunchingKey = @"runAppleScriptInLaunching";
NSString *_Nonnull const CEDefaultShowAlertForNotWritableKey = @"showAlertForNotWritable";
NSString *_Nonnull const CEDefaultNotifyEditByAnotherKey = @"notifyEditByAnother";
NSString *_Nonnull const CEDefaultColoringRangeBufferLengthKey = @"coloringRangeBufferLength";
NSString *_Nonnull const CEDefaultLargeFileAlertThresholdKey = @"largeFileAlertThreshold";

View File

@ -37,7 +37,6 @@
// Notifications
extern NSString *_Nonnull const CEDocumentDidFinishOpenNotification;
extern NSString *_Nonnull const CEDocumentSyntaxStyleDidChangeNotification;
// Incompatible chars listController key

View File

@ -64,7 +64,6 @@ static NSString *_Nonnull const CESyntaxStyleKey = @"syntaxStyle";
static NSString *_Nonnull const CEAutosaveIdentierKey = @"autosaveIdentifier";
// notifications
NSString *_Nonnull const CEDocumentDidFinishOpenNotification = @"CEDocumentDidFinishOpenNotification";
NSString *_Nonnull const CEDocumentSyntaxStyleDidChangeNotification = @"CEDocumentSyntaxStyleDidChangeNotification";
// incompatible chars dictionary keys
@ -82,7 +81,6 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
@property (nonatomic) NSStringEncoding readingEncoding; // encoding to read document file
@property (nonatomic) BOOL needsShowUpdateAlertWithBecomeKey;
@property (nonatomic, getter=isRevertingForExternalFileUpdate) BOOL revertingForExternalFileUpdate;
@property (nonatomic) BOOL didAlertNotWritable; //
@property (nonatomic, nullable, copy) NSData *fileMD5;
@property (nonatomic, nullable, copy) NSString *fileContentString; // string that is read from the document file
@property (nonatomic, getter=isVerticalText) BOOL verticalText;
@ -164,10 +162,6 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
// -> This must be set before `readFromData:ofType:error:` is called.
_readingEncoding = [[CEDocumentController sharedDocumentController] accessorySelectedEncoding];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(documentDidFinishOpen:)
name:CEDocumentDidFinishOpenNotification object:nil];
// observe sytnax style update
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(syntaxDidUpdate:)
@ -687,9 +681,6 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
if ([coder containsValueForKey:CESyntaxStyleKey]) {
[self setSyntaxStyleWithName:[coder decodeObjectForKey:CESyntaxStyleKey]];
}
// not need to show unwritable alert on resume
[self setDidAlertNotWritable:YES];
}
@ -735,11 +726,7 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
{
NSInteger state = NSOffState;
if ([menuItem action] == @selector(saveDocument:)) {
// OK
return ([self isWritable] || [self didAlertNotWritable]);
} else if ([menuItem action] == @selector(changeEncoding:)) {
if ([menuItem action] == @selector(changeEncoding:)) {
NSInteger encodingTag = [self hasUTF8BOM] ? -[self encoding] : [self encoding];
state = ([menuItem tag] == encodingTag) ? NSOnState : NSOffState;
@ -1142,22 +1129,6 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
#pragma mark Notifications
//=======================================================
// Notification <- CEWindowController
//=======================================================
// ------------------------------------------------------
///
- (void)documentDidFinishOpen:(nonnull NSNotification *)notification
// ------------------------------------------------------
{
if ([notification object] == [self windowController] && ![self isInViewingMode]) {
//
[self showNotWritableAlert];
}
}
//=======================================================
// Notification <- CESyntaxManager
//=======================================================
@ -1638,29 +1609,6 @@ NSString *_Nonnull const CEIncompatibleConvertedCharKey = @"convertedChar";
}
// ------------------------------------------------------
///
- (void)showNotWritableAlert
// ------------------------------------------------------
{
if ([self isWritable] || [self didAlertNotWritable]) { return; }
if ([[NSUserDefaults standardUserDefaults] boolForKey:CEDefaultShowAlertForNotWritableKey]) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:NSLocalizedString(@"The file is not writable.", nil)];
[alert setInformativeText:NSLocalizedString(@"You may not be able to save your changes, but you will be able to save a copy somewhere else.", nil)];
[alert setShowsSuppressionButton:YES];
[alert compatibleBeginSheetModalForWindow:[self windowForSheet] completionHandler:^(NSInteger returnCode) {
if ([[alert suppressionButton] state] == NSOnState) {
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:CEDefaultShowAlertForNotWritableKey];
}
}];
}
[self setDidAlertNotWritable:YES];
}
// ------------------------------------------------------
/// notify about external file update
- (void)notifyExternalFileUpdate

View File

@ -140,13 +140,6 @@ typedef NS_ENUM(NSUInteger, CESidebarTag) {
// apply document state to UI
[[self document] applyContentToWindow];
// notify finish of the document open process (Here is probably the final point.)
__weak typeof(self) weakSelf = self;
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:CEDocumentDidFinishOpenNotification
object:weakSelf];
});
// observe opacity setting change
[[NSUserDefaults standardUserDefaults] addObserver:self
forKeyPath:CEDefaultWindowAlphaKey

View File

@ -261,10 +261,6 @@
"Show or hide invisible characters in document" = "Unsichtbare Zeichen im Text ein-/ausblenden";
"To show invisible characters, set them in Preferences and re-open the document" = "Um unsichtbare Zeichen anzuzeigen, setzen Sie sie in den Einstellungen und öffnen Sie das Dokument wieder";
// Alert strings
"The file is not writable." = "Die Datei ist nicht schreibbar.";
"You may not be able to save your changes, but you will be able to save a copy somewhere else." = "Sie können möglicherweise die Änderungen nicht speichern doch eine Kopie an anderer Stelle speichern.";
/* MARK: CESplitView */

View File

@ -263,10 +263,6 @@
"Show or hide invisible characters in document" = "書類中の不可視文字を表示/隠す";
"To show invisible characters, set them in Preferences and re-open the document" = "不可視文字を表示させるには、環境設定を変更し書類を開き直してください";
// Alert strings
"The file is not writable." = "このファイルは書き込み不可です。";
"You may not be able to save your changes, but you will be able to save a copy somewhere else." = "このファイルに加えられた変更は保存できない場合がありますが、コピーを別の場所に保存することができます。";
/* MARK: CESplitView */

View File

@ -261,11 +261,6 @@
"To show invisible characters, set them in Preferences and re-open the document" = "要显示不可见字符,请在偏好设置中进行设定,然后重新打开文档";
// Alert strings
"The file is not writable." = "该文件不能写入。";
"You may not be able to save your changes, but you will be able to save a copy somewhere else." = "无法保存更改,但是可以在其他路径保存一份拷贝。";
/* MARK: CESplitView */
// Menu items