Search
lxdream.org :: lxdream :: r691:ad3356543392
lxdream 0.9.1
released Jun 29
Download Now
changeset691:ad3356543392
parent690:1e8fd13a67ef
child692:44b8ded54a9c
authornkeynes
dateThu Jun 19 04:40:37 2008 +0000 (11 years ago)
Refactor the gd-rom list management out of the GUI (devices, recent files, etc).
Add gd-rom list to the cocoa UI.
src/Makefile.am
src/Makefile.in
src/cocoaui/cocoa_gd.c
src/cocoaui/cocoaui.c
src/cocoaui/cocoaui.h
src/gdlist.c
src/gdlist.h
src/gdrom/gdrom.c
src/gtkui/gdrom_menu.c
src/gtkui/gtkui.c
src/main.c
src/mem.c
1.1 --- a/src/Makefile.am Mon Jun 16 11:00:40 2008 +0000
1.2 +++ b/src/Makefile.am Thu Jun 19 04:40:37 2008 +0000
1.3 @@ -40,7 +40,7 @@
1.4 pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c pvr2/glutil.h pvr2/glrender.c \
1.5 maple/maple.c maple/maple.h \
1.6 maple/controller.c maple/controller.h maple/kbd.c maple/mouse.c \
1.7 - loader.c bootstrap.c util.c \
1.8 + loader.c bootstrap.c util.c gdlist.c gdlist.h \
1.9 display.c display.h dckeysyms.h \
1.10 drivers/audio_null.c drivers/video_null.c \
1.11 drivers/video_gl.c drivers/video_gl.h drivers/gl_fbo.c
1.12 @@ -72,7 +72,7 @@
1.13
1.14 if GUI_COCOA
1.15 lxdream_SOURCES += cocoaui/cocoaui.c cocoaui/cocoaui.h \
1.16 - cocoaui/cocoa_win.c drivers/video_osx.c drivers/mac_keymap.h
1.17 + cocoaui/cocoa_win.c cocoaui/cocoa_gd.c drivers/video_osx.c drivers/mac_keymap.h
1.18 endif
1.19
1.20 if VIDEO_OSMESA
2.1 --- a/src/Makefile.in Mon Jun 16 11:00:40 2008 +0000
2.2 +++ b/src/Makefile.in Thu Jun 19 04:40:37 2008 +0000
2.3 @@ -53,7 +53,7 @@
2.4 @GUI_GTK_TRUE@ drivers/video_gtk.c drivers/video_gtk.h
2.5
2.6 @GUI_COCOA_TRUE@am__append_4 = cocoaui/cocoaui.c cocoaui/cocoaui.h \
2.7 -@GUI_COCOA_TRUE@ cocoaui/cocoa_win.c drivers/video_osx.c drivers/mac_keymap.h
2.8 +@GUI_COCOA_TRUE@ cocoaui/cocoa_win.c cocoaui/cocoa_gd.c drivers/video_osx.c drivers/mac_keymap.h
2.9
2.10 @VIDEO_OSMESA_TRUE@am__append_5 = drivers/video_gdk.c drivers/video_gdk.h
2.11 @VIDEO_GLX_TRUE@am__append_6 = drivers/video_glx.c drivers/video_glx.h
2.12 @@ -103,22 +103,23 @@
2.13 pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c \
2.14 pvr2/glutil.h pvr2/glrender.c maple/maple.c maple/maple.h \
2.15 maple/controller.c maple/controller.h maple/kbd.c \
2.16 - maple/mouse.c loader.c bootstrap.c util.c display.c display.h \
2.17 - dckeysyms.h drivers/audio_null.c drivers/video_null.c \
2.18 - drivers/video_gl.c drivers/video_gl.h drivers/gl_fbo.c \
2.19 - sh4/sh4x86.c sh4/x86op.h sh4/ia32abi.h sh4/ia32mac.h \
2.20 - sh4/ia64abi.h sh4/sh4trans.c sh4/sh4trans.h x86dasm/x86dasm.c \
2.21 - x86dasm/x86dasm.h x86dasm/i386-dis.c x86dasm/dis-init.c \
2.22 - x86dasm/dis-buf.c gtkui/gtkui.c gtkui/gtkui.h gtkui/main_win.c \
2.23 - gtkui/gtkcb.c gtkui/mmio_win.c gtkui/debug_win.c \
2.24 - gtkui/dump_win.c gtkui/ctrl_dlg.c gtkui/path_dlg.c \
2.25 - gtkui/gdrom_menu.c drivers/video_gtk.c drivers/video_gtk.h \
2.26 - cocoaui/cocoaui.c cocoaui/cocoaui.h cocoaui/cocoa_win.c \
2.27 - drivers/video_osx.c drivers/mac_keymap.h drivers/video_gdk.c \
2.28 - drivers/video_gdk.h drivers/video_glx.c drivers/video_glx.h \
2.29 - drivers/video_nsgl.c drivers/video_nsgl.h \
2.30 - drivers/audio_pulse.c drivers/audio_esd.c drivers/audio_alsa.c \
2.31 - drivers/cd_linux.c drivers/cd_none.c drivers/joy_linux.c
2.32 + maple/mouse.c loader.c bootstrap.c util.c gdlist.c gdlist.h \
2.33 + display.c display.h dckeysyms.h drivers/audio_null.c \
2.34 + drivers/video_null.c drivers/video_gl.c drivers/video_gl.h \
2.35 + drivers/gl_fbo.c sh4/sh4x86.c sh4/x86op.h sh4/ia32abi.h \
2.36 + sh4/ia32mac.h sh4/ia64abi.h sh4/sh4trans.c sh4/sh4trans.h \
2.37 + x86dasm/x86dasm.c x86dasm/x86dasm.h x86dasm/i386-dis.c \
2.38 + x86dasm/dis-init.c x86dasm/dis-buf.c gtkui/gtkui.c \
2.39 + gtkui/gtkui.h gtkui/main_win.c gtkui/gtkcb.c gtkui/mmio_win.c \
2.40 + gtkui/debug_win.c gtkui/dump_win.c gtkui/ctrl_dlg.c \
2.41 + gtkui/path_dlg.c gtkui/gdrom_menu.c drivers/video_gtk.c \
2.42 + drivers/video_gtk.h cocoaui/cocoaui.c cocoaui/cocoaui.h \
2.43 + cocoaui/cocoa_win.c cocoaui/cocoa_gd.c drivers/video_osx.c \
2.44 + drivers/mac_keymap.h drivers/video_gdk.c drivers/video_gdk.h \
2.45 + drivers/video_glx.c drivers/video_glx.h drivers/video_nsgl.c \
2.46 + drivers/video_nsgl.h drivers/audio_pulse.c drivers/audio_esd.c \
2.47 + drivers/audio_alsa.c drivers/cd_linux.c drivers/cd_none.c \
2.48 + drivers/joy_linux.c
2.49 @BUILD_SH4X86_TRUE@am__objects_1 = sh4x86.$(OBJEXT) sh4trans.$(OBJEXT) \
2.50 @BUILD_SH4X86_TRUE@ x86dasm.$(OBJEXT) i386-dis.$(OBJEXT) \
2.51 @BUILD_SH4X86_TRUE@ dis-init.$(OBJEXT) dis-buf.$(OBJEXT)
2.52 @@ -128,7 +129,7 @@
2.53 @GUI_GTK_TRUE@ ctrl_dlg.$(OBJEXT) path_dlg.$(OBJEXT) \
2.54 @GUI_GTK_TRUE@ gdrom_menu.$(OBJEXT) video_gtk.$(OBJEXT)
2.55 @GUI_COCOA_TRUE@am__objects_3 = cocoaui.$(OBJEXT) cocoa_win.$(OBJEXT) \
2.56 -@GUI_COCOA_TRUE@ video_osx.$(OBJEXT)
2.57 +@GUI_COCOA_TRUE@ cocoa_gd.$(OBJEXT) video_osx.$(OBJEXT)
2.58 @VIDEO_OSMESA_TRUE@am__objects_4 = video_gdk.$(OBJEXT)
2.59 @VIDEO_GLX_TRUE@am__objects_5 = video_glx.$(OBJEXT)
2.60 @VIDEO_NSGL_TRUE@am__objects_6 = video_nsgl.$(OBJEXT)
2.61 @@ -154,13 +155,13 @@
2.62 gl_sl.$(OBJEXT) gl_slsrc.$(OBJEXT) glutil.$(OBJEXT) \
2.63 glrender.$(OBJEXT) maple.$(OBJEXT) controller.$(OBJEXT) \
2.64 kbd.$(OBJEXT) mouse.$(OBJEXT) loader.$(OBJEXT) \
2.65 - bootstrap.$(OBJEXT) util.$(OBJEXT) display.$(OBJEXT) \
2.66 - audio_null.$(OBJEXT) video_null.$(OBJEXT) video_gl.$(OBJEXT) \
2.67 - gl_fbo.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
2.68 - $(am__objects_3) $(am__objects_4) $(am__objects_5) \
2.69 - $(am__objects_6) $(am__objects_7) $(am__objects_8) \
2.70 - $(am__objects_9) $(am__objects_10) $(am__objects_11) \
2.71 - $(am__objects_12)
2.72 + bootstrap.$(OBJEXT) util.$(OBJEXT) gdlist.$(OBJEXT) \
2.73 + display.$(OBJEXT) audio_null.$(OBJEXT) video_null.$(OBJEXT) \
2.74 + video_gl.$(OBJEXT) gl_fbo.$(OBJEXT) $(am__objects_1) \
2.75 + $(am__objects_2) $(am__objects_3) $(am__objects_4) \
2.76 + $(am__objects_5) $(am__objects_6) $(am__objects_7) \
2.77 + $(am__objects_8) $(am__objects_9) $(am__objects_10) \
2.78 + $(am__objects_11) $(am__objects_12)
2.79 lxdream_OBJECTS = $(am_lxdream_OBJECTS)
2.80 lxdream_DEPENDENCIES = $(am__DEPENDENCIES_1)
2.81 am__test_testsh4x86_SOURCES_DIST = test/testsh4x86.c x86dasm/x86dasm.c \
2.82 @@ -379,13 +380,14 @@
2.83 pvr2/scene.h pvr2/gl_sl.c pvr2/gl_slsrc.c pvr2/glutil.c \
2.84 pvr2/glutil.h pvr2/glrender.c maple/maple.c maple/maple.h \
2.85 maple/controller.c maple/controller.h maple/kbd.c \
2.86 - maple/mouse.c loader.c bootstrap.c util.c display.c display.h \
2.87 - dckeysyms.h drivers/audio_null.c drivers/video_null.c \
2.88 - drivers/video_gl.c drivers/video_gl.h drivers/gl_fbo.c \
2.89 - $(am__append_1) $(am__append_3) $(am__append_4) \
2.90 - $(am__append_5) $(am__append_6) $(am__append_7) \
2.91 - $(am__append_8) $(am__append_9) $(am__append_10) \
2.92 - $(am__append_11) $(am__append_12) $(am__append_13)
2.93 + maple/mouse.c loader.c bootstrap.c util.c gdlist.c gdlist.h \
2.94 + display.c display.h dckeysyms.h drivers/audio_null.c \
2.95 + drivers/video_null.c drivers/video_gl.c drivers/video_gl.h \
2.96 + drivers/gl_fbo.c $(am__append_1) $(am__append_3) \
2.97 + $(am__append_4) $(am__append_5) $(am__append_6) \
2.98 + $(am__append_7) $(am__append_8) $(am__append_9) \
2.99 + $(am__append_10) $(am__append_11) $(am__append_12) \
2.100 + $(am__append_13)
2.101 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @GLIB_LIBS@ @GTK_LIBS@ @LIBPNG_LIBS@
2.102 @BUILD_SH4X86_TRUE@test_testsh4x86_SOURCES = test/testsh4x86.c x86dasm/x86dasm.c \
2.103 @BUILD_SH4X86_TRUE@ x86dasm/x86dasm.h x86dasm/i386-dis.c x86dasm/dis-init.c \
2.104 @@ -501,6 +503,7 @@
2.105 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cd_linux.Po@am__quote@
2.106 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cd_none.Po@am__quote@
2.107 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cdi.Po@am__quote@
2.108 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cocoa_gd.Po@am__quote@
2.109 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cocoa_win.Po@am__quote@
2.110 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cocoaui.Po@am__quote@
2.111 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@
2.112 @@ -518,6 +521,7 @@
2.113 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eventq.Po@am__quote@
2.114 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdi.Po@am__quote@
2.115 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdimage.Po@am__quote@
2.116 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdlist.Po@am__quote@
2.117 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdrom.Po@am__quote@
2.118 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdrom_menu.Po@am__quote@
2.119 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gendec.Po@am__quote@
2.120 @@ -1516,6 +1520,20 @@
2.121 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.122 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cocoa_win.obj `if test -f 'cocoaui/cocoa_win.c'; then $(CYGPATH_W) 'cocoaui/cocoa_win.c'; else $(CYGPATH_W) '$(srcdir)/cocoaui/cocoa_win.c'; fi`
2.123
2.124 +cocoa_gd.o: cocoaui/cocoa_gd.c
2.125 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cocoa_gd.o -MD -MP -MF "$(DEPDIR)/cocoa_gd.Tpo" -c -o cocoa_gd.o `test -f 'cocoaui/cocoa_gd.c' || echo '$(srcdir)/'`cocoaui/cocoa_gd.c; \
2.126 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cocoa_gd.Tpo" "$(DEPDIR)/cocoa_gd.Po"; else rm -f "$(DEPDIR)/cocoa_gd.Tpo"; exit 1; fi
2.127 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cocoaui/cocoa_gd.c' object='cocoa_gd.o' libtool=no @AMDEPBACKSLASH@
2.128 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.129 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cocoa_gd.o `test -f 'cocoaui/cocoa_gd.c' || echo '$(srcdir)/'`cocoaui/cocoa_gd.c
2.130 +
2.131 +cocoa_gd.obj: cocoaui/cocoa_gd.c
2.132 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cocoa_gd.obj -MD -MP -MF "$(DEPDIR)/cocoa_gd.Tpo" -c -o cocoa_gd.obj `if test -f 'cocoaui/cocoa_gd.c'; then $(CYGPATH_W) 'cocoaui/cocoa_gd.c'; else $(CYGPATH_W) '$(srcdir)/cocoaui/cocoa_gd.c'; fi`; \
2.133 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/cocoa_gd.Tpo" "$(DEPDIR)/cocoa_gd.Po"; else rm -f "$(DEPDIR)/cocoa_gd.Tpo"; exit 1; fi
2.134 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='cocoaui/cocoa_gd.c' object='cocoa_gd.obj' libtool=no @AMDEPBACKSLASH@
2.135 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.136 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cocoa_gd.obj `if test -f 'cocoaui/cocoa_gd.c'; then $(CYGPATH_W) 'cocoaui/cocoa_gd.c'; else $(CYGPATH_W) '$(srcdir)/cocoaui/cocoa_gd.c'; fi`
2.137 +
2.138 video_osx.o: drivers/video_osx.c
2.139 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT video_osx.o -MD -MP -MF "$(DEPDIR)/video_osx.Tpo" -c -o video_osx.o `test -f 'drivers/video_osx.c' || echo '$(srcdir)/'`drivers/video_osx.c; \
2.140 @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/video_osx.Tpo" "$(DEPDIR)/video_osx.Po"; else rm -f "$(DEPDIR)/video_osx.Tpo"; exit 1; fi
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/src/cocoaui/cocoa_gd.c Thu Jun 19 04:40:37 2008 +0000
3.3 @@ -0,0 +1,87 @@
3.4 +/**
3.5 + * $Id$
3.6 + *
3.7 + * Management of the GDRom menu under cocoa
3.8 + *
3.9 + * Copyright (c) 2005 Nathan Keynes.
3.10 + *
3.11 + * This program is free software; you can redistribute it and/or modify
3.12 + * it under the terms of the GNU General Public License as published by
3.13 + * the Free Software Foundation; either version 2 of the License, or
3.14 + * (at your option) any later version.
3.15 + *
3.16 + * This program is distributed in the hope that it will be useful,
3.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.19 + * GNU General Public License for more details.
3.20 + */
3.21 +
3.22 +
3.23 +#include <AppKit/AppKit.h>
3.24 +#include <stdio.h>
3.25 +#include <stdlib.h>
3.26 +#include <string.h>
3.27 +#include <sys/time.h>
3.28 +#include "lxdream.h"
3.29 +#include "dreamcast.h"
3.30 +#include "dream.h"
3.31 +#include "gdlist.h"
3.32 +#include "cocoaui/cocoaui.h"
3.33 +
3.34 +void cocoa_gdrom_menu_build( NSMenu *menu )
3.35 +{
3.36 + int i,len = gdrom_list_size();
3.37 + for( i=0; i<len; i++ ) {
3.38 + const gchar *entry = gdrom_list_get_display_name(i);
3.39 + if( entry[0] == '\0' ) {
3.40 + [menu addItem: [NSMenuItem separatorItem]];
3.41 + } else {
3.42 + [[menu addItemWithTitle: [NSString stringWithCString: entry]
3.43 + action: @selector(gdrom_list_action:) keyEquivalent: @""]
3.44 + setTag: i];
3.45 + }
3.46 + }
3.47 + [menu addItem: [NSMenuItem separatorItem]];
3.48 + [menu addItemWithTitle: NS_("Open image file...") action: @selector(mount_action:)
3.49 + keyEquivalent: @"i"];
3.50 +}
3.51 +
3.52 +void cocoa_gdrom_menu_rebuild( NSMenu *menu )
3.53 +{
3.54 + while( [menu numberOfItems] > 0 ) {
3.55 + [ menu removeItemAtIndex: 0 ];
3.56 + }
3.57 +
3.58 + cocoa_gdrom_menu_build( menu );
3.59 +}
3.60 +
3.61 +void cocoa_gdrom_menu_update( gboolean list_changed, int selection, void *user_data )
3.62 +{
3.63 + // Create an auto-release pool - we may be called outside of the GUI main loop
3.64 + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
3.65 + NSMenu *menu = (NSMenu *)user_data;
3.66 + int i;
3.67 +
3.68 + if( list_changed ) {
3.69 + cocoa_gdrom_menu_rebuild(menu);
3.70 + }
3.71 +
3.72 + for( i=0; i< [menu numberOfItems]; i++ ) {
3.73 + if( i == selection ) {
3.74 + [[menu itemAtIndex: i] setState: NSOnState];
3.75 + } else {
3.76 + [[menu itemAtIndex: i] setState: NSOffState];
3.77 + }
3.78 + }
3.79 + [pool release];
3.80 +}
3.81 +
3.82 +NSMenu *cocoa_gdrom_menu_new()
3.83 +{
3.84 + NSMenu *menu = [[NSMenu alloc] initWithTitle: @"GD-Rom Settings"];
3.85 + cocoa_gdrom_menu_build(menu);
3.86 +
3.87 + register_gdrom_list_change_hook(cocoa_gdrom_menu_update, menu);
3.88 + cocoa_gdrom_menu_update( FALSE, gdrom_list_get_selection(), menu );
3.89 + return menu;
3.90 +}
4.1 --- a/src/cocoaui/cocoaui.c Mon Jun 16 11:00:40 2008 +0000
4.2 +++ b/src/cocoaui/cocoaui.c Thu Jun 19 04:40:37 2008 +0000
4.3 @@ -96,9 +96,12 @@
4.4 NSMenu *menu = [NSMenu new];
4.5 [menu addItem: menuItem];
4.6
4.7 + NSMenu *gdromMenu = cocoa_gdrom_menu_new();
4.8 +
4.9 NSMenu *fileMenu = [[NSMenu alloc] initWithTitle: NS_("File")];
4.10 [fileMenu addItemWithTitle: NS_("Load Binary") action: @selector(load_binary_action:) keyEquivalent: @"b"];
4.11 - [fileMenu addItemWithTitle: NS_("GD-Rom") action: @selector(mount_action:) keyEquivalent: @"g"];
4.12 + [[fileMenu addItemWithTitle: NS_("GD-Rom") action: nil keyEquivalent: @""]
4.13 + setSubmenu: gdromMenu];
4.14 [fileMenu addItem: [NSMenuItem separatorItem]];
4.15 [[fileMenu addItemWithTitle: NS_("Reset") action: @selector(reset_action:) keyEquivalent: @"r"]
4.16 setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)];
4.17 @@ -194,6 +197,10 @@
4.18 {
4.19 dreamcast_run();
4.20 }
4.21 +- (void) gdrom_list_action: (id)sender
4.22 +{
4.23 + gdrom_list_set_selection( [sender tag] );
4.24 +}
4.25 @end
4.26
4.27
5.1 --- a/src/cocoaui/cocoaui.h Mon Jun 16 11:00:40 2008 +0000
5.2 +++ b/src/cocoaui/cocoaui.h Thu Jun 19 04:40:37 2008 +0000
5.3 @@ -25,6 +25,7 @@
5.4 #define NS_(x) [NSString stringWithUTF8String: _(x)]
5.5
5.6 NSWindow *cocoa_gui_create_main_window();
5.7 +NSMenu *cocoa_gdrom_menu_new();
5.8 NSView *video_osx_create_drawable();
5.9
5.10 @interface LxdreamMainWindow : NSWindow
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/src/gdlist.c Thu Jun 19 04:40:37 2008 +0000
6.3 @@ -0,0 +1,225 @@
6.4 +/**
6.5 + * $Id$
6.6 + *
6.7 + * GD-Rom list manager - maintains the list of recently accessed images and
6.8 + * available devices for the UI + config.
6.9 + *
6.10 + * Copyright (c) 2005 Nathan Keynes.
6.11 + *
6.12 + * This program is free software; you can redistribute it and/or modify
6.13 + * it under the terms of the GNU General Public License as published by
6.14 + * the Free Software Foundation; either version 2 of the License, or
6.15 + * (at your option) any later version.
6.16 + *
6.17 + * This program is distributed in the hope that it will be useful,
6.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.20 + * GNU General Public License for more details.
6.21 + */
6.22 +
6.23 +#include <string.h>
6.24 +#include <stdlib.h>
6.25 +#include <glib/gstrfuncs.h>
6.26 +#include <glib/gi18n.h>
6.27 +#include <libgen.h>
6.28 +#include "gdrom/gdrom.h"
6.29 +#include "gdlist.h"
6.30 +#include "lxdream.h"
6.31 +#include "config.h"
6.32 +
6.33 +#define MAX_RECENT_ITEMS 5
6.34 +
6.35 +#define FIRST_RECENT_INDEX (gdrom_device_count+2)
6.36 +
6.37 +DEFINE_HOOK(gdrom_list_change_hook, gdrom_list_change_hook_t);
6.38 +
6.39 +static GList *gdrom_device_list = NULL;
6.40 +static GList *gdrom_recent_list = NULL;
6.41 +static unsigned int gdrom_device_count = 0, gdrom_recent_count = 0;
6.42 +
6.43 +gint gdrom_list_find( const gchar *name )
6.44 +{
6.45 + gint posn = 0;
6.46 + GList *ptr;
6.47 +
6.48 + for( ptr = gdrom_device_list; ptr != NULL; ptr = g_list_next(ptr) ) {
6.49 + gchar *device = (gchar *)ptr->data;
6.50 + posn++;
6.51 + if( strcmp(device, name) == 0 ) {
6.52 + return posn;
6.53 + }
6.54 + }
6.55 + posn++;
6.56 + for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
6.57 + gchar *file = (gchar *)ptr->data;
6.58 + posn++;
6.59 + if( strcmp(file, name) == 0 ) {
6.60 + return posn;
6.61 + }
6.62 + }
6.63 + return -1;
6.64 +}
6.65 +
6.66 +/**
6.67 + * Update the recent list in the lxdream config (but does not save)
6.68 + */
6.69 +void gdrom_list_update_config()
6.70 +{
6.71 + GList *ptr;
6.72 + int size = 0;
6.73 + for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
6.74 + size += strlen( (gchar *)ptr->data ) + 1;
6.75 + }
6.76 + char buf[size];
6.77 + strcpy( buf, (gchar *)gdrom_recent_list->data );
6.78 + for( ptr = g_list_next(gdrom_recent_list); ptr != NULL; ptr = g_list_next(ptr) ) {
6.79 + strcat( buf, ":" );
6.80 + strcat( buf, (gchar *)ptr->data );
6.81 + }
6.82 + lxdream_set_global_config_value( CONFIG_RECENT, buf );
6.83 +}
6.84 +
6.85 +
6.86 +void gdrom_list_add_recent_item( const gchar *name )
6.87 +{
6.88 + gdrom_recent_list = g_list_prepend( gdrom_recent_list, g_strdup(name) );
6.89 + if( g_list_length(gdrom_recent_list) > MAX_RECENT_ITEMS ) {
6.90 + GList *ptr = g_list_nth( gdrom_recent_list, MAX_RECENT_ITEMS );
6.91 + g_free( ptr->data );
6.92 + gdrom_recent_list = g_list_remove( gdrom_recent_list, ptr->data );
6.93 + } else {
6.94 + gdrom_recent_count ++;
6.95 + }
6.96 + gdrom_list_update_config();
6.97 +}
6.98 +
6.99 +void gdrom_list_move_to_front( const gchar *name )
6.100 +{
6.101 + GList *ptr;
6.102 + for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
6.103 + gchar *file = (gchar *)ptr->data;
6.104 + if( strcmp(file, name) == 0 ) {
6.105 + gdrom_recent_list = g_list_delete_link( gdrom_recent_list, ptr );
6.106 + gdrom_recent_list = g_list_prepend( gdrom_recent_list, file );
6.107 + gdrom_list_update_config();
6.108 + return;
6.109 + }
6.110 + }
6.111 +}
6.112 +
6.113 +/**
6.114 + * Disc-changed callback from the GD-Rom driver. Updates the list accordingly.
6.115 + */
6.116 +gboolean gdrom_list_disc_changed( gdrom_disc_t disc, const gchar *disc_name, void *user_data )
6.117 +{
6.118 + gboolean list_changed = FALSE;
6.119 + int posn = 0;
6.120 + if( disc != NULL ) {
6.121 + posn = gdrom_list_find( disc_name );
6.122 + if( posn == -1 ) {
6.123 + gdrom_list_add_recent_item( disc_name );
6.124 + posn = FIRST_RECENT_INDEX;
6.125 + list_changed = TRUE;
6.126 + } else if( posn > FIRST_RECENT_INDEX ) {
6.127 + gdrom_list_move_to_front( disc_name );
6.128 + posn = FIRST_RECENT_INDEX;
6.129 + list_changed = TRUE;
6.130 + }
6.131 + }
6.132 +
6.133 + lxdream_set_global_config_value( CONFIG_GDROM, disc_name );
6.134 + lxdream_save_config();
6.135 +
6.136 + CALL_HOOKS( gdrom_list_change_hook, list_changed, posn );
6.137 + return TRUE;
6.138 +}
6.139 +
6.140 +/**
6.141 + * Drives-changed callback from the host CD-Rom drivers. Probably not likely to
6.142 + * happen too often unless you're adding/removing external drives...
6.143 + */
6.144 +void gdrom_list_drives_changed( GList *device_list )
6.145 +{
6.146 +}
6.147 +
6.148 +/************ Public interface ***********/
6.149 +
6.150 +void gdrom_list_init()
6.151 +{
6.152 + const gchar *recent = lxdream_get_config_value( CONFIG_RECENT );
6.153 + register_gdrom_disc_change_hook( gdrom_list_disc_changed, NULL );
6.154 + gdrom_device_list = gdrom_get_native_devices();
6.155 + if( recent != NULL ) {
6.156 + gchar **list = g_strsplit(recent, ":", MAX_RECENT_ITEMS);
6.157 + int i;
6.158 + for( i=0; list[i] != NULL; i++ ) {
6.159 + gdrom_recent_list = g_list_append( gdrom_recent_list, g_strdup(list[i]) );
6.160 + }
6.161 + g_strfreev(list);
6.162 + }
6.163 + gdrom_device_count = g_list_length(gdrom_device_list);
6.164 + gdrom_recent_count = g_list_length(gdrom_recent_list);
6.165 +
6.166 + // Run the hooks in case anyone registered before the list was initialized
6.167 + CALL_HOOKS( gdrom_list_change_hook, TRUE, gdrom_list_get_selection() );
6.168 +}
6.169 +
6.170 +gboolean gdrom_list_set_selection( int posn )
6.171 +{
6.172 + if( posn == 0 ) { // Always 'Empty'
6.173 + gdrom_unmount_disc();
6.174 + return TRUE;
6.175 + }
6.176 +
6.177 + if( posn <= gdrom_device_count ) {
6.178 + gchar *entry = g_list_nth_data(gdrom_device_list, posn-1);
6.179 + gdrom_mount_image(entry);
6.180 + return TRUE;
6.181 + }
6.182 +
6.183 + posn -= FIRST_RECENT_INDEX;
6.184 + if( posn >= 0 && posn < gdrom_recent_count ) {
6.185 + gchar *entry = g_list_nth_data(gdrom_recent_list, posn);
6.186 + gdrom_mount_image(entry);
6.187 + return TRUE;
6.188 + }
6.189 +
6.190 + return FALSE;
6.191 +}
6.192 +
6.193 +gint gdrom_list_get_selection( )
6.194 +{
6.195 + const char *name = gdrom_get_current_disc_name();
6.196 + if( name == NULL ) {
6.197 + return 0;
6.198 + } else {
6.199 + return gdrom_list_find(name);
6.200 + }
6.201 +}
6.202 +
6.203 +int gdrom_list_size()
6.204 +{
6.205 + return gdrom_device_count + gdrom_recent_count + 2;
6.206 +}
6.207 +
6.208 +const gchar *gdrom_list_get_display_name( int posn )
6.209 +{
6.210 + if( posn == 0 ) {
6.211 + return _("Empty");
6.212 + }
6.213 +
6.214 + if( posn <= gdrom_device_count ) {
6.215 + return g_list_nth_data(gdrom_device_list, posn-1);
6.216 + }
6.217 +
6.218 + if( posn == gdrom_device_count + 1) {
6.219 + return "";
6.220 + }
6.221 +
6.222 + if( posn < 0 || posn > gdrom_list_size() ) {
6.223 + return NULL;
6.224 + }
6.225 +
6.226 + gchar *entry = g_list_nth_data(gdrom_recent_list, posn-FIRST_RECENT_INDEX);
6.227 + return basename(entry);
6.228 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/src/gdlist.h Thu Jun 19 04:40:37 2008 +0000
7.3 @@ -0,0 +1,65 @@
7.4 +/**
7.5 + * $Id$
7.6 + *
7.7 + * GD-Rom list manager - maintains the list of recently accessed images and
7.8 + * available devices for the UI + config.
7.9 + *
7.10 + * Copyright (c) 2005 Nathan Keynes.
7.11 + *
7.12 + * This program is free software; you can redistribute it and/or modify
7.13 + * it under the terms of the GNU General Public License as published by
7.14 + * the Free Software Foundation; either version 2 of the License, or
7.15 + * (at your option) any later version.
7.16 + *
7.17 + * This program is distributed in the hope that it will be useful,
7.18 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
7.19 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7.20 + * GNU General Public License for more details.
7.21 + */
7.22 +
7.23 +#ifndef lxdream_gdlist_H
7.24 +#define lxdream_gdlist_H 1
7.25 +
7.26 +#include "hook.h"
7.27 +
7.28 +typedef gboolean (*gdrom_list_change_hook_t)(gboolean list_changed, int selection, void *user_data);
7.29 +DECLARE_HOOK(gdrom_list_change_hook, gdrom_list_change_hook_t);
7.30 +
7.31 +
7.32 +/**
7.33 + * Initialize the gdrom list (registers with the gdrom driver, creates the
7.34 + * initial lists, etc). Must be called exactly once before using the lists.
7.35 + */
7.36 +void gdrom_list_init(void);
7.37 +
7.38 +/**
7.39 + * Return the index of the currently selected GD-Rom item. If there is no disc
7.40 + * currently mounted, returns 0.
7.41 + */
7.42 +int gdrom_list_get_selection(void);
7.43 +
7.44 +/**
7.45 + * Return the number of items in the list, including separators.
7.46 + */
7.47 +int gdrom_list_size(void);
7.48 +
7.49 +/**
7.50 + * Return the display name of the item at the specified index. If the
7.51 + * item is a separator, returns the empty string. If the index is out
7.52 + * of bounds, returns NULL.
7.53 + * The list will currently follow the following structure:
7.54 + * "Empty" (localised)
7.55 + * Any CD/DVD drives attached to the system
7.56 + * "" (empty string) - separator item
7.57 + * An LRU list of disc image files (note without directory components).
7.58 + */
7.59 +const gchar *gdrom_list_get_display_name(int index);
7.60 +
7.61 +/**
7.62 + * Change the current gdrom selection to the selected index. This will mount the
7.63 + * appropriate drive/image where necessary.
7.64 + * @return TRUE if the selection was updated, FALSE if the position was invalid.
7.65 + */
7.66 +gboolean gdrom_list_set_selection(int posn);
7.67 +
7.68 +#endif /* lxdream_gdlist_H */
8.1 --- a/src/gdrom/gdrom.c Mon Jun 16 11:00:40 2008 +0000
8.2 +++ b/src/gdrom/gdrom.c Thu Jun 19 04:40:37 2008 +0000
8.3 @@ -121,9 +121,8 @@
8.4 if( gdrom_disc != NULL ) {
8.5 gdrom_disc->close(gdrom_disc);
8.6 gdrom_fire_disc_changed(NULL);
8.7 + gdrom_disc = NULL;
8.8 }
8.9 - gdrom_disc = NULL;
8.10 -
8.11 }
8.12
8.13 gdrom_disc_t gdrom_get_current_disc()
9.1 --- a/src/gtkui/gdrom_menu.c Mon Jun 16 11:00:40 2008 +0000
9.2 +++ b/src/gtkui/gdrom_menu.c Thu Jun 19 04:40:37 2008 +0000
9.3 @@ -26,173 +26,41 @@
9.4 #include "gdrom/gdrom.h"
9.5 #include "gtkui/gtkui.h"
9.6
9.7 -#define MAX_RECENT_ITEMS 5
9.8 +static gboolean gdrom_menu_adjusting = FALSE;
9.9
9.10 -static GList *gdrom_menu_list = NULL;
9.11 -static gboolean gdrom_menu_adjusting = FALSE;
9.12 -static GList *gdrom_device_list = NULL;
9.13 -static GList *gdrom_recent_list = NULL;
9.14 -
9.15 -void gdrom_menu_rebuild_all();
9.16 -
9.17 -
9.18 -gint gdrom_menu_find_item( const gchar *name )
9.19 -{
9.20 - gint posn = 0;
9.21 - GList *ptr;
9.22 -
9.23 - for( ptr = gdrom_device_list; ptr != NULL; ptr = g_list_next(ptr) ) {
9.24 - gchar *device = (gchar *)ptr->data;
9.25 - posn++;
9.26 - if( strcmp(device, name) == 0 ) {
9.27 - return posn;
9.28 - }
9.29 - }
9.30 - posn++;
9.31 - for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
9.32 - gchar *file = (gchar *)ptr->data;
9.33 - posn++;
9.34 - if( strcmp(file, name) == 0 ) {
9.35 - return posn;
9.36 - }
9.37 - }
9.38 - return -1;
9.39 -}
9.40 -
9.41 -gint gdrom_menu_add_recent_item( const gchar *name )
9.42 -{
9.43 - gdrom_recent_list = g_list_prepend( gdrom_recent_list, g_strdup(name) );
9.44 - if( g_list_length(gdrom_recent_list) > MAX_RECENT_ITEMS ) {
9.45 - GList *ptr = g_list_nth( gdrom_recent_list, MAX_RECENT_ITEMS );
9.46 - g_free( ptr->data );
9.47 - gdrom_recent_list = g_list_remove( gdrom_recent_list, ptr->data );
9.48 - }
9.49 -
9.50 - GList *ptr;
9.51 - int size = 0;
9.52 - for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
9.53 - size += strlen( (gchar *)ptr->data ) + 1;
9.54 - }
9.55 - char buf[size];
9.56 - strcpy( buf, (gchar *)gdrom_recent_list->data );
9.57 - ptr = g_list_next(gdrom_recent_list);
9.58 - while( ptr != NULL ) {
9.59 - strcat( buf, ":" );
9.60 - strcat( buf, (gchar *)ptr->data );
9.61 - ptr = g_list_next(ptr);
9.62 - }
9.63 - lxdream_set_global_config_value( CONFIG_RECENT, buf );
9.64 - lxdream_save_config();
9.65 -
9.66 - return g_list_length( gdrom_device_list ) + 2; // menu posn of new item
9.67 -}
9.68 -
9.69 -void gdrom_menu_update_all()
9.70 -{
9.71 - const gchar *disc_name = gdrom_get_current_disc_name();
9.72 - gint posn = 0;
9.73 - GList *ptr;
9.74 -
9.75 - gdrom_menu_adjusting = TRUE;
9.76 -
9.77 - if( disc_name != NULL ) {
9.78 - posn = gdrom_menu_find_item( disc_name );
9.79 - if( posn == -1 ) {
9.80 - posn = gdrom_menu_add_recent_item( disc_name );
9.81 - gdrom_menu_rebuild_all();
9.82 - }
9.83 - }
9.84 -
9.85 - for( ptr = gdrom_menu_list; ptr != NULL; ptr = g_list_next(ptr) ) {
9.86 - GtkWidget *menu = GTK_WIDGET(ptr->data);
9.87 - GList *children = gtk_container_get_children( GTK_CONTAINER(menu) );
9.88 - GList *item = g_list_nth( children, posn );
9.89 - assert( item != NULL );
9.90 - gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(item->data), TRUE );
9.91 - g_list_free(children);
9.92 - }
9.93 -
9.94 - gdrom_menu_adjusting = FALSE;
9.95 -}
9.96 -
9.97 -void gdrom_menu_empty_callback( GtkWidget *widget, gpointer user_data )
9.98 +static void gdrom_menu_open_image_callback( GtkWidget *widget, gpointer user_data )
9.99 {
9.100 if( !gdrom_menu_adjusting ) {
9.101 - gdrom_unmount_disc();
9.102 - lxdream_set_global_config_value( CONFIG_GDROM, NULL );
9.103 - lxdream_save_config();
9.104 + const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
9.105 + open_file_dialog( _("Open..."), gdrom_mount_image, NULL, NULL, dir );
9.106 }
9.107 }
9.108
9.109 -void gdrom_menu_disc_changed( gdrom_disc_t disc, const gchar *name, void *user_data )
9.110 +void gdrom_menu_item_callback( GtkWidget *widget, gpointer user_data )
9.111 {
9.112 if( !gdrom_menu_adjusting ) {
9.113 - gdrom_menu_update_all();
9.114 - }
9.115 -}
9.116 -
9.117 -gboolean gdrom_menu_open_file( const char *filename )
9.118 -{
9.119 - gboolean result = FALSE;
9.120 - if( filename != NULL ) {
9.121 - result = gdrom_mount_image(filename);
9.122 - }
9.123 - if( result ) {
9.124 - lxdream_set_global_config_value( CONFIG_GDROM, filename );
9.125 - lxdream_save_config();
9.126 - }
9.127 - return result;
9.128 -}
9.129 -
9.130 -void gdrom_menu_open_image_callback( GtkWidget *widget, gpointer user_data )
9.131 -{
9.132 - if( !gdrom_menu_adjusting ) {
9.133 - const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
9.134 - open_file_dialog( _("Open..."), gdrom_menu_open_file, NULL, NULL, dir );
9.135 - }
9.136 -}
9.137 -
9.138 -
9.139 -void gdrom_menu_open_specified_callback( GtkWidget *widget, gpointer user_data )
9.140 -{
9.141 - if( !gdrom_menu_adjusting ) {
9.142 - gdrom_menu_open_file( (gchar *)user_data );
9.143 + gdrom_list_set_selection( GPOINTER_TO_INT(user_data) );
9.144 }
9.145 }
9.146
9.147 void gdrom_menu_build( GtkWidget *menu )
9.148 {
9.149 + unsigned int i, len;
9.150 GSList *group = NULL;
9.151 - GtkWidget *empty = gtk_radio_menu_item_new_with_label( group, _("Empty") );
9.152 - group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(empty) );
9.153 - g_signal_connect_after( empty, "activate", G_CALLBACK(gdrom_menu_empty_callback), NULL );
9.154 - gtk_menu_shell_append( GTK_MENU_SHELL(menu), empty );
9.155
9.156 - GList *ptr;
9.157 - for( ptr = gdrom_device_list; ptr != NULL; ptr = g_list_next(ptr) ) {
9.158 - gchar *name = (gchar *)ptr->data;
9.159 - GtkWidget *item = gtk_radio_menu_item_new_with_label( group, name);
9.160 - gtk_widget_set_name( item, name );
9.161 - group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item) );
9.162 - g_signal_connect_after( item, "activate", G_CALLBACK(gdrom_menu_open_specified_callback),
9.163 - name );
9.164 - gtk_menu_shell_append( GTK_MENU_SHELL(menu), item );
9.165 + len = gdrom_list_size();
9.166 + for( i=0; i < len; i++ ) {
9.167 + const gchar *entry = gdrom_list_get_display_name(i);
9.168 + if( entry[0] == '\0' ) { // Empty string = separator
9.169 + gtk_menu_shell_append( GTK_MENU_SHELL(menu), gtk_separator_menu_item_new() );
9.170 + } else {
9.171 + GtkWidget *item = gtk_radio_menu_item_new_with_label( group, entry );
9.172 + group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item) );
9.173 + g_signal_connect_after( item, "activate", G_CALLBACK(gdrom_menu_item_callback), GINT_TO_POINTER(i) );
9.174 + gtk_menu_shell_append( GTK_MENU_SHELL(menu), item );
9.175 + }
9.176 }
9.177
9.178 - if( gdrom_recent_list != NULL ) {
9.179 - gtk_menu_shell_append( GTK_MENU_SHELL(menu), gtk_separator_menu_item_new() );
9.180 - for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
9.181 - gchar *path = (gchar *)ptr->data;
9.182 - gchar *name = basename(path);
9.183 - GtkWidget *item = gtk_radio_menu_item_new_with_label( group, name );
9.184 - gtk_widget_set_name( item, path );
9.185 - group = gtk_radio_menu_item_get_group( GTK_RADIO_MENU_ITEM(item) );
9.186 - g_signal_connect_after( item, "activate", G_CALLBACK(gdrom_menu_open_specified_callback),
9.187 - path );
9.188 - gtk_menu_shell_append( GTK_MENU_SHELL(menu), item );
9.189 -
9.190 - }
9.191 - }
9.192 gtk_menu_shell_append( GTK_MENU_SHELL(menu), gtk_separator_menu_item_new() );
9.193 GtkWidget *open = gtk_image_menu_item_new_with_label( _("Open image file...") );
9.194 g_signal_connect_after( open, "activate", G_CALLBACK(gdrom_menu_open_image_callback), NULL );
9.195 @@ -200,47 +68,45 @@
9.196 gtk_widget_show_all(menu);
9.197 }
9.198
9.199 +void gdrom_menu_rebuild( GtkWidget *menu )
9.200 +{
9.201 + GList *children = gtk_container_get_children( GTK_CONTAINER(menu) );
9.202 + GList *listptr;
9.203 + for( listptr = children; listptr != NULL; listptr = g_list_next(listptr) ) {
9.204 + gtk_widget_destroy( GTK_WIDGET(listptr->data) );
9.205 + }
9.206 + g_list_free(children);
9.207 + gdrom_menu_build(menu);
9.208 +}
9.209 +
9.210 +gboolean gdrom_menu_update( gboolean list_changed, int selection, void *user_data )
9.211 +{
9.212 + gdrom_menu_adjusting = TRUE;
9.213 + GtkWidget *menu = GTK_WIDGET(user_data);
9.214 +
9.215 + if( list_changed ) {
9.216 + gdrom_menu_rebuild(menu);
9.217 + }
9.218 +
9.219 + GList *children = gtk_container_get_children( GTK_CONTAINER(menu) );
9.220 + GList *item = g_list_nth( children, selection );
9.221 + assert( item != NULL );
9.222 + gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(item->data), TRUE );
9.223 + g_list_free(children);
9.224 +
9.225 + gdrom_menu_adjusting = FALSE;
9.226 + return TRUE;
9.227 +}
9.228 +
9.229 GtkWidget *gdrom_menu_new()
9.230 {
9.231 GtkWidget *menu = gtk_menu_new();
9.232 gtk_menu_set_title( GTK_MENU(menu), _("GD-Rom Settings") );
9.233
9.234 gdrom_menu_build(menu);
9.235 -
9.236 - gdrom_menu_list = g_list_append(gdrom_menu_list, menu);
9.237 + register_gdrom_list_change_hook(gdrom_menu_update, menu);
9.238 + gdrom_menu_update( FALSE, gdrom_list_get_selection(), menu );
9.239 gtk_widget_show_all(menu);
9.240 - gdrom_menu_update_all();
9.241 +
9.242 return menu;
9.243 }
9.244 -
9.245 -void gdrom_menu_rebuild_all()
9.246 -{
9.247 - GList *ptr;
9.248 -
9.249 - for( ptr = gdrom_menu_list; ptr != NULL; ptr = g_list_next(ptr) ) {
9.250 - GtkWidget *menu = GTK_WIDGET(ptr->data);
9.251 - GList *children = gtk_container_get_children( GTK_CONTAINER(menu) );
9.252 - GList *listptr;
9.253 - for( listptr = children; listptr != NULL; listptr = g_list_next(listptr) ) {
9.254 - gtk_widget_destroy( GTK_WIDGET(listptr->data) );
9.255 - }
9.256 - g_list_free(children);
9.257 - gdrom_menu_build(menu);
9.258 - }
9.259 - gdrom_menu_update_all();
9.260 -}
9.261 -
9.262 -void gdrom_menu_init()
9.263 -{
9.264 - const gchar *recent = lxdream_get_config_value( CONFIG_RECENT );
9.265 - register_gdrom_disc_change_hook( gdrom_menu_disc_changed, NULL );
9.266 - gdrom_device_list = gdrom_get_native_devices();
9.267 - if( recent != NULL ) {
9.268 - gchar **list = g_strsplit(recent, ":", 5);
9.269 - int i;
9.270 - for( i=0; list[i] != NULL; i++ ) {
9.271 - gdrom_recent_list = g_list_append( gdrom_recent_list, g_strdup(list[i]) );
9.272 - }
9.273 - g_strfreev(list);
9.274 - }
9.275 -}
10.1 --- a/src/gtkui/gtkui.c Mon Jun 16 11:00:40 2008 +0000
10.2 +++ b/src/gtkui/gtkui.c Thu Jun 19 04:40:37 2008 +0000
10.3 @@ -225,7 +225,6 @@
10.4 GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");
10.5
10.6 GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");
10.7 - gdrom_menu_init();
10.8 GtkWidget *gdrommenu = gdrom_menu_new();
10.9 gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );
10.10 main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );
11.1 --- a/src/main.c Mon Jun 16 11:00:40 2008 +0000
11.2 +++ b/src/main.c Thu Jun 19 04:40:37 2008 +0000
11.3 @@ -133,7 +133,8 @@
11.4 }
11.5
11.6 lxdream_load_config( );
11.7 -
11.8 + gdrom_list_init();
11.9 +
11.10 if( aica_program == NULL ) {
11.11 dreamcast_init();
11.12 } else {
12.1 --- a/src/mem.c Mon Jun 16 11:00:40 2008 +0000
12.2 +++ b/src/mem.c Thu Jun 19 04:40:37 2008 +0000
12.3 @@ -178,7 +178,7 @@
12.4 if( len > (length-total) )
12.5 len = (length-total);
12.6 if( fwrite( region, len, 1, f ) != 1 ) {
12.7 - ERROR( "Unexpected error: %d %d", len, errno );
12.8 + ERROR( "Unexpected error writing blocks: %d (%s)", len, strerror(errno) );
12.9 break;
12.10 }
12.11
12.12 @@ -212,7 +212,7 @@
12.13 if( len > (length-total) )
12.14 len = (length-total);
12.15 if( fread( region, len, 1, f ) != 1 ) {
12.16 - ERROR( "Unexpected error: %d %d", len, errno );
12.17 + ERROR( "Unexpected error reading: %d (%s)", len, strerror(errno) );
12.18 break;
12.19 }
12.20
.