示例#1
0
void AddFuncToTopwidget(const FuncInfo* func)
{
	WidgetInfo *widget_info = NULL;
	TopWidget* top_widget = NULL;
	TopWidget* prop_topwidget = NULL;
	SpecialInfo* special = NULL;
	int len = 0;
	int found = 0;
	int i = 0;
	GtkWidget *widget = NULL;
	char* id = NULL;
	SignalInfo *signal = NULL;
	char* opt = NULL;

	len = g_list_length(g_topwidget_list);
	if(g_config_file_data != NULL){
		special = g_config_file_data->special_list;
	}else{
		return;
	}
	while(special != NULL){
		if((1 == special->type) && (0 == strcasecmp(special->parent, g_main_dlg_name))){
			break;
		}
		special = special->next;
	}
	for(i = 0; i < len; i++){
		top_widget = (TopWidget*)g_list_nth_data(g_topwidget_list, i);
		if(top_widget != NULL){
			if(0 == strcmp(top_widget->name, special->name)){
				prop_topwidget = top_widget;
				break;
			}
		}
	}
	if(func != NULL){
		if(func->func_id != NULL){
			id = func->func_id->name;
		}
		widget_info = func->widget_list;
	}
	while(widget_info != NULL){
		signal = widget_info->signal_list;
		if(signal != NULL){
			if(signal->condition != NULL){
				id = signal->condition->id;
			}else{
				id = signal->id;
			}
		}
		if(NULL == id){
			widget_info = widget_info->next;
			continue;
		}
		for(i = 0; i < len; i++){
			top_widget = (TopWidget*)g_list_nth_data(g_topwidget_list, i);
			if(top_widget != NULL){
				widget = glade_xml_get_widget(top_widget->xml, widget_info->name);
			}
			if(widget != NULL){
				TopWidgetSaveData* search = NULL;
				int savedata_len = 0;
				int j = 0;
				int tmp = GetModID(id);
				found = 0;
				if(top_widget != NULL){
					savedata_len = g_list_length(top_widget->save_data);
				}
				for(; j < savedata_len; j++){
					search = g_list_nth_data(top_widget->save_data, j);
					if(search != NULL){
						if(search->id == tmp){
							found = 1;
							break;
						}
					}
				}
				if(found == 1){
					break;
				}
				if(tmp == ID_CNPRINTSTYLE){
					opt = GetOptionList(g_cngplp_data, ID_DUPLEX);
					if(opt != NULL){
						AddSaveData(ID_DUPLEX, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_BOOKLET);
					if(opt != NULL){
						AddSaveData(ID_BOOKLET, top_widget);
						memFree(opt);
					}
				}else if(tmp == ID_CNFOLDSETTING){
					opt = GetOptionList(g_cngplp_data, ID_CNZFOLDING);
					if(opt != NULL){
						AddSaveData(ID_CNZFOLDING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNCFOLDING);
					if(opt != NULL){
						AddSaveData(ID_CNCFOLDING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNHALFFOLDING);
					if(opt != NULL){
						AddSaveData(ID_CNHALFFOLDING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNACCORDIONZFOLDING);
					if(opt != NULL){
						AddSaveData(ID_CNACCORDIONZFOLDING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNDOUBLEPARALLELFOLDING);
					if(opt != NULL){
						AddSaveData(ID_CNDOUBLEPARALLELFOLDING, top_widget);
						memFree(opt);
					}
				}else if(tmp == ID_CNFOLDDETAIL){
					opt = GetOptionList(g_cngplp_data, ID_CNCFOLDSETTING);
					if(opt != NULL){
						AddSaveData(ID_CNCFOLDSETTING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNHALFFOLDSETTING);
					if(opt != NULL){
						AddSaveData(ID_CNHALFFOLDSETTING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNACCORDIONZFOLDSETTING);
					if(opt != NULL){
						AddSaveData(ID_CNACCORDIONZFOLDSETTING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNDOUBLEPARALLELFOLDSETTING);
					if(opt != NULL){
						AddSaveData(ID_CNDOUBLEPARALLELFOLDSETTING, top_widget);
						memFree(opt);
					}
				}else if(tmp == ID_CNSADDLESETTING){
					opt = GetOptionList(g_cngplp_data, ID_CNVFOLDING);
					if(opt != NULL){
						AddSaveData(ID_CNVFOLDING, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNSADDLESTITCH);
					if(opt != NULL){
						AddSaveData(ID_CNSADDLESTITCH, top_widget);
						memFree(opt);
					}
					opt = GetOptionList(g_cngplp_data, ID_CNTRIMMING);
					if(opt != NULL){
						AddSaveData(ID_CNTRIMMING, top_widget);
						memFree(opt);
					}
				}else{
					TopWidgetSaveData* data = (TopWidgetSaveData*)malloc(sizeof(TopWidgetSaveData));
					if(data != NULL){
						memset(data, 0, sizeof(TopWidgetSaveData));
						data->id = GetModID(id);
					}
					if(top_widget != NULL){
						if(0 != strcmp(top_widget->name, special->name)){
							TopWidgetSaveData* prop_data = (TopWidgetSaveData*)malloc(sizeof(TopWidgetSaveData));
							if(prop_data != NULL){
								memset(prop_data, 0, sizeof(TopWidgetSaveData));
								prop_data->id = GetModID(id);
							}
							if(prop_topwidget != NULL){
								prop_topwidget->save_data = g_list_append(prop_topwidget->save_data, prop_data);
							}
						}
						top_widget->save_data = g_list_append(top_widget->save_data, data);
					}
					break;
				}
			}
		}
		widget_info = widget_info->next;
	}
}
示例#2
0
文件: dxsmp.c 项目: albinoz/raine
void read_dx_file() {
  int i,err;
  char buff[80];
  unzFile dat;
  UINT8 *buffer;
  unz_file_info file_info;
/*   int start,end; */
/*   short *src; */

  if (!dx_file[0])
    return;
  if (raine_nb_samples && emudx_samples && sample_data) {
    return;
  }

  dat = unzOpen(dx_file);
  if (!dat) return;
  for (raine_nb_samples=1; raine_nb_samples<32; raine_nb_samples++) {
    sprintf(buff,"%d.wav",raine_nb_samples);
    err = unzLocateFile(dat,buff,2);
    if (err != UNZ_OK)
      break;
  }
  raine_nb_samples--;

  emudx_samples = (struct wave_spec*)AllocateMem((raine_nb_samples+1) * sizeof(struct wave_spec));
  AddSaveData(ASCII_ID('S','A','M','P'),
	      (UINT8*)emudx_samples,
	      (raine_nb_samples+1) * sizeof(struct wave_spec));

  sample_data = (struct private_data*)AllocateMem((raine_nb_samples+1)*sizeof(struct private_data));
  for (i=1; i<=raine_nb_samples; i++) {
    sprintf(buff,"%d.wav",i);
    unzLocateFile(dat,buff,2);

    err = unzOpenCurrentFile(dat);
    unzGetCurrentFileInfo(dat,&file_info,NULL,0,NULL,0,NULL,0);
    buffer = malloc(file_info.uncompressed_size);
    unzReadCurrentFile(dat,buffer,file_info.uncompressed_size);
    emudx_samples[i].pos = emudx_samples[i].playing = 0;
#ifdef SDL
  SDL_RWops *rw;
  unsigned int len_in_bytes;
  SDL_AudioCVT  wav_cvt;
  SDL_AudioSpec wave;
  UINT8 *wav_buffer;
    extern SDL_AudioSpec gotspec;
    if (!gotspec.freq) {
	/* Now read_dx_file is called before the soundcard init, so we
	 * must put sensible default values here... */
	gotspec.freq = audio_sample_rate;
	gotspec.channels = 2;
	gotspec.format = AUDIO_S16;
    }
    rw = SDL_RWFromMem(buffer, file_info.uncompressed_size);
    if (!SDL_LoadWAV_RW(rw,1,&wave,&wav_buffer,&len_in_bytes)) {
      printf("couldn't load sample %d: %s\n",i,SDL_GetError());
      exit(1);
    }
    unzCloseCurrentFile(dat);	// Is this needed when open failed?

    if (SDL_BuildAudioCVT(&wav_cvt,
			  wave.format, wave.channels, wave.freq,
			  gotspec.format, gotspec.channels,gotspec.freq) == -1) {
      printf("can't build converter\n");
      exit(1);
    }

    wav_cvt.buf = sample_data[i].data = AllocateMem(len_in_bytes*wav_cvt.len_mult);
    sample_data[i].len =len_in_bytes*wav_cvt.len_ratio;
    wav_cvt.len = len_in_bytes;
    memcpy(sample_data[i].data, wav_buffer, len_in_bytes);
    SDL_FreeWAV(wav_buffer);

    SDL_ConvertAudio(&wav_cvt);
#else
    convert_wav((char*)buffer,file_info.uncompressed_size,
	    (char**)&sample_data[i].data,&sample_data[i].len);
#endif
    free(buffer);
  }
  unzClose(dat);
}