1 /*****************************************************************************
2 * VLCLoginPanel.m: A Generic Login Panel created for VLC
3 *****************************************************************************
4 * Copyright (C) 2009-2010 the VideoLAN team
7 * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
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.
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.
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 *****************************************************************************/
24 #import "VLCLoginPanel.h"
27 @implementation VLCLoginPanel
32 windowRect.size.height = 278;
33 windowRect.size.width = 505;
34 windowRect.origin.x = windowRect.origin.y = 0;
36 return [super initWithContentRect:windowRect
37 styleMask:NSTitledWindowMask
38 backing:NSBackingStoreBuffered
42 - (void)createContentView
44 NSRect s_rc = [self frame];
45 id ourContentView = [self contentView];
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];
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];
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];
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];
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];
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];
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];
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];
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];
155 - (IBAction)buttonAction:(id)sender
157 if (sender == _okayButton)
158 [NSApp stopModalWithCode: 1];
160 [NSApp stopModalWithCode: 0];
163 - (void)setDialogTitle:(NSString *)title
165 [_titleField setStringValue:title];
166 [self setTitle:title];
168 - (void)setDialogMessage:(NSString *)message
170 [_informativeTextField setStringValue:message];
173 - (NSString *)userName
175 return [_userNameField stringValue];
178 - (NSString *)password
180 return [_passwordField stringValue];