mirror of
https://github.com/textmate/textmate.git
synced 2026-01-23 05:37:55 -05:00
Refactor: Remove code duplication
This commit is contained in:
@@ -77,6 +77,7 @@ PUBLIC @interface DocumentController : NSWindowController <OakFileBrowserDelegat
|
||||
+ (DocumentController*)controllerForUUID:(oak::uuid_t const&)aUUID;
|
||||
|
||||
- (id)init;
|
||||
- (void)synchronizeWindowTitle;
|
||||
|
||||
- (IBAction)goToFileCounterpart:(id)sender;
|
||||
- (IBAction)selectNextTab:(id)sender;
|
||||
|
||||
@@ -387,8 +387,7 @@ OAK_DEBUG_VAR(DocumentController);
|
||||
{
|
||||
if(!documentTabs.empty())
|
||||
[textView performSelector:@selector(applicationDidBecomeActiveNotification:) withObject:aNotification];
|
||||
settings_t const& settings = [self selectedDocument]->settings();
|
||||
self.windowTitle = [NSString stringWithCxxString:settings.get(kSettingsWindowTitleKey, [self selectedDocument]->display_name())];
|
||||
[self synchronizeWindowTitle];
|
||||
}
|
||||
|
||||
- (void)applicationDidResignActiveNotification:(NSNotification*)aNotification
|
||||
@@ -496,6 +495,14 @@ OAK_DEBUG_VAR(DocumentController);
|
||||
[self updateProxyIcon];
|
||||
}
|
||||
|
||||
- (void)synchronizeWindowTitle
|
||||
{
|
||||
settings_t const& settings = [self selectedDocument]->settings();
|
||||
self.windowTitle = [NSString stringWithCxxString:settings.get(kSettingsWindowTitleKey, [self selectedDocument]->display_name())];
|
||||
self.representedFile = [NSString stringWithCxxString:[self selectedDocument]->path()];
|
||||
self.isDocumentEdited = [self selectedDocument]->is_modified();
|
||||
}
|
||||
|
||||
- (void)windowDidBecomeMain:(NSNotification*)aNotification
|
||||
{
|
||||
if(!windowHasLoaded)
|
||||
|
||||
@@ -10,12 +10,6 @@
|
||||
|
||||
OAK_DEBUG_VAR(DocumentController_Tabs);
|
||||
|
||||
@interface DocumentController ()
|
||||
@property (nonatomic, retain) NSString* windowTitle;
|
||||
@property (nonatomic, retain) NSString* representedFile;
|
||||
@property (nonatomic, assign) BOOL isDocumentEdited;
|
||||
@end
|
||||
|
||||
namespace
|
||||
{
|
||||
struct callback_info_t
|
||||
@@ -41,10 +35,7 @@ namespace
|
||||
document::schedule_session_backup();
|
||||
|
||||
// This is also set after open succeeds
|
||||
settings_t const& settings = [self selectedDocument]->settings();
|
||||
self.windowTitle = [NSString stringWithCxxString:settings.get(kSettingsWindowTitleKey, [self selectedDocument]->display_name())];
|
||||
self.representedFile = [NSString stringWithCxxString:[self selectedDocument]->path()];
|
||||
self.isDocumentEdited = [self selectedDocument]->is_modified();
|
||||
[self synchronizeWindowTitle];
|
||||
|
||||
if(windowHasLoaded)
|
||||
[[DocumentOpenHelper new] tryOpenDocument:self.selectedDocument forWindow:self.window delegate:self];
|
||||
@@ -75,12 +66,7 @@ namespace
|
||||
{
|
||||
D(DBF_DocumentController_Tabs, bug("\n"););
|
||||
if(*aDocument == *[self selectedDocument])
|
||||
{
|
||||
settings_t const& settings = [self selectedDocument]->settings();
|
||||
self.windowTitle = [NSString stringWithCxxString:settings.get(kSettingsWindowTitleKey, [self selectedDocument]->display_name())];
|
||||
self.representedFile = [NSString stringWithCxxString:[self selectedDocument]->path()];
|
||||
self.isDocumentEdited = [self selectedDocument]->is_modified();
|
||||
}
|
||||
[self synchronizeWindowTitle];
|
||||
[tabBarView reloadData];
|
||||
[self updateFileBrowserStatus:self];
|
||||
document::schedule_session_backup();
|
||||
@@ -283,10 +269,7 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
settings_t const& settings = aDocument->settings();
|
||||
self.windowTitle = [NSString stringWithCxxString:settings.get(kSettingsWindowTitleKey, aDocument->display_name())];
|
||||
self.representedFile = [NSString stringWithCxxString:aDocument->path()];
|
||||
self.isDocumentEdited = aDocument->is_modified();
|
||||
[self synchronizeWindowTitle];
|
||||
|
||||
[documentView setDocument:aDocument];
|
||||
[self makeTextViewFirstResponder:self];
|
||||
|
||||
Reference in New Issue
Block a user