-
Notifications
You must be signed in to change notification settings - Fork 2
/
ViewerDocument.m
839 lines (689 loc) · 23.4 KB
/
ViewerDocument.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
/////////////////////////////////////////////////////////////////////////
// File: $URL$
// Module: Document object for a viewer window.
// Part of: VitaminSEE
//
// ID: $Id: ApplicationController.m 123 2005-04-18 00:21:02Z elliot $
// Revision: $Revision$
// Last edited: $Date$
// Author: $Author$
// Copyright: (c) 2005 Elliot Glaysher
// Created: 8/11/05
//
/////////////////////////////////////////////////////////////////////////
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
////////////////////////////////////////////////////////////////////////
#import "ApplicationController.h"
#import "ViewerDocument.h"
#import "ComponentManager.h"
#import "ImageLoader.h"
#import "VitaminSEEWindowController.h"
#import "EGPath.h"
#import "NSString+FileTasks.h"
#import "DesktopBackground.h"
#import "FavoritesMenuFactory.h"
#import "Util.h"
#import "FileOperations.h"
#import "RenameFileSheetController.h"
#import "FullscreenWindowController.h"
@implementation ViewerDocument
/** Default initializer. Really calls the initWithPath: initializer with
* whatever the default startup path is.
*/
-(id)init
{
return [self initWithPath:[[NSUserDefaults standardUserDefaults]
objectForKey:@"DefaultStartupPath"]];
}
//-----------------------------------------------------------------------------
/** Deallocator
*/
-(void)dealloc
{
NSLog(@"Destroyed!");
// [window release];
[documentID release];
[super dealloc];
}
-(void)close
{
NSLog(@"Closing document!");
// Release ourselves from the ApplicationController's list of viewers
[[ApplicationController controller] remvoeViewerDocument:self];
id appController = [ApplicationController controller];
[NSObject cancelPreviousPerformRequestsWithTarget:appController
selector:@selector(becomeMainDocument:)
object:self];
// Remove ourselves from the ImageLoader. We do this before any other
// cleanup because there's a race condition where some parts of
// ViewerDocument get released while receiveImage: is running...
[ImageLoader unregisterRequester:self];
documentClosed = YES;
[currentFile release];
[fileList cleanup];
[fileList release];
[viewerNotifications release];
[undoManager release];
[super close];
// Release ourselves; we aren't owned by any other object
[self release];
}
//-----------------------------------------------------------------------------
/** Initializer that takes a path, creates a normal ViewAsIcons fileList and
* displays the incoming path.
*
* @param path The directory to display
*/
-(id)initWithPath:(EGPath*)path
{
if(self = [super init])
{
// Obtain a unique document ID from the Application controller
documentID = [[ApplicationController controller] getNextAvailableID];
[documentID retain];
documentClosed = NO;
// If we say that we have an undo manager, then we
[self setHasUndoManager:NO];
undoManager = [[NSUndoManager alloc] init];
// We need a file list
fileListName = @"ViewAsIcons";
fileList = [[ComponentManager getFileListPluginNamed:fileListName] build];
[fileList setDelegate:self];
window = [[[VitaminSEEWindowController alloc] initWithFileList:fileList] autorelease];
[self addWindowController:window];
[window setShouldCloseDocument:YES];
viewerNotifications = [[NSNotificationCenter alloc] init];
[window showWindow:window];
scaleRatio = 1.0f;
scaleMode = SCALE_IMAGE_TO_FIT;
[fileList setDirectory:path];
[[ApplicationController controller] addViewerDocument:self];
}
return self;
}
//-----------------------------------------------------------------------------
/** Returns the current documentID, a number unique across sessions that
* represents this ViewerDocument. This number is used to keep track of which
* windows request what images by the ImageLoader so that the ImageLoader will
* cancel old tasks when a new task from the same ViewerDocument is called.
*/
-(NSNumber*)documentID
{
return documentID;
}
//-----------------------------------------------------------------------------
/** Used for the Goto Folder method...
*/
-(void)setDirectoryFromRawPath:(NSString*)path
{
if([path isDir])
[fileList setDirectory:[EGPath pathWithPath:path]];
else
AlertSoundPlay();
}
//-----------------------------------------------------------------------------
/** Will set the directory of the FileList if the FileList canSetDirectory.
*/
-(void)setDirectory:(EGPath*)path
{
if([path isDirectory])
[fileList setDirectory:path];
else
AlertSoundPlay();
}
//-----------------------------------------------------------------------------
/** Focuses on a file in the FileList, and set it as the displayed file. This
* method is meant to be invoked by objects unrelated to the FileList or the
* ViewerDocument/VitaminSEEWindowController classes.
*/
-(BOOL)focusOnFile:(EGPath*)path
{
// First, we need to make sure we're in the current directory, and move
// there if we aren't.
if([fileList canSetDirectory] &&
![[fileList directory] isEqual:[path pathByDeletingLastPathComponent]])
{
[fileList setDirectory:[path pathByDeletingLastPathComponent]];
}
BOOL ret = [fileList focusOnFile:path];
[self setDisplayedFileTo:path];
return ret;
}
//-----------------------------------------------------------------------------
/** Sets the file being displayed. Will spawn a task to the ImageLoader to
* load and scale the image. This method is usually called by the current
* fileList plugin.
*
* @param file EGPath pointing to the file to display.
*/
-(void)setDisplayedFileTo:(EGPath*)file
{
[file retain];
[currentFile release];
currentFile = file;
// OK, so we're going to cancel any recent becomeMainDocument: message,
// and then we're going to try to become the main document after a
// moment. (So if the user is just holding "down" while scrolling
// throught the filelist, we aren't going to have slowdowns...)
id appController = [ApplicationController controller];
[NSObject cancelPreviousPerformRequestsWithTarget:appController
selector:@selector(becomeMainDocument:)
object:self];
[appController performSelector:@selector(becomeMainDocument:)
withObject:self
afterDelay:0.15];
// Now tell the actual window to hide that stupid progress spinner.
[window stopProgressIndicator];
if([[file fileSystemPath] isImage])
{
NSNumber* tag = [[NSUserDefaults standardUserDefaults]
objectForKey:@"SmoothingTag"];
id smoothing;
switch([tag intValue])
{
case 1:
smoothing = NO_SMOOTHING;
break;
case 2:
smoothing = LOW_SMOOTHING;
break;
default:
case 3:
smoothing = HIGH_SMOOTHING;
}
NSMutableDictionary* dic = [NSMutableDictionary
dictionaryWithObjectsAndKeys:
scaleMode, IL_SCALE_MODE,
[NSNumber numberWithDouble:[window viewingAreaWidth]],
IL_VIEWING_AREA_WIDTH,
[NSNumber numberWithDouble:[window viewingAreaHeight]],
IL_VIEWING_AREA_HEIGHT,
smoothing, IL_SMOOTHING,
[NSNumber numberWithDouble:scaleRatio], IL_SCALE_RATIO,
currentFile, IL_PATH,
self, IL_REQUESTER,
nil];
// NSLog(@"Task dictionary: %@", dic);
[ImageLoader loadTask:dic];
}
else
{
// We want to display the folder icon (or whatever it is), since it
// isn't an image and we want to reflect that.
[window setImageSizeLabelText:NSMakeSize(0,0)];
[window setFileSizeLabelText:-1 forPath:nil];
[window setZoomStatusBarCellFromTask:nil];
// Display the icon.
NSImage* image = [file iconImageOfSize:NSMakeSize(128,128)];
[window setImage:image];
if(pixelWidth == 0)
pixelWidth = 128;
if(pixelHeight == 0)
pixelHeight = 128;
}
}
//-----------------------------------------------------------------------------
/** Callback method used by the ImageLoader to actually set the image.
* ImageLoader is given tasks by the method setDisplayedFileTo:.
*/
-(void)receiveImage:(NSDictionary*)task
{
// NSLog(@"Receiving image!");
// If this is still the current file (i.e., not stale...)
if([[task objectForKey:IL_PATH] isEqual:currentFile]) {
NSImage* image = [task objectForKey:IL_IMAGE];
if(image && !documentClosed) {
// Set the image
[window setImage:image];
pixelWidth = [[task objectForKey:IL_PIXEL_WIDTH] floatValue];
pixelHeight = [[task objectForKey:IL_PIXEL_HEIGHT] floatValue];
// Set the image size label
[window setImageSizeLabelText:NSMakeSize(pixelWidth, pixelHeight)];
// Set the size of the image in bytes
[window setFileSizeLabelText:[[task objectForKey:IL_DATA_SIZE] intValue]
forPath:[task objectForKey:IL_PATH]];
// Set the zoom data on the status bar
[window setZoomStatusBarCellFromTask:task];
// If we're in scale mode, update the zoom factor so that if the
// user zooms in or out, it's relative to the current image.
scaleRatio = [[task objectForKey:IL_SCALE_RATIO] floatValue];
}
}
// Only stop the progress spinner (and the countdown to display it) if this
// task message doesn't have a @"Partial" tag on it (since the final results
// are on the way
if(![task objectForKey:IL_PARTIAL])
[self stopProgressIndicator];
[task release];
}
//-----------------------------------------------------------------------------
/** Perform a full redraw event, which will ask the ImageLoader to rescale the
* iamge.
*/
-(void)redraw
{
[self setDisplayedFileTo:currentFile];
}
//-----------------------------------------------------------------------------
-(float)pixelWidth
{
return pixelWidth;
}
//-----------------------------------------------------------------------------
-(float)pixelHeight
{
return pixelHeight;
}
//-----------------------------------------------------------------------------
-(NSString*)scaleMode
{
return scaleMode;
}
//-----------------------------------------------------------------------------
/** Returns the current file being displayed.
*/
-(EGPath*)currentFile
{
return currentFile;
}
//-----------------------------------------------------------------------------
-(void)beginCountdownToDisplayProgressIndicator
{
[window beginCountdownToDisplayProgressIndicator];
}
//-----------------------------------------------------------------------------
-(void)startProgressIndicator
{
// Pass this message on to the Window
if(!documentClosed)
[window startProgressIndicator];
}
//-----------------------------------------------------------------------------
-(void)stopProgressIndicator
{
if(!documentClosed)
[window stopProgressIndicator];
}
//-----------------------------------------------------------------------------
-(void)updateWindowTitle
{
if(!documentClosed)
[window updateWindowTitle];
}
//-----------------------------------------------------------------------------
// FIRST RESPONDER ACTIONS GENERATED BY MENU CLICKS HANDLED BY THIS CLASS.
//-----------------------------------------------------------------------------
/** Validates toolbar items. Everything gets passed on to our generic validator.
*/
-(BOOL)validateToolbarItem:(NSToolbarItem*)toolbarItem
{
return [self validateAction:[toolbarItem action]];
}
//-----------------------------------------------------------------------------
/** Validates menu items. Most things are just handled by our generic validator,
* but we also have some menu specific validation that needs to be done.
*/
-(BOOL)validateMenuItem:(NSMenuItem *)anItem
{
SEL action = [anItem action];
BOOL enable = [self validateAction:action];
// Check to see if we have to change the label on the desktop pictures item.
if(action == @selector(setAsDesktopImage:))
enable = [self validateSetAsDesktopImageItem:anItem];
else if(action == @selector(setFileListFromMenu:))
{
// These entries will always be on. The big thing we have to do is
// check to see if this item should be checked.
enable = YES;
NSString* name = [anItem representedObject];
if([fileListName isEqualTo:name])
[anItem setState:NSOnState];
else
[anItem setState:NSOffState];
}
else if(action == @selector(becomeFullScreen:))
{
if(![[window class] isEqual:[VitaminSEEWindowController class]])
[anItem setState:NSOnState];
else
[anItem setState:NSOffState];
}
return enable;
}
-(void)setFileListFromMenu:(id)menuItem
{
NSString* name = [menuItem representedObject];
if(![name isEqualTo:fileListName])
{
// Set the new file here
// TODO: Make this work.
}
}
//-----------------------------------------------------------------------------
/** Validate the "Set As Desktop Image" File menu item.
*/
-(BOOL)validateSetAsDesktopImageItem:(NSMenuItem*)item
{
BOOL isImage = [currentFile isImage];
BOOL isDir = [currentFile isDirectory];
BOOL enable = isImage || isDir;
if(isImage)
{
[item setTitle:NSLocalizedString(@"Set As Desktop Picture",
@"Text in File menu")];
}
else
{
[item setTitle:NSLocalizedString(@"Use Folder For Desktop Pictures",
@"Text in File menu")];
// Only enable if the folder contains an image
BOOL containsImage = NO;
NSArray* directoryContents = [currentFile directoryContents];
int i = 0, count = [directoryContents count];
for(; i < count; ++i)
{
if([((id)CFArrayGetValueAtIndex((CFArrayRef)directoryContents, i)) isImage])
{
containsImage = YES;
break;
}
}
enable = enable && containsImage;
}
return enable;
}
//-----------------------------------------------------------------------------
-(BOOL)validateAction:(SEL)action
{
// Default behaviour: only enable if we respond to this selector.
BOOL enable = [self respondsToSelector:action];
// NSLog(@"Validating %@ (Is %d)", NSStringFromSelector(action), enable);
// Disable menu items when they would put the image in the state it's
// already currently in.
// File menu
if(action == @selector(openCurrentItem:))
enable = [fileList canOpenCurrentItem];
if(action == @selector(openInPreview:))
enable = [currentFile isImage];
else if(action == @selector(moveToTrash:))
enable = [currentFile isNaturalFile]; //[self validateMoveToTrash];
else if(action == @selector(addToFavorites:))
enable = [currentFile isDirectory] && [currentFile isNaturalFile] &&
!isInFavorites([currentFile fileSystemPath]);
// View menu
else if(action == @selector(actualSize:))
enable = [currentFile isImage] &&
(scaleMode != SCALE_IMAGE_PROPORTIONALLY || scaleRatio != 1);
else if(action == @selector(zoomToFit:))
enable = [currentFile isImage] && scaleMode != SCALE_IMAGE_TO_FIT;
else if(action == @selector(zoomIn:) ||
action == @selector(zoomOut:))
enable = [currentFile isImage];
else if(action == @selector(revealInFinder:))
enable = YES;
// Go menu
else if(action == @selector(goNextFile:))
enable = [fileList canGoNextFile];
else if(action == @selector(goPreviousFile:))
enable = [fileList canGoPreviousFile];
else if(action == @selector(goBack:))
enable = [fileList canGoBack];
else if(action == @selector(goForward:))
enable = [fileList canGoForward];
else if(action == @selector(goEnclosingFolder:))
enable = [fileList canGoEnclosingFolder];
return enable;
}
//-----------------------------------------------------------------------------
/** This is a high level TODO!
*
*/
-(BOOL)validateMoveToTrash
{
BOOL ok = YES;
// NSFileManager* fm = [NSFileManager defaultManager];
// If our user doesn't have +w on the current folder, set ok to NO.
// unsigned long folderPermissions = [fm fileAttributesAtPath:<#(NSString *)path#>
// traverseLink:NO];
// If our user doesn't have +w on the current file, set ok to NO.
// unsigned long filePermissions = [fm fileAttributesAtPath:<#(NSString *)path#>
// traverseLink:NO];
// FIXME HERE! Detect
return ok;
}
//-----------------------------------------------------------------------------
/** Redefine undoManager. The NSDocument object also has support to own an
* NSUndoManager object, but it then observes that object to set the NSDocument
* dirty bit, which marks the proxy icon and the close button. On Panther, this
* also has the undesierable effect of forcing a Don't Save/Cancel/Save dialog
* when the window is closed. So instead, mark -setHasUndoManager:NO in the
* constructor, and override this method so that it returns the ViewerDocument
* owned NSUndoManager.
*/
-(NSUndoManager*)undoManager
{
return undoManager;
}
//-----------------------------------------------------------------------------
// FILE MENU
//-----------------------------------------------------------------------------
/** Function invoked when File > Open is activated. This function should go into
* the currently selected directory, though different FileLists may have
* different semantics.
*/
-(void)openCurrentItem:(id)sender
{
[fileList openCurrentItem];
}
//-----------------------------------------------------------------------------
/** Opens the current image in Preview
*/
-(void)openInPreview:(id)sender
{
[[NSWorkspace sharedWorkspace] openFile:[currentFile fileSystemPath]
withApplication:@"Preview"];
}
//-----------------------------------------------------------------------------
// *** Open With handled in Application Controller
//-----------------------------------------------------------------------------
/** Cause the rename dialog to display
*/
-(void)renameFile:(id)sender
{
id fileop = [ComponentManager getInteranlComponentNamed:@"FileOperations"];
id controller = [fileop buildRenameSheetController];
[controller showSheet:[window window]
initialValue:currentFile
notifyWhenDone:self];
}
//-----------------------------------------------------------------------------
/** Add the current directory to the favorites.
*/
-(void)addToFavorites:(id)sender
{
NSString* filepath = [currentFile fileSystemPath];
id favoritesComponent = [ComponentManager
getInteranlComponentNamed:@"FavoritesMenu"];
[favoritesComponent addDirectoryToFavorites:filepath];
}
//-----------------------------------------------------------------------------
/** Sets the current selection {file, directory} as the desktop image.
*/
-(void)setAsDesktopImage:(id)sender
{
id desktopBackground = [ComponentManager
getInteranlComponentNamed:@"DesktopBackground"];
if([currentFile isImage])
[desktopBackground setDesktopBackgroundToFile:[currentFile fileSystemPath]];
else if([currentFile isDirectory])
[desktopBackground setDesktopBackgroundToFolder:[currentFile fileSystemPath]];
}
//-----------------------------------------------------------------------------
/** Deletes the file
*/
-(void)moveToTrash:(id)sender
{
[[ComponentManager getInteranlComponentNamed:@"FileOperations"]
deleteFile:currentFile];
}
//-----------------------------------------------------------------------------
// VIEW MENU
//-----------------------------------------------------------------------------
/** Scales the image so there is one pixel in the image is one pixel on screen.
*/
-(void)actualSize:(id)sender
{
scaleMode = SCALE_IMAGE_PROPORTIONALLY;
scaleRatio = 1.0f;
[self setDisplayedFileTo:currentFile];
}
//-----------------------------------------------------------------------------
/** Zooms in on the image.
*/
-(void)zoomIn:(id)sender
{
scaleMode = SCALE_IMAGE_PROPORTIONALLY;
scaleRatio += 0.10f;
[self setDisplayedFileTo:currentFile];
}
//-----------------------------------------------------------------------------
/** Zooms out from the image.
*/
-(void)zoomOut:(id)sender
{
scaleMode = SCALE_IMAGE_PROPORTIONALLY;
scaleRatio -= 0.10f;
[self setDisplayedFileTo:currentFile];
}
//-----------------------------------------------------------------------------
/** Scales the image so that it fits perfectly in the window.
*/
-(void)zoomToFit:(id)sender
{
scaleMode = SCALE_IMAGE_TO_FIT;
scaleRatio = 1.0f;
[self setDisplayedFileTo:currentFile];
}
//-----------------------------------------------------------------------------
/** Reveals the current file in the Finder.
*/
-(void)revealInFinder:(id)sender
{
[[NSWorkspace sharedWorkspace] selectFile:[currentFile fileSystemPath]
inFileViewerRootedAtPath:@""];
}
/** Switch between fullscreen and not.
*/
-(void)becomeFullScreen:(id)sender
{
if([[window class] isEqual:[VitaminSEEWindowController class]])
{
[window setShouldCloseDocument:NO];
// Make all the document windows hide, recording their current state
// so we can restore it later
previousVisibleState = [[NSMutableArray alloc] init];
id otherDocuments = [[ApplicationController controller] viewerDocuments];
NSEnumerator* e = [otherDocuments objectEnumerator];
id curDocument;
while(curDocument = [e nextObject])
{
if(curDocument != self) {
NSWindow* curWindow = [[[curDocument windowControllers] objectAtIndex:0] window];
[previousVisibleState addObject:curWindow];
[curWindow orderOut:self];
}
}
// Alert the application controller that we are now fullscreen
[[ApplicationController controller] setFullScreenDocument:self];
// Become fullscreen
id old = window;
windowLocation = [[old window] frame];
window = [[[ComponentManager getInteranlComponentNamed:@"FullScreenMode"]
build] autorelease];
[self addWindowController:window];
[window setFileList:fileList];
[window becomeFullscreen];
[self redraw];
[old close];
}
else
{
// Leave fullscreen
NSWindowController* old = window;
// Now restore all the other windows
NSEnumerator* e = [previousVisibleState objectEnumerator];
id curWindow;
while(curWindow = [e nextObject])
{
[curWindow orderFront:self];
}
// Recreate the real VitaminSEE window.
window = [[[VitaminSEEWindowController alloc] initWithFileList:fileList] autorelease];
[self addWindowController:window];
[[window window] setFrame:windowLocation display:NO];
[window setFileList:fileList];
[window updateWindowTitle];
[[window window] makeKeyAndOrderFront:self];
[self redraw];
[old close];
[window setShouldCloseDocument:YES];
// Alert the application controller that we are not fullscreen anymore
[[ApplicationController controller] setFullScreenDocument:nil];
// Now redisplay the file list
[fileList makeFirstResponderTo:[window window]];
}
}
//-----------------------------------------------------------------------------
// GO MENU
//-----------------------------------------------------------------------------
/** Go Next
*/
-(void)goNextFile:(id)sender
{
[fileList goNextFile];
}
//-----------------------------------------------------------------------------
/** Go Previous
*/
-(void)goPreviousFile:(id)sender
{
[fileList goPreviousFile];
}
//-----------------------------------------------------------------------------
/** Go Back
*/
-(void)goBack:(id)sender
{
[fileList goBack];
}
//-----------------------------------------------------------------------------
/** Go Forward
*
*/
-(void)goForward:(id)sender
{
[fileList goForward];
}
//-----------------------------------------------------------------------------
/** Go Enclosing Folder
*
*/
-(void)goEnclosingFolder:(id)sender
{
[fileList goEnclosingFolder];
}
@end