Check whether a resolution has been set in GtkPrintSettings

If resolution has not been set then use default resolution from ppd.

https://bugzilla.gnome.org/show_bug.cgi?id=635254
This commit is contained in:
Marek Kasik 2010-11-19 10:55:25 +01:00 committed by Matthias Clasen
parent 1876823ef0
commit 9a0700e20c

View File

@ -4091,23 +4091,29 @@ set_option_from_settings (GtkPrinterOption *option,
gtk_printer_option_set (option, cups_value); gtk_printer_option_set (option, cups_value);
else else
{ {
int res = gtk_print_settings_get_resolution (settings); if (gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION, -1) != -1 ||
int res_x = gtk_print_settings_get_resolution_x (settings); gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION_X, -1) != -1 ||
int res_y = gtk_print_settings_get_resolution_y (settings); gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION_Y, -1) != -1 ||
option->value == NULL || option->value[0] == '\0')
if (res_x != res_y)
{
value = g_strdup_printf ("%dx%ddpi", res_x, res_y);
gtk_printer_option_set (option, value);
g_free (value);
}
else if (res != 0)
{ {
value = g_strdup_printf ("%ddpi", res); int res = gtk_print_settings_get_resolution (settings);
gtk_printer_option_set (option, value); int res_x = gtk_print_settings_get_resolution_x (settings);
g_free (value); int res_y = gtk_print_settings_get_resolution_y (settings);
}
} if (res_x != res_y)
{
value = g_strdup_printf ("%dx%ddpi", res_x, res_y);
gtk_printer_option_set (option, value);
g_free (value);
}
else if (res != 0)
{
value = g_strdup_printf ("%ddpi", res);
gtk_printer_option_set (option, value);
g_free (value);
}
}
}
} }
else if (strcmp (option->name, "gtk-paper-type") == 0) else if (strcmp (option->name, "gtk-paper-type") == 0)
map_settings_to_option (option, media_type_map, G_N_ELEMENTS (media_type_map), map_settings_to_option (option, media_type_map, G_N_ELEMENTS (media_type_map),