4 * Construct and manage the paths configuration pane
6 * Copyright (c) 2008 Nathan Keynes.
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.
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.
21 #include "dreamcast.h"
23 @interface LxdreamPrefsPathPane: LxdreamPrefsPane
26 + (LxdreamPrefsPathPane *)new;
29 @implementation LxdreamPrefsPathPane
30 + (LxdreamPrefsPathPane *)new
32 return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)];
34 - (id)initWithFrame: (NSRect)frameRect
36 if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) {
40 int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
42 for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
43 const struct lxdream_config_entry *entry = lxdream_get_config_entry(i);
44 if( entry->label != NULL ) {
45 NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2),
47 NSTextField *label = cocoa_gui_add_label(self, NS_(entry->label), frame);
48 [label setAlignment: NSRightTextAlignment];
50 frame = NSMakeRect( 150 + (TEXT_GAP*2),
51 height -((TEXT_HEIGHT+TEXT_GAP)*i),
53 NSTextField *field = [[NSTextField alloc] initWithFrame: frame];
55 [field setStringValue: [NSString stringWithCString: entry->value]];
56 [field setDelegate: self];
57 [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)];
58 [self addSubview: label];
59 [self addSubview: field];
65 - (void)controlTextDidEndEditing:(NSNotification *)notify
67 int tag = [[notify object] tag];
68 const char *str = [[[notify object] stringValue] UTF8String];
69 const char *oldval = lxdream_get_config_value(tag);
72 if( oldval == NULL ? str != NULL : (str == NULL || strcmp(oldval,str) != 0 ) ) {
73 lxdream_set_global_config_value(tag, str);
74 lxdream_save_config();
75 dreamcast_config_changed();
81 NSView *cocoa_gui_create_prefs_path_pane()
83 return [LxdreamPrefsPathPane new];
.