1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/cocoaui/cocoa_gd.c Mon Jun 30 04:58:26 2008 +0000
1.7 + * Management of the GDRom menu under cocoa
1.9 + * Copyright (c) 2005 Nathan Keynes.
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.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.23 +#include <AppKit/AppKit.h>
1.25 +#include <stdlib.h>
1.26 +#include <string.h>
1.27 +#include <sys/time.h>
1.28 +#include "lxdream.h"
1.29 +#include "dreamcast.h"
1.31 +#include "gdlist.h"
1.32 +#include "cocoaui/cocoaui.h"
1.34 +void cocoa_gdrom_menu_build( NSMenu *menu )
1.36 + int i,len = gdrom_list_size();
1.37 + for( i=0; i<len; i++ ) {
1.38 + const gchar *entry = gdrom_list_get_display_name(i);
1.39 + if( entry[0] == '\0' ) {
1.40 + [menu addItem: [NSMenuItem separatorItem]];
1.42 + [[menu addItemWithTitle: [NSString stringWithCString: entry]
1.43 + action: @selector(gdrom_list_action:) keyEquivalent: @""]
1.47 + [menu addItem: [NSMenuItem separatorItem]];
1.48 + [menu addItemWithTitle: NS_("Open image file...") action: @selector(mount_action:)
1.49 + keyEquivalent: @"i"];
1.52 +void cocoa_gdrom_menu_rebuild( NSMenu *menu )
1.54 + while( [menu numberOfItems] > 0 ) {
1.55 + [ menu removeItemAtIndex: 0 ];
1.58 + cocoa_gdrom_menu_build( menu );
1.61 +void cocoa_gdrom_menu_update( gboolean list_changed, int selection, void *user_data )
1.63 + // Create an auto-release pool - we may be called outside of the GUI main loop
1.64 + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1.65 + NSMenu *menu = (NSMenu *)user_data;
1.68 + if( list_changed ) {
1.69 + cocoa_gdrom_menu_rebuild(menu);
1.72 + for( i=0; i< [menu numberOfItems]; i++ ) {
1.73 + if( i == selection ) {
1.74 + [[menu itemAtIndex: i] setState: NSOnState];
1.76 + [[menu itemAtIndex: i] setState: NSOffState];
1.82 +NSMenu *cocoa_gdrom_menu_new()
1.84 + NSMenu *menu = [[NSMenu alloc] initWithTitle: @"GD-Rom Settings"];
1.85 + cocoa_gdrom_menu_build(menu);
1.87 + register_gdrom_list_change_hook(cocoa_gdrom_menu_update, menu);
1.88 + cocoa_gdrom_menu_update( FALSE, gdrom_list_get_selection(), menu );