Skip to content

Commit

Permalink
#1413: 64-bit support for win32 printing, add printing command path i…
Browse files Browse the repository at this point in the history
…nfo to Print.exe tool output

git-svn-id: https://xpra.org/svn/Xpra/trunk@14859 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Jan 26, 2017
1 parent 473a66c commit d384e47
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion src/xpra/platform/printing.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# This file is part of Xpra.
# Copyright (C) 2014, 2015 Antoine Martin <antoine@devloop.org.uk>
# Copyright (C) 2014-2017 Antoine Martin <antoine@devloop.org.uk>
# Xpra is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

Expand Down Expand Up @@ -71,6 +71,9 @@ def get_mimetypes():


def get_info():
return default_get_info

def default_get_info():
return {
"mimetypes" : {
"" : get_mimetypes(),
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
31 changes: 25 additions & 6 deletions src/xpra/platform/win32/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit d384e47

Please sign in to comment.