nkeynes@765: /** nkeynes@765: * $Id$ nkeynes@765: * nkeynes@765: * Construct and manage the paths configuration pane nkeynes@765: * nkeynes@765: * Copyright (c) 2008 Nathan Keynes. nkeynes@765: * nkeynes@765: * This program is free software; you can redistribute it and/or modify nkeynes@765: * it under the terms of the GNU General Public License as published by nkeynes@765: * the Free Software Foundation; either version 2 of the License, or nkeynes@765: * (at your option) any later version. nkeynes@765: * nkeynes@765: * This program is distributed in the hope that it will be useful, nkeynes@765: * but WITHOUT ANY WARRANTY; without even the implied warranty of nkeynes@765: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the nkeynes@765: * GNU General Public License for more details. nkeynes@765: */ nkeynes@765: nkeynes@765: #include "cocoaui.h" nkeynes@765: #include "config.h" nkeynes@765: nkeynes@770: @interface LxdreamPrefsPathPane: LxdreamPrefsPane nkeynes@770: { nkeynes@770: } nkeynes@770: + (LxdreamPrefsPathPane *)new; nkeynes@770: @end nkeynes@765: nkeynes@765: @implementation LxdreamPrefsPathPane nkeynes@765: + (LxdreamPrefsPathPane *)new nkeynes@765: { nkeynes@765: return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)]; nkeynes@765: } nkeynes@765: - (id)initWithFrame: (NSRect)frameRect nkeynes@765: { nkeynes@765: if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) { nkeynes@765: return nil; nkeynes@765: } else { nkeynes@765: int i; nkeynes@765: int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP; nkeynes@765: nkeynes@765: for( i=0; i<=CONFIG_KEY_MAX; i++ ) { nkeynes@765: const struct lxdream_config_entry *entry = lxdream_get_config_entry(i); nkeynes@765: if( entry->label != NULL ) { nkeynes@765: NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2), nkeynes@765: 150, LABEL_HEIGHT ); nkeynes@770: NSTextField *label = cocoa_gui_add_label(self, NS_(entry->label), frame); nkeynes@765: [label setAlignment: NSRightTextAlignment]; nkeynes@765: nkeynes@765: frame = NSMakeRect( 150 + (TEXT_GAP*2), nkeynes@765: height -((TEXT_HEIGHT+TEXT_GAP)*i), nkeynes@765: 360, TEXT_HEIGHT ); nkeynes@765: NSTextField *field = [[NSTextField alloc] initWithFrame: frame]; nkeynes@765: [field setTag: i]; nkeynes@765: [field setStringValue: [NSString stringWithCString: entry->value]]; nkeynes@765: [field setDelegate: self]; nkeynes@765: [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)]; nkeynes@765: [self addSubview: label]; nkeynes@765: [self addSubview: field]; nkeynes@765: } nkeynes@765: } nkeynes@765: } nkeynes@765: return self; nkeynes@765: } nkeynes@765: - (void)controlTextDidEndEditing:(NSNotification *)notify nkeynes@765: { nkeynes@765: int tag = [[notify object] tag]; nkeynes@765: const char *str = [[[notify object] stringValue] UTF8String]; nkeynes@765: const char *oldval = lxdream_get_config_value(tag); nkeynes@765: if( str[0] == '\0' ) nkeynes@765: str = NULL; nkeynes@765: if( oldval == NULL ? str != NULL : (str == NULL || strcmp(oldval,str) != 0 ) ) { nkeynes@765: lxdream_set_global_config_value(tag, str); nkeynes@765: lxdream_save_config(); nkeynes@765: } nkeynes@765: } nkeynes@765: @end nkeynes@770: nkeynes@770: nkeynes@770: NSView *cocoa_gui_create_prefs_path_pane() nkeynes@770: { nkeynes@770: return [LxdreamPrefsPathPane new]; nkeynes@770: }