summaryrefslogtreecommitdiffstats
path: root/Liaison/LoadPanelController.m
blob: efed8333b3f123b06ebbff7cf7d10904c4286b8a (plain)
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
#import "LoadPanelController.h"

@implementation LoadPanelController
- (id)init
{
    self = [super init];

    isShowing = NO;
    
    return self;
}

- (void)sheetDidEnd: (NSWindow *)sheet
         returnCode: (int)returnCode
        contextInfo: (void  *)contextInfo
{
    [sheet close];
}

- (void)show
{
    if (isShowing == NO) {
        [NSApp beginSheet: theLoadPanel
           modalForWindow: [NSApp mainWindow]
            modalDelegate: self
           didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:)
              contextInfo: nil];
        modalSession = [NSApp beginModalSessionForWindow: theLoadPanel];
        isShowing = YES;
    }
}

- (void)hide
{
    if (isShowing) {
        [NSApp endModalSession: modalSession];
        [NSApp endSheet: theLoadPanel];
        isShowing = NO;
    }
}

- (void)setStatus: (NSString *)aStatusMsg
{
    [theStatusField setStringValue: aStatusMsg];
}

- (void)setPath: (NSString *)aPath
{
    [thePathField setStringValue: aPath];
}

- (void)setProgress: (double)aProgress
{
    [theProgressBar setDoubleValue: aProgress];
}

- (void)setIndeterminantProgress: (BOOL)isIndeterminante
{
    [theProgressBar setIndeterminate: isIndeterminante];
}

- (void)update
{
    if (isShowing) {
        if ([theProgressBar isIndeterminate])
            [theProgressBar animate: self];
        [NSApp runModalSession: modalSession];
    }
}
@synthesize modalSession;
@synthesize isShowing;
@synthesize theProgressBar;
@synthesize theLoadPanel;
@end