From d384e470bbc5887d400f117221ac4b7855e1f1d5 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Thu, 26 Jan 2017 08:43:11 +0000 Subject: [PATCH] #1413: 64-bit support for win32 printing, add printing command path info to Print.exe tool output git-svn-id: https://xpra.org/svn/Xpra/trunk@14859 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/setup.py | 10 +++++----- src/xpra/platform/printing.py | 7 ++++++- src/xpra/platform/win32/printing.py | 31 +++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/setup.py b/src/setup.py index 369a42ac0d..1e9d1c1e77 100755 --- a/src/setup.py +++ b/src/setup.py @@ -1565,14 +1565,14 @@ def add_gui_exe(*args): add_console_exe("xpra/scripts/show_webcam.py", "webcam.ico", "Webcam_Test") if printing_ENABLED: add_console_exe("xpra/platform/printing.py", "printer.ico", "Print") - if os.path.exists("C:\\Program Files (x86)\\Ghostgum\\gsview"): - GSVIEW = "C:\\Program Files (x86)\\Ghostgum\\gsview" - else: + if os.path.exists("C:\\Program Files\\Ghostgum\\gsview"): GSVIEW = "C:\\Program Files\\Ghostgum\\gsview" - if os.path.exists("C:\\Program Files (x86)\\gs"): - GHOSTSCRIPT_PARENT_DIR = "C:\\Program Files (x86)\\gs" else: + GSVIEW = "C:\\Program Files (x86)\\Ghostgum\\gsview" + if os.path.exists("C:\\Program Files\\gs"): GHOSTSCRIPT_PARENT_DIR = "C:\\Program Files\\gs" + else: + GHOSTSCRIPT_PARENT_DIR = "C:\\Program Files (x86)\\gs" GHOSTSCRIPT = None for x in reversed(sorted(os.listdir(GHOSTSCRIPT_PARENT_DIR))): f = os.path.join(GHOSTSCRIPT_PARENT_DIR, x) diff --git a/src/xpra/platform/printing.py b/src/xpra/platform/printing.py index 64926bb204..b34ebe0bc8 100755 --- a/src/xpra/platform/printing.py +++ b/src/xpra/platform/printing.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # This file is part of Xpra. -# Copyright (C) 2014, 2015 Antoine Martin +# Copyright (C) 2014-2017 Antoine Martin # Xpra is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. @@ -71,6 +71,9 @@ def get_mimetypes(): def get_info(): + return default_get_info + +def default_get_info(): return { "mimetypes" : { "" : get_mimetypes(), @@ -137,6 +140,7 @@ def dump_info(d): def dump_printers(d): for k in sorted(d.keys()): v = d[k] + print("Printers:") print("* %s" % k) dump_dict(v) attr = get_printer_attributes(k) @@ -156,6 +160,7 @@ def dump_printers(d): print(" %s" % e) if len(sys.argv)<=1: dump_printers(get_printers()) + print("") dump_info(get_info()) return 0 printers = get_printers() diff --git a/src/xpra/platform/win32/printing.py b/src/xpra/platform/win32/printing.py index b82c73a3b5..bd7fd8e865 100644 --- a/src/xpra/platform/win32/printing.py +++ b/src/xpra/platform/win32/printing.py @@ -63,10 +63,10 @@ GSVIEW_DIR = None GSPRINT_EXE = None -GSWIN32C_EXE = None +GSWINXXC_EXE = None printers_modified_callback = None def init_printing(callback=None): - global printers_modified_callback, GSVIEW_DIR, GSPRINT_EXE, GSWIN32C_EXE + global printers_modified_callback, GSVIEW_DIR, GSPRINT_EXE, GSWINXXC_EXE log("init_printing(%s) printers_modified_callback=%s", callback, printers_modified_callback) printers_modified_callback = callback #ensure we can find gsprint.exe in a subdirectory: @@ -75,8 +75,11 @@ def init_printing(callback=None): assert os.path.exists(GSVIEW_DIR) and os.path.isdir(GSVIEW_DIR), "cannot find gsview directory in '%s'" % GSVIEW_DIR GSPRINT_EXE = os.path.join(GSVIEW_DIR, "gsprint.exe") assert os.path.exists(GSPRINT_EXE), "cannot find gsprint.exe in '%s'" % GSVIEW_DIR - GSWIN32C_EXE = os.path.join(GSVIEW_DIR, "gswin32c.exe") - assert os.path.exists(GSWIN32C_EXE), "cannot find gswin32c.exe in '%s'" % GSVIEW_DIR + for bits in (32, 64): + GSWINXXC_EXE = os.path.join(GSVIEW_DIR, "gswin%sc.exe" % bits) + if os.path.exists(GSWINXXC_EXE): + break + assert os.path.exists(GSWINXXC_EXE), "cannot find gswin??c.exe in '%s'" % GSVIEW_DIR try: init_winspool_listener() except Exception: @@ -141,6 +144,22 @@ class PRINTER_INFO(ctypes.Structure): msvcrt.free(buf) return printers +def get_info(): + from xpra.platform.printing import default_get_info + i = default_get_info() + #win32 extras: + i.update({ + "skipped-printers" : SKIPPED_PRINTERS, + "printer-level" : PRINTER_LEVEL, + "default-printer-flags" : DEFAULT_PRINTER_FLAGS, + "printer-flags" : PRINTER_FLAGS, + "commands" : { + "gsview" : GSPRINT_EXE or "", + "gswin" : GSWINXXC_EXE or "", + }, + }) + return i + def get_printers(): global PRINTER_ENUMS, PRINTER_ENUM_VALUES, SKIPPED_PRINTERS, PRINTER_LEVEL, GSVIEW_DIR printers = {} @@ -184,12 +203,12 @@ def get_printers(): def print_files(printer, filenames, title, options): log("win32.print_files%s", (printer, filenames, title, options)) - global JOB_ID, PROCESSES, GSVIEW_DIR, GSPRINT_EXE, GSWIN32C_EXE + global JOB_ID, PROCESSES, GSVIEW_DIR, GSPRINT_EXE, GSWINXXC_EXE assert GSVIEW_DIR, "cannot print files without gsprint!" processes = [] for filename in filenames: #command = ["C:\\Program Files\\Xpra\\gsview\\gsprint.exe"] - command = [GSPRINT_EXE, "-ghostscript", GSWIN32C_EXE, "-colour"] + command = [GSPRINT_EXE, "-ghostscript", GSWINXXC_EXE, "-colour"] if printer: command += ["-printer", printer] command += [filename]