filename | src/cocoaui/cocoa_path.c |
changeset | 765:4cd066048203 |
next | 770:429ff505c450 |
author | nkeynes |
date | Mon Jul 28 00:27:32 2008 +0000 (15 years ago) |
permissions | -rw-r--r-- |
last change | Add -headerpad_max_install_names linker flag for OS/X builds - ensures bundle build doesn't run out of space for name changes |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * Construct and manage the paths configuration pane
5 *
6 * Copyright (c) 2008 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #include "cocoaui.h"
20 #include "config.h"
24 @implementation LxdreamPrefsPathPane
25 + (LxdreamPrefsPathPane *)new
26 {
27 return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)];
28 }
29 - (id)initWithFrame: (NSRect)frameRect
30 {
31 if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) {
32 return nil;
33 } else {
34 int i;
35 int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
37 for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
38 const struct lxdream_config_entry *entry = lxdream_get_config_entry(i);
39 if( entry->label != NULL ) {
40 NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2),
41 150, LABEL_HEIGHT );
42 NSTextField *label = [self addLabel: NS_(entry->label) withFrame: frame];
43 [label setAlignment: NSRightTextAlignment];
45 frame = NSMakeRect( 150 + (TEXT_GAP*2),
46 height -((TEXT_HEIGHT+TEXT_GAP)*i),
47 360, TEXT_HEIGHT );
48 NSTextField *field = [[NSTextField alloc] initWithFrame: frame];
49 [field setTag: i];
50 [field setStringValue: [NSString stringWithCString: entry->value]];
51 [field setDelegate: self];
52 [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)];
53 [self addSubview: label];
54 [self addSubview: field];
55 }
56 }
57 }
58 return self;
59 }
60 - (void)controlTextDidEndEditing:(NSNotification *)notify
61 {
62 int tag = [[notify object] tag];
63 const char *str = [[[notify object] stringValue] UTF8String];
64 const char *oldval = lxdream_get_config_value(tag);
65 if( str[0] == '\0' )
66 str = NULL;
67 if( oldval == NULL ? str != NULL : (str == NULL || strcmp(oldval,str) != 0 ) ) {
68 lxdream_set_global_config_value(tag, str);
69 lxdream_save_config();
70 }
71 }
72 @end
.