void InitCheckbutton(GladeXML *xml, cngplpData* data, const gpointer *widget) { WidgetInfo *widget_checkbutton = (WidgetInfo *)widget; PropInfo *prop_list = widget_checkbutton->prop_list; PropInfo *property = NULL; const char *text = NULL; if(prop_list != NULL){ property = FindProperty(prop_list, "text"); } if(property != NULL){ text = NameToTextByName(property->res); if(text != NULL){ SetButtonLabel(widget_checkbutton->name, text); } } }
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); } } } } } } }
void SetWidgetStatus(const WidgetInfo *widget_info) { GtkWidget *widget = NULL; gboolean value = TRUE; PropInfo *property = NULL; char *type = NULL; int id; if(widget_info != NULL){ widget = glade_xml_get_widget(g_cngplp_xml, widget_info->name); property = widget_info->prop_list; type = widget_info->type; } while(property != NULL){ if(property->value != NULL){ if(strcmp(property->value, "False") == 0){ value = FALSE; } if(strcmp(property->value, "True") == 0){ value = TRUE; } } if(strcmp(property->prop_name, "sensitive") == 0){ gtk_widget_set_sensitive(widget, value); } if(strcmp(property->prop_name, "toggled") == 0){ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), value); } if(strcmp(property->prop_name, "visible") == 0){ if(strcmp(property->value, "True") == 0){ gtk_widget_show(widget); } if(strcmp(property->value, "False") == 0){ gtk_widget_hide(widget); } } if(strcmp(property->prop_name, "text") == 0){ if(strcmp(type, "entry") == 0){ gtk_entry_set_text(GTK_ENTRY(widget), property->value); } if(strcmp(type, "label") == 0){ const char *text = NULL; text = NameToTextByName(property->res); if(text != NULL){ SetTextToLabel(widget_info->name, text); } } } if(strcmp(property->prop_name, "update") == 0){ if(strcmp(type, "combo") == 0){ id = GetModID(property->id); UpdateCpcaComboWidget(id, widget_info->name); } if(strcmp(type, "entry") == 0){ id = GetModID(property->id); UpdateEntryWidget(id, widget_info->name); } if(strcmp(type, "checkbutton") == 0){ id = GetModID(property->id); SetCpcaWidgetSensitive(id, widget_info->name); } } property = property->next; } }