Search
lxdream.org :: lxdream :: r470:e09a16196693
lxdream 0.9.1
released Jun 29
Download Now
changeset470:e09a16196693
parent469:3e2a0fde5cd8
child471:826c89a6f12c
authornkeynes
dateSun Oct 28 08:29:29 2007 +0000 (12 years ago)
Maintain current gdrom and recently-used list in config file
src/config.c
src/config.h
src/gui/gdrom_menu.c
src/gui/gtkui.c
src/gui/gtkui.h
src/main.c
1.1 --- a/src/config.c Sun Oct 28 07:36:11 2007 +0000
1.2 +++ b/src/config.c Sun Oct 28 08:29:29 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: config.c,v 1.4 2007-10-27 05:44:53 nkeynes Exp $
1.6 + * $Id: config.c,v 1.5 2007-10-28 08:29:29 nkeynes Exp $
1.7 *
1.8 * User configuration support
1.9 *
1.10 @@ -38,6 +38,7 @@
1.11 { "save path", CONFIG_TYPE_PATH, "save" },
1.12 { "bootstrap", CONFIG_TYPE_FILE, "IP.BIN" },
1.13 { "gdrom", CONFIG_TYPE_FILE, NULL },
1.14 + { "recent", CONFIG_TYPE_FILE, NULL },
1.15 { NULL, CONFIG_TYPE_NONE }};
1.16
1.17 static struct lxdream_config_entry serial_config[] =
1.18 @@ -290,7 +291,9 @@
1.19
1.20 if( entry != NULL ) {
1.21 while( entry->key != NULL ) {
1.22 - fprintf( f, "%s = %s\n", entry->key, entry->value );
1.23 + if( entry->value != NULL ) {
1.24 + fprintf( f, "%s = %s\n", entry->key, entry->value );
1.25 + }
1.26 entry++;
1.27 }
1.28 } else if( strcmp(group->key, "controllers") == 0 ) {
1.29 @@ -305,7 +308,9 @@
1.30 fprintf( f, "Subdevice %d = %s\n", j, dev->device_class->name );
1.31 entry = dev->get_config(dev);
1.32 while( entry->key != NULL ) {
1.33 - fprintf( f, "%*c%s = %s\n", j==0?4:8, ' ',entry->key, entry->value );
1.34 + if( entry->value != NULL ) {
1.35 + fprintf( f, "%*c%s = %s\n", j==0?4:8, ' ',entry->key, entry->value );
1.36 + }
1.37 entry++;
1.38 }
1.39 }
2.1 --- a/src/config.h Sun Oct 28 07:36:11 2007 +0000
2.2 +++ b/src/config.h Sun Oct 28 08:29:29 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: config.h,v 1.4 2007-10-27 05:44:53 nkeynes Exp $
2.6 + * $Id: config.h,v 1.5 2007-10-28 08:29:29 nkeynes Exp $
2.7 *
2.8 * User configuration support
2.9 *
2.10 @@ -46,6 +46,7 @@
2.11 #define CONFIG_SAVE_PATH 3
2.12 #define CONFIG_BOOTSTRAP 4
2.13 #define CONFIG_GDROM 5
2.14 +#define CONFIG_RECENT 6
2.15
2.16 extern struct lxdream_config_group lxdream_config_root[];
2.17
3.1 --- a/src/gui/gdrom_menu.c Sun Oct 28 07:36:11 2007 +0000
3.2 +++ b/src/gui/gdrom_menu.c Sun Oct 28 08:29:29 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: gdrom_menu.c,v 1.2 2007-10-28 07:36:11 nkeynes Exp $
3.6 + * $Id: gdrom_menu.c,v 1.3 2007-10-28 08:29:29 nkeynes Exp $
3.7 *
3.8 * Creates and manages the GD-Rom attachment menu.
3.9 *
3.10 @@ -66,6 +66,23 @@
3.11 g_free( ptr->data );
3.12 gdrom_recent_list = g_list_remove( gdrom_recent_list, ptr->data );
3.13 }
3.14 +
3.15 + GList *ptr;
3.16 + int size;
3.17 + for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
3.18 + size += strlen( (gchar *)ptr->data ) + 1;
3.19 + }
3.20 + char buf[size];
3.21 + strcpy( buf, (gchar *)gdrom_recent_list->data );
3.22 + ptr = g_list_next(gdrom_recent_list);
3.23 + while( ptr != NULL ) {
3.24 + strcat( buf, ":" );
3.25 + strcat( buf, (gchar *)ptr->data );
3.26 + ptr = g_list_next(ptr);
3.27 + }
3.28 + lxdream_set_global_config_value( CONFIG_RECENT, buf );
3.29 + lxdream_save_config();
3.30 +
3.31 return g_list_length( gdrom_device_list ) + 2; // menu posn of new item
3.32 }
3.33
3.34 @@ -102,6 +119,8 @@
3.35 if( !gdrom_menu_adjusting ) {
3.36 gdrom_unmount_disc();
3.37 gdrom_menu_update_all();
3.38 + lxdream_set_global_config_value( CONFIG_GDROM, NULL );
3.39 + lxdream_save_config();
3.40 }
3.41 }
3.42
3.43 @@ -113,6 +132,8 @@
3.44 }
3.45 if( result ) {
3.46 gdrom_menu_update_all();
3.47 + lxdream_set_global_config_value( CONFIG_GDROM, filename );
3.48 + lxdream_save_config();
3.49 }
3.50 return result;
3.51 }
3.52 @@ -141,9 +162,6 @@
3.53 g_signal_connect_after( empty, "activate", G_CALLBACK(gdrom_menu_empty_callback), NULL );
3.54 gtk_menu_shell_append( GTK_MENU_SHELL(menu), empty );
3.55
3.56 - if( gdrom_device_list == NULL ) {
3.57 - gdrom_device_list = gdrom_get_native_devices();
3.58 - }
3.59 GList *ptr;
3.60 for( ptr = gdrom_device_list; ptr != NULL; ptr = g_list_next(ptr) ) {
3.61 gchar *name = (gchar *)ptr->data;
3.62 @@ -205,3 +223,17 @@
3.63 }
3.64 gdrom_menu_update_all();
3.65 }
3.66 +
3.67 +void gdrom_menu_init()
3.68 +{
3.69 + const gchar *recent = lxdream_get_config_value( CONFIG_RECENT );
3.70 + gdrom_device_list = gdrom_get_native_devices();
3.71 + if( recent != NULL ) {
3.72 + gchar **list = g_strsplit(recent, ":", 5);
3.73 + int i;
3.74 + for( i=0; list[i] != NULL; i++ ) {
3.75 + gdrom_recent_list = g_list_append( gdrom_recent_list, g_strdup(list[i]) );
3.76 + }
3.77 + g_strfreev(list);
3.78 + }
3.79 +}
4.1 --- a/src/gui/gtkui.c Sun Oct 28 07:36:11 2007 +0000
4.2 +++ b/src/gui/gtkui.c Sun Oct 28 08:29:29 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: gtkui.c,v 1.7 2007-10-27 05:44:54 nkeynes Exp $
4.6 + * $Id: gtkui.c,v 1.8 2007-10-28 08:29:29 nkeynes Exp $
4.7 *
4.8 * Core GTK-based user interface
4.9 *
4.10 @@ -215,6 +215,7 @@
4.11 GtkWidget *toolbar = gtk_ui_manager_get_widget(global_ui_manager, "/MainToolbar");
4.12
4.13 GtkWidget *gdrommenuitem = gtk_ui_manager_get_widget(global_ui_manager, "/MainMenu/FileMenu/GdromSettings");
4.14 + gdrom_menu_init();
4.15 GtkWidget *gdrommenu = gdrom_menu_new();
4.16 gtk_menu_item_set_submenu( GTK_MENU_ITEM(gdrommenuitem), gdrommenu );
4.17 main_win = main_window_new( APP_NAME " " APP_VERSION, menubar, toolbar, accel_group );
5.1 --- a/src/gui/gtkui.h Sun Oct 28 07:36:11 2007 +0000
5.2 +++ b/src/gui/gtkui.h Sun Oct 28 08:29:29 2007 +0000
5.3 @@ -1,5 +1,5 @@
5.4 /**
5.5 - * $Id: gtkui.h,v 1.7 2007-10-27 05:44:54 nkeynes Exp $
5.6 + * $Id: gtkui.h,v 1.8 2007-10-28 08:29:29 nkeynes Exp $
5.7 *
5.8 * Core GTK-based user interface
5.9 *
5.10 @@ -71,6 +71,9 @@
5.11 void gtk_gui_enable_action( const gchar *action, gboolean enabled );
5.12 gint gtk_gui_run_property_dialog( const gchar *title, GtkWidget *panel, gtk_dialog_done_fn fn );
5.13
5.14 +void gdrom_menu_init();
5.15 +GtkWidget *gdrom_menu_new();
5.16 +
5.17 /******************** Video driver hooks *********************/
5.18
5.19 GtkWidget *gtk_gui_get_renderarea();
6.1 --- a/src/main.c Sun Oct 28 07:36:11 2007 +0000
6.2 +++ b/src/main.c Sun Oct 28 08:29:29 2007 +0000
6.3 @@ -1,5 +1,5 @@
6.4 /**
6.5 - * $Id: main.c,v 1.32 2007-10-28 07:36:11 nkeynes Exp $
6.6 + * $Id: main.c,v 1.33 2007-10-28 08:29:29 nkeynes Exp $
6.7 *
6.8 * Main program, initializes dreamcast and gui, then passes control off to
6.9 * the gtk main loop (currently).
6.10 @@ -189,7 +189,7 @@
6.11 }
6.12
6.13 if( disc_file != NULL ) {
6.14 - gdrom_mount_image( disc_file );
6.15 + gdrom_menu_open_file( disc_file );
6.16 }
6.17
6.18 if( gdrom_get_current_disc() == NULL ) {
6.19 @@ -197,8 +197,6 @@
6.20 if( disc_file != NULL ) {
6.21 gdrom_menu_open_file( disc_file );
6.22 }
6.23 - } else {
6.24 - lxdream_set_global_config_value( CONFIG_GDROM, gdrom_get_current_disc()->name );
6.25 }
6.26
6.27 sh4_set_use_xlat( use_xlat );
.