static gint gnome_print_fax_construct (GnomePrintContext *ctx) { GnomePrintFAX *fax; ArtDRect rect; gdouble dpix, dpiy; gboolean result; const GnomePrintUnit *unit; fax = GNOME_PRINT_FAX (ctx); fax->priv = g_new (GnomePrintFAXPrivate, 1); fax->priv->fax_encode_buffer_pivot = 7; fax->priv->first_code_of_doc = TRUE ; rect.x0 = 0.0; rect.y0 = 0.0; rect.x1 = 21.0 * 72.0 / 2.54; rect.y1 = 29.7 * 72.0 / 2.54; dpix = 198.0; dpiy = 198.0; if (gnome_print_config_get_length (ctx->config, GNOME_PRINT_KEY_PAPER_WIDTH, &rect.x1, &unit)) { gnome_print_convert_distance (&rect.x1, unit, GNOME_PRINT_PS_UNIT); } if (gnome_print_config_get_length (ctx->config, GNOME_PRINT_KEY_PAPER_HEIGHT, &rect.y1, &unit)) { gnome_print_convert_distance (&rect.x1, unit, GNOME_PRINT_PS_UNIT); } gnome_print_config_get_double (ctx->config, GNOME_PRINT_KEY_RESOLUTION_DPI_X, &dpix); gnome_print_config_get_double (ctx->config, GNOME_PRINT_KEY_RESOLUTION_DPI_Y, &dpiy); /* fixme: should rgbp_construct take settings as argument? */ /* telemaco : the fax driver need width=1728 pixels , the heigth is arbitrary .. usually heigth=2100 pixels . And the resolution we take it from gpa . */ if (!gnome_print_rgbp_construct (GNOME_PRINT_RGBP (fax), &rect, dpix, dpiy, 256)) return GNOME_PRINT_ERROR_UNKNOWN; result = gnome_print_context_create_transport (ctx); g_return_val_if_fail (result == GNOME_PRINT_OK, GNOME_PRINT_ERROR_UNKNOWN); result = gnome_print_transport_open (ctx->transport); g_return_val_if_fail (result == GNOME_PRINT_OK, GNOME_PRINT_ERROR_UNKNOWN); return GNOME_PRINT_OK; }
static VALUE gp_convert_distance(VALUE self, VALUE distance, VALUE to) { gboolean ret; gdouble dist = NUM2DBL(distance); VALUE result; ret = gnome_print_convert_distance(&dist, RVAL2GPU(self), RVAL2GPU(to)); if (ret) { result = rb_float_new(dist); } else { result = Qnil; } return result; }
/** * gnome_print_convert_distance_full: * @distance: The distance to convert, and the result on success * @from: Units to convert from * @to: Units to convert to * @ctmscale: The userspace scale to use * @devicescale: The device scale to use * * Convert a distance from one unit to another. You should supply a scale * as necessary. * * ctmscale is userspace->absolute, devicescale is device->absolute * * Returns: %TRUE if the conversion is possible, %FALSE if * it is not or on error **/ gboolean gnome_print_convert_distance_full (gdouble *distance, const GnomePrintUnit *from, const GnomePrintUnit *to, gdouble ctmscale, gdouble devicescale) { gdouble absolute; g_return_val_if_fail (distance != NULL, FALSE); g_return_val_if_fail (from != NULL, FALSE); g_return_val_if_fail (to != NULL, FALSE); if (from->base == to->base) return gnome_print_convert_distance (distance, from, to); if ((from->base == GNOME_PRINT_UNIT_DIMENSIONLESS) || (to->base == GNOME_PRINT_UNIT_DIMENSIONLESS)) { *distance = *distance * from->unittobase / to->unittobase; } switch (from->base) { case GNOME_PRINT_UNIT_ABSOLUTE: absolute = *distance * from->unittobase; break; case GNOME_PRINT_UNIT_DEVICE: if (devicescale) { absolute = *distance * from->unittobase * devicescale; } else { return FALSE; } break; case GNOME_PRINT_UNIT_USERSPACE: if (ctmscale) { absolute = *distance * from->unittobase * ctmscale; } else { return FALSE; } break; default: g_warning ("file %s: line %d: Illegal unit (base %d)", __FILE__, __LINE__, from->base); return FALSE; break; } switch (to->base) { case GNOME_PRINT_UNIT_DIMENSIONLESS: case GNOME_PRINT_UNIT_ABSOLUTE: *distance = absolute / to->unittobase; break; case GNOME_PRINT_UNIT_DEVICE: if (devicescale) { *distance = absolute / (to->unittobase * devicescale); } else { return FALSE; } break; case GNOME_PRINT_UNIT_USERSPACE: if (ctmscale) { *distance = absolute / (to->unittobase * ctmscale); } else { return FALSE; } break; default: g_warning ("file %s: line %d: Illegal unit (base %d)", __FILE__, __LINE__, to->base); return FALSE; break; } return TRUE; }