void CheckbuttonSpecialFunction(cngplpData* data, const char *widget_name) { if(0 == strcmp(widget_name, "CreepUse_checkbutton")){ char *opt = NULL, *opt1 = NULL; SetWidgetSensitive("hbox82", FALSE); opt = GetCurrOpt(data, ID_CNDISPLACEMENTCORRECTION, NULL); if(opt != NULL){ if(0 == strcasecmp(opt, "Manual")){ opt1 = GetCurrOpt(data, ID_CNCREEP, NULL); if(opt1 != NULL){ if(0 == strcmp(opt1, "True")){ SetWidgetSensitive("hbox82", TRUE); } memFree(opt1); } } memFree(opt); } } if((0 == strcmp(widget_name, "JobAccouting_checkbutton")) || (0 == strcmp(widget_name, "DisableJobAccountingBW_checkbutton"))){ int user_id; gboolean active; gboolean active1; gboolean enable; user_id = GetCurrOptInt(ID_USERID, DEFAULT_USERID); enable = (user_id == 0) ? TRUE : FALSE; if(GetCurrOptInt(ID_SPECIAL_FUNC, 0) != 0){ active = GetCurrOptInt(ID_JOBACCOUNT, 0); SetActiveCheckButton("JobAccouting_checkbutton", active); if(active != FALSE){ active1 = GetCurrOptInt(ID_DISABLE_JOBACCOUNT_BW, 0); SetActiveCheckButton("DisableJobAccountingBW_checkbutton", active1); }else{ UpdateDataInt(ID_DISABLE_JOBACCOUNT_BW, 0); } SetWidgetSensitive("DisableJobAccountingBW_checkbutton", active); SetWidgetSensitive("AllowPasswd_checkbutton", active); SetWidgetSensitive("JobAccount_button", active); if(FALSE == active){ SetActiveCheckButton("DisableJobAccountingBW_checkbutton", active); SetActiveCheckButton("AllowPasswd_checkbutton", active); } } if(FALSE == enable){ SetWidgetSensitive("JobAccouting_checkbutton", enable); SetWidgetSensitive("DisableJobAccountingBW_checkbutton", enable); SetWidgetSensitive("AllowPasswd_checkbutton", enable); SetWidgetSensitive("JobAccount_button", enable); } } }
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; } } } } }
void ShowDialog(const char *dialog, const int print) { GtkWidget *widget = NULL, *parent = NULL; char *str = NULL; SpecialInfo* special = NULL; char* printer_name = NULL; widget = glade_xml_get_widget(g_cngplp_xml, dialog); if(NULL == widget){ return; } SigDisable(); if(g_config_file_data != NULL){ special = g_config_file_data->special_list; } while(special != NULL){ if((1 == special->type) && (0 == strcasecmp(special->name, dialog))){ special->print = print; if(special->parent != NULL){ if(0 == strcasecmp(special->parent, g_main_dlg_name)){ str = cngplpGetData(g_cngplp_data, ID_PPD_OPTION); UpdateAllPPDWidgets(str); memFree(str); printer_name = GetCurrOpt(g_cngplp_data, ID_PRINTERNAME, NULL); gtk_window_set_title(GTK_WINDOW(widget), printer_name); memFree(printer_name); if(g_main_dlg != NULL){ gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(g_main_dlg)); } ChangeShowPage(0); }else{ UpdateTopWidget(dialog); parent = glade_xml_get_widget(g_cngplp_xml, special->parent); if(parent != NULL){ gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(parent)); } if((NULL == parent) && (g_main_dlg != NULL)){ gtk_window_set_transient_for(GTK_WINDOW(widget), GTK_WINDOW(g_main_dlg)); } } } if(!special->print){ if(special->conflict_list != NULL){ UpdateFunctionWidget(special->conflict_list); } } SaveTopWidgetData(dialog); gtk_widget_show(widget); break; } special = special->next; } SigEnable(); gtk_main(); }
void ComboSpecialFunction(cngplpData *data, const char *widget_name) { char *opt = NULL, *opt1 = NULL; if(0 == strcmp(widget_name, "SaddleSetting_combo")) { SetWidgetSensitive("TrimWidth_hbox", FALSE); opt = GetCurrOpt(data, ID_CNADJUSTTRIM, NULL); if(opt != NULL) { if(0 == strcasecmp(opt, "Manual")) { opt1 = GetCurrOpt(data, ID_CNTRIMMING, NULL); if(opt1 != NULL) { if(0 == strcmp(opt1, "True")) { SetWidgetSensitive("TrimWidth_hbox", TRUE); } memFree(opt1); } } memFree(opt); } } }
int GetCurrOptInt(const int id, const int def) { char *value; int num; value = GetCurrOpt(g_cngplp_data, id, NULL); if(value != NULL){ num = atoi(value); memFree(value); return num; }else{ return def; } }
int GetActive(const int id, const char *list) { char *active; int ret = 0; active = GetCurrOpt(g_cngplp_data, id, list); if(active != NULL){ if((strcasecmp(active, "False") == 0) || (strcasecmp(active, "None") == 0)){ ret = 0; }else if(strcasecmp(active, "True") == 0){ ret = 1; } free(active); } return ret; }
double GetCurrOptDouble(const int id, const double def) { char *value; double num; value = GetCurrOpt(g_cngplp_data, id, NULL); if(value != NULL){ setlocale (LC_NUMERIC, "C"); num = atof(value); setlocale (LC_NUMERIC, ""); memFree(value); return num; }else{ return def; } }
void on_button_clicked (GtkButton *button, gpointer user_data) { const ButtonData *data = (ButtonData *)user_data; if(data != NULL){ ConditionInfo *condition = data->condition; if(data->showdialog != NULL){ ShowDialog(data->showdialog, 0); }else{ while(condition != NULL){ char *method; method = GetCurrOpt(g_cngplp_data, data->id, NULL); if((method != NULL) && (strcmp(method, condition->name) == 0)){ ShowDialog(condition->widget, 0); free(method); break; } condition = condition->next; } } } }
void InitLabel(GladeXML *xml, cngplpData* data, const gpointer *widget) { WidgetInfo *widget_label = (WidgetInfo *)widget; if((widget_label != NULL) && (widget_label->name != NULL)){ PropInfo *prop_list = widget_label->prop_list; PropInfo *property = NULL; char label[LABEL_MAX]; const char *text = NULL; char *value = NULL; int def_int = 0; int max_int = 0; int min_int = 0; double def_double = 0.0; double max_double = 0.0; double min_double = 0.0; int max_sign = 0; int min_sign = 0; int digit = -1; int id; property = FindProperty(prop_list, "digit"); if(property != NULL){ if(property->id != NULL){ id = GetModID(property->id); if(-1 == id){ value = GetCNUIValue(property->id); }else{ value = GetCurrOpt(data, id, NULL); } if((value != NULL) && (0 == strcasecmp(value, "True"))){ digit = 1; }else{ digit = 0; } memFree(value); }else{ if(0 == strcmp(property->value, "int")){ digit = 0; } if(0 == strcmp(property->value, "double")){ digit = 1; } } } property = FindProperty(prop_list, "max"); if(property != NULL){ max_sign = 1; if(digit == 0){ def_int = atoi(property->def); id = GetModID(property->id); max_int = GetCurrOptInt(id, def_int); if((0 == max_int) && (0 < def_int)){ max_int = def_int; } }else{ def_double = atof(property->def); id = GetModID(property->id); max_double = GetCurrOptDouble(id, def_double); if((max_double < FLOAT_ZERO) && (def_double > FLOAT_ZERO)){ max_double = def_double; } } } property = FindProperty(prop_list, "min"); if(property != NULL){ min_sign = 1; if(digit == 0){ def_int = atoi(property->def); id = GetModID(property->id); min_int = GetCurrOptInt(id, def_int); }else{ def_double = atof(property->def); id = GetModID(property->id); min_double = GetCurrOptDouble(id, def_double); } } property = FindProperty(prop_list, "text"); if(property != NULL){ if(-1 == digit){ text = NameToTextByName(property->res); if(text != NULL){ SetTextToLabel(widget_label->name, text); } }else{ if(0 == digit){ if(property->value != NULL){ while(0 != strcmp(property->value, "int")){ property = FindProperty(property->next, "text"); if(NULL == property){ return; } } } if((1 == min_sign) && (1 == max_sign)){ text = NameToTextByName(property->res); if(text != NULL){ snprintf(label, LABEL_MAX - 1, text, min_int, max_int); SetTextToLabel(widget_label->name, label); } } if((1 == min_sign) && (0 == max_sign)){ text = NameToTextByName(property->res); if(text != NULL){ snprintf(label, LABEL_MAX - 1, text, min_int); SetTextToLabel(widget_label->name, label); } } if((0 == min_sign) && (1 == max_sign)){ text = NameToTextByName(property->res); if(text != NULL){ snprintf(label, LABEL_MAX - 1, text, max_int); SetTextToLabel(widget_label->name, label); } } } if(1 == digit){ if(property->value != NULL){ while(0 != strcmp(property->value, "double")){ property = FindProperty(property->next, "text"); if(NULL == property){ return; } } } if((1 == min_sign) && (1 == max_sign)){ text = NameToTextByName(property->res); if(text != NULL){ snprintf(label, LABEL_MAX - 1, text, min_double, max_double); SetTextToLabel(widget_label->name, label); } } if((1 == min_sign) && (0 == max_sign)){ text = NameToTextByName(property->res); if(text != NULL){ snprintf(label, LABEL_MAX - 1, text, min_double); SetTextToLabel(widget_label->name, label); } } if((0 == min_sign) && (1 == max_sign)){ text = NameToTextByName(property->res); if(text != NULL){ snprintf(label, LABEL_MAX - 1, text, max_double); SetTextToLabel(widget_label->name, label); } } } } } } }
char *GetData2(const int id) { return GetCurrOpt(g_cngplp_data, id, NULL); }
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; }
void UpdateFunctionWidget(const ConflictInfo *conflict_list) { GtkWidget *widget; const ConflictInfo *conflict = conflict_list; int id; char *curr = NULL; while(conflict != NULL){ char *type = conflict->type; WidgetInfo *update = conflict->update_list; if((conflict_list != NULL) && (conflict_list->widget != NULL)){ gboolean active; widget = glade_xml_get_widget(g_cngplp_xml, conflict_list->widget); active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); if(active == TRUE){ if(strcasecmp(conflict->value, "True") == 0){ while(update != NULL){ SetWidgetStatus(update); update = update->next; } } }else{ if(strcasecmp(conflict->value, "False") == 0){ while(update != NULL){ SetWidgetStatus(update); update = update->next; } } } }else{ id = GetModID(conflict->id); curr = GetCurrOpt(g_cngplp_data, id, NULL); if(NULL != curr){ if(type != NULL){ if(conflict->value != NULL){ if((strcasecmp(conflict->value, curr) != 0) && (strcasecmp(type, "no") == 0)){ while(update != NULL){ SetWidgetStatus(update); update = update->next; } } } }else if(conflict->value != NULL){ if(strcasecmp(conflict->value, curr) == 0){ while(update != NULL){ SetWidgetStatus(update); update = update->next; } } }else{ while(update != NULL){ SetWidgetStatus(update); update = update->next; } } }else{ if(type != NULL){ if((NULL == conflict->value) && (0 == strcasecmp(type, "no"))){ while(update != NULL){ SetWidgetStatus(update); update = update->next; } } } } memFree(curr); } conflict = conflict->next; } }
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; }