1.1 --- a/src/cocoaui/cocoa_path.m Wed Jun 24 06:06:40 2009 +0000
1.2 +++ b/src/cocoaui/cocoa_path.m Thu Jun 25 09:06:44 2009 +0000
1.5 @interface LxdreamPrefsPathPane: LxdreamPrefsPane
1.7 + NSTextField *fields[CONFIG_KEY_MAX];
1.9 + (LxdreamPrefsPathPane *)new;
1.14 int height = [self contentHeight] - TEXT_HEIGHT - TEXT_GAP;
1.17 for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
1.18 const struct lxdream_config_entry *entry = lxdream_get_global_config_entry(i);
1.19 if( entry->label != NULL ) {
1.20 - NSRect frame = NSMakeRect( TEXT_GAP, height -((TEXT_HEIGHT+TEXT_GAP)*i - 2),
1.21 - 150, LABEL_HEIGHT );
1.22 + NSRect frame = NSMakeRect( TEXT_GAP, y - 2, 150, LABEL_HEIGHT );
1.23 NSTextField *label = cocoa_gui_add_label(self, NS_(entry->label), frame);
1.24 [label setAlignment: NSRightTextAlignment];
1.26 - frame = NSMakeRect( 150 + (TEXT_GAP*2),
1.27 - height -((TEXT_HEIGHT+TEXT_GAP)*i),
1.28 - 360, TEXT_HEIGHT );
1.29 + frame = NSMakeRect( 150 + (TEXT_GAP*2), y, 360, TEXT_HEIGHT );
1.30 NSTextField *field = [[NSTextField alloc] initWithFrame: frame];
1.32 [field setStringValue: [NSString stringWithCString: entry->value]];
1.33 [field setDelegate: self];
1.34 [field setAutoresizingMask: (NSViewMinYMargin|NSViewWidthSizable)];
1.36 + frame = NSMakeRect( 510 + (TEXT_GAP*3), y, TEXT_HEIGHT, TEXT_HEIGHT );
1.37 + NSButton *button = [[NSButton alloc] initWithFrame: frame];
1.38 + [button setTag: i];
1.39 + [button setTitle: @""];
1.40 + [button setButtonType: NSMomentaryPushInButton];
1.41 + [button setBezelStyle: NSRoundedDisclosureBezelStyle];
1.42 + [button setAutoresizingMask: (NSViewMinYMargin|NSViewMinXMargin)];
1.43 + [button setTarget: self];
1.44 + if( entry->type == CONFIG_TYPE_FILE ) {
1.45 + [button setAction: @selector(openFileDialog:)];
1.47 + [button setAction: @selector(openDirDialog:)];
1.50 [self addSubview: label];
1.51 [self addSubview: field];
1.52 + [self addSubview: button];
1.53 + fields[i] = field;
1.54 + y -= (TEXT_HEIGHT + TEXT_GAP);
1.59 dreamcast_config_changed();
1.62 +- (void)openFileDialog: (id)sender
1.64 + int tag = [sender tag];
1.65 + NSString *text = [fields[tag] stringValue];
1.66 + NSOpenPanel *panel = [NSOpenPanel openPanel];
1.67 + int result = [panel runModalForDirectory: nil file: nil types: nil];
1.68 + if( result == NSOKButton && [[panel filenames] count] > 0 ) {
1.69 + NSString *filename = [[panel filenames] objectAtIndex: 0];
1.70 + gchar *str = get_escaped_path( [filename UTF8String] );
1.71 + [fields[tag] setStringValue: [NSString stringWithUTF8String: str]];
1.72 + lxdream_set_global_config_value(tag,str);
1.73 + lxdream_save_config();
1.74 + dreamcast_config_changed();
1.77 +- (void)openDirDialog: (id)sender
1.79 + int tag = [sender tag];
1.80 + NSString *text = [fields[tag] stringValue];
1.81 + NSOpenPanel *panel = [NSOpenPanel openPanel];
1.82 + [panel setCanChooseDirectories: YES];
1.83 + [panel setCanCreateDirectories: YES];
1.84 + int result = [panel runModalForDirectory: nil file: nil types: nil];
1.85 + if( result == NSOKButton && [[panel filenames] count] > 0 ) {
1.86 + NSString *filename = [[panel filenames] objectAtIndex: 0];
1.87 + gchar *str = get_escaped_path( [filename UTF8String] );
1.88 + [fields[tag] setStringValue: [NSString stringWithUTF8String: str]];
1.89 + lxdream_set_global_config_value(tag,str);
1.90 + lxdream_save_config();
1.91 + dreamcast_config_changed();