Ejemplo n.º 1
0
void SaveTopWidgetData(const char *dlg_name)
{
	const int top_widget_num = g_list_length(g_topwidget_list);
	int i = 0;
	TopWidget* top_widget = NULL, *found = NULL;
	char *option = NULL;
	UIItemsList *tmp;
	const PPDOptions *ppd_opt = NULL;
	if(g_cngplp_data != NULL){
		ppd_opt = g_cngplp_data->ppd_opt;
	}

	for(; i < top_widget_num; i++){
		top_widget = (TopWidget*)g_list_nth_data(g_topwidget_list, i);
		if(top_widget != NULL){
			if(!strcmp(dlg_name, top_widget->name)){
				found = top_widget;
				break;
			}
		}
	}
	i = 0;
	if(found != NULL){
		const int len = g_list_length(found->save_data);
		TopWidgetSaveData* data = NULL;
		char *value;
		for(; i < len; i++){
			data = g_list_nth_data(found->save_data, i);
			if((data != NULL) && (data->key_value != NULL)){
				free(data->key_value);
				data->key_value = NULL;
			}
			if(data != NULL){
				option = IDtoPPDOption(data->id - 1);
			}
			if(NULL == option){
				if((ID_NUMBER_UP == data->id) || (ID_JOB_SHEETS_START == data->id) || (ID_JOB_SHEETS_END == data->id) || (ID_BOOKLET_DLG == data->id)){
					value = GetCurrOpt(g_cngplp_data, data->id, NULL);
				}else{
					value = GetOptionList(g_cngplp_data, data->id);
				}
				data->key_value = value;
			}else{
				tmp = ppd_opt->items_list;
				while(tmp->current_option != NULL){
					if(strcmp(option, tmp->name) == 0){
						data->key_value = strdup(tmp->current_option->name);
						break;
					}
					if(tmp->next == NULL){
						break;
					}
					tmp = tmp->next;
				}
			}
		}
	}
}
Ejemplo n.º 2
0
void SetTextview(const WidgetInfo* widget_info)
{
	char *text = NULL;
	PropInfo *property = NULL;
	int id = -1;

	if(widget_info != NULL){
		property = FindProperty(widget_info->prop_list, "text");
	}
	if(property != NULL){
		id = GetModID(property->id);
		if(id != -1){
			text = GetOptionList(g_cngplp_data, id);
			if(text != NULL){
				SetTextofTextView(widget_info->name, text, -1);
				memFree(text);
			}
		}
	}
}
Ejemplo n.º 3
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;
	}
}
Ejemplo n.º 4
0
void DealIDFunctions(const FuncInfo* func, int id)
{
	const char *key;
	KeyInfo *key_info = NULL;
	FuncInfo *findfunc = NULL;
	FuncInfo *curr = NULL;
	WidgetInfo* widget_info = NULL;

	if((ID_CNZFOLDING == id) || (ID_CNCFOLDING == id) || (ID_CNHALFFOLDING == id) || (ID_CNACCORDIONZFOLDING == id) || (ID_CNDOUBLEPARALLELFOLDING == id)){
		id = ID_CNFOLDSETTING;
	}
	if((ID_CNCFOLDSETTING == id) || (ID_CNHALFFOLDSETTING == id) || (ID_CNACCORDIONZFOLDSETTING == id) || (ID_CNDOUBLEPARALLELFOLDSETTING == id)){
		id = ID_CNFOLDDETAIL;
	}
	if((ID_CNVFOLDING == id) || (ID_CNVFOLDINGTRIMMING == id) || (ID_CNSADDLESTITCH == id) || (ID_CNTRIMMING == id)){
		id = ID_CNSADDLESETTING;
	}
	if((ID_DUPLEX == id) || (ID_BOOKLET == id)){
		id = ID_CNPRINTSTYLE;
	}
	if(ID_BOOKLET_DLG == id){
		return;
	}
	key = GetModStringID(id);

	if(key == NULL){
		return;
	}
	while(func != NULL){
		key_info = func->func_id;
		while(key_info != NULL){
			if(key_info->name != NULL){
				if(strcmp(key, key_info->name) == 0){
					if(findfunc == NULL){
						findfunc = (FuncInfo *)malloc(sizeof(FuncInfo));
						if(findfunc == NULL){
							return;
						}
						memset(findfunc, 0, sizeof(FuncInfo));
						memcpy(findfunc, func, sizeof(FuncInfo));
						curr = findfunc;
						curr->next = NULL;
					}else{
						if(curr != NULL){
							while(curr->next != NULL){
								curr = curr->next;
							}
						}
						if(curr != NULL){
							curr->next = (FuncInfo *)malloc(sizeof(FuncInfo));
						}
						if(curr->next == NULL){
							return;
						}
						memset(curr->next, 0, sizeof(FuncInfo));
						memcpy(curr->next, func, sizeof(FuncInfo));
						curr->next->next = NULL;
					}
				}
			}
			key_info = key_info->next;
		}
		func = func->next;
	}
	if(findfunc == NULL){
		return;
	}
	if(findfunc->next == NULL){
		widget_info = findfunc->widget_list;
		while(widget_info != NULL){
			if(widget_info->type != NULL){
				if(strcmp(widget_info->type, "combo") == 0){
					UpdateCpcaComboWidget(id, widget_info->name);
				}else if(strcmp(widget_info->type, "checkbutton") == 0){
					SetCpcaWidgetSensitive(id, widget_info->name);
				}else if(strcmp(widget_info->type, "radiobutton") == 0){
					int disable = GetCurrDisable(id, NULL);
					if(disable != -1){
						disable = (disable > 0) ? 0 : 1;
						SetWidgetSensitive(widget_info->name, disable);
					}
				}else if(strcmp(widget_info->type, "spinbutton") == 0){
					SetSpinButtonValue(widget_info);
				}else if(strcmp(widget_info->type, "entry") == 0){
					SetEntryText(widget_info);
				}else if(strcmp(widget_info->type, "textview") == 0){
					SetTextview(widget_info);
				}
			}
			if(widget_info->func != NULL){
				WidgetInformation *lib = g_widget_table;
				while(lib->widget_name != NULL){
					if(strcmp(widget_info->type, lib->widget_name) == 0){
						lib->SpecialFunction(g_cngplp_data, widget_info->name);
						break;
					}
					lib++;
				}
			}
			widget_info = widget_info->next;
		}
		if(findfunc->conflict_list != NULL){
			UpdateFunctionWidget(findfunc->conflict_list);
		}
		MemFree(findfunc);
	}else{
		while(findfunc != NULL){
			widget_info = findfunc->widget_list;
			char *plist;
			char *list = GetOptionList(g_cngplp_data, id);
			int disable = 0;
			plist = strstr(list, findfunc->func_id->value);
			if(plist != NULL){
				char *ptr;
				ptr = strchr(plist, '<');
				if(ptr != NULL){
					ptr++;
					disable = atoi(ptr);
				}
			}
			MemFree(list);
			disable = (disable > 0) ? 0 : 1;
			SetWidgetSensitive(widget_info->name, disable);
			if(findfunc->conflict_list != NULL){
				UpdateFunctionWidget(findfunc->conflict_list);
			}
			curr = findfunc;
			findfunc = findfunc->next;
			MemFree(curr);
		}
	}
	return;
}
Ejemplo n.º 5
0
char *GetData(const int id)
{
	return GetOptionList(g_cngplp_data, id);
}
Ejemplo n.º 6
0
int ExecJobMode()
{
	char *job;
	int print = 1;
	SpecialInfo* special = NULL;

	if(g_config_file_data != NULL){
		special = g_config_file_data->special_list;
	}
	job = GetCurrOpt(g_cngplp_data, ID_CNJOBEXECMODE, NULL);
	if(job != NULL){
		if(strcmp(job, "print") == 0){
			print = 1;
		}else if(strcmp(job, "store") == 0){
			print = 1;
		}else if(strcmp(job, "secured") == 0){
			if((g_cngplp_data != NULL) && (NULL == g_cngplp_data->file_name)){
				HideWidget("DocName_label");
				HideWidget("DocName_entry");
			}else{
				char *file = NULL;

				file = GetOptionList(g_cngplp_data, ID_SECURED_DOCNAME);
				ShowWidget("DocName_label");
				ShowWidget("DocName_entry");
				if(file != NULL){
					SetTextEntry("DocName_entry", file);
					free(file);
				}
			}
			ShowDialog("IdPassWdDlg", 1);
			while(special != NULL){
				if(0 == strcasecmp(special->name, "IdPassWdDlg")){
					if(!special->print){
						memFree(job);
						return 0;
					}
					break;
				}
				special = special->next;
			}
		}else if(strcmp(job, "hold") == 0){
			print = 1;
		}
		memFree(job);
	}

	const int special_func = GetCurrOptInt(ID_SPECIAL_FUNC, 0);
	if(special_func != 0){
		int job_account;
		int active_job;
		int is_color = 0;
		char *active_color;
		job_account = GetCurrOptInt(ID_JOBACCOUNT, 0);
		if(job_account != 0){
			active_job = GetCurrOptInt(ID_DISABLE_JOBACCOUNT_BW, 0);
			active_color = GetCurrOpt(g_cngplp_data, ID_CNCOLORMODE, NULL);
			if(active_color != NULL){
				if(strcmp(active_color, "mono") != 0){
					is_color = 1;
				}
				memFree(active_color);
			}
			if(!((active_job == 1) && (is_color == 0))){
				ShowWidget("JobAccountPassWD_label");
				ShowWidget("JobAccountPassWD_entry");
				ShowDialog("JobAccountDlg", 1);
				while(special != NULL){
					if(0 == strcasecmp(special->name, "JobAccountDlg")){
						if(!special->print){
							return 0;
						}else{
							return 1;
						}
					}
					special = special->next;
				}
			}
		}
	}

	return print;
}
Ejemplo n.º 7
0
gboolean FindKey(const KeyInfo *key, cngplpData *data)
{
	char *opt = NULL;
	gboolean found = FALSE;
	if(NULL == key){
		return FALSE;
	}
	const int id = GetModID(key->name);
	if(ID_RESOLUTION == id){
		UIItemsList *item = NULL;
		if((g_cngplp_data != NULL) && (g_cngplp_data->ppd_opt != NULL)){
			item = FindItemsList(g_cngplp_data->ppd_opt->items_list, "Resolution");
		}
		if(item != NULL){
			if(item->num_options > 1){
				return TRUE;
			}else{
				return FALSE;
			}
		}
	}else if(ID_CNFOLDDETAIL == id){
		char *folddetail = NULL;

		opt = GetCurrOpt(data, ID_CNCFOLDING, NULL);
		if(NULL != opt){
			folddetail = GetCurrOpt(data, ID_CNCFOLDSETTING, NULL);
			if(NULL != folddetail){
				memFree(opt);
				memFree(folddetail);
				return TRUE;
			}
		}
		opt = GetCurrOpt(data, ID_CNHALFFOLDING, NULL);
		if(NULL != opt){
			folddetail = GetCurrOpt(data, ID_CNHALFFOLDSETTING, NULL);
			if(NULL != folddetail){
				memFree(opt);
				memFree(folddetail);
				return TRUE;
			}
		}
		opt = GetCurrOpt(data, ID_CNACCORDIONZFOLDING, NULL);
		if(NULL != opt){
			folddetail = GetCurrOpt(data, ID_CNACCORDIONZFOLDSETTING, NULL);
			if(NULL != folddetail){
				memFree(opt);
				memFree(folddetail);
				return TRUE;
			}
		}
		opt = GetCurrOpt(data, ID_CNDOUBLEPARALLELFOLDING, NULL);
		if(NULL != opt){
			folddetail = GetCurrOpt(data, ID_CNDOUBLEPARALLELFOLDING, NULL);
			if(NULL != folddetail){
				memFree(opt);
				memFree(folddetail);
				return TRUE;
			}
		}
	}else{
		if(IDtoPPDOption(id - 1) != NULL){
			opt = GetCurrOpt(data, id, NULL);
		}else{
			opt = GetOptionList(data, id);
		}
	}
	if(NULL == opt){
		opt = GetCNUIValue(key->name);
		if(NULL == opt){
			return FALSE;
		}
	}

	if(NULL == key->value){
		found = TRUE;
	}else{
		if(NULL != key->type){
		 	if(0 == strcmp(key->type, "no")){
				if(strcmp(key->value, opt) != 0){
					found = TRUE;
				}
			}else if(0 == strcmp(key->type, "include")){
				MemFree(opt);
				opt = GetOptionList(data, id);
				if((opt != NULL) && (strstr(opt, key->value) != NULL)){
					found = TRUE;
				}
			}else if(0 == strcmp(key->type, "other")){
				int i = 0, j = 0, k = 0;
				char *option = NULL;
				UIItemsList *item = NULL;
				char *plist = NULL;
				char *list = key->value;

				plist = list;
				option = IDtoPPDOption(id -1);
				if((g_cngplp_data != NULL) && (g_cngplp_data->ppd_opt != NULL)){
					item = FindItemsList(g_cngplp_data->ppd_opt->items_list, option);
				}
				while(1){
					if(*plist == '\0'){
						i++;
						break;
					}
					if(*plist == ','){
						i++;
					}
					plist++;
				}
				if(item != NULL){
					UIOptionList *tmp = item->opt_lists;
					while(tmp != NULL){
						if(strstr(list, tmp->name) != NULL){
							j++;
							k++;
						}
						tmp = tmp->next;
					}
					if((i == j) && (i == k)){
						found = FALSE;
					}else{
						found = TRUE;
					}
				}
			}
		}else{
			if(0 == strcmp(key->value, opt)){
				found  = TRUE;
			}
		}
	}
	if(opt != NULL){
		free(opt);
		opt = NULL;
	}
	return found;
}