Search
lxdream.org :: lxdream/src/cocoaui/cocoa_path.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/cocoaui/cocoa_path.c
changeset 765:4cd066048203
next770:429ff505c450
author nkeynes
date Wed Jul 23 11:11:30 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Cocoa preferences panel work-in-progress
file annotate diff log raw
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.3 @@ -0,0 +1,72 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * Construct and manage the paths configuration pane
1.8 + *
1.9 + * Copyright (c) 2008 Nathan Keynes.
1.10 + *
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.15 + *
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.20 + */
1.21 +
1.22 +#include "cocoaui.h"
1.23 +#include "config.h"
1.24 +
1.25 +
1.26 +
1.27 +@implementation LxdreamPrefsPathPane
1.28 ++ (LxdreamPrefsPathPane *)new
1.29 +{
1.30 + return [[LxdreamPrefsPathPane alloc] initWithFrame: NSMakeRect(0,0,600,400)];
1.31 +}
1.32 +- (id)initWithFrame: (NSRect)frameRect
1.33 +{
1.34 + if( [super initWithFrame: frameRect title: NS_("Paths")] == nil ) {
1.35 + return nil;
1.36 + } else {
1.37 + int i;
1.38 + int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
1.39 +
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.47 +
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.58 + }
1.59 + }
1.60 + }
1.61 + return self;
1.62 +}
1.63 +- (void)controlTextDidEndEditing:(NSNotification *)notify
1.64 +{
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.69 + str = NULL;
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();
1.73 + }
1.74 +}
1.75 +@end
.