Search
lxdream.org :: lxdream/src/gui/gdrom_menu.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui/gdrom_menu.c
changeset 470:e09a16196693
prev469:3e2a0fde5cd8
next479:e030b18d2744
author nkeynes
date Sun Oct 28 08:29:29 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Maintain current gdrom and recently-used list in config file
file annotate diff log raw
1.1 --- a/src/gui/gdrom_menu.c Sun Oct 28 07:36:11 2007 +0000
1.2 +++ b/src/gui/gdrom_menu.c Sun Oct 28 08:29:29 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: gdrom_menu.c,v 1.2 2007-10-28 07:36:11 nkeynes Exp $
1.6 + * $Id: gdrom_menu.c,v 1.3 2007-10-28 08:29:29 nkeynes Exp $
1.7 *
1.8 * Creates and manages the GD-Rom attachment menu.
1.9 *
1.10 @@ -66,6 +66,23 @@
1.11 g_free( ptr->data );
1.12 gdrom_recent_list = g_list_remove( gdrom_recent_list, ptr->data );
1.13 }
1.14 +
1.15 + GList *ptr;
1.16 + int size;
1.17 + for( ptr = gdrom_recent_list; ptr != NULL; ptr = g_list_next(ptr) ) {
1.18 + size += strlen( (gchar *)ptr->data ) + 1;
1.19 + }
1.20 + char buf[size];
1.21 + strcpy( buf, (gchar *)gdrom_recent_list->data );
1.22 + ptr = g_list_next(gdrom_recent_list);
1.23 + while( ptr != NULL ) {
1.24 + strcat( buf, ":" );
1.25 + strcat( buf, (gchar *)ptr->data );
1.26 + ptr = g_list_next(ptr);
1.27 + }
1.28 + lxdream_set_global_config_value( CONFIG_RECENT, buf );
1.29 + lxdream_save_config();
1.30 +
1.31 return g_list_length( gdrom_device_list ) + 2; // menu posn of new item
1.32 }
1.33
1.34 @@ -102,6 +119,8 @@
1.35 if( !gdrom_menu_adjusting ) {
1.36 gdrom_unmount_disc();
1.37 gdrom_menu_update_all();
1.38 + lxdream_set_global_config_value( CONFIG_GDROM, NULL );
1.39 + lxdream_save_config();
1.40 }
1.41 }
1.42
1.43 @@ -113,6 +132,8 @@
1.44 }
1.45 if( result ) {
1.46 gdrom_menu_update_all();
1.47 + lxdream_set_global_config_value( CONFIG_GDROM, filename );
1.48 + lxdream_save_config();
1.49 }
1.50 return result;
1.51 }
1.52 @@ -141,9 +162,6 @@
1.53 g_signal_connect_after( empty, "activate", G_CALLBACK(gdrom_menu_empty_callback), NULL );
1.54 gtk_menu_shell_append( GTK_MENU_SHELL(menu), empty );
1.55
1.56 - if( gdrom_device_list == NULL ) {
1.57 - gdrom_device_list = gdrom_get_native_devices();
1.58 - }
1.59 GList *ptr;
1.60 for( ptr = gdrom_device_list; ptr != NULL; ptr = g_list_next(ptr) ) {
1.61 gchar *name = (gchar *)ptr->data;
1.62 @@ -205,3 +223,17 @@
1.63 }
1.64 gdrom_menu_update_all();
1.65 }
1.66 +
1.67 +void gdrom_menu_init()
1.68 +{
1.69 + const gchar *recent = lxdream_get_config_value( CONFIG_RECENT );
1.70 + gdrom_device_list = gdrom_get_native_devices();
1.71 + if( recent != NULL ) {
1.72 + gchar **list = g_strsplit(recent, ":", 5);
1.73 + int i;
1.74 + for( i=0; list[i] != NULL; i++ ) {
1.75 + gdrom_recent_list = g_list_append( gdrom_recent_list, g_strdup(list[i]) );
1.76 + }
1.77 + g_strfreev(list);
1.78 + }
1.79 +}
.