| @@ -1,97 +1,126 @@ | | | @@ -1,97 +1,126 @@ |
1 | $NetBSD: patch-ak,v 1.5 2012/01/29 10:56:44 drochner Exp $ | | 1 | $NetBSD: patch-ak,v 1.6 2012/02/01 18:23:05 drochner Exp $ |
2 | | | 2 | |
3 | revert upstream commit 8170436e61ea68c713d75ad374d22c3261be9203, | | 3 | gnome bug #543520 |
4 | it causes firefox crashes (see gnome bug #543520) | | | |
5 | | | 4 | |
6 | --- modules/printbackends/cups/gtkprintbackendcups.c.orig 2012-01-24 19:38:37.000000000 +0000 | | 5 | --- modules/printbackends/cups/gtkprintbackendcups.c.orig 2012-01-24 19:38:37.000000000 +0000 |
7 | +++ modules/printbackends/cups/gtkprintbackendcups.c | | 6 | +++ modules/printbackends/cups/gtkprintbackendcups.c |
8 | @@ -483,44 +483,22 @@ cups_print_cb (GtkPrintBackendCups *prin | | 7 | @@ -485,7 +485,7 @@ cups_print_cb (GtkPrintBackendCups *prin |
9 | GDK_THREADS_LEAVE (); | | | |
10 | } | | | |
11 | | | 8 | |
12 | -typedef struct { | | 9 | typedef struct { |
13 | - GtkCupsRequest *request; | | 10 | GtkCupsRequest *request; |
14 | - GtkPrinterOptionSet *options; | | 11 | - GtkPrinterOptionSet *options; |
15 | -} CupsOptionsData; | | 12 | + GtkPrinterCups *printer; |
16 | - | | 13 | } CupsOptionsData; |
| | | 14 | |
17 | static void | | 15 | static void |
18 | add_cups_options (const gchar *key, | | 16 | @@ -495,9 +495,13 @@ add_cups_options (const gchar *key, |
19 | const gchar *value, | | | |
20 | gpointer user_data) | | | |
21 | { | | 17 | { |
22 | - CupsOptionsData *data = (CupsOptionsData *) user_data; | | 18 | CupsOptionsData *data = (CupsOptionsData *) user_data; |
23 | - GtkCupsRequest *request = data->request; | | 19 | GtkCupsRequest *request = data->request; |
24 | - GtkPrinterOptionSet *options = data->options; | | 20 | - GtkPrinterOptionSet *options = data->options; |
25 | - GtkPrinterOption *option = NULL; | | 21 | - GtkPrinterOption *option = NULL; |
26 | - gchar *new_value = NULL; | | 22 | + GtkPrinterCups *printer = data->printer; |
27 | + GtkCupsRequest *request = user_data; | | 23 | + gboolean custom_value = FALSE; |
| | | 24 | gchar *new_value = NULL; |
| | | 25 | + gint i; |
| | | 26 | + |
| | | 27 | + if (!key || !value) |
| | | 28 | + return; |
28 | | | 29 | |
29 | if (!g_str_has_prefix (key, "cups-")) | | 30 | if (!g_str_has_prefix (key, "cups-")) |
30 | return; | | 31 | return; |
31 | | | 32 | @@ -505,17 +509,37 @@ add_cups_options (const gchar *key, |
32 | if (strcmp (value, "gtk-ignore-value") == 0) | | 33 | if (strcmp (value, "gtk-ignore-value") == 0) |
33 | return; | | 34 | return; |
34 | - | | 35 | |
35 | - option = gtk_printer_option_set_lookup (options, key); | | 36 | - option = gtk_printer_option_set_lookup (options, key); |
36 | | | 37 | - |
37 | key = key + strlen ("cups-"); | | 38 | key = key + strlen ("cups-"); |
38 | | | 39 | |
39 | - /* Add "Custom." prefix to custom values */ | | 40 | - /* Add "Custom." prefix to custom values */ |
40 | - if (value && option && | | 41 | - if (value && option && |
41 | - !gtk_printer_option_has_choice (option, value)) | | 42 | - !gtk_printer_option_has_choice (option, value)) |
42 | - new_value = g_strdup_printf ("Custom.%s", value); | | 43 | - new_value = g_strdup_printf ("Custom.%s", value); |
43 | - | | 44 | + if (printer && printer->ppd_file) |
44 | - if (new_value) | | 45 | + { |
45 | - { | | 46 | + ppd_coption_t *coption; |
46 | - gtk_cups_request_encode_option (request, key, new_value); | | 47 | + gboolean found = FALSE; |
47 | - g_free (new_value); | | 48 | + gboolean custom_values_enabled = FALSE; |
48 | - } | | 49 | + |
49 | - else | | 50 | + coption = ppdFindCustomOption (printer->ppd_file, key); |
50 | - gtk_cups_request_encode_option (request, key, value); | | 51 | + if (coption && coption->option) |
51 | + gtk_cups_request_encode_option (request, key, value); | | 52 | + { |
52 | } | | 53 | + for (i = 0; i < coption->option->num_choices; i++) |
| | | 54 | + { |
| | | 55 | + /* Are custom values enabled ? */ |
| | | 56 | + if (g_str_equal (coption->option->choices[i].choice, "Custom")) |
| | | 57 | + custom_values_enabled = TRUE; |
| | | 58 | + |
| | | 59 | + /* Is the value among available choices ? */ |
| | | 60 | + if (g_str_equal (coption->option->choices[i].choice, value)) |
| | | 61 | + found = TRUE; |
| | | 62 | + } |
| | | 63 | + |
| | | 64 | + if (custom_values_enabled && !found) |
| | | 65 | + custom_value = TRUE; |
| | | 66 | + } |
| | | 67 | + } |
53 | | | 68 | |
54 | static void | | 69 | - if (new_value) |
55 | @@ -533,12 +511,8 @@ gtk_print_backend_cups_print_stream (Gtk | | 70 | + /* Add "Custom." prefix to custom values. */ |
56 | { | | 71 | + if (custom_value) |
57 | GtkPrinterCups *cups_printer; | | 72 | { |
58 | CupsPrintStreamData *ps; | | 73 | + new_value = g_strdup_printf ("Custom.%s", value); |
59 | - CupsOptionsData *options_data; | | 74 | gtk_cups_request_encode_option (request, key, new_value); |
| | | 75 | g_free (new_value); |
| | | 76 | } |
| | | 77 | @@ -536,9 +560,6 @@ gtk_print_backend_cups_print_stream (Gtk |
| | | 78 | CupsOptionsData *options_data; |
60 | GtkCupsRequest *request; | | 79 | GtkCupsRequest *request; |
61 | GtkPrintSettings *settings; | | 80 | GtkPrintSettings *settings; |
62 | - GtkPrinterOptionSet *options; | | 81 | - GtkPrinterOptionSet *options; |
63 | - GtkPrintCapabilities capabilities; | | 82 | - GtkPrintCapabilities capabilities; |
64 | - GtkPageSetup *page_setup; | | 83 | - GtkPageSetup *page_setup; |
65 | const gchar *title; | | 84 | const gchar *title; |
66 | char printer_absolute_uri[HTTP_MAX_URI]; | | 85 | char printer_absolute_uri[HTTP_MAX_URI]; |
67 | | | 86 | |
68 | @@ -547,8 +521,6 @@ gtk_print_backend_cups_print_stream (Gtk | | 87 | @@ -547,8 +568,6 @@ gtk_print_backend_cups_print_stream (Gtk |
69 | | | 88 | |
70 | cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job)); | | 89 | cups_printer = GTK_PRINTER_CUPS (gtk_print_job_get_printer (job)); |
71 | settings = gtk_print_job_get_settings (job); | | 90 | settings = gtk_print_job_get_settings (job); |
72 | - capabilities = cups_printer_get_capabilities (GTK_PRINTER (cups_printer)); | | 91 | - capabilities = cups_printer_get_capabilities (GTK_PRINTER (cups_printer)); |
73 | - page_setup = gtk_printer_get_default_page_size (GTK_PRINTER (cups_printer)); | | 92 | - page_setup = gtk_printer_get_default_page_size (GTK_PRINTER (cups_printer)); |
74 | | | 93 | |
75 | request = gtk_cups_request_new_with_username (NULL, | | 94 | request = gtk_cups_request_new_with_username (NULL, |
76 | GTK_CUPS_POST, | | 95 | GTK_CUPS_POST, |
77 | @@ -586,18 +558,8 @@ gtk_print_backend_cups_print_stream (Gtk | | 96 | @@ -586,16 +605,10 @@ gtk_print_backend_cups_print_stream (Gtk |
78 | IPP_TAG_NAME, "job-name", | | 97 | IPP_TAG_NAME, "job-name", |
79 | NULL, title); | | 98 | NULL, title); |
80 | | | 99 | |
81 | - options = cups_printer_get_options (GTK_PRINTER (cups_printer), settings, page_setup, capabilities); | | 100 | - options = cups_printer_get_options (GTK_PRINTER (cups_printer), settings, page_setup, capabilities); |
82 | - | | 101 | - |
83 | - options_data = g_new0 (CupsOptionsData, 1); | | 102 | options_data = g_new0 (CupsOptionsData, 1); |
84 | - options_data->request = request; | | 103 | options_data->request = request; |
85 | - options_data->options = options; | | 104 | - options_data->options = options; |
86 | - | | 105 | - |
87 | - gtk_print_settings_foreach (settings, add_cups_options, options_data); | | 106 | + options_data->printer = cups_printer; |
| | | 107 | gtk_print_settings_foreach (settings, add_cups_options, options_data); |
88 | - | | 108 | - |
89 | - g_object_unref (page_setup); | | 109 | - g_object_unref (page_setup); |
90 | - g_object_unref (options); | | 110 | - g_object_unref (options); |
91 | - g_free (options_data); | | 111 | g_free (options_data); |
92 | - | | 112 | |
93 | + gtk_print_settings_foreach (settings, add_cups_options, request); | | | |
94 | + | | | |
95 | ps = g_new0 (CupsPrintStreamData, 1); | | 113 | ps = g_new0 (CupsPrintStreamData, 1); |
96 | ps->callback = callback; | | 114 | @@ -4606,7 +4619,12 @@ cups_printer_get_default_page_size (GtkP |
97 | ps->user_data = user_data; | | 115 | return NULL; |
| | | 116 | |
| | | 117 | option = ppdFindOption (ppd_file, "PageSize"); |
| | | 118 | + if (option == NULL) |
| | | 119 | + return NULL; |
| | | 120 | + |
| | | 121 | size = ppdPageSize (ppd_file, option->defchoice); |
| | | 122 | + if (size == NULL) |
| | | 123 | + return NULL; |
| | | 124 | |
| | | 125 | return create_page_setup (ppd_file, size); |
| | | 126 | } |