[gtk/ebassi/for-master] cups: Disable deprecation warnings
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/ebassi/for-master] cups: Disable deprecation warnings
- Date: Fri, 17 Apr 2020 22:36:10 +0000 (UTC)
commit d690c81cabc1df04ef8bc33485b98d75841c1339
Author: Emmanuele Bassi <ebassi gnome org>
Date: Fri Apr 17 23:33:20 2020 +0100
cups: Disable deprecation warnings
It seems newer releases of CUPS removed the ability to disable
deprecation warnings by defining a pre-processor symbol, so we
have to resort to the usual begin/end ignore deprecation pragmas
to avoid a ton of deprecation warnings.
modules/printbackends/gtkprintbackendcups.c | 63 +++++++++++++++++++++++------
1 file changed, 51 insertions(+), 12 deletions(-)
---
diff --git a/modules/printbackends/gtkprintbackendcups.c b/modules/printbackends/gtkprintbackendcups.c
index fe182d2c95..aa2f0b9e6b 100644
--- a/modules/printbackends/gtkprintbackendcups.c
+++ b/modules/printbackends/gtkprintbackendcups.c
@@ -25,12 +25,6 @@
#include <stdlib.h>
#include <time.h>
-/* Cups 1.6 deprecates ppdFindAttr(), ppdFindCustomOption(),
- * ppdFirstCustomParam(), and ppdNextCustomParam() among others. This
- * turns off the warning so that it will compile.
- */
-#define _PPD_DEPRECATED
-
#include <cups/cups.h>
#include <cups/language.h>
#include <cups/http.h>
@@ -322,6 +316,11 @@ gtk_print_backend_cups_class_finalize (GtkPrintBackendCupsClass *class)
{
}
+/* Cups 1.6 deprecates ppdFindAttr(), ppdFindCustomOption(),
+ * ppdFirstCustomParam(), and ppdNextCustomParam() among others. This
+ * turns off the warning so that it will compile.
+ */
+
static gboolean
option_is_ipp_option (GtkPrinterOption *option)
{
@@ -396,6 +395,8 @@ cups_printer_create_cairo_surface (GtkPrinter *printer,
gchar *res_string = NULL;
gint level = 2;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
if (gtk_printer_accepts_pdf (printer))
surface = cairo_pdf_surface_create_for_stream (_cairo_write_to_cups, cache_io, width, height);
else
@@ -466,6 +467,8 @@ cups_printer_create_cairo_surface (GtkPrinter *printer,
2.0 * gtk_print_settings_get_printer_lpi (settings),
2.0 * gtk_print_settings_get_printer_lpi (settings));
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
return surface;
}
@@ -568,6 +571,8 @@ add_cups_options (const gchar *key,
key = key + strlen ("cups-");
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
if (printer && printer->ppd_file && !g_str_has_prefix (value, "Custom."))
{
ppd_coption_t *coption;
@@ -652,6 +657,8 @@ add_cups_options (const gchar *key,
}
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
/* Add "Custom." prefix to custom values if not already added. */
if (custom_value)
{
@@ -3809,11 +3816,15 @@ cups_request_ppd_cb (GtkPrintBackendCups *print_backend,
if (!gtk_cups_result_is_error (result))
{
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
/* let ppdOpenFd take over the ownership of the open file */
g_io_channel_seek_position (data->ppd_io, 0, G_SEEK_SET, NULL);
data->printer->ppd_file = ppdOpenFd (dup (g_io_channel_unix_get_fd (data->ppd_io)));
ppdLocalize (data->printer->ppd_file);
ppdMarkDefaults (data->printer->ppd_file);
+
+ G_GNUC_END_IGNORE_DEPRECATIONS
}
fstat (g_io_channel_unix_get_fd (data->ppd_io), &data_info);
@@ -4772,6 +4783,8 @@ available_choices (ppd_file_t *ppd,
}
}
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
for (i = ppd->num_consts, constraint = ppd->consts; i > 0; i--, constraint++)
{
option1 = ppdFindOption (ppd, constraint->option1);
@@ -4831,6 +4844,8 @@ available_choices (ppd_file_t *ppd,
}
}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
num_conflicts = 0;
all_default = TRUE;
for (j = 0; j < option->num_choices; j++)
@@ -4920,6 +4935,8 @@ create_pickone_option (ppd_file_t *ppd_file,
option = NULL;
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
n_choices = available_choices (ppd_file, ppd_option, &available, g_str_has_prefix (gtk_name, "gtk-"));
if (n_choices > 0)
{
@@ -5020,6 +5037,9 @@ create_pickone_option (ppd_file_t *ppd_file,
else
g_warning ("CUPS Backend: Ignoring pickone %s\n", ppd_option->text);
#endif
+
+G_GNUC_END_IGNORE_DEPRECATIONS
+
g_free (available);
return option;
@@ -5638,6 +5658,8 @@ cups_printer_get_options (GtkPrinter *printer,
ppd_option_t *ppd_option;
const gchar *ppd_name;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
ppdMarkDefaults (ppd_file);
paper_size = gtk_page_setup_get_paper_size (page_setup);
@@ -5675,6 +5697,7 @@ cups_printer_get_options (GtkPrinter *printer,
g_free (custom_name);
}
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
for (i = 0; i < ppd_file->num_groups; i++)
handle_group (set, ppd_file, &ppd_file->groups[i], &ppd_file->groups[i], settings);
@@ -5820,11 +5843,15 @@ mark_option_from_set (GtkPrinterOptionSet *set,
GtkPrinterOption *option;
char *name = get_ppd_option_name (ppd_option->keyword);
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
option = gtk_printer_option_set_lookup (set, name);
if (option)
ppdMarkOption (ppd_file, ppd_option->keyword, option->value);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
g_free (name);
}
@@ -5894,6 +5921,8 @@ cups_printer_mark_conflicts (GtkPrinter *printer,
if (ppd_file == NULL)
return FALSE;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
ppdMarkDefaults (ppd_file);
for (i = 0; i < ppd_file->num_groups; i++)
@@ -5907,6 +5936,8 @@ cups_printer_mark_conflicts (GtkPrinter *printer,
set_conflicts_from_group (options, ppd_file, &ppd_file->groups[i]);
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
return num_conflicts > 0;
}
@@ -6540,12 +6571,14 @@ cups_printer_prepare_for_print (GtkPrinter *printer,
static GtkPageSetup *
create_page_setup (ppd_file_t *ppd_file,
ppd_size_t *size)
- {
- char *display_name;
- GtkPageSetup *page_setup;
- GtkPaperSize *paper_size;
- ppd_option_t *option;
- ppd_choice_t *choice;
+{
+ char *display_name;
+ GtkPageSetup *page_setup;
+ GtkPaperSize *paper_size;
+ ppd_option_t *option;
+ ppd_choice_t *choice;
+
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
display_name = NULL;
option = ppdFindOption (ppd_file, "PageSize");
@@ -6556,6 +6589,8 @@ create_page_setup (ppd_file_t *ppd_file,
display_name = ppd_text_to_utf8 (ppd_file, choice->text);
}
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
if (display_name == NULL)
display_name = g_strdup (size->name);
@@ -6681,6 +6716,8 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
ppd_file = gtk_printer_cups_get_ppd (GTK_PRINTER_CUPS (printer));
if (ppd_file != NULL)
{
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
option = ppdFindOption (ppd_file, "PageSize");
if (option == NULL)
return NULL;
@@ -6689,6 +6726,8 @@ cups_printer_get_default_page_size (GtkPrinter *printer)
if (size == NULL)
return NULL;
+ G_GNUC_END_IGNORE_DEPRECATIONS
+
result = create_page_setup (ppd_file, size);
}
else if (cups_printer->media_default != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]