diff --git a/README b/README index 5c71b62..9414aa5 100644 --- a/README +++ b/README @@ -2,7 +2,8 @@ YMS - Open Source Yacht Management System Preview Version Free, self-hosted software for managing your boat's equipment, -inventory, documents, maintenance and tasks. +inventory, documents, maintenance, projects, tasks and some +other things. Your boat. Your data. Your software. diff --git a/debian/control b/debian/control index 78f8d2f..4ecf81b 100644 --- a/debian/control +++ b/debian/control @@ -26,6 +26,8 @@ Depends: php-xml, gettext, mupdf-tools +Suggests: + python3-sane Description: Yacht Management Software Yacht Management Software (YMS) is an application for managing yachts and sailboats. It provides a native GTK desktop interface and a web interface. diff --git a/icons/favicon.ico b/icons/favicon.ico new file mode 100644 index 0000000..e01f43b Binary files /dev/null and b/icons/favicon.ico differ diff --git a/icons/yms16.png b/icons/yms16.png new file mode 100644 index 0000000..3156d7a Binary files /dev/null and b/icons/yms16.png differ diff --git a/icons/yms32.png b/icons/yms32.png new file mode 100644 index 0000000..3f346cc Binary files /dev/null and b/icons/yms32.png differ diff --git a/yms/view/documents.py b/yms/view/documents.py index 00d1e3b..108dd86 100644 --- a/yms/view/documents.py +++ b/yms/view/documents.py @@ -3,7 +3,6 @@ import os from gi.repository import GLib, Gtk, Gdk, GdkPixbuf, Rsvg import fitz -import sane from .view import View from yms import gtkutils, combobox, treeview @@ -18,8 +17,21 @@ class DocumentsView(View): self.doc = document.Document(context.db) # current record self.newrecord = False - self.scandialog = self.builder.get_object("dlg_scanner") - self.scandialog.set_title("Scan new document") + # init scan feature + if context.scan_enabled: + # checks have been done by context initialization + import sane + # TODO + # multiple scanner? + # open scanner + self.scandialog = self.builder.get_object("dlg_scanner") + self.scandialog.set_title("Scan new document") + else: + # if deactivated from config hide otherwise disable + if self.context.cfg['scanner'] == 'off': + self.button['scan'].set_visible(False) + else: + self.button['scan'].set_sensitive(False) self.uploaddialog = self.builder.get_object("dlg_upload") self.uploaddialog.set_title("Upload new document") diff --git a/ymsgui.py b/ymsgui.py index f715afc..8aea362 100755 --- a/ymsgui.py +++ b/ymsgui.py @@ -71,7 +71,7 @@ class AppContext: 'user': 'yms', 'docpath': '/var/local/lib/yms', 'shapedir': '/usr/local/share/yms/shapes', - 'scanner': 'off' + 'scanner': False } # mapping between PHP and Python @@ -95,6 +95,7 @@ class AppContext: self.textdomain = "ymsgui" # static here for early initialization self.localedir = "locale" self.datefmt = '%d.%m.%Y' + self.scan_enabled = False # system settings stored in database self.curr_sym = '€' self.img_max_width = 1024 @@ -122,6 +123,32 @@ class AppContext: # perhaps create missing record here? pass self.lookup.load() + self.init_scanner() + + def init_scanner(self): + self.scan_enabled = False + if not self.cfg['scanner']: + return + try: + import sane + except ImportError: + print("Module python3-sane not found. Scanning disabled!") + return + print("Initializing sane document scanning...") + try: + version = sane.init() + print(f"Found sane version {version[1]}.{version[2]}.{version[3]}") + except sane._sane.error as e: + print("Error initializing sane") + return + devices = sane.get_devices(localOnly=True) # this will take a while + if not devices: + return + # TODO cameras may be also detected + for dev in devices: + print(f"Found scanner {dev[2]}") + self.scan_enabled = True + print("Done.") def get_sharepath(self): path = os.path.realpath(__file__) @@ -280,8 +307,14 @@ if __name__ == "__main__": # TODO check database schema version schema_required = 1 context.load() - # check if shapedir exists + context.cfg['scanner'] = config.getboolean('Documents', 'scanner') context.cfg['shapedir'] = config.get('Data', 'shapedir') + if not os.path.isdir(context.cfg['shapedir']): + gtkutils.messagebox( + _("Directory with deck plan files not found.\n\n" + "Please check your configuration file!", + title="YMS") + sys.exit(1) # everything seems to be fine: continue to start frontend app = Frontend(context) app.run()