Compare commits
2 Commits
fa64b68f33
...
d4fa7e8afc
Author | SHA1 | Date | |
---|---|---|---|
d4fa7e8afc | |||
|
dd0809b0eb |
1
CONTRIBUTORS
Normal file
1
CONTRIBUTORS
Normal file
@ -0,0 +1 @@
|
||||
Piotr Chmura
|
@ -16,6 +16,6 @@ By default, XSane's device chooser dialog is displayed. To hard-code a specific
|
||||
|
||||
## Licence
|
||||
|
||||
Copyright © 2024 Lee Yingtong Li (RunasSudo)
|
||||
Copyright © 2024–2025 Lee Yingtong Li (RunasSudo) and CONTRIBUTORS
|
||||
|
||||
Licensed under the GNU General Public License version 3 or later.
|
||||
|
23
xsanecli.py
23
xsanecli.py
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# GIMP 3.0 plug-in for scanning via XSane
|
||||
# Copyright (C) 2024-2025 Lee Yingtong Li (RunasSudo)
|
||||
# Copyright (C) 2024-2025 Lee Yingtong Li (RunasSudo) and CONTRIBUTORS
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -52,19 +52,15 @@ def xsanecli_run(procedure, config, run_data, *args):
|
||||
args = ['xsane', '--save', '--no-mode-selection', '--force-filename', png_out, '--print-filenames'] + ([DEVICE_NAME] if DEVICE_NAME else [])
|
||||
proc = subprocess.Popen(args, stdout=subprocess.PIPE, encoding='utf-8', env=xsane_env)
|
||||
|
||||
while True:
|
||||
while proc.poll() is None:
|
||||
# Wait until XSane prints the name of the scanned file, indicating scanning is finished
|
||||
# This blocks Python but that is ok because GIMP UI is not affected
|
||||
try:
|
||||
result = proc.stdout.readline().strip()
|
||||
except UnicodeDecodeError as e:
|
||||
result = ''
|
||||
|
||||
if result == '':
|
||||
# XSane was closed
|
||||
break
|
||||
|
||||
if result != 'XSANE_IMAGE_FILENAME: ' + png_out:
|
||||
Gimp.message('Unexpected XSane result')
|
||||
return Gimp.ValueArray.new_from_values([GObject.Value(Gimp.PDBStatusType, Gimp.PDBStatusType.EXECUTION_ERROR)])
|
||||
|
||||
if result == 'XSANE_IMAGE_FILENAME: ' + png_out:
|
||||
# Open image
|
||||
image = Gimp.file_load(Gimp.RunMode.NONINTERACTIVE, Gio.File.new_for_path(png_out))
|
||||
Gimp.Display.new(image)
|
||||
@ -74,7 +70,6 @@ def xsanecli_run(procedure, config, run_data, *args):
|
||||
|
||||
if not SCAN_MULTIPLE:
|
||||
proc.terminate()
|
||||
break
|
||||
|
||||
os.rmdir(tempdir)
|
||||
|
||||
@ -99,9 +94,9 @@ class XSaneCLI(Gimp.PlugIn):
|
||||
raise Exception('Unknown procedure')
|
||||
|
||||
procedure.set_attribution(
|
||||
'Lee Yingtong Li (RunasSudo)', # Author
|
||||
'Lee Yingtong Li (RunasSudo)', # Copyright
|
||||
'Lee Yingtong Li (RunasSudo)' # Year
|
||||
'Lee Yingtong Li (RunasSudo) and CONTRIBUTORS', # Author
|
||||
'Lee Yingtong Li (RunasSudo) and CONTRIBUTORS', # Copyright
|
||||
'2024-2025' # Year
|
||||
)
|
||||
return procedure
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user