]> git.sesse.net Git - vlc/blob - modules/gui/macosx_dialog_provider/VLCLoginPanel.m
osx dialog provider: minor cleanup
[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     [ourContentView addSubview:_cancelButton];
59
60     s_rc.origin.x = 383;
61     s_rc.origin.y = 44;
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];
72     
73     s_rc.origin.x = 94;
74     s_rc.origin.y = 170;
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];
85
86     s_rc.origin.x = 97;
87     s_rc.origin.y = 148;
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];
95
96     s_rc.origin.x = 94;
97     s_rc.origin.y = 116;
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];
108
109     s_rc.origin.x = 97;
110     s_rc.origin.y = 94;
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];
118     
119     s_rc.origin.x = 94;
120     s_rc.origin.y = 238;
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];
130
131     s_rc.origin.x = 94;
132     s_rc.origin.y = 183;
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];
142
143     s_rc.origin.x = 20;
144     s_rc.origin.y = 188;
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];
151 }
152
153 - (IBAction)buttonAction:(id)sender
154 {
155     if (sender == _okayButton)
156         [NSApp stopModalWithCode: 1];
157     else
158         [NSApp stopModalWithCode: 0];
159 }
160
161 - (void)setDialogTitle:(NSString *)title
162 {
163     [_titleField setStringValue:title];
164     [self setTitle:title];
165 }
166 - (void)setDialogMessage:(NSString *)message
167 {
168     [_informativeTextField setStringValue:message];
169 }
170
171 - (NSString *)userName
172 {
173     return [_userNameField stringValue];
174 }
175
176 - (NSString *)password
177 {
178     return [_passwordField stringValue];
179 }
180
181 @end