Search
lxdream.org :: lxdream :: r1057:6f2158c421bb
lxdream 0.9.1
released Jun 29
Download Now
changeset1057:6f2158c421bb
parent1056:d0896e6530d6
child1058:37f6fdc738e7
authornkeynes
dateSun Jun 28 12:08:16 2009 +0000 (11 years ago)
Fix creating first VMU (failed to add to list)
Fix device-changed causing second device-changed to fire
src/gtkui/gtk_ctrl.c
1.1 --- a/src/gtkui/gtk_ctrl.c Sun Jun 28 12:07:21 2009 +0000
1.2 +++ b/src/gtkui/gtk_ctrl.c Sun Jun 28 12:08:16 2009 +0000
1.3 @@ -58,6 +58,12 @@
1.4
1.5 static struct maple_slot_data maple_data[MAPLE_MAX_DEVICES];
1.6
1.7 +/**
1.8 + * Flag set when changing the selection on one of the combo boxes manually -
1.9 + * avoids the followup changed event.
1.10 + */
1.11 +static gboolean maple_device_adjusting = FALSE;
1.12 +
1.13 static void config_keysym_hook( void *data, const gchar *keysym )
1.14 {
1.15 GtkWidget *widget = (GtkWidget *)data;
1.16 @@ -233,6 +239,10 @@
1.17
1.18 static gboolean maple_device_changed( GtkComboBox *combo, gpointer user_data )
1.19 {
1.20 + if( maple_device_adjusting ) {
1.21 + return TRUE;
1.22 + }
1.23 +
1.24 maple_slot_data_t data = (maple_slot_data_t)user_data;
1.25 int active = gtk_combo_box_get_active(combo), i;
1.26 gboolean has_config = FALSE;
1.27 @@ -378,8 +388,9 @@
1.28 gboolean valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list), &iter);
1.29 while( valid ) {
1.30 gchar *vmu_filename;
1.31 - gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, 2, &vmu_filename, -1 );
1.32 - if( vmu_filename != NULL )
1.33 + gpointer devclz;
1.34 + gtk_tree_model_get(GTK_TREE_MODEL(list), &iter, 1, &devclz, 2, &vmu_filename, -1 );
1.35 + if( vmu_filename != NULL || devclz == LOAD_VMU_TAG || devclz == CREATE_VMU_TAG )
1.36 break;
1.37 valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(list), &iter);
1.38 }
1.39 @@ -409,30 +420,33 @@
1.40 GtkTreeModel *model = gtk_combo_box_get_model(GTK_COMBO_BOX(combo));
1.41 GtkTreeIter iter;
1.42
1.43 + maple_device_adjusting = TRUE;
1.44 if( device == NULL ) {
1.45 gtk_combo_box_set_active( GTK_COMBO_BOX(combo), 0 );
1.46 - return;
1.47 + } else {
1.48 + gboolean valid = gtk_tree_model_get_iter_first(model, &iter);
1.49 + while( valid ) {
1.50 + const struct maple_device_class *clz;
1.51 + const gchar *vmu_filename;
1.52 +
1.53 + gtk_tree_model_get(model, &iter, 1, &clz, 2, &vmu_filename, -1 );
1.54 +
1.55 + if( device->device_class == clz ) {
1.56 + gtk_combo_box_set_active_iter( GTK_COMBO_BOX(combo), &iter );
1.57 + break;
1.58 + } else if( vmu_filename != NULL && MAPLE_IS_VMU(device) &&
1.59 + MAPLE_VMU_HAS_NAME(device, vmu_filename) ) {
1.60 + gtk_combo_box_set_active_iter( GTK_COMBO_BOX(combo), &iter );
1.61 + break;
1.62 + }
1.63 +
1.64 + valid = gtk_tree_model_iter_next(model, &iter);
1.65 + }
1.66 + if( !valid ) {
1.67 + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
1.68 + }
1.69 }
1.70 -
1.71 - gboolean valid = gtk_tree_model_get_iter_first(model, &iter);
1.72 - while( valid ) {
1.73 - const struct maple_device_class *clz;
1.74 - const gchar *vmu_filename;
1.75 -
1.76 - gtk_tree_model_get(model, &iter, 1, &clz, 2, &vmu_filename, -1 );
1.77 -
1.78 - if( device->device_class == clz ) {
1.79 - gtk_combo_box_set_active_iter( GTK_COMBO_BOX(combo), &iter );
1.80 - return;
1.81 - } else if( vmu_filename != NULL && MAPLE_IS_VMU(device) &&
1.82 - MAPLE_VMU_HAS_NAME(device, vmu_filename) ) {
1.83 - gtk_combo_box_set_active_iter( GTK_COMBO_BOX(combo), &iter );
1.84 - return;
1.85 - }
1.86 -
1.87 - valid = gtk_tree_model_iter_next(model, &iter);
1.88 - }
1.89 - gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
1.90 + maple_device_adjusting = FALSE;
1.91 }
1.92
1.93 static void maple_dialog_done( GtkWidget *panel, gboolean isOK )
1.94 @@ -470,9 +484,10 @@
1.95 GtkWidget *table = gtk_table_new( MAPLE_PORTS * (MAPLE_USER_SLOTS+1), 3, TRUE);
1.96 int i,j,k;
1.97 const struct maple_device_class **devices = maple_get_device_classes();
1.98 -
1.99 +
1.100 gtk_table_set_row_spacings(GTK_TABLE(table), 3);
1.101 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1.102 + maple_device_adjusting = FALSE;
1.103
1.104 /* Device models */
1.105 GtkListStore *dev_model = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING);
1.106 @@ -487,7 +502,7 @@
1.107 for( i=0; i< MAPLE_PORTS; i++ ) {
1.108 char buf[16];
1.109 GtkWidget *combo, *button;
1.110 - int active = 0, length = 1;
1.111 + int length = 1;
1.112 maple_device_t device = maple_get_device(i,0);
1.113 int has_slots = device == NULL ? 0 : MAPLE_SLOTS(device->device_class);
1.114
1.115 @@ -502,7 +517,7 @@
1.116 gtk_table_attach_defaults( GTK_TABLE(table), combo, 1, 2, y, y+1 );
1.117
1.118 button = gtk_button_new_from_stock( GTK_STOCK_PROPERTIES );
1.119 - gtk_widget_set_sensitive(button, active != 0 && device->get_config != NULL);
1.120 + gtk_widget_set_sensitive(button, device != NULL && device->get_config != NULL);
1.121 gtk_table_attach_defaults( GTK_TABLE(table), button, 2, 3, y, y+1 );
1.122
1.123 maple_data[MAPLE_DEVID(i,0)].old_device = device;
1.124 @@ -519,7 +534,6 @@
1.125 for( k=0; k< MAPLE_USER_SLOTS; k++ ) {
1.126 char tmp[32] = " ";
1.127 device = maple_get_device(i,k+1);
1.128 - active = 0;
1.129 snprintf( tmp+8, sizeof(tmp)-8, _("VMU %d."), (k+1) );
1.130 gtk_table_attach_defaults( GTK_TABLE(table), gtk_label_new(tmp), 0, 1, y, y+1 );
1.131 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(subdev_model));
.