Advertisement
Guest User

Remove obsolete print portal

a guest
Mar 23rd, 2022
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.88 KB | None | 0 0
  1. Description: <short summary of the patch>
  2.  TODO: Put a short summary on the line above and replace this paragraph
  3.  with a longer explanation of this change. Complete the meta-information
  4.  with other relevant fields (see below for details). To make it easier, the
  5.  information below has been extracted from the changelog. Adjust it or drop
  6.  it.
  7.  .
  8.  firefox-esr (91.7.0esr-1s2~deb9u1) misc; urgency=medium
  9.  .
  10.    * Port to Ordissimo.
  11. Author: Thierry HUCHARD <thierry@ordissimo.com>
  12.  
  13. ---
  14. The information above should follow the Patch Tagging Guidelines, please
  15. checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
  16. are templates for supplementary fields that you might want to add:
  17.  
  18. Origin: <vendor|upstream|other>, <url of original patch>
  19. Bug: <url in upstream bugtracker>
  20. Bug-Debian: https://bugs.debian.org/<bugnumber>
  21. Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
  22. Forwarded: <no|not-needed|url proving that it has been forwarded>
  23. Reviewed-By: <name and email of someone who approved the patch>
  24. Last-Update: 2022-03-23
  25.  
  26. --- firefox-esr-91.7.0esr.orig/widget/gtk/nsDeviceContextSpecG.cpp
  27. +++ firefox-esr-91.7.0esr/widget/gtk/nsDeviceContextSpecG.cpp
  28. @@ -231,7 +231,7 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::In
  29.    mGtkPageSetup = gtk_page_setup_copy(mGtkPageSetup);
  30.    mGtkPrintSettings = gtk_print_settings_copy(mGtkPrintSettings);
  31.  
  32. -  if (!aPS->GetPrintInColor() && StaticPrefs::print_cups_monochrome_enabled()) {
  33. +  if (!aPS->GetPrintInColor()) {
  34.      for (const auto& setting : kKnownMonochromeSettings) {
  35.        gtk_print_settings_set(mGtkPrintSettings, setting.mKey, setting.mValue);
  36.      }
  37. @@ -294,71 +294,18 @@ gboolean nsDeviceContextSpecGTK::Printer
  38.  
  39.  void nsDeviceContextSpecGTK::StartPrintJob() {
  40.    // When using flatpak, we have to call the Print method of the portal
  41. -  nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  42. -  bool shouldUsePortal;
  43. -  giovfs->ShouldUseFlatpakPortal(&shouldUsePortal);
  44. -  if (shouldUsePortal) {
  45. -    GError* error = nullptr;
  46. -    GDBusProxy* dbusProxy = g_dbus_proxy_new_for_bus_sync(
  47. -        G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_NONE, nullptr,
  48. -        "org.freedesktop.portal.Desktop", "/org/freedesktop/portal/desktop",
  49. -        "org.freedesktop.portal.Print", nullptr, &error);
  50. -    if (dbusProxy == nullptr) {
  51. -      NS_WARNING(
  52. -          nsPrintfCString("Unable to create dbus proxy: %s", error->message)
  53. -              .get());
  54. -      g_error_free(error);
  55. -      return;
  56. -    }
  57. -    int fd = open(mSpoolName.get(), O_RDONLY | O_CLOEXEC);
  58. -    if (fd == -1) {
  59. -      NS_WARNING("Failed to open spool file.");
  60. -      return;
  61. -    }
  62. -    static auto s_g_unix_fd_list_new = reinterpret_cast<GUnixFDList* (*)(void)>(
  63. -        dlsym(RTLD_DEFAULT, "g_unix_fd_list_new"));
  64. -    NS_ASSERTION(s_g_unix_fd_list_new,
  65. -                 "Cannot find g_unix_fd_list_new function.");
  66. -
  67. -    GUnixFDList* fd_list = s_g_unix_fd_list_new();
  68. -    static auto s_g_unix_fd_list_append =
  69. -        reinterpret_cast<gint (*)(GUnixFDList*, gint, GError**)>(
  70. -            dlsym(RTLD_DEFAULT, "g_unix_fd_list_append"));
  71. -    int idx = s_g_unix_fd_list_append(fd_list, fd, NULL);
  72. -    close(fd);
  73. -
  74. -    // We'll pass empty options as long as we don't have token from PreparePrint
  75. -    // dbus call (which we don't use). This unfortunatelly lead to showing
  76. -    // gtk print dialog and also the duplex or printer specific settings
  77. -    // is not honored, so this needs to be fixed when the portal provides
  78. -    // more options.
  79. -    GVariantBuilder opt_builder;
  80. -    g_variant_builder_init(&opt_builder, G_VARIANT_TYPE_VARDICT);
  81. -
  82. -    g_dbus_proxy_call_with_unix_fd_list(
  83. -        dbusProxy, "Print",
  84. -        g_variant_new("(ssh@a{sv})", "", /* window */
  85. -                      "Print",           /* title */
  86. -                      idx, g_variant_builder_end(&opt_builder)),
  87. -        G_DBUS_CALL_FLAGS_NONE, -1, fd_list, NULL,
  88. -        NULL,      // portal result cb function
  89. -        nullptr);  // userdata
  90. -    g_object_unref(fd_list);
  91. -    g_object_unref(dbusProxy);
  92. -  } else {
  93. -    GtkPrintJob* job =
  94. -        gtk_print_job_new(mTitle.get(), mPrintSettings->GetGtkPrinter(),
  95. -                          mGtkPrintSettings, mGtkPageSetup);
  96. -
  97. -    if (!gtk_print_job_set_source_file(job, mSpoolName.get(), nullptr)) return;
  98. -
  99. -    // Now gtk owns the print job, and will be released via our callback.
  100. -    gtk_print_job_send(job, print_callback, mSpoolFile.forget().take(),
  101. -                       [](gpointer aData) {
  102. -                         auto* spoolFile = static_cast<nsIFile*>(aData);
  103. -                         NS_RELEASE(spoolFile);
  104. -                       });
  105. -  }
  106. +  GtkPrintJob* job =
  107. +      gtk_print_job_new(mTitle.get(), mPrintSettings->GetGtkPrinter(),
  108. +                        mGtkPrintSettings, mGtkPageSetup);
  109. +
  110. +  if (!gtk_print_job_set_source_file(job, mSpoolName.get(), nullptr)) return;
  111. +
  112. +  // Now gtk owns the print job, and will be released via our callback.
  113. +  gtk_print_job_send(job, print_callback, mSpoolFile.forget().take(),
  114. +                     [](gpointer aData) {
  115. +                       auto* spoolFile = static_cast<nsIFile*>(aData);
  116. +                       NS_RELEASE(spoolFile);
  117. +                     });
  118.  }
  119.  
  120.  void nsDeviceContextSpecGTK::EnumeratePrinters() {
  121. @@ -432,21 +379,6 @@ NS_IMETHODIMP nsDeviceContextSpecGTK::En
  122.      // different numbers of bits for their permissions)
  123.      destFile->SetPermissions(0666 & ~(mask));
  124.  
  125. -    // Notify flatpak printing portal that file is completely written
  126. -    nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
  127. -    bool shouldUsePortal;
  128. -    if (giovfs) {
  129. -      giovfs->ShouldUseFlatpakPortal(&shouldUsePortal);
  130. -      if (shouldUsePortal) {
  131. -        // Use the name of the file for printing to match with
  132. -        // nsFlatpakPrintPortal
  133. -        nsCOMPtr<nsIObserverService> os =
  134. -            mozilla::services::GetObserverService();
  135. -        // Pass filename to be sure that observer process the right data
  136. -        os->NotifyObservers(nullptr, "print-to-file-finished",
  137. -                            targetPath.get());
  138. -      }
  139. -    }
  140.    }
  141.    return NS_OK;
  142.  }
  143. --- firefox-esr-91.7.0esr.orig/widget/nsPrinterCUPS.h
  144. +++ firefox-esr-91.7.0esr/widget/nsPrinterCUPS.h
  145. @@ -135,6 +135,7 @@ class nsPrinterCUPS final : public nsPri
  146.        macro_("BRMonoColor", "Mono")               /* Brother */                \
  147.        macro_("BRPrintQuality", "Black")           /* Brother */                \
  148.        macro_("CNIJGrayScale", "1")                /* Canon */                  \
  149. +      macro_("CNGrayscale", "True")               /* Canon */                  \
  150.        macro_("INK", "MONO")                       /* Epson */                  \
  151.        macro_("HPColorMode", "GrayscalePrint")     /* HP */                     \
  152.        macro_("ColorMode", "Mono")                 /* Samsung */                \
  153.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement