Skip to content
Browse files

show a different close icon in tabs for modified documents, don't app…

…end a silly asterisk to the document title

fixes http://help.vicoapp.com/ideas/changes-indicator-in-tabs
  • Loading branch information...
1 parent 4ac35d1 commit 6b644e1386bedf416311970cd1bdb7f070f7e322 @martinh martinh committed Sep 30, 2011
View
BIN Images/TabCloseModified_Front.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Images/TabCloseModified_Front_Pressed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Images/TabCloseModified_Front_Rollover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Images/TabNewMetal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Images/TabNewMetalPressed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN Images/TabNewMetalRollover.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3 Makefile
@@ -239,6 +239,9 @@ IMAGES = \
Images/TabClose_Front.tif \
Images/TabClose_Front_Pressed.tif \
Images/TabClose_Front_Rollover.tif \
+ Images/TabCloseModified_Front.png \
+ Images/TabCloseModified_Front_Pressed.png \
+ Images/TabCloseModified_Front_Rollover.png \
Images/TabNewMetal.png \
Images/TabNewMetalPressed.png \
Images/TabNewMetalRollover.png \
View
2 TODO.txt
@@ -7,7 +7,6 @@
* group by attribute != grouped display string
* can't assume ack's output is in newline chunks
* don't overwrite read-only files!
-* show baseURL in window title!
* explorer spinner is hidden by new path control
=> move it, where!? auto-hide something else?
@@ -39,7 +38,6 @@
* convert horizontal split to vertical and vice versa
* @kamens: Any way to resize splits w/ key bindings? Like <c-w>_ or <c-w>+
-* less lame notification of modified documents in tabs (don't append * in title!)
* bring back explorer / folder bookmarks
* ctags should present menu for duplicate tags
* draw marks in gutter view
View
3 app/PSMMetalTabStyle.h
@@ -13,6 +13,9 @@
NSImage *_metalCloseButton;
NSImage *_metalCloseButtonDown;
NSImage *_metalCloseButtonOver;
+ NSImage *_metalCloseModifiedButton;
+ NSImage *_metalCloseModifiedButtonDown;
+ NSImage *_metalCloseModifiedButtonOver;
NSImage *_addTabButtonImage;
NSImage *_addTabButtonPressedImage;
NSImage *_addTabButtonRolloverImage;
View
184 app/PSMMetalTabStyle.m
@@ -26,17 +26,20 @@ - (NSString *)name
- (id) init
{
- if((self = [super init]))
- {
- _metalCloseButton = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabClose_Front"]];
- _metalCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabClose_Front_Pressed"]];
- _metalCloseButtonOver = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabClose_Front_Rollover"]];
-
- _addTabButtonImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabNewMetal"]];
- _addTabButtonPressedImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabNewMetalPressed"]];
- _addTabButtonRolloverImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabNewMetalRollover"]];
- }
- return self;
+ if ((self = [super init])) {
+ _metalCloseButton = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabClose_Front"]];
+ _metalCloseButtonDown = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabClose_Front_Pressed"]];
+ _metalCloseButtonOver = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabClose_Front_Rollover"]];
+
+ _metalCloseModifiedButton = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabCloseModified_Front"]];
+ _metalCloseModifiedButtonDown = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabCloseModified_Front_Pressed"]];
+ _metalCloseModifiedButtonOver = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabCloseModified_Front_Rollover"]];
+
+ _addTabButtonImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabNewMetal"]];
+ _addTabButtonPressedImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabNewMetalPressed"]];
+ _addTabButtonRolloverImage = [[NSImage alloc] initByReferencingFile:[[PSMTabBarControl bundle] pathForImageResource:@"TabNewMetalRollover"]];
+ }
+ return self;
}
- (void)dealloc
@@ -45,6 +48,9 @@ - (void)dealloc
[_metalCloseButton release];
[_metalCloseButtonDown release];
[_metalCloseButtonOver release];
+ [_metalCloseModifiedButton release];
+ [_metalCloseModifiedButtonDown release];
+ [_metalCloseModifiedButtonOver release];
[_addTabButtonImage release];
[_addTabButtonPressedImage release];
[_addTabButtonRolloverImage release];
@@ -368,81 +374,87 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
- (void)drawInteriorWithTabCell:(PSMTabBarCell *)cell inView:(NSView*)controlView
{
- NSRect cellFrame = [cell frame];
- float labelPosition = cellFrame.origin.x + MARGIN_X;
-
- // close button
- if ([cell hasCloseButton] && ![cell isCloseButtonSuppressed]) {
- NSSize closeButtonSize = NSZeroSize;
- NSRect closeButtonRect = [cell closeButtonRectForFrame:cellFrame];
- NSImage * closeButton = nil;
-
- closeButton = _metalCloseButton;
- if ([cell closeButtonOver]) closeButton = _metalCloseButtonOver;
- if ([cell closeButtonPressed]) closeButton = _metalCloseButtonDown;
-
- closeButtonSize = [closeButton size];
- if ([controlView isFlipped]) {
- closeButtonRect.origin.y += closeButtonRect.size.height;
- }
-
- [closeButton compositeToPoint:closeButtonRect.origin operation:NSCompositeSourceOver fraction:1.0];
-
- // scoot label over
- labelPosition += closeButtonSize.width + kPSMTabBarCellPadding;
- }
-
- // icon
- if([cell hasIcon]){
- NSRect iconRect = [self iconRectForTabCell:cell];
- NSImage *icon = [[[[cell representedObject] identifier] content] icon];
- if ([controlView isFlipped]) {
- iconRect.origin.y = cellFrame.size.height - iconRect.origin.y;
- }
- [icon compositeToPoint:iconRect.origin operation:NSCompositeSourceOver fraction:1.0];
-
- // scoot label over
- labelPosition += iconRect.size.width + kPSMTabBarCellPadding;
- }
-
- // object counter
- if([cell count] > 0){
- [[NSColor colorWithCalibratedWhite:0.3 alpha:0.6] set];
- NSBezierPath *path = [NSBezierPath bezierPath];
- NSRect myRect = [self objectCounterRectForTabCell:cell];
- if([cell state] == NSOnState)
- myRect.origin.y -= 1.0;
- [path moveToPoint:NSMakePoint(myRect.origin.x + kPSMMetalObjectCounterRadius, myRect.origin.y)];
- [path lineToPoint:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMMetalObjectCounterRadius, myRect.origin.y)];
- [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMMetalObjectCounterRadius, myRect.origin.y + kPSMMetalObjectCounterRadius) radius:kPSMMetalObjectCounterRadius startAngle:270.0 endAngle:90.0];
- [path lineToPoint:NSMakePoint(myRect.origin.x + kPSMMetalObjectCounterRadius, myRect.origin.y + myRect.size.height)];
- [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + kPSMMetalObjectCounterRadius, myRect.origin.y + kPSMMetalObjectCounterRadius) radius:kPSMMetalObjectCounterRadius startAngle:90.0 endAngle:270.0];
- [path fill];
-
- // draw attributed string centered in area
- NSRect counterStringRect;
- NSAttributedString *counterString = [self attributedObjectCountValueForTabCell:cell];
- counterStringRect.size = [counterString size];
- counterStringRect.origin.x = myRect.origin.x + ((myRect.size.width - counterStringRect.size.width) / 2.0) + 0.25;
- counterStringRect.origin.y = myRect.origin.y + ((myRect.size.height - counterStringRect.size.height) / 2.0) + 0.5;
- [counterString drawInRect:counterStringRect];
- }
-
- // label rect
- NSRect labelRect;
- labelRect.origin.x = labelPosition;
- labelRect.size.width = cellFrame.size.width - (labelRect.origin.x - cellFrame.origin.x) - kPSMTabBarCellPadding;
- labelRect.size.height = cellFrame.size.height;
- labelRect.origin.y = cellFrame.origin.y + MARGIN_Y;
-
- if(![[cell indicator] isHidden])
- labelRect.size.width -= (kPSMTabBarIndicatorWidth + kPSMTabBarCellPadding);
-
- if([cell count] > 0)
- labelRect.size.width -= ([self objectCounterRectForTabCell:cell].size.width + kPSMTabBarCellPadding);
-
- // label
- [[cell attributedStringValue] drawInRect:labelRect];
+ NSRect cellFrame = [cell frame];
+ float labelPosition = cellFrame.origin.x + MARGIN_X;
+
+ // close button
+ if ([cell hasCloseButton] && ![cell isCloseButtonSuppressed]) {
+ NSSize closeButtonSize = NSZeroSize;
+ NSRect closeButtonRect = [cell closeButtonRectForFrame:cellFrame];
+ NSImage * closeButton = nil;
+
+ if (cell.isModified) {
+ closeButton = _metalCloseModifiedButton;
+ if ([cell closeButtonOver]) closeButton = _metalCloseModifiedButtonOver;
+ if ([cell closeButtonPressed]) closeButton = _metalCloseModifiedButtonDown;
+ } else {
+ closeButton = _metalCloseButton;
+ if ([cell closeButtonOver]) closeButton = _metalCloseButtonOver;
+ if ([cell closeButtonPressed]) closeButton = _metalCloseButtonDown;
+ }
+
+ closeButtonSize = [closeButton size];
+ if ([controlView isFlipped]) {
+ closeButtonRect.origin.y += closeButtonRect.size.height;
+ }
+
+ [closeButton compositeToPoint:closeButtonRect.origin operation:NSCompositeSourceOver fraction:1.0];
+
+ // scoot label over
+ labelPosition += closeButtonSize.width + kPSMTabBarCellPadding;
+ }
+
+ // icon
+ if([cell hasIcon]){
+ NSRect iconRect = [self iconRectForTabCell:cell];
+ NSImage *icon = [[[[cell representedObject] identifier] content] icon];
+ if ([controlView isFlipped]) {
+ iconRect.origin.y = cellFrame.size.height - iconRect.origin.y;
+ }
+ [icon compositeToPoint:iconRect.origin operation:NSCompositeSourceOver fraction:1.0];
+
+ // scoot label over
+ labelPosition += iconRect.size.width + kPSMTabBarCellPadding;
+ }
+
+ // object counter
+ if([cell count] > 0){
+ [[NSColor colorWithCalibratedWhite:0.3 alpha:0.6] set];
+ NSBezierPath *path = [NSBezierPath bezierPath];
+ NSRect myRect = [self objectCounterRectForTabCell:cell];
+ if([cell state] == NSOnState)
+ myRect.origin.y -= 1.0;
+ [path moveToPoint:NSMakePoint(myRect.origin.x + kPSMMetalObjectCounterRadius, myRect.origin.y)];
+ [path lineToPoint:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMMetalObjectCounterRadius, myRect.origin.y)];
+ [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + myRect.size.width - kPSMMetalObjectCounterRadius, myRect.origin.y + kPSMMetalObjectCounterRadius) radius:kPSMMetalObjectCounterRadius startAngle:270.0 endAngle:90.0];
+ [path lineToPoint:NSMakePoint(myRect.origin.x + kPSMMetalObjectCounterRadius, myRect.origin.y + myRect.size.height)];
+ [path appendBezierPathWithArcWithCenter:NSMakePoint(myRect.origin.x + kPSMMetalObjectCounterRadius, myRect.origin.y + kPSMMetalObjectCounterRadius) radius:kPSMMetalObjectCounterRadius startAngle:90.0 endAngle:270.0];
+ [path fill];
+
+ // draw attributed string centered in area
+ NSRect counterStringRect;
+ NSAttributedString *counterString = [self attributedObjectCountValueForTabCell:cell];
+ counterStringRect.size = [counterString size];
+ counterStringRect.origin.x = myRect.origin.x + ((myRect.size.width - counterStringRect.size.width) / 2.0) + 0.25;
+ counterStringRect.origin.y = myRect.origin.y + ((myRect.size.height - counterStringRect.size.height) / 2.0) + 0.5;
+ [counterString drawInRect:counterStringRect];
+ }
+
+ // label rect
+ NSRect labelRect;
+ labelRect.origin.x = labelPosition;
+ labelRect.size.width = cellFrame.size.width - (labelRect.origin.x - cellFrame.origin.x) - kPSMTabBarCellPadding;
+ labelRect.size.height = cellFrame.size.height;
+ labelRect.origin.y = cellFrame.origin.y + MARGIN_Y;
+
+ if(![[cell indicator] isHidden])
+ labelRect.size.width -= (kPSMTabBarIndicatorWidth + kPSMTabBarCellPadding);
+
+ if([cell count] > 0)
+ labelRect.size.width -= ([self objectCounterRectForTabCell:cell].size.width + kPSMTabBarCellPadding);
+
+ // label
+ [[cell attributedStringValue] drawInRect:labelRect];
}
- (void)drawTabBar:(PSMTabBarControl *)bar inRect:(NSRect)rect
View
3 app/PSMTabBarCell.h
@@ -33,8 +33,11 @@
BOOL _isCloseButtonSuppressed;
BOOL _hasIcon;
int _count;
+ BOOL _modified;
}
+@property (readwrite,getter=isModified) BOOL modified;
+
// creation/destruction
- (id)initWithControlView:(PSMTabBarControl *)controlView;
- (id)initPlaceholderWithFrame:(NSRect)frame expanded:(BOOL)value inControlView:(PSMTabBarControl *)controlView;
View
5 app/PSMTabBarCell.m
@@ -11,12 +11,16 @@
#import "PSMTabStyle.h"
#import "PSMProgressIndicator.h"
#import "PSMTabDragAssistant.h"
+#include "logging.h"
@implementation PSMTabBarCell
+@synthesize modified = _modified;
+
#pragma mark -
#pragma mark Creation/Destruction
+
- (id)initWithControlView:(PSMTabBarControl *)controlView
{
self = [super init];
@@ -29,6 +33,7 @@ - (id)initWithControlView:(PSMTabBarControl *)controlView
_indicator = [[PSMProgressIndicator alloc] initWithFrame:NSMakeRect(0.0,0.0,kPSMTabBarIndicatorWidth,kPSMTabBarIndicatorWidth)];
[_indicator setStyle:NSProgressIndicatorSpinningStyle];
[_indicator setAutoresizingMask:NSViewMinYMargin];
+ [_indicator setControlSize:NSSmallControlSize];
_hasCloseButton = YES;
_isCloseButtonSuppressed = NO;
_count = 0;
View
90 app/PSMTabBarControl.m
@@ -13,6 +13,7 @@
#import "PSMTabStyle.h"
#import "PSMMetalTabStyle.h"
#import "PSMTabDragAssistant.h"
+#import "ViTabController.h"
#include "logging.h"
@interface PSMTabBarControl (Private)
@@ -349,57 +350,51 @@ - (PSMOverflowPopUpButton *)overflowPopUpButton
#pragma mark -
#pragma mark Functionality
+
- (void)addTabViewItem:(NSTabViewItem *)item
{
- // create cell
- PSMTabBarCell *cell = [[[PSMTabBarCell alloc] initWithControlView:self] autorelease];
- [cell setRepresentedObject:item];
- // bind the indicator to the represented object's status (if it exists)
- [[cell indicator] setHidden:YES];
- if([item identifier] != nil){
- if([[item identifier] respondsToSelector:@selector(content)]){
- if([[[[cell representedObject] identifier] content] respondsToSelector:@selector(isProcessing)]){
- NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
- [bindingOptions setObject:NSNegateBooleanTransformerName forKey:@"NSValueTransformerName"];
- [[cell indicator] bind:@"animate" toObject:[item identifier] withKeyPath:@"selection.isProcessing" options:nil];
- [[cell indicator] bind:@"hidden" toObject:[item identifier] withKeyPath:@"selection.isProcessing" options:bindingOptions];
- [[item identifier] addObserver:self forKeyPath:@"selection.isProcessing" options:0 context:nil];
- }
- }
- }
+ // create cell
+ PSMTabBarCell *cell = [[[PSMTabBarCell alloc] initWithControlView:self] autorelease];
+ [cell setRepresentedObject:item];
- // bind for the existence of an icon
- [cell setHasIcon:NO];
- if([item identifier] != nil){
- if([[item identifier] respondsToSelector:@selector(content)]){
- if([[[[cell representedObject] identifier] content] respondsToSelector:@selector(icon)]){
- NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
- [bindingOptions setObject:NSIsNotNilTransformerName forKey:@"NSValueTransformerName"];
- [cell bind:@"hasIcon" toObject:[item identifier] withKeyPath:@"selection.icon" options:bindingOptions];
- [[item identifier] addObserver:self forKeyPath:@"selection.icon" options:0 context:nil];
- }
- }
- }
+ // bind the indicator to the represented object's status (if it exists)
+ [[cell indicator] setHidden:NO];
+ ViTabController *tabController = [item identifier];
+ if (tabController != nil) {
+ NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
+ [bindingOptions setObject:NSNegateBooleanTransformerName forKey:@"NSValueTransformerName"];
+ [[cell indicator] bind:@"animate" toObject:tabController withKeyPath:@"selectedView.processing" options:nil];
+ [[cell indicator] bind:@"hidden" toObject:tabController withKeyPath:@"selectedView.processing" options:bindingOptions];
+ [tabController addObserver:self forKeyPath:@"selectedView.processing" options:0 context:nil];
- // bind for the existence of a counter
- [cell setCount:0];
- if([item identifier] != nil){
- if([[item identifier] respondsToSelector:@selector(content)]){
- if([[[[cell representedObject] identifier] content] respondsToSelector:@selector(objectCount)]){
- [cell bind:@"count" toObject:[item identifier] withKeyPath:@"selection.objectCount" options:nil];
- [[item identifier] addObserver:self forKeyPath:@"selection.objectCount" options:0 context:nil];
- }
- }
- }
+#if 0
+ // bind for the existence of an icon
+ [cell setHasIcon:NO];
+ NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
+ [bindingOptions setObject:NSIsNotNilTransformerName forKey:@"NSValueTransformerName"];
+ [cell bind:@"hasIcon" toObject:tabController withKeyPath:@"selectedView.icon" options:bindingOptions];
+ [tabController addObserver:self forKeyPath:@"selectedView.icon" options:0 context:nil];
+
+ // bind for the existence of a counter
+ [cell setCount:0];
+ [cell bind:@"count" toObject:tabController withKeyPath:@"selection.objectCount" options:nil];
+ [tabController addObserver:self forKeyPath:@"selection.objectCount" options:0 context:nil];
+#endif
- // bind my string value to the label on the represented tab
- [cell bind:@"title" toObject:item withKeyPath:@"label" options:nil];
+ // bind for modified state
+ [cell setModified:NO];
+ [cell bind:@"modified" toObject:tabController withKeyPath:@"selectedView.modified" options:nil];
+ [tabController addObserver:self forKeyPath:@"selectedView.modified" options:0 context:nil];
+ }
- // add to collection
- [_cells addObject:cell];
- if([_cells count] == [tabView numberOfTabViewItems]){
- [self update]; // don't update unless all are accounted for!
- }
+ // bind my string value to the label on the represented tab
+ [cell bind:@"title" toObject:item withKeyPath:@"label" options:nil];
+
+ // add to collection
+ [_cells addObject:cell];
+ if([_cells count] == [tabView numberOfTabViewItems]){
+ [self update]; // don't update unless all are accounted for!
+ }
}
- (void)removeTabForCell:(PSMTabBarCell *)cell
@@ -412,6 +407,7 @@ - (void)removeTabForCell:(PSMTabBarCell *)cell
[cell unbind:@"hasIcon"];
[cell unbind:@"title"];
[cell unbind:@"count"];
+ [cell unbind:@"modified"];
// remove indicator
if ([[self subviews] containsObject:[cell indicator]])
@@ -433,8 +429,8 @@ - (void)removeTabForCell:(PSMTabBarCell *)cell
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- // the progress indicator, label, icon, or count has changed - must redraw
- [self update];
+ // the progress indicator, label, icon, count or modified state has changed - must redraw
+ [self update];
}
#pragma mark -
View
2 app/ViDocument.h
@@ -31,6 +31,7 @@
id<ViDeferred> _loader;
BOOL _busy;
+ BOOL _modified;
ViTextStorage *_textStorage;
NSDictionary *_typingAttributes;
@@ -80,6 +81,7 @@
@property(nonatomic,readonly) NSStringEncoding encoding;
@property(nonatomic,readwrite) BOOL isTemporary;
@property(nonatomic,readwrite) BOOL busy;
+@property(nonatomic,readwrite,getter=isModified) BOOL modified;
@property(nonatomic,readwrite,copy) void (^closeCallback)(int);
@property(nonatomic,readwrite,retain) id<ViDeferred> loader;
@property(nonatomic,readwrite) BOOL ignoreChangeCountNotification;
View
15 app/ViDocument.m
@@ -62,6 +62,7 @@ @implementation ViDocument
@synthesize hiddenView = _hiddenView;
@synthesize syntaxParser = _syntaxParser;
@synthesize marks = _marks;
+@synthesize modified = _modified;
+ (BOOL)canConcurrentlyReadDocumentsOfType:(NSString *)typeName
{
@@ -250,7 +251,7 @@ - (BOOL)readFromURL:(NSURL *)absoluteURL
void (^completionCallback)(NSURL *, NSDictionary *, NSError *error) = ^(NSURL *normalizedURL, NSDictionary *attributes, NSError *error) {
DEBUG(@"error is %@", error);
returnError = error;
- _busy = NO;
+ [self setBusy:NO];
[self setLoader:nil];
if (error) {
/* If the file doesn't exist, treat it as an untitled file. */
@@ -313,7 +314,7 @@ - (BOOL)readFromURL:(NSURL *)absoluteURL
[tv prepareRevertDocument];
}];
- _busy = YES;
+ [self setBusy:YES];
[self setLoader:[[ViURLManager defaultManager] dataWithContentsOfURL:absoluteURL
onData:dataCallback
onCompletion:completionCallback]];
@@ -910,9 +911,6 @@ - (NSString *)title
displayName = [[self fileURL] host];
}
- if ([self isDocumentEdited])
- return [NSString stringWithFormat:@"%@", displayName];
-
return displayName;
}
@@ -926,14 +924,11 @@ - (void)updateChangeCount:(NSDocumentChangeType)changeType
}
BOOL edited = [self isDocumentEdited];
[super updateChangeCount:changeType];
- if (edited != [self isDocumentEdited]) {
- [self willChangeValueForKey:@"title"];
- [self didChangeValueForKey:@"title"];
-
+ [self setModified:[self isDocumentEdited]];
+ if (edited != _modified)
[[NSNotificationCenter defaultCenter] postNotificationName:ViDocumentEditedChangedNotification
object:self
userInfo:nil];
- }
}
- (void)setFileURL:(NSURL *)absoluteURL
View
4 app/ViDocumentView.h
@@ -10,11 +10,15 @@
IBOutlet NSScrollView *_scrollView;
ViDocument *_document;
ViTabController *_tabController;
+ BOOL _processing;
+ BOOL _modified;
}
@property(nonatomic,readonly) NSView *view;
@property(nonatomic,readonly) NSView *innerView;
@property(nonatomic,readwrite,assign) ViTabController *tabController;
+@property(nonatomic,readwrite,getter=isProcessing) BOOL processing;
+@property(nonatomic,readwrite,getter=isModified) BOOL modified;
- (ViDocumentView *)initWithDocument:(ViDocument *)aDocument;
- (ViTextView *)textView;
View
16 app/ViDocumentView.m
@@ -8,6 +8,8 @@ @implementation ViDocumentView
@synthesize innerView = _innerView;
@synthesize document = _document;
@synthesize tabController = _tabController;
+@synthesize processing = _processing;
+@synthesize modified = _modified;
- (ViDocumentView *)initWithDocument:(ViDocument *)aDocument
{
@@ -34,14 +36,20 @@ - (void)dealloc
- (void)setDocument:(ViDocument *)document
{
DEBUG(@"set document %@ -> %@", _document, document);
+ [self unbind:@"processing"];
+ [self unbind:@"modified"];
[_document removeObserver:self forKeyPath:@"title"];
[document retain];
[_document release];
_document = document;
- [_document addObserver:self
- forKeyPath:@"title"
- options:NSKeyValueObservingOptionNew
- context:nil];
+ if (_document) {
+ [_document addObserver:self
+ forKeyPath:@"title"
+ options:NSKeyValueObservingOptionNew
+ context:nil];
+ [self bind:@"processing" toObject:_document withKeyPath:@"busy" options:nil];
+ [self bind:@"modified" toObject:_document withKeyPath:@"modified" options:nil];
+ }
}
- (NSString *)description

0 comments on commit 6b644e1

Please sign in to comment.
Something went wrong with that request. Please try again.