# HG changeset patch # User Matti Hamalainen # Date 1352203254 -7200 # Node ID fcda6f365e026a2348544796c167e531c2ba224f # Parent 45b8649f0ef98245b09b706efd47872faf471d25 More cleanups. diff -r 45b8649f0ef9 -r fcda6f365e02 src/xs_config.c --- a/src/xs_config.c Tue Nov 06 13:44:46 2012 +0200 +++ b/src/xs_config.c Tue Nov 06 14:00:54 2012 +0200 @@ -72,13 +72,14 @@ /* Samplerates */ -static const gchar *xs_samplerates_table[] = { +static const gchar *xs_samplerates_table[] = +{ "8000", "11025", "22050", "44100", "48000", "64000", "96000" }; -static const gint xs_nsamplerates_table = (sizeof(xs_samplerates_table) / sizeof(xs_samplerates_table[0])); +static const gint xs_nsamplerates_table = sizeof(xs_samplerates_table) / sizeof(xs_samplerates_table[0]); /* * Configuration specific stuff @@ -132,10 +133,10 @@ { CTYPE_INT, &xs_cfg.subAutoMinTime, "subAutoMinTime" }, }; -static const gint xs_cfgtable_max = (sizeof(xs_cfgtable) / sizeof(xs_cfgtable[0])); +static const gint xs_ncfgtable = sizeof(xs_cfgtable) / sizeof(xs_cfgtable[0]); -static xs_wid_item_t xs_widtable[] = { +static xs_wid_item_t xs_cfgitems[] = { { WTYPE_BGROUP, CTYPE_INT, "cfg_res_16bit", &xs_cfg.audioBitsPerSample, XS_RES_16BIT }, { WTYPE_BGROUP, CTYPE_INT, "cfg_res_8bit", &xs_cfg.audioBitsPerSample, XS_RES_8BIT }, { WTYPE_BGROUP, CTYPE_INT, "cfg_chn_mono", &xs_cfg.audioChannels, XS_CHN_MONO }, @@ -195,7 +196,7 @@ { WTYPE_SPIN, CTYPE_INT, "cfg_subauto_mintime", &xs_cfg.subAutoMinTime, 0 }, }; -static const gint xs_widtable_max = (sizeof(xs_widtable) / sizeof(xs_widtable[0])); +static const gint xs_nwidtable = sizeof(xs_cfgitems) / sizeof(xs_cfgitems[0]); /* Reset/initialize the configuration @@ -303,7 +304,8 @@ static void xs_filter_free(xs_sid_filter_t *filter) { - if (filter) { + if (filter) + { g_free(filter->name); filter->name = NULL; g_free(filter); @@ -316,6 +318,7 @@ static gboolean xs_filter_load_into(XS_CONFIG_FILE *cfg, gint nFilter, xs_sid_filter_t *filter) { gchar tmpKey[64], *tmpStr; + gint i, j; /* Get fields from config */ g_snprintf(tmpKey, sizeof(tmpKey), "filter%dType", nFilter); @@ -330,54 +333,61 @@ if (filter->name == NULL) return FALSE; - if (filter->type == 1) { - gint i, j; + switch (filter->type) + { + case 1: + + /* Types 1 has points */ + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dNPoints", nFilter); + if (!XS_CFG_GET_INT(tmpKey, &(filter->npoints))) + return FALSE; - /* Types 1 has points */ - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dNPoints", nFilter); - if (!XS_CFG_GET_INT(tmpKey, &(filter->npoints))) - return FALSE; - - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dPoints", nFilter); - if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) - return FALSE; - - for (i = 0, j = 0; i < filter->npoints; i++, j += XS_FITEM) { - if (sscanf(&tmpStr[j], "%4x%4x", - &(filter->points[i].x), - &(filter->points[i].y)) != 2) + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dPoints", nFilter); + if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) return FALSE; - } - } else if (filter->type == 3) { - /* Type 3 has tunables */ - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dData", nFilter); - if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) - return FALSE; + + for (i = 0, j = 0; i < filter->npoints; i++, j += XS_FITEM) + { + if (sscanf(&tmpStr[j], "%4x%4x", + &(filter->points[i].x), + &(filter->points[i].y)) != 2) + return FALSE; + } + break; - if (sscanf(tmpStr, "%f,%f,%f,%f", &filter->rate, &filter->point, - &filter->voice_nonlinearity, &filter->cf_treshold) != 4) - return FALSE; + case 3: + /* Type 3 has tunables */ + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dData", nFilter); + if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) + return FALSE; + + if (sscanf(tmpStr, "%f,%f,%f,%f", &filter->rate, &filter->point, + &filter->voice_nonlinearity, &filter->cf_treshold) != 4) + return FALSE; + + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dData3", nFilter); + if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) + return FALSE; + + if (sscanf(tmpStr, "%f,%f,%f,%f", &filter->baseresistance, + &filter->offset, &filter->steepness, + &filter->minimumfetresistance) != 4) + return FALSE; + break; - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dData3", nFilter); - if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) - return FALSE; + case 4: + /* Type 4 has fewer tunables */ + g_snprintf(tmpKey, sizeof(tmpKey), "filter%dData4", nFilter); + if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) + return FALSE; + + if (sscanf(tmpStr, "%f,%f", &filter->k, &filter->b) != 2) + return FALSE; + break; - if (sscanf(tmpStr, "%f,%f,%f,%f", &filter->baseresistance, - &filter->offset, &filter->steepness, - &filter->minimumfetresistance) != 4) + default: + xs_error("Unknown filter type %d for '%s' (#%d).\n", filter->type, filter->name, nFilter); return FALSE; - - } else if (filter->type == 4) { - /* Type 4 has fewer tunables */ - g_snprintf(tmpKey, sizeof(tmpKey), "filter%dData4", nFilter); - if (!XS_CFG_GET_STRING(tmpKey, &tmpStr)) - return FALSE; - - if (sscanf(tmpStr, "%f,%f", &filter->k, &filter->b) != 2) - return FALSE; - } else { - xs_error("Unknown filter type %d for '%s' (#%d).\n", filter->type, filter->name, nFilter); - return FALSE; } return TRUE; @@ -392,7 +402,8 @@ if ((filter = g_malloc0(sizeof(xs_sid_filter_t))) == NULL) return NULL; - if (!xs_filter_load_into(cfg, nFilter, filter)) { + if (!xs_filter_load_into(cfg, nFilter, filter)) + { xs_error("Error loading filter %d from configuration.\n", nFilter); xs_filter_free(filter); return NULL; @@ -413,7 +424,8 @@ return FALSE; /* Make value string */ - for (i = 0, j = 0; i < pFilter->npoints; i++, j += XS_FITEM) { + for (i = 0, j = 0; i < pFilter->npoints; i++, j += XS_FITEM) + { g_snprintf(&tmpValue[j], XS_FITEM+1, "%04x%04x", pFilter->points[i].x, pFilter->points[i].y); @@ -458,11 +470,16 @@ { if (g_strncasecmp(str, name, strlen(name))) return FALSE; - if (filter->type != type) { - if (filter->type == -1) { + + if (filter->type != type) + { + if (filter->type == -1) + { filter->type = type; return TRUE; - } else { + } + else + { xs_error("Unexpected key '%s' for filter type %d.\n"); return FALSE; } @@ -481,7 +498,8 @@ fprintf(stderr, "xs_filters_import(%s)\n", filename); - if ((inFile = fopen(filename, "ra")) == NULL) { + if ((inFile = fopen(filename, "ra")) == NULL) + { xs_filters_error(""); return FALSE; } @@ -490,43 +508,64 @@ inSection = FALSE; lineNum = 0; - while (fgets(inLine, XS_BUF_SIZE, inFile) != NULL && !isError) { + while (fgets(inLine, XS_BUF_SIZE, inFile) != NULL && !isError) + { size_t linePos = 0; lineNum++; xs_findnext(inLine, &linePos); - if (isalpha(inLine[linePos])) { + if (isalpha(inLine[linePos])) + { /* A new key/value pair */ - if (!xs_fgetitem(inLine, &linePos, '=', tmpStr, XS_BUF_SIZE)) { + if (!xs_fgetitem(inLine, &linePos, '=', tmpStr, XS_BUF_SIZE)) + { xs_error("Invalid line '%s' :: expected =", inLine); isError = TRUE; - } else if (inSection) { + } + else + if (inSection) + { linePos++; xs_findnext(inLine, &linePos); - if (xs_chkf(filter, tmpStr, "points", 1)) { - - } else if (xs_chkf(filter, tmpStr, "point", 1)) { + if (xs_chkf(filter, tmpStr, "points", 1)) + { + } + else + if (xs_chkf(filter, tmpStr, "point", 1)) + { - } else if (!g_strncasecmp(tmpStr, "type", 4)) { - if (filter->type != -1) { + } + else + if (!g_strncasecmp(tmpStr, "type", 4)) + { + if (filter->type != -1) + { xs_error("Filter type %d already set for '%s'\n", filter->type, sectName); } - - } else { + } + else + { xs_error("Unsupported definition '%s' @ '%s'\n", tmpStr, sectName); } } - } else if (inLine[linePos] == '[') { + } + else + if (inLine[linePos] == '[') + { /* Check for existing section */ - if (inSection) { + if (inSection) + { /* Submit definition */ fprintf(stderr, "filter ends: %s\n", sectName); - if ((filter = g_malloc0(sizeof(xs_sid_filter_t))) == NULL) { + if ((filter = g_malloc0(sizeof(xs_sid_filter_t))) == NULL) + { fprintf(stderr, "could not allocate ..\n"); - } else { + } + else + { } g_free(sectName); @@ -538,19 +577,27 @@ tmpStr[i] = inLine[linePos]; tmpStr[i] = 0; - if (inLine[linePos] != ']') { + if (inLine[linePos] != ']') + { fprintf(stderr, "invalid! expected ']': %s\n", inLine); - } else { - if (!g_strncasecmp(tmpStr, "filter", 6)) { + } + else + { + if (!g_strncasecmp(tmpStr, "filter", 6)) + { sectName = strdup(tmpStr + 6); fprintf(stderr, "filter: %s\n", sectName); inSection = TRUE; - } else { + } + else + { fprintf(stderr, "ignoring section: %s\n", tmpStr); inSection = FALSE; } } - } else if (inLine[linePos] != '#' && inLine[linePos] != ';' && inLine[linePos] != 0) { + } + else if (inLine[linePos] != '#' && inLine[linePos] != ';' && inLine[linePos] != 0) + { /* Syntax error */ xs_error("Syntax error: '%s'\n", inLine); isError = TRUE; @@ -564,49 +611,58 @@ static gboolean xs_filter_export(FILE *outFile, xs_sid_filter_t *filter) { + gint i; + fprintf(outFile, "[Filter%s]\n" "type=%d\n", filter->name, filter->type); - if (filter->type == 1) { - gint i; - fprintf(outFile, "points=%d\n", filter->npoints); + switch (filter->type) + { + case 1: + fprintf(outFile, "points=%d\n", filter->npoints); + + for (i = 0; i < filter->npoints; i++) + { + fprintf(outFile, + "point%d=%d,%d\n", + i + 1, + filter->points[i].x, + filter->points[i].y); + } + break; - for (i = 0; i < filter->npoints; i++) { + case 3: fprintf(outFile, - "point%d=%d,%d\n", - i + 1, - filter->points[i].x, - filter->points[i].y); - } - } else if (filter->type == 3) { - fprintf(outFile, - "DistortionRate = %f\n" - "DistortionPoint = %f\n" - "VoiceNonlinearity = %f\n" - "DistortionCFThreshold = %f\n", - filter->rate, filter->point, - filter->voice_nonlinearity, - filter->cf_treshold); + "DistortionRate = %f\n" + "DistortionPoint = %f\n" + "VoiceNonlinearity = %f\n" + "DistortionCFThreshold = %f\n", + filter->rate, filter->point, + filter->voice_nonlinearity, + filter->cf_treshold); + + fprintf(outFile, + "Type3BaseResistance = %f\n" + "Type3Offset = %f\n" + "Type3Steepness = %f\n" + "Type3MinimumFETResistance = %f\n", + filter->baseresistance, filter->offset, + filter->steepness, filter->minimumfetresistance); + break; + + case 4: + fprintf(outFile, + "Type4K=%f\n" + "Type4B=%f\n", + filter->k, filter->b); + break; - fprintf(outFile, - "Type3BaseResistance = %f\n" - "Type3Offset = %f\n" - "Type3Steepness = %f\n" - "Type3MinimumFETResistance = %f\n", - filter->baseresistance, filter->offset, - filter->steepness, filter->minimumfetresistance); - - } else if (filter->type == 4) { - fprintf(outFile, - "Type4K=%f\n" - "Type4B=%f\n", - filter->k, filter->b); - } else { - xs_error("Filter '%s' has type %d, which is unsupported by export.\n", - filter->name, filter->type); - return FALSE; + default: + xs_error("Filter '%s' has type %d, which is unsupported by export.\n", + filter->name, filter->type); + return FALSE; } fprintf(outFile, "\n"); @@ -614,14 +670,15 @@ } -static gboolean xs_filters_export(const gchar *filename, xs_sid_filter_t **filters, gint nFilters) +static gboolean xs_filters_export(const gchar *filename, xs_sid_filter_t **filters, gint nfilters) { gboolean result = TRUE; FILE *outFile; gint n; /* Open/create the file */ - if ((outFile = fopen(filename, "wa")) == NULL) { + if ((outFile = fopen(filename, "wa")) == NULL) + { xs_filters_error("Could not open '%s' for writing! Not exporting.", filename); return FALSE; } @@ -632,8 +689,10 @@ "; Exported by " PACKAGE_STRING "\n\n"); /* Write each filter spec in "INI"-style format */ - for (n = 0; n < nFilters; n++) { - if (!xs_filter_export(outFile, filters[n])) { + for (n = 0; n < nfilters; n++) + { + if (!xs_filter_export(outFile, filters[n])) + { result = FALSE; break; } @@ -662,15 +721,17 @@ cfg = XS_CONFIG_OPEN(); - if (cfg == NULL) { + if (cfg == NULL) + { XSDEBUG("Could not open configuration, trying to write defaults...\n"); xs_write_configuration(); return; } /* Read the new settings from XMMS configuration file */ - for (i = 0; i < xs_cfgtable_max; i++) { - switch (xs_cfgtable[i].itemType) { + for (i = 0; i < xs_ncfgtable; i++) + switch (xs_cfgtable[i].itemType) + { case CTYPE_INT: XS_CFG_GET_INT(xs_cfgtable[i].itemName, (gint *) xs_cfgtable[i].itemData); @@ -693,20 +754,22 @@ g_free(tmpStr); } break; - } } /* Filters and presets are a special case */ xs_filter_load_into(cfg, 0, &xs_cfg.sid2Filter); - if (xs_cfg.sid2NFilterPresets > 0) { + if (xs_cfg.sid2NFilterPresets > 0) + { xs_cfg.sid2FilterPresets = g_malloc0(xs_cfg.sid2NFilterPresets * sizeof(xs_sid_filter_t *)); - if (!xs_cfg.sid2FilterPresets) { + if (!xs_cfg.sid2FilterPresets) + { xs_error("Allocation of sid2FilterPresets structure failed!\n"); - } else { - for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { + } + else + { + for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) xs_cfg.sid2FilterPresets[i] = xs_filter_load(cfg, i); - } } } @@ -736,8 +799,9 @@ #endif /* Write the new settings to XMMS configuration file */ - for (i = 0; i < xs_cfgtable_max; i++) { - switch (xs_cfgtable[i].itemType) { + for (i = 0; i < xs_ncfgtable; i++) + switch (xs_cfgtable[i].itemType) + { case CTYPE_INT: XS_CFG_SET_INT(xs_cfgtable[i].itemName, *(gint *) xs_cfgtable[i].itemData); @@ -757,7 +821,6 @@ XS_CFG_SET_STRING(xs_cfgtable[i].itemName, *(gchar **) xs_cfgtable[i].itemData); break; - } } @@ -791,66 +854,69 @@ XSDEBUG("get data from widgets to config...\n"); - for (i = 0; i < xs_widtable_max; i++) { - switch (xs_widtable[i].widType) { + for (i = 0; i < xs_nwidtable; i++) + switch (xs_cfgitems[i].widType) + { case WTYPE_BGROUP: /* Check if toggle-button is active */ - if (GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName))->active) { + if (GTK_TOGGLE_BUTTON(LUW(xs_cfgitems[i].widName))->active) + { /* Yes, set the constant value */ - *((gint *) xs_widtable[i].itemData) = xs_widtable[i].itemSet; + *((gint *) xs_cfgitems[i].itemData) = xs_cfgitems[i].itemSet; } break; case WTYPE_COMBO: /* Get text from text-widget */ - tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW(xs_widtable[i].widName))); + tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW(xs_cfgitems[i].widName))); if (sscanf(tmpStr, "%d", &tmpInt) != 1) - tmpInt = xs_widtable[i].itemSet; + tmpInt = xs_cfgitems[i].itemSet; - *((gint *) xs_widtable[i].itemData) = tmpInt; + *((gint *) xs_cfgitems[i].itemData) = tmpInt; break; case WTYPE_SPIN: case WTYPE_SCALE: /* Get the value */ - switch (xs_widtable[i].widType) { - case WTYPE_SPIN: - tmpValue = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW(xs_widtable[i].widName)))->value; - break; + switch (xs_cfgitems[i].widType) + { + case WTYPE_SPIN: + tmpValue = gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(LUW(xs_cfgitems[i].widName)))->value; + break; - case WTYPE_SCALE: - tmpValue = gtk_range_get_adjustment(GTK_RANGE(LUW(xs_widtable[i].widName)))->value; - break; - - default: - tmpValue = -1; - break; + case WTYPE_SCALE: + tmpValue = gtk_range_get_adjustment(GTK_RANGE(LUW(xs_cfgitems[i].widName)))->value; + break; + + default: + tmpValue = -1; + break; } /* Set the value */ - switch (xs_widtable[i].itemType) { - case CTYPE_INT: - *((gint *) xs_widtable[i].itemData) = (gint) tmpValue; - break; + switch (xs_cfgitems[i].itemType) + { + case CTYPE_INT: + *((gint *) xs_cfgitems[i].itemData) = (gint) tmpValue; + break; - case CTYPE_FLOAT: - *((gfloat *) xs_widtable[i].itemData) = tmpValue; - break; + case CTYPE_FLOAT: + *((gfloat *) xs_cfgitems[i].itemData) = tmpValue; + break; } break; case WTYPE_BUTTON: /* Check if toggle-button is active */ - *((gboolean *) xs_widtable[i].itemData) = - (GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName))->active); + *((gboolean *) xs_cfgitems[i].itemData) = + (GTK_TOGGLE_BUTTON(LUW(xs_cfgitems[i].widName))->active); break; case WTYPE_TEXT: /* Get text from text-widget */ - xs_pstrcpy((gchar **) xs_widtable[i].itemData, - gtk_entry_get_text(GTK_ENTRY(LUW(xs_widtable[i].widName)))); + xs_pstrcpy((gchar **) xs_cfgitems[i].itemData, + gtk_entry_get_text(GTK_ENTRY(LUW(xs_cfgitems[i].widName)))); break; - } } /* Get filter settings */ @@ -895,7 +961,8 @@ (void) button; (void) user_data; - if (xs_sldb_fileselector != NULL) { + if (xs_sldb_fileselector != NULL) + { XS_WINDOW_PRESENT(xs_sldb_fileselector); return; } @@ -972,7 +1039,8 @@ (void) button; (void) user_data; - if (xs_hvsc_selector != NULL) { + if (xs_hvsc_selector != NULL) + { XS_WINDOW_PRESENT(xs_hvsc_selector); return; } @@ -1024,7 +1092,8 @@ xs_curve_reset(curve); xs_curve_set_range(curve, 0,0, XS_SIDPLAY2_NFPOINTS, XS_SIDPLAY2_FMAX); - if (!xs_curve_set_points(curve, f->points, f->npoints)) { + if (!xs_curve_set_points(curve, f->points, f->npoints)) + { // FIXME xs_error("Warning: Could not set filter curve widget points!\n"); } @@ -1036,7 +1105,8 @@ GList *tmpList = NULL; gint i; - for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { + for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) + { tmpList = g_list_append(tmpList, (gpointer) xs_cfg.sid2FilterPresets[i]->name); } @@ -1059,19 +1129,24 @@ XS_MUTEX_LOCK(xs_cfg); tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sp2_filter_combo_entry"))); - for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) { - if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) { + for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) + { + if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) + { j = i; break; } } - if (j != -1) { + if (j != -1) + { fprintf(stderr, "Updating from '%s'\n", tmpStr); xs_cfg_sp2_filter_update( XS_CURVE(LUW("cfg_sp2_filter_curve")), xs_cfg.sid2FilterPresets[i]); - } else { + } + else + { /* error/warning: no such filter preset */ fprintf(stderr, "No such filter preset '%s'!\n", tmpStr); } @@ -1098,14 +1173,17 @@ XS_MUTEX_LOCK(xs_cfg); tmpStr = gtk_entry_get_text(GTK_ENTRY(LUW("cfg_sp2_filter_combo_entry"))); - for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) { - if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) { + for (i = 0, j = -1; i < xs_cfg.sid2NFilterPresets; i++) + { + if (!strcmp(tmpStr, xs_cfg.sid2FilterPresets[i]->name)) + { j = i; break; } } - if (j != -1) { + if (j != -1) + { fprintf(stderr, "Found, confirm overwrite?\n"); } @@ -1133,7 +1211,8 @@ (void) button; (void) user_data; - if (xs_filt_importselector != NULL) { + if (xs_filt_importselector != NULL) + { XS_WINDOW_PRESENT(xs_filt_importselector); return; } @@ -1172,7 +1251,8 @@ (void) button; (void) user_data; - if (xs_filt_exportselector != NULL) { + if (xs_filt_exportselector != NULL) + { XS_WINDOW_PRESENT(xs_filt_exportselector); return; } @@ -1366,7 +1446,8 @@ GtkWidget *tmpCurve; /* Check if the window already exists */ - if (xs_configwin) { + if (xs_configwin) + { XS_WINDOW_PRESENT(xs_configwin); return; } @@ -1378,7 +1459,8 @@ XS_MUTEX_LOCK(xs_cfg); /* Add samplerates */ - for (i = 0; i < xs_nsamplerates_table; i++) { + for (i = 0; i < xs_nsamplerates_table; i++) + { tmpList = g_list_append (tmpList, (gpointer) xs_samplerates_table[i]); } @@ -1427,66 +1509,71 @@ /* Set current data to widgets */ - for (i = 0; i < xs_widtable_max; i++) { - switch (xs_widtable[i].widType) { + for (i = 0; i < xs_nwidtable; i++) + { + switch (xs_cfgitems[i].widType) + { case WTYPE_BGROUP: - assert(xs_widtable[i].itemType == CTYPE_INT); + assert(xs_cfgitems[i].itemType == CTYPE_INT); /* Check if current value matches the given one */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName)), - (*((gint *) xs_widtable[i].itemData) == xs_widtable[i].itemSet)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_cfgitems[i].widName)), + (*((gint *) xs_cfgitems[i].itemData) == xs_cfgitems[i].itemSet)); break; case WTYPE_COMBO: - assert(xs_widtable[i].itemType == CTYPE_INT); - g_snprintf(tmpStr, sizeof(tmpStr), "%d", *(gint *) xs_widtable[i].itemData); - gtk_entry_set_text(GTK_ENTRY(LUW(xs_widtable[i].widName)), tmpStr); + assert(xs_cfgitems[i].itemType == CTYPE_INT); + g_snprintf(tmpStr, sizeof(tmpStr), "%d", *(gint *) xs_cfgitems[i].itemData); + gtk_entry_set_text(GTK_ENTRY(LUW(xs_cfgitems[i].widName)), tmpStr); break; case WTYPE_SPIN: case WTYPE_SCALE: /* Get the value */ - switch (xs_widtable[i].itemType) { - case CTYPE_INT: - tmpValue = (gfloat) * ((gint *) xs_widtable[i].itemData); - break; + switch (xs_cfgitems[i].itemType) + { + case CTYPE_INT: + tmpValue = (gfloat) * ((gint *) xs_cfgitems[i].itemData); + break; - case CTYPE_FLOAT: - tmpValue = *((gfloat *) xs_widtable[i].itemData); - break; + case CTYPE_FLOAT: + tmpValue = *((gfloat *) xs_cfgitems[i].itemData); + break; - default: - tmpValue = -1; - assert(0); - break; + default: + tmpValue = -1; + assert(0); + break; } /* Set the value */ - switch (xs_widtable[i].widType) { - case WTYPE_SPIN: - gtk_adjustment_set_value(gtk_spin_button_get_adjustment - (GTK_SPIN_BUTTON(LUW(xs_widtable[i].widName))), tmpValue); - break; + switch (xs_cfgitems[i].widType) + { + case WTYPE_SPIN: + gtk_adjustment_set_value(gtk_spin_button_get_adjustment + (GTK_SPIN_BUTTON(LUW(xs_cfgitems[i].widName))), tmpValue); + break; - case WTYPE_SCALE: - gtk_adjustment_set_value(gtk_range_get_adjustment - (GTK_RANGE(LUW(xs_widtable[i].widName))), tmpValue); - break; + case WTYPE_SCALE: + gtk_adjustment_set_value(gtk_range_get_adjustment + (GTK_RANGE(LUW(xs_cfgitems[i].widName))), tmpValue); + break; } break; case WTYPE_BUTTON: - assert(xs_widtable[i].itemType == CTYPE_BOOL); + assert(xs_cfgitems[i].itemType == CTYPE_BOOL); /* Set toggle-button */ - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_widtable[i].widName)), - *((gboolean *) xs_widtable[i].itemData)); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(LUW(xs_cfgitems[i].widName)), + *((gboolean *) xs_cfgitems[i].itemData)); break; case WTYPE_TEXT: - assert(xs_widtable[i].itemType == CTYPE_STR); + assert(xs_cfgitems[i].itemType == CTYPE_STR); /* Set text to text-widget */ - if (*(gchar **) xs_widtable[i].itemData != NULL) { - gtk_entry_set_text(GTK_ENTRY(LUW(xs_widtable[i].widName)), - *(gchar **) xs_widtable[i].itemData); + if (*(gchar **) xs_cfgitems[i].itemData != NULL) + { + gtk_entry_set_text(GTK_ENTRY(LUW(xs_cfgitems[i].widName)), + *(gchar **) xs_cfgitems[i].itemData); } break; }