]> git.sesse.net Git - vlc/blob - modules/gui/macosx_dialog_provider/VLCLoginPanel.m
Use var_InheritString for --decklink-video-connection.
[vlc] / modules / gui / macosx_dialog_provider / VLCLoginPanel.m
1 /*****************************************************************************
2  * VLCLoginPanel.m: A Generic Login Panel created for VLC
3  *****************************************************************************
4  * Copyright (C) 2009-2010 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
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  *****************************************************************************/
23
24 #import "VLCLoginPanel.h"
25
26
27 @implementation VLCLoginPanel
28
29 - (id)init
30 {
31     NSRect windowRect;
32     windowRect.size.height = 278;
33     windowRect.size.width = 505;
34     windowRect.origin.x = windowRect.origin.y = 0;
35
36     return [super initWithContentRect:windowRect
37                             styleMask:NSTitledWindowMask
38                               backing:NSBackingStoreBuffered
39                                 defer:YES];
40 }
41
42 - (void)createContentView
43 {
44     NSRect s_rc = [self frame];
45     id ourContentView = [self contentView];
46
47     s_rc.origin.x = 275;
48     s_rc.origin.y = 44;
49     s_rc.size.height = 32;
50     s_rc.size.width = 108;
51     _cancelButton = [[NSButton alloc] initWithFrame:s_rc];
52     [_cancelButton setButtonType:NSMomentaryLightButton];
53     [_cancelButton setTitle:@"Cancel"];
54     [_cancelButton setBezelStyle:NSRoundedBezelStyle];
55     [_cancelButton setBordered:YES];
56     [_cancelButton setTarget:self];
57     [_cancelButton setAction:@selector(buttonAction:)];
58     [_cancelButton setKeyEquivalent:@"\e"] ; // escape key
59     [ourContentView addSubview:_cancelButton];
60
61     s_rc.origin.x = 383;
62     s_rc.origin.y = 44;
63     s_rc.size.height = 32;
64     s_rc.size.width = 108;
65     _okayButton = [[NSButton alloc] initWithFrame:s_rc];
66     [_okayButton setButtonType:NSMomentaryLightButton];
67     [_okayButton setTitle:@"OK"];
68     [_okayButton setBezelStyle:NSRoundedBezelStyle];
69     [_okayButton setBordered:YES];
70     [_okayButton setTarget:self];
71     [_okayButton setAction:@selector(buttonAction:)];
72     [_okayButton setKeyEquivalent:@"\r"] ; // enter key
73     [ourContentView addSubview:_okayButton];
74     
75     s_rc.origin.x = 94;
76     s_rc.origin.y = 170;
77     s_rc.size.height = 14;
78     s_rc.size.width = 129;
79     _userNameLabel = [[NSTextField alloc] initWithFrame:s_rc];
80     [_userNameLabel setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
81     [_userNameLabel setStringValue:@"User Name"];
82     [_userNameLabel setBezeled:NO];
83     [_userNameLabel setEditable:NO];
84     [_userNameLabel setSelectable:NO];
85     [_userNameLabel setDrawsBackground:NO];
86     [ourContentView addSubview:_userNameLabel];
87
88     s_rc.origin.x = 97;
89     s_rc.origin.y = 148;
90     s_rc.size.height = 22;
91     s_rc.size.width = 310;
92     _userNameField = [[NSTextField alloc] initWithFrame:s_rc];
93     [_userNameField setBezeled:YES];
94     [_userNameField setEditable:YES];
95     [_userNameField setImportsGraphics:NO];
96     [ourContentView addSubview:_userNameField];
97
98     s_rc.origin.x = 94;
99     s_rc.origin.y = 116;
100     s_rc.size.height = 14;
101     s_rc.size.width = 129;
102     _passwordLabel = [[NSTextField alloc] initWithFrame:s_rc];
103     [_passwordLabel setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
104     [_passwordLabel setStringValue:@"Password"];
105     [_passwordLabel setBezeled:NO];
106     [_passwordLabel setEditable:NO];
107     [_passwordLabel setSelectable:NO];
108     [_passwordLabel setDrawsBackground:NO];
109     [ourContentView addSubview:_passwordLabel];
110
111     s_rc.origin.x = 97;
112     s_rc.origin.y = 94;
113     s_rc.size.height = 22;
114     s_rc.size.width = 310;
115     _passwordField = [[NSSecureTextField alloc] initWithFrame:s_rc];
116     [_passwordField setBezeled:YES];
117     [_passwordField setEditable:YES];
118     [_passwordField setImportsGraphics:NO];
119     [ourContentView addSubview:_passwordField];
120     
121     s_rc.origin.x = 94;
122     s_rc.origin.y = 238;
123     s_rc.size.height = 17;
124     s_rc.size.width = 316;
125     _titleField = [[NSTextField alloc] initWithFrame:s_rc];
126     [_titleField setFont:[NSFont boldSystemFontOfSize:0]];
127     [_titleField setBezeled:NO];
128     [_titleField setEditable:NO];
129     [_titleField setSelectable:YES];
130     [_titleField setDrawsBackground:NO];
131     [ourContentView addSubview:_titleField];
132
133     s_rc.origin.x = 94;
134     s_rc.origin.y = 183;
135     s_rc.size.height = 44;
136     s_rc.size.width = 394;
137     _informativeTextField = [[NSTextField alloc] initWithFrame:s_rc];
138     [_informativeTextField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
139     [_informativeTextField setBezeled:NO];
140     [_informativeTextField setEditable:NO];
141     [_informativeTextField setSelectable:YES];
142     [_informativeTextField setDrawsBackground:NO];
143     [ourContentView addSubview:_informativeTextField];
144
145     s_rc.origin.x = 20;
146     s_rc.origin.y = 188;
147     s_rc.size.height = s_rc.size.width = 64;
148     _iconView = [[NSImageView alloc] initWithFrame:s_rc];
149     [_iconView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
150     [_iconView setEditable:NO];
151     [_iconView setAllowsCutCopyPaste:NO];
152     [ourContentView addSubview:_iconView];
153 }
154
155 - (IBAction)buttonAction:(id)sender
156 {
157     if (sender == _okayButton)
158         [NSApp stopModalWithCode: 1];
159     else
160         [NSApp stopModalWithCode: 0];
161 }
162
163 - (void)setDialogTitle:(NSString *)title
164 {
165     [_titleField setStringValue:title];
166     [self setTitle:title];
167 }
168 - (void)setDialogMessage:(NSString *)message
169 {
170     [_informativeTextField setStringValue:message];
171 }
172
173 - (NSString *)userName
174 {
175     return [_userNameField stringValue];
176 }
177
178 - (NSString *)password
179 {
180     return [_passwordField stringValue];
181 }
182
183 @end