diff options
Diffstat (limited to 'src/main/printers.c')
-rw-r--r-- | src/main/printers.c | 174 |
1 files changed, 55 insertions, 119 deletions
diff --git a/src/main/printers.c b/src/main/printers.c index 4cb0bc8..8df5ea9 100644 --- a/src/main/printers.c +++ b/src/main/printers.c @@ -1,5 +1,5 @@ /* - * "$Id: printers.c,v 1.83 2008/01/21 23:34:25 rlk Exp $" + * "$Id: printers.c,v 1.85 2008/06/03 11:40:39 rlk Exp $" * * Print plug-in driver utility functions for the GIMP. * @@ -288,7 +288,7 @@ stp_printer_describe_parameter(const stp_vars_t *v, const char *name, } static void -set_printer_defaults(stp_vars_t *v, int core_only) +set_printer_defaults(stp_vars_t *v, int core_only, int soft) { stp_parameter_list_t *params; int count; @@ -306,32 +306,60 @@ set_printer_defaults(stp_vars_t *v, int core_only) switch (p->p_type) { case STP_PARAMETER_TYPE_STRING_LIST: - stp_set_string_parameter(v, p->name, desc.deflt.str); - stp_set_string_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + if (!soft || + !stp_check_string_parameter(v, p->name, STP_PARAMETER_DEFAULTED)) + { + stp_set_string_parameter(v, p->name, desc.deflt.str); + stp_set_string_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + } break; case STP_PARAMETER_TYPE_DOUBLE: - stp_set_float_parameter(v, p->name, desc.deflt.dbl); - stp_set_float_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + if (!soft || + !stp_check_float_parameter(v, p->name, STP_PARAMETER_DEFAULTED)) + { + stp_set_float_parameter(v, p->name, desc.deflt.dbl); + stp_set_float_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + } break; case STP_PARAMETER_TYPE_INT: - stp_set_int_parameter(v, p->name, desc.deflt.integer); - stp_set_int_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + if (!soft || + !stp_check_int_parameter(v, p->name, STP_PARAMETER_DEFAULTED)) + { + stp_set_int_parameter(v, p->name, desc.deflt.integer); + stp_set_int_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + } break; case STP_PARAMETER_TYPE_DIMENSION: - stp_set_dimension_parameter(v, p->name, desc.deflt.dimension); - stp_set_dimension_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + if (!soft || + !stp_check_dimension_parameter(v, p->name, STP_PARAMETER_DEFAULTED)) + { + stp_set_dimension_parameter(v, p->name, desc.deflt.dimension); + stp_set_dimension_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + } break; case STP_PARAMETER_TYPE_BOOLEAN: - stp_set_boolean_parameter(v, p->name, desc.deflt.boolean); - stp_set_boolean_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + if (!soft || + !stp_check_boolean_parameter(v, p->name, STP_PARAMETER_DEFAULTED)) + { + stp_set_boolean_parameter(v, p->name, desc.deflt.boolean); + stp_set_boolean_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + } break; case STP_PARAMETER_TYPE_CURVE: - stp_set_curve_parameter(v, p->name, desc.deflt.curve); - stp_set_curve_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + if (!soft || + !stp_check_curve_parameter(v, p->name, STP_PARAMETER_DEFAULTED)) + { + stp_set_curve_parameter(v, p->name, desc.deflt.curve); + stp_set_curve_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + } break; case STP_PARAMETER_TYPE_ARRAY: - stp_set_array_parameter(v, p->name, desc.deflt.array); - stp_set_array_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + if (!soft || + !stp_check_array_parameter(v, p->name, STP_PARAMETER_DEFAULTED)) + { + stp_set_array_parameter(v, p->name, desc.deflt.array); + stp_set_array_parameter_active(v, p->name, STP_PARAMETER_ACTIVE); + } break; default: break; @@ -346,7 +374,14 @@ void stp_set_printer_defaults(stp_vars_t *v, const stp_printer_t *printer) { stp_set_driver(v, stp_printer_get_driver(printer)); - set_printer_defaults(v, 0); + set_printer_defaults(v, 0, 0); +} + +void +stp_set_printer_defaults_soft(stp_vars_t *v, const stp_printer_t *printer) +{ + stp_set_driver(v, stp_printer_get_driver(printer)); + set_printer_defaults(v, 0, 1); } void @@ -368,7 +403,7 @@ stp_printer_get_defaults(const stp_printer_t *printer) { stp_printer_t *nc_printer = (stp_printer_t *) printer; stp_deprintf(STP_DBG_PRINTERS, " ==>init %s\n", printer->driver); - set_printer_defaults (nc_printer->printvars, 1); + set_printer_defaults (nc_printer->printvars, 1, 0); nc_printer->vars_initialized = 1; } return printer->printvars; @@ -939,105 +974,6 @@ stp_family_unregister(stp_list_t *family) return 0; } -static void -stp_fill_printvars_from_xmltree(stp_mxml_node_t *prop, - stp_vars_t *v) -{ - while (prop) - { - if (prop->type == STP_MXML_ELEMENT) - { - const char *prop_name = prop->value.element.name; - if (!strcmp(prop_name, "parameter")) - { - const char *p_type = stp_mxmlElementGetAttr(prop, "type"); - const char *p_name = stp_mxmlElementGetAttr(prop, "name"); - stp_mxml_node_t *child = prop->child; - if (!p_type || !p_name) - stp_erprintf("Bad property found!\n"); - else if (strcmp(p_type, "float") == 0) - { - if (child->type == STP_MXML_TEXT) - { - stp_set_float_parameter - (v, p_name, stp_xmlstrtod(child->value.text.string)); - stp_deprintf(STP_DBG_XML, " Set float '%s' to '%s' (%f)\n", - p_name, child->value.text.string, - stp_get_float_parameter(v, p_name)); - } - } - else if (strcmp(p_type, "integer") == 0) - { - if (child->type == STP_MXML_TEXT) - { - stp_set_int_parameter - (v, p_name, (int) stp_xmlstrtol(child->value.text.string)); - stp_deprintf(STP_DBG_XML, " Set int '%s' to '%s' (%d)\n", - p_name, child->value.text.string, - stp_get_int_parameter(v, p_name)); - } - } - else if (strcmp(p_type, "boolean") == 0) - { - if (child->type == STP_MXML_TEXT) - { - stp_set_boolean_parameter - (v, p_name, (int) stp_xmlstrtol(child->value.text.string)); - stp_deprintf(STP_DBG_XML, " Set bool '%s' to '%s' (%d)\n", - p_name, child->value.text.string, - stp_get_boolean_parameter(v, p_name)); - } - } - else if (strcmp(p_type, "string") == 0) - { - if (child->type == STP_MXML_TEXT) - { - stp_set_string_parameter - (v, p_name, child->value.text.string); - stp_deprintf(STP_DBG_XML, " Set string '%s' to '%s' (%s)\n", - p_name, child->value.text.string, - stp_get_string_parameter(v, p_name)); - } - } - else if (strcmp(p_type, "curve") == 0) - { - stp_curve_t *curve; - while (child->type == STP_MXML_TEXT && child->next) - child = child->next; - curve = stp_curve_create_from_xmltree(child); - if (curve) - { - stp_set_curve_parameter(v, p_name, curve); - stp_deprintf(STP_DBG_XML, " Set curve '%s' to '%s' (%s)\n", - p_name, child->value.text.string, - stp_curve_write_string(curve)); - stp_curve_destroy(curve); - } - } - else if (strcmp(p_type, "array") == 0) - { - stp_array_t *array; - while (child->type == STP_MXML_TEXT && child->next) - child = child->next; - array = stp_array_create_from_xmltree(child); - if (array) - { - stp_set_array_parameter(v, p_name, array); - stp_deprintf(STP_DBG_XML, " Set array '%s' to '%s'\n", - p_name, child->value.text.string); - stp_array_destroy(array); - } - } - else - { - stp_erprintf("Bad property %s type %s\n", p_name, p_type); - } - } - } - prop = prop->next; - } -} - static stp_printvars_t * stp_printvars_create_from_xmltree(stp_mxml_node_t *printer, const char *family) @@ -1070,7 +1006,7 @@ stp_printvars_create_from_xmltree(stp_mxml_node_t *printer, prop = printer->child; stp_deprintf(STP_DBG_XML, ">>stp_printvars_create_from_xmltree: %p, %s\n", (void *) (outprintvars->printvars), outprintvars->name); - stp_fill_printvars_from_xmltree(prop, outprintvars->printvars); + stp_vars_fill_from_xmltree(prop, outprintvars->printvars); stp_deprintf(STP_DBG_XML, "<<stp_printvars_create_from_xmltree: %p, %s\n", (void *) (outprintvars->printvars), outprintvars->name); return outprintvars; @@ -1127,7 +1063,7 @@ stp_printer_create_from_xmltree(stp_mxml_node_t *printer, /* The printer node */ outprinter->printfuncs = printfuncs; prop = printer->child; - stp_fill_printvars_from_xmltree(prop, outprinter->printvars); + stp_vars_fill_from_xmltree(prop, outprinter->printvars); if (driver && long_name && printfuncs) { if (stp_get_debug_level() & STP_DBG_XML) |