core: remove the 360 video viewpoint zoom
[vlc.git] / modules / gui / macosx / VLCResumeDialogController.m
blob8d03f32f14f783fcd1c1b14219aa5044b0fb1bb8
1 /*****************************************************************************
2  * VLCResumeDialogController.m: MacOS X interface module
3  *****************************************************************************
4  * Copyright (C) 2015 VLC authors and VideoLAN
5  *
6  * Authors: Felix Paul Kühne <fkuehne -at- videolan -dot- org>
7  *          David Fuhrmann <david dot fuhrmann at googlemail dot com>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
25 #import "VLCResumeDialogController.h"
27 #import "VLCMain.h"
28 #import "VLCStringUtility.h"
30 @interface VLCResumeDialogController()
32     int currentResumeTimeout;
33     CompletionBlock completionBlock;
35 @end
37 @implementation VLCResumeDialogController
39 - (id)init
41     self = [super initWithWindowNibName:@"ResumeDialog"];
43     return self;
46 - (void)windowDidLoad
48     [o_title_lbl setStringValue:_NS("Continue playback?")];
49     [o_resume_btn setTitle:_NS("Continue")];
51     [o_always_resume_chk setTitle:_NS("Always continue media playback")];
54 - (void)showWindowWithItem:(input_item_t *)p_item withLastPosition:(NSInteger)pos completionBlock:(CompletionBlock)block
56     NSWindow *w = [self window];
58     currentResumeTimeout = 10;
59     completionBlock = [block copy];
62     NSString *o_restartButtonLabel = _NS("Restart playback");
63     o_restartButtonLabel = [o_restartButtonLabel stringByAppendingFormat:@" (%d)", currentResumeTimeout];
64     [o_restart_btn setTitle:o_restartButtonLabel];
66     char *psz_title_name = input_item_GetTitleFbName(p_item);
67     NSString *o_title = toNSStr(psz_title_name);
68     free(psz_title_name);
69     NSString *labelString = [NSString stringWithFormat:_NS("Playback of \"%@\" will continue at %@"), o_title, [[VLCStringUtility sharedInstance] stringForTime:pos]];
70     [o_text_lbl setStringValue:labelString];
71     [o_always_resume_chk setState: NSOffState];
73     o_countdown_timer = [NSTimer scheduledTimerWithTimeInterval:1
74                                                          target:self
75                                                        selector:@selector(updateAlertWindow:)
76                                                        userInfo:nil
77                                                         repeats:YES];
79     [w setLevel:[[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]];
80     [w center];
82     [w makeKeyAndOrderFront:nil];
85 - (void)updateAlertWindow:(NSTimer *)timer
87     --currentResumeTimeout;
88     if (currentResumeTimeout <= 0) {
89         [self buttonClicked:o_restart_btn];
90         [timer invalidate];
91         timer = nil;
92     }
94     NSString *buttonLabel = _NS("Restart playback");
95     buttonLabel = [buttonLabel stringByAppendingFormat:@" (%d)", currentResumeTimeout];
97     [o_restart_btn setTitle:buttonLabel];
100 - (IBAction)buttonClicked:(id)sender
102     enum ResumeResult resumeResult;
104     if (sender == o_restart_btn)
105         resumeResult = RESUME_RESTART;
106     else if (sender == o_resume_btn)
107         resumeResult = RESUME_NOW;
109     [[self window] close];
111     if (completionBlock) {
112         completionBlock(resumeResult);
113         completionBlock = nil;
114     }
117 - (IBAction)resumeSettingChanged:(id)sender
119     int newState = [sender state] == NSOnState ? 1 : 0;
120     msg_Dbg(getIntf(), "Changing resume setting to %i", newState);
121     config_PutInt(getIntf(), "macosx-continue-playback", newState);
124 - (void)updateCocoaWindowLevel:(NSInteger)i_level
126     if (self.isWindowLoaded && [self.window isVisible] && [self.window level] != i_level)
127         [self.window setLevel: i_level];
130 - (void)cancel
132     if (![self isWindowLoaded])
133         return;
135     if (o_countdown_timer != nil) {
136         [o_countdown_timer invalidate];
137         o_countdown_timer = nil;
138     }
140     [[self window] close];
143 @end