revision 1043:ec716f2b8ffb
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 1043:ec716f2b8ffb |
parent | 1042:0fd066956482 |
child | 1044:01e46b0aafaf |
author | nkeynes |
date | Sat Jun 27 09:55:00 2009 +0000 (14 years ago) |
Ensure each VMU is only attached once
Handle removal of sub-devices when detaching parent device
Handle removal of sub-devices when detaching parent device
src/cocoaui/cocoa_ctrl.m | view | annotate | diff | log | ||
src/gtkui/gtk_ctrl.c | view | annotate | diff | log |
1.1 --- a/src/cocoaui/cocoa_ctrl.m Fri Jun 26 13:53:54 2009 +00001.2 +++ b/src/cocoaui/cocoa_ctrl.m Sat Jun 27 09:55:00 2009 +00001.3 @@ -649,6 +649,12 @@1.4 }1.5 if( new_device_class == NULL ) {1.6 maple_detach_device(port,slot);1.7 + if( slot == 0 ) {1.8 + /* If we detached the top-level dev, any children are automatically detached */1.9 + for( i=1; i<=MAPLE_USER_SLOTS; i++ ) {1.10 + [popup[MAPLE_DEVID(port,i)] selectItemWithTag: 0];1.11 + }1.12 + }1.13 } else {1.14 if( new_device_class == &controller_class && save_controller[tag] != NULL ) {1.15 new_device = save_controller[tag];1.16 @@ -657,6 +663,14 @@1.17 new_device = maple_new_device( new_device_class->name );1.18 }1.19 if( MAPLE_IS_VMU(new_device) ) {1.20 + /* Remove the VMU from any other attachment point */1.21 + for( i=0; i<MAPLE_MAX_DEVICES; i++ ) {1.22 + maple_device_t dev = maple_get_device(MAPLE_DEVID_PORT(i),MAPLE_DEVID_SLOT(i));1.23 + if( dev != NULL && MAPLE_IS_VMU(dev) && MAPLE_VMU_HAS_NAME(dev,vmu_filename) ) {1.24 + maple_detach_device(MAPLE_DEVID_PORT(i),MAPLE_DEVID_SLOT(i));1.25 + [popup[i] selectItemWithTag: 0];1.26 + }1.27 + }1.28 MAPLE_SET_VMU_NAME(new_device,vmu_filename);1.29 }1.30 maple_attach_device(new_device,port,slot);
2.1 --- a/src/gtkui/gtk_ctrl.c Fri Jun 26 13:53:54 2009 +00002.2 +++ b/src/gtkui/gtk_ctrl.c Sat Jun 27 09:55:00 2009 +00002.3 @@ -292,9 +292,17 @@2.4 } else {2.5 data->new_device = devclz->new_device();2.6 }2.7 - has_config = data->new_device != NULL && data->new_device->get_config != NULL;2.8 + has_config = data->new_device != NULL && data->new_device->get_config != NULL && !MAPLE_IS_VMU(data->new_device);2.9 has_slots = data->new_device == NULL ? 0 : MAPLE_SLOTS(devclz);2.10 if( MAPLE_IS_VMU(data->new_device) ) {2.11 + for( i=0; i<MAPLE_MAX_DEVICES; i++ ) {2.12 + if( maple_data[i].new_device != NULL && MAPLE_IS_VMU(maple_data[i].new_device) &&2.13 + MAPLE_VMU_HAS_NAME(maple_data[i].new_device, vmu_filename) ) {2.14 + maple_data[i].new_device->destroy(maple_data[i].new_device);2.15 + maple_data[i].new_device = NULL;2.16 + gtk_combo_box_set_active(maple_data[i].combo,0);2.17 + }2.18 + }2.19 MAPLE_SET_VMU_NAME(data->new_device,vmu_filename);2.20 }2.22 @@ -314,7 +322,7 @@2.23 /* This is a little morally dubious... */2.24 maple_slot_data_t subdata = data + MAPLE_DEVID(0,(i+1));2.25 gtk_widget_set_sensitive(subdata->combo, i < has_slots );2.26 - gtk_widget_set_sensitive(subdata->button, i < has_slots && subdata->new_device != NULL && subdata->new_device->get_config != NULL );2.27 + gtk_widget_set_sensitive(subdata->button, i < has_slots && subdata->new_device != NULL && subdata->new_device->get_config != NULL && !MAPLE_IS_VMU(subdata->new_device) );2.28 }2.29 }2.30 return TRUE;
.