1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/cocoaui/cocoa_path.m Mon Feb 09 00:13:46 2009 +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.24 +#include "dreamcast.h"
1.26 +@interface LxdreamPrefsPathPane: LxdreamPrefsPane
1.29 ++ (LxdreamPrefsPathPane *)new;
1.32 +@implementation LxdreamPrefsPathPane
1.33 ++ (LxdreamPrefsPathPane *)new
1.35 + return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)];
1.37 +- (id)initWithFrame: (NSRect)frameRect
1.39 + if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) {
1.43 + int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
1.45 + for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
1.46 + const struct lxdream_config_entry *entry = lxdream_get_config_entry(i);
1.47 + if( entry->label != NULL ) {
1.48 + NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2),
1.49 + 150, LABEL_HEIGHT );
1.50 + NSTextField *label = cocoa_gui_add_label(self, NS_(entry->label), frame);
1.51 + [label setAlignment: NSRightTextAlignment];
1.53 + frame = NSMakeRect( 150 + (TEXT_GAP*2),
1.54 + height -((TEXT_HEIGHT+TEXT_GAP)*i),
1.55 + 360, TEXT_HEIGHT );
1.56 + NSTextField *field = [[NSTextField alloc] initWithFrame: frame];
1.57 + [field setTag: i];
1.58 + [field setStringValue: [NSString stringWithCString: entry->value]];
1.59 + [field setDelegate: self];
1.60 + [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)];
1.61 + [self addSubview: label];
1.62 + [self addSubview: field];
1.68 +- (void)controlTextDidEndEditing:(NSNotification *)notify
1.70 + int tag = [[notify object] tag];
1.71 + const char *str = [[[notify object] stringValue] UTF8String];
1.72 + const char *oldval = lxdream_get_config_value(tag);
1.73 + if( str[0] == '\0' )
1.75 + if( oldval == NULL ? str != NULL : (str == NULL || strcmp(oldval,str) != 0 ) ) {
1.76 + lxdream_set_global_config_value(tag, str);
1.77 + lxdream_save_config();
1.78 + dreamcast_config_changed();
1.84 +NSView *cocoa_gui_create_prefs_path_pane()
1.86 + return [LxdreamPrefsPathPane new];