Logo Search packages:      
Sourcecode: inkscape version File versions

void sp_export_xdpi_value_changed ( GtkAdjustment *  adj,
GtkObject *  base 
) [static]

A function to adjust the bitmap width when the xdpi value changes.

Parameters:
adj The adjustment that was changed
base The export dialog itself
The first thing this function checks is to see if we are doing an update. If we are, this function just returns because there is another instance of it that will handle everything for us. If there is a units change, we also assume that everyone is being updated appropriately and there is nothing for us to do.

If we're the highest level function, we set the update flag, and continue on our way.

All of the values are grabbed using the sp_export_value_get functions (call to the _pt ones for x0 and x1 but just standard for xdpi). The xdpi value is saved in the preferences for the next time the dialog is opened. (does the selection dpi need to be set here?)

A check is done to to ensure that we aren't outputing an invalid width, this is set by SP_EXPORT_MIN_SIZE. If that is the case the dpi is changed to make it valid.

After all of this the bitmap width is changed.

We also change the ydpi. This is a temporary hack as these can not currently be independent. This is likely to change in the future.

Definition at line 1562 of file export.cpp.

References sp_export_set_image_y(), sp_export_value_get(), sp_export_value_get_px(), and sp_export_value_set().

Referenced by sp_export_dialog().

{
    float x0, x1, xdpi, bmwidth;

    if (gtk_object_get_data (base, "update")) 
        return;
    
    if (sp_unit_selector_update_test ((SPUnitSelector *)gtk_object_get_data 
           (base, "units"))) {
       return;
    }
    
    gtk_object_set_data (base, "update", GUINT_TO_POINTER (TRUE));

    x0 = sp_export_value_get_px (base, "x0");
    x1 = sp_export_value_get_px (base, "x1");
    xdpi = sp_export_value_get (base, "xdpi");

    // remember xdpi setting
    prefs_set_double_attribute ("dialogs.export.defaultxdpi", "value", xdpi);

    bmwidth = (x1 - x0) * xdpi / DPI_BASE;

    if (bmwidth < SP_EXPORT_MIN_SIZE) {
        bmwidth = SP_EXPORT_MIN_SIZE;
        if (x1 != x0) 
            xdpi = bmwidth * DPI_BASE / (x1 - x0);
        else 
            xdpi = DPI_BASE;
        sp_export_value_set (base, "xdpi", xdpi);
    }

    sp_export_value_set (base, "bmwidth", bmwidth);

    sp_export_set_image_y (base);

    gtk_object_set_data (base, "update", GUINT_TO_POINTER (FALSE));

    return;
} // end of sp_export_xdpi_value_changed()


Generated by  Doxygen 1.6.0   Back to index