[gtk+/gtk-3-0] Check whether a resolution has been set in GtkPrintSettings



commit 3dde093b71b47e2512d74d6573af4c2eea54043e
Author: Marek Kasik <mkasik redhat com>
Date:   Fri Nov 19 10:55:25 2010 +0100

    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

 modules/printbackends/cups/gtkprintbackendcups.c |   36 +++++++++++++---------
 1 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/modules/printbackends/cups/gtkprintbackendcups.c b/modules/printbackends/cups/gtkprintbackendcups.c
index 614e752..2e1e1a9 100644
--- a/modules/printbackends/cups/gtkprintbackendcups.c
+++ b/modules/printbackends/cups/gtkprintbackendcups.c
@@ -4091,23 +4091,29 @@ set_option_from_settings (GtkPrinterOption *option,
 	gtk_printer_option_set (option, cups_value);
       else
 	{
-	  int res = gtk_print_settings_get_resolution (settings);
-	  int res_x = gtk_print_settings_get_resolution_x (settings);
-	  int res_y = gtk_print_settings_get_resolution_y (settings);
+	  if (gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION, -1) != -1 ||
+	      gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION_X, -1) != -1 ||
+	      gtk_print_settings_get_int_with_default (settings, GTK_PRINT_SETTINGS_RESOLUTION_Y, -1) != -1 ||
+	      option->value == NULL || option->value[0] == '\0')
+	    {
+              int res = gtk_print_settings_get_resolution (settings);
+              int res_x = gtk_print_settings_get_resolution_x (settings);
+              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);
+              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 (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)
     map_settings_to_option (option, media_type_map, G_N_ELEMENTS (media_type_map),



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]