-
Notifications
You must be signed in to change notification settings - Fork 0
/
XeeControllerNavigationActions.m
176 lines (147 loc) · 3.71 KB
/
XeeControllerNavigationActions.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
#import "XeeControllerNavigationActions.h"
#import "XeeImageSource.h"
@implementation XeeController (NavigationActions)
-(IBAction)skipNext:(id)sender
{
[self setResizeBlockFromSender:sender];
[source skip:1];
[self setResizeBlock:NO];
}
-(IBAction)skipPrev:(id)sender
{
[self setResizeBlockFromSender:sender];
[source skip:-1];
[self setResizeBlock:NO];
}
-(IBAction)skipFirst:(id)sender
{
[self setResizeBlockFromSender:sender];
[source pickFirstImage];
[self setResizeBlock:NO];
}
-(IBAction)skipLast:(id)sender
{
[self setResizeBlockFromSender:sender];
[source pickLastImage];
[self setResizeBlock:NO];
}
-(IBAction)skip10Forward:(id)sender
{
[self setResizeBlockFromSender:sender];
[source skip:10];
[self setResizeBlock:NO];
}
-(IBAction)skip100Forward:(id)sender
{
[self setResizeBlockFromSender:sender];
[source skip:100];
[self setResizeBlock:NO];
}
-(IBAction)skip10Back:(id)sender
{
[self setResizeBlockFromSender:sender];
[source skip:-10];
[self setResizeBlock:NO];
}
-(IBAction)skip100Back:(id)sender
{
[self setResizeBlockFromSender:sender];
[source skip:-100];
[self setResizeBlock:NO];
}
-(IBAction)skipRandom:(id)sender
{
[self setResizeBlockFromSender:sender];
[source pickNextImageAtRandom];
[self setResizeBlock:NO];
}
-(IBAction)skipRandomPrev:(id)sender
{
[self setResizeBlockFromSender:sender];
[source pickPreviousImageAtRandom];
[self setResizeBlock:NO];
}
-(IBAction)setSortOrder:(id)sender
{
[source setSortOrder:[sender tag]];
}
-(IBAction)runSlideshow:(id)sender
{
if(slideshowtimer)
{
[slideshowtimer invalidate];
[slideshowtimer release];
slideshowtimer=nil;
}
else
{
slideshowcount=0;
slideshowtimer=[[NSTimer scheduledTimerWithTimeInterval:1
target:self selector:@selector(slideshowStep:) userInfo:nil repeats:YES] retain];
}
}
-(IBAction)setSlideshowDelay:(id)sender
{
[[NSUserDefaults standardUserDefaults] setInteger:[sender tag] forKey:@"slideshowDelay"];
}
-(IBAction)setCustomSlideshowDelay:(id)sender
{
if(!delaypanel)
{
NSNib *nib=[[[NSNib alloc] initWithNibNamed:@"SlideshowDelayPanel" bundle:nil] autorelease];
[nib instantiateNibWithOwner:self topLevelObjects:nil];
}
int delay=[[NSUserDefaults standardUserDefaults] integerForKey:@"slideshowCustomDelay"];
if(!delay) delay=[[NSUserDefaults standardUserDefaults] integerForKey:@"slideshowDelay"];
[delayfield setIntValue:delay];
if(fullscreenwindow)
{
[delaypanel makeKeyAndOrderFront:nil];
delaysheet=NO;
}
else
{
[NSApp beginSheet:delaypanel modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil];
delaysheet=YES;
}
}
-(IBAction)delayPanelOK:(id)sender
{
[[NSUserDefaults standardUserDefaults] setInteger:[delayfield intValue] forKey:@"slideshowCustomDelay"];
[[NSUserDefaults standardUserDefaults] setInteger:[delayfield intValue] forKey:@"slideshowDelay"];
if(delaysheet) [NSApp endSheet:delaypanel];
[delaypanel orderOut:nil];
}
-(IBAction)delayPanelCancel:(id)sender
{
if(delaysheet) [NSApp endSheet:delaypanel];
[delaypanel orderOut:nil];
}
-(void)slideshowStep:(NSTimer *)timer
{
// Prevent sleeping
UpdateSystemActivity(UsrActivity);
int slideshowdelay=[[NSUserDefaults standardUserDefaults] integerForKey:@"slideshowDelay"];
if(++slideshowcount>=slideshowdelay)
{
slideshowcount=0;
if([[NSUserDefaults standardUserDefaults] boolForKey:@"randomizeSlideshow"])
{
[source pickNextImageAtRandom];
}
else
{
if([source indexOfCurrentImage]<[source numberOfImages]-1
||[[NSUserDefaults standardUserDefaults] boolForKey:@"wrapImageBrowsing"])
[source skip:1];
else
{
[slideshowtimer invalidate];
[slideshowtimer release];
slideshowtimer=nil;
}
}
}
}
-(BOOL)isSlideshowRunning { return slideshowtimer?YES:NO; }
@end