1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/cocoaui/cocoa_path.c Wed Jul 23 11:11:30 2008 +0000
1.7 + * Construct and manage the paths configuration pane
1.9 + * Copyright (c) 2008 Nathan Keynes.
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.22 +#include "cocoaui.h"
1.23 +#include "config.h"
1.27 +@implementation LxdreamPrefsPathPane
1.28 ++ (LxdreamPrefsPathPane *)new
1.30 + return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)];
1.32 +- (id)initWithFrame: (NSRect)frameRect
1.34 + if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) {
1.38 + int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
1.40 + for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
1.41 + const struct lxdream_config_entry *entry = lxdream_get_config_entry(i);
1.42 + if( entry->label != NULL ) {
1.43 + NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2),
1.44 + 150, LABEL_HEIGHT );
1.45 + NSTextField *label = [self addLabel: NS_(entry->label) withFrame: frame];
1.46 + [label setAlignment: NSRightTextAlignment];
1.48 + frame = NSMakeRect( 150 + (TEXT_GAP*2),
1.49 + height -((TEXT_HEIGHT+TEXT_GAP)*i),
1.50 + 360, TEXT_HEIGHT );
1.51 + NSTextField *field = [[NSTextField alloc] initWithFrame: frame];
1.52 + [field setTag: i];
1.53 + [field setStringValue: [NSString stringWithCString: entry->value]];
1.54 + [field setDelegate: self];
1.55 + [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)];
1.56 + [self addSubview: label];
1.57 + [self addSubview: field];
1.63 +- (void)controlTextDidEndEditing:(NSNotification *)notify
1.65 + int tag = [[notify object] tag];
1.66 + const char *str = [[[notify object] stringValue] UTF8String];
1.67 + const char *oldval = lxdream_get_config_value(tag);
1.68 + if( str[0] == '\0' )
1.70 + if( oldval == NULL ? str != NULL : (str == NULL || strcmp(oldval,str) != 0 ) ) {
1.71 + lxdream_set_global_config_value(tag, str);
1.72 + lxdream_save_config();