Search
lxdream.org :: lxdream/src/cocoaui/cocoa_prefs.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/cocoaui/cocoa_prefs.c
changeset 725:4d4018e8eeb8
next729:4cc913eabd3d
author nkeynes
date Sun Jul 06 03:18:55 2008 +0000 (11 years ago)
permissions -rw-r--r--
last change Add slightly more detailed about dialog
Add (currently empty) preferences dialog (WIP)
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/cocoaui/cocoa_prefs.c Sun Jul 06 03:18:55 2008 +0000
1.3 @@ -0,0 +1,127 @@
1.4 +/**
1.5 + * $Id: cocoa_win.c 723 2008-06-25 00:39:02Z nkeynes $
1.6 + *
1.7 + * Construct and manage the preferences panel under cocoa.
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/cocoaui.h"
1.23 +#include "lxdream.h"
1.24 +#include "config.h"
1.25 +
1.26 +@interface LxdreamPrefsToolbarDelegate : NSObject {
1.27 + NSArray *identifiers;
1.28 + NSArray *defaults;
1.29 + NSDictionary *items;
1.30 +}
1.31 +- (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label
1.32 + tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action;
1.33 +@end
1.34 +
1.35 +@implementation LxdreamPrefsToolbarDelegate
1.36 +- (id) init
1.37 +{
1.38 + NSToolbarItem *paths = [self createToolbarItem: @"Paths" label: @"Paths"
1.39 + tooltip: @"Configure system paths" icon: @"tb-paths"
1.40 + action: @selector(paths_action:)];
1.41 + NSToolbarItem *ctrls = [self createToolbarItem: @"Controllers" label: @"Controllers"
1.42 + tooltip: @"Configure controllers" icon: @"tb-ctrls"
1.43 + action: @selector(controllers_action:)];
1.44 + identifiers = [NSArray arrayWithObjects: @"Paths", @"Controllers", nil ];
1.45 + defaults = [NSArray arrayWithObjects: @"Paths", @"Controllers", nil ];
1.46 + NSArray *values = [NSArray arrayWithObjects: paths, ctrls, nil ];
1.47 + items = [NSDictionary dictionaryWithObjects: values forKeys: identifiers];
1.48 + return self;
1.49 +}
1.50 +
1.51 +- (NSToolbarItem *) createToolbarItem: (NSString *)id label: (NSString *) label
1.52 + tooltip: (NSString *)tooltip icon: (NSString *)icon action: (SEL) action
1.53 +{
1.54 + NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier: id];
1.55 + [item setLabel: label];
1.56 + [item setToolTip: tooltip];
1.57 + [item setTarget: self];
1.58 + NSString *iconFile = [[NSBundle mainBundle] pathForResource:icon ofType:@"png"];
1.59 + NSImage *image = [[NSImage alloc] initWithContentsOfFile: iconFile];
1.60 + [item setImage: image];
1.61 + [item setAction: action];
1.62 + return item;
1.63 +}
1.64 +
1.65 +- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar
1.66 +{
1.67 + return identifiers;
1.68 +}
1.69 +
1.70 +- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
1.71 +{
1.72 + return defaults;
1.73 +}
1.74 +
1.75 +- (NSArray *)toolbarSelectableItemIdentifiers: (NSToolbar *)toolbar
1.76 +{
1.77 + return [NSArray arrayWithObjects: @"Paths", @"Controllers", nil];
1.78 +}
1.79 +
1.80 +- (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier
1.81 + willBeInsertedIntoToolbar:(BOOL)flag
1.82 +{
1.83 + return [items objectForKey: itemIdentifier];
1.84 +}
1.85 +- (void)paths_action: (id)sender
1.86 +{
1.87 +}
1.88 +- (void)controllers_action: (id)sender
1.89 +{
1.90 +}
1.91 +@end
1.92 +
1.93 +@implementation LxdreamPrefsPanel
1.94 +- (NSView *)createPathsPane
1.95 +{
1.96 + NSView *pane = [NSView new];
1.97 + int i;
1.98 + for( i=0; i<=CONFIG_KEY_MAX; i++ ) {
1.99 + lxdream_config_entry_t entry = lxdream_get_config_entry(i);
1.100 + if( entry->label != NULL ) {
1.101 + }
1.102 + }
1.103 + return pane;
1.104 +}
1.105 +- (id)initWithContentRect:(NSRect)contentRect
1.106 +{
1.107 + if( [super initWithContentRect: contentRect
1.108 + styleMask: ( NSTitledWindowMask | NSClosableWindowMask |
1.109 + NSMiniaturizableWindowMask | NSResizableWindowMask |
1.110 + NSUnifiedTitleAndToolbarWindowMask )
1.111 + backing: NSBackingStoreBuffered defer: NO ] == nil ) {
1.112 + return nil;
1.113 + } else {
1.114 + [self setTitle: NS_("Preferences")];
1.115 + [self setDelegate: self];
1.116 + NSToolbar *toolbar = [[NSToolbar alloc] initWithIdentifier: @"LxdreamPrefsToolbar"];
1.117 + [toolbar setDelegate: [[LxdreamPrefsToolbarDelegate alloc] init]];
1.118 + [toolbar setDisplayMode: NSToolbarDisplayModeIconOnly];
1.119 + [toolbar setSizeMode: NSToolbarSizeModeSmall];
1.120 + [toolbar setSelectedItemIdentifier: @"Paths"];
1.121 + [self setToolbar: toolbar];
1.122 + [self setContentView: [self createPathsPane]];
1.123 + return self;
1.124 + }
1.125 +}
1.126 +- (void)windowWillClose: (NSNotification *)notice
1.127 +{
1.128 + [NSApp stopModal];
1.129 +}
1.130 +@end
.