PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 0ms app.codeStats 0ms

/XeeControllerNavigationActions.m

https://code.google.com/p/xee/
Objective C | 176 lines | 146 code | 29 blank | 1 comment | 9 complexity | 4ed562e78107088ee2238035574cc5c6 MD5 | raw file
  1#import "XeeControllerNavigationActions.h"
  2#import "XeeImageSource.h"
  3
  4@implementation XeeController (NavigationActions)
  5
  6-(IBAction)skipNext:(id)sender
  7{
  8	[self setResizeBlockFromSender:sender];
  9	[source skip:1];
 10	[self setResizeBlock:NO];
 11}
 12
 13-(IBAction)skipPrev:(id)sender
 14{
 15	[self setResizeBlockFromSender:sender];
 16	[source skip:-1];
 17	[self setResizeBlock:NO];
 18}
 19
 20-(IBAction)skipFirst:(id)sender
 21{
 22	[self setResizeBlockFromSender:sender];
 23	[source pickFirstImage];
 24	[self setResizeBlock:NO];
 25}
 26
 27-(IBAction)skipLast:(id)sender
 28{
 29	[self setResizeBlockFromSender:sender];
 30	[source pickLastImage];
 31	[self setResizeBlock:NO];
 32}
 33
 34-(IBAction)skip10Forward:(id)sender
 35{
 36	[self setResizeBlockFromSender:sender];
 37	[source skip:10];
 38	[self setResizeBlock:NO];
 39}
 40
 41-(IBAction)skip100Forward:(id)sender
 42{
 43	[self setResizeBlockFromSender:sender];
 44	[source skip:100];
 45	[self setResizeBlock:NO];
 46}
 47
 48-(IBAction)skip10Back:(id)sender
 49{
 50	[self setResizeBlockFromSender:sender];
 51	[source skip:-10];
 52	[self setResizeBlock:NO];
 53}
 54
 55-(IBAction)skip100Back:(id)sender
 56{
 57	[self setResizeBlockFromSender:sender];
 58	[source skip:-100];
 59	[self setResizeBlock:NO];
 60}
 61
 62-(IBAction)skipRandom:(id)sender
 63{
 64	[self setResizeBlockFromSender:sender];
 65	[source pickNextImageAtRandom];
 66	[self setResizeBlock:NO];
 67}
 68
 69-(IBAction)skipRandomPrev:(id)sender
 70{
 71	[self setResizeBlockFromSender:sender];
 72	[source pickPreviousImageAtRandom];
 73	[self setResizeBlock:NO];
 74}
 75
 76
 77
 78-(IBAction)setSortOrder:(id)sender
 79{
 80	[source setSortOrder:[sender tag]];
 81}
 82
 83
 84
 85-(IBAction)runSlideshow:(id)sender
 86{
 87	if(slideshowtimer)
 88	{
 89		[slideshowtimer invalidate];
 90		[slideshowtimer release];
 91		slideshowtimer=nil;
 92	}
 93	else
 94	{
 95		slideshowcount=0;
 96		slideshowtimer=[[NSTimer scheduledTimerWithTimeInterval:1
 97		target:self selector:@selector(slideshowStep:) userInfo:nil repeats:YES] retain];
 98	}
 99}
100
101-(IBAction)setSlideshowDelay:(id)sender
102{
103	[[NSUserDefaults standardUserDefaults] setInteger:[sender tag] forKey:@"slideshowDelay"];
104}
105
106-(IBAction)setCustomSlideshowDelay:(id)sender
107{
108	if(!delaypanel)
109	{
110		NSNib *nib=[[[NSNib alloc] initWithNibNamed:@"SlideshowDelayPanel" bundle:nil] autorelease];
111		[nib instantiateNibWithOwner:self topLevelObjects:nil];
112	}
113
114	int delay=[[NSUserDefaults standardUserDefaults] integerForKey:@"slideshowCustomDelay"];
115	if(!delay) delay=[[NSUserDefaults standardUserDefaults] integerForKey:@"slideshowDelay"];
116	[delayfield setIntValue:delay];
117
118	if(fullscreenwindow)
119	{
120		[delaypanel makeKeyAndOrderFront:nil];
121		delaysheet=NO;
122	}
123	else
124	{
125		[NSApp beginSheet:delaypanel modalForWindow:window modalDelegate:nil didEndSelector:nil contextInfo:nil];
126		delaysheet=YES;
127	}
128}
129
130-(IBAction)delayPanelOK:(id)sender
131{
132	[[NSUserDefaults standardUserDefaults] setInteger:[delayfield intValue] forKey:@"slideshowCustomDelay"];
133	[[NSUserDefaults standardUserDefaults] setInteger:[delayfield intValue] forKey:@"slideshowDelay"];
134
135	if(delaysheet) [NSApp endSheet:delaypanel];
136	[delaypanel orderOut:nil];
137}
138
139-(IBAction)delayPanelCancel:(id)sender
140{
141	if(delaysheet) [NSApp endSheet:delaypanel];
142	[delaypanel orderOut:nil];
143}
144
145-(void)slideshowStep:(NSTimer *)timer
146{
147	// Prevent sleeping
148	UpdateSystemActivity(UsrActivity);
149
150	int slideshowdelay=[[NSUserDefaults standardUserDefaults] integerForKey:@"slideshowDelay"];
151	if(++slideshowcount>=slideshowdelay)
152	{
153		slideshowcount=0;
154
155		if([[NSUserDefaults standardUserDefaults] boolForKey:@"randomizeSlideshow"])
156		{
157			[source pickNextImageAtRandom];
158		}
159		else
160		{
161			if([source indexOfCurrentImage]<[source numberOfImages]-1
162			||[[NSUserDefaults standardUserDefaults] boolForKey:@"wrapImageBrowsing"])
163			[source skip:1];
164			else
165			{
166				[slideshowtimer invalidate];
167				[slideshowtimer release];
168				slideshowtimer=nil;
169			}
170		}
171	}
172}
173
174-(BOOL)isSlideshowRunning { return slideshowtimer?YES:NO; }
175
176@end