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 [ourContentView addSubview:_cancelButton];
62 s_rc.size.height = 32;
63 s_rc.size.width = 108;
64 _okayButton = [[NSButton alloc] initWithFrame:s_rc];
65 [_okayButton setButtonType:NSMomentaryLightButton];
66 [_okayButton setTitle:@"OK"];
67 [_okayButton setBezelStyle:NSRoundedBezelStyle];
68 [_okayButton setBordered:YES];
69 [_okayButton setTarget:self];
70 [_okayButton setAction:@selector(buttonAction:)];
71 [ourContentView addSubview:_okayButton];
75 s_rc.size.height = 14;
76 s_rc.size.width = 129;
77 _userNameLabel = [[NSTextField alloc] initWithFrame:s_rc];
78 [_userNameLabel setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
79 [_userNameLabel setStringValue:@"User Name"];
80 [_userNameLabel setBezeled:NO];
81 [_userNameLabel setEditable:NO];
82 [_userNameLabel setSelectable:NO];
83 [_userNameLabel setDrawsBackground:NO];
84 [ourContentView addSubview:_userNameLabel];
88 s_rc.size.height = 22;
89 s_rc.size.width = 310;
90 _userNameField = [[NSTextField alloc] initWithFrame:s_rc];
91 [_userNameField setBezeled:YES];
92 [_userNameField setEditable:YES];
93 [_userNameField setImportsGraphics:NO];
94 [ourContentView addSubview:_userNameField];
98 s_rc.size.height = 14;
99 s_rc.size.width = 129;
100 _passwordLabel = [[NSTextField alloc] initWithFrame:s_rc];
101 [_passwordLabel setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
102 [_passwordLabel setStringValue:@"Password"];
103 [_passwordLabel setBezeled:NO];
104 [_passwordLabel setEditable:NO];
105 [_passwordLabel setSelectable:NO];
106 [_passwordLabel setDrawsBackground:NO];
107 [ourContentView addSubview:_passwordLabel];
111 s_rc.size.height = 22;
112 s_rc.size.width = 310;
113 _passwordField = [[NSSecureTextField alloc] initWithFrame:s_rc];
114 [_passwordField setBezeled:YES];
115 [_passwordField setEditable:YES];
116 [_passwordField setImportsGraphics:NO];
117 [ourContentView addSubview:_passwordField];
121 s_rc.size.height = 17;
122 s_rc.size.width = 316;
123 _titleField = [[NSTextField alloc] initWithFrame:s_rc];
124 [_titleField setFont:[NSFont boldSystemFontOfSize:0]];
125 [_titleField setBezeled:NO];
126 [_titleField setEditable:NO];
127 [_titleField setSelectable:YES];
128 [_titleField setDrawsBackground:NO];
129 [ourContentView addSubview:_titleField];
133 s_rc.size.height = 44;
134 s_rc.size.width = 394;
135 _informativeTextField = [[NSTextField alloc] initWithFrame:s_rc];
136 [_informativeTextField setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
137 [_informativeTextField setBezeled:NO];
138 [_informativeTextField setEditable:NO];
139 [_informativeTextField setSelectable:YES];
140 [_informativeTextField setDrawsBackground:NO];
141 [ourContentView addSubview:_informativeTextField];
145 s_rc.size.height = s_rc.size.width = 64;
146 _iconView = [[NSImageView alloc] initWithFrame:s_rc];
147 [_iconView setImage:[NSImage imageNamed:@"NSApplicationIcon"]];
148 [_iconView setEditable:NO];
149 [_iconView setAllowsCutCopyPaste:NO];
150 [ourContentView addSubview:_iconView];
153 - (IBAction)buttonAction:(id)sender
155 if (sender == _okayButton)
156 [NSApp stopModalWithCode: 1];
158 [NSApp stopModalWithCode: 0];
161 - (void)setDialogTitle:(NSString *)title
163 [_titleField setStringValue:title];
164 [self setTitle:title];
166 - (void)setDialogMessage:(NSString *)message
168 [_informativeTextField setStringValue:message];
171 - (NSString *)userName
173 return [_userNameField stringValue];
176 - (NSString *)password
178 return [_passwordField stringValue];