Search
lxdream.org :: lxdream/src/gtkui/gdrom_menu.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gtkui/gdrom_menu.c
changeset 678:35eb00945316
prev561:533f6b478071
next691:ad3356543392
author nkeynes
date Thu May 29 11:00:26 2008 +0000 (12 years ago)
permissions -rw-r--r--
last change Split gdrom.h into public and private gddriver.h
Reorganize gdrom mount to use a disc change hook
file annotate diff log raw
1.1 --- a/src/gtkui/gdrom_menu.c Tue Jan 01 05:08:38 2008 +0000
1.2 +++ b/src/gtkui/gdrom_menu.c Thu May 29 11:00:26 2008 +0000
1.3 @@ -89,27 +89,27 @@
1.4
1.5 void gdrom_menu_update_all()
1.6 {
1.7 - gdrom_disc_t disc = gdrom_get_current_disc();
1.8 + const gchar *disc_name = gdrom_get_current_disc_name();
1.9 gint posn = 0;
1.10 GList *ptr;
1.11
1.12 gdrom_menu_adjusting = TRUE;
1.13
1.14 - if( disc != NULL ) {
1.15 - posn = gdrom_menu_find_item( disc->name );
1.16 - if( posn == -1 ) {
1.17 - posn = gdrom_menu_add_recent_item( disc->name );
1.18 - gdrom_menu_rebuild_all();
1.19 - }
1.20 + if( disc_name != NULL ) {
1.21 + posn = gdrom_menu_find_item( disc_name );
1.22 + if( posn == -1 ) {
1.23 + posn = gdrom_menu_add_recent_item( disc_name );
1.24 + gdrom_menu_rebuild_all();
1.25 + }
1.26 }
1.27
1.28 for( ptr = gdrom_menu_list; ptr != NULL; ptr = g_list_next(ptr) ) {
1.29 - GtkWidget *menu = GTK_WIDGET(ptr->data);
1.30 - GList *children = gtk_container_get_children( GTK_CONTAINER(menu) );
1.31 - GList *item = g_list_nth( children, posn );
1.32 - assert( item != NULL );
1.33 - gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(item->data), TRUE );
1.34 - g_list_free(children);
1.35 + GtkWidget *menu = GTK_WIDGET(ptr->data);
1.36 + GList *children = gtk_container_get_children( GTK_CONTAINER(menu) );
1.37 + GList *item = g_list_nth( children, posn );
1.38 + assert( item != NULL );
1.39 + gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM(item->data), TRUE );
1.40 + g_list_free(children);
1.41 }
1.42
1.43 gdrom_menu_adjusting = FALSE;
1.44 @@ -118,10 +118,16 @@
1.45 void gdrom_menu_empty_callback( GtkWidget *widget, gpointer user_data )
1.46 {
1.47 if( !gdrom_menu_adjusting ) {
1.48 - gdrom_unmount_disc();
1.49 - gdrom_menu_update_all();
1.50 - lxdream_set_global_config_value( CONFIG_GDROM, NULL );
1.51 - lxdream_save_config();
1.52 + gdrom_unmount_disc();
1.53 + lxdream_set_global_config_value( CONFIG_GDROM, NULL );
1.54 + lxdream_save_config();
1.55 + }
1.56 +}
1.57 +
1.58 +void gdrom_menu_disc_changed( gdrom_disc_t disc, const gchar *name, void *user_data )
1.59 +{
1.60 + if( !gdrom_menu_adjusting ) {
1.61 + gdrom_menu_update_all();
1.62 }
1.63 }
1.64
1.65 @@ -129,12 +135,11 @@
1.66 {
1.67 gboolean result = FALSE;
1.68 if( filename != NULL ) {
1.69 - result = gdrom_mount_image(filename);
1.70 + result = gdrom_mount_image(filename);
1.71 }
1.72 if( result ) {
1.73 - gdrom_menu_update_all();
1.74 - lxdream_set_global_config_value( CONFIG_GDROM, filename );
1.75 - lxdream_save_config();
1.76 + lxdream_set_global_config_value( CONFIG_GDROM, filename );
1.77 + lxdream_save_config();
1.78 }
1.79 return result;
1.80 }
1.81 @@ -142,8 +147,8 @@
1.82 void gdrom_menu_open_image_callback( GtkWidget *widget, gpointer user_data )
1.83 {
1.84 if( !gdrom_menu_adjusting ) {
1.85 - const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
1.86 - open_file_dialog( _("Open..."), gdrom_menu_open_file, NULL, NULL, dir );
1.87 + const gchar *dir = lxdream_get_config_value(CONFIG_DEFAULT_PATH);
1.88 + open_file_dialog( _("Open..."), gdrom_menu_open_file, NULL, NULL, dir );
1.89 }
1.90 }
1.91
1.92 @@ -228,6 +233,7 @@
1.93 void gdrom_menu_init()
1.94 {
1.95 const gchar *recent = lxdream_get_config_value( CONFIG_RECENT );
1.96 + register_gdrom_disc_change_hook( gdrom_menu_disc_changed, NULL );
1.97 gdrom_device_list = gdrom_get_native_devices();
1.98 if( recent != NULL ) {
1.99 gchar **list = g_strsplit(recent, ":", 5);
.