summaryrefslogtreecommitdiffstats
path: root/src/curses-ui/main.vala
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2018-06-29 21:05:46 +0200
committerSebastian Reichel <sre@ring0.de>2018-07-15 22:59:57 +0200
commitcce1953eb1f8fe8c927a1720c95caed45b71ef1d (patch)
tree4ce0e1a234360ebb99f8bf6b6f2fa5d8ab842c55 /src/curses-ui/main.vala
parent2d532b4a537327d66a15d20dc2e8aaad9b5f1dfc (diff)
downloadserial-barcode-scanner-cce1953eb1f8fe8c927a1720c95caed45b71ef1d.tar.bz2
all: simplify datadir configuration
This simplifies the datadir configuration and removes the expectation, that the code is executed from the repository. It should now be possible to install this into the system like any other common Linux application.
Diffstat (limited to 'src/curses-ui/main.vala')
-rw-r--r--src/curses-ui/main.vala14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/curses-ui/main.vala b/src/curses-ui/main.vala
index e5ad4c8..3518bb2 100644
--- a/src/curses-ui/main.vala
+++ b/src/curses-ui/main.vala
@@ -19,6 +19,7 @@ public MainLoop loop;
public AudioPlayer audio;
public ScannerSession scanner;
public CursesUI ui;
+private Config cfg;
private static void play(string file) {
try {
@@ -56,14 +57,19 @@ public static int main(string[] args) {
try {
audio = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.AudioPlayer", "/io/mainframe/shopsystem/audio");
scanner = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.ScannerSession", "/io/mainframe/shopsystem/scanner_session");
+ cfg = Bus.get_proxy_sync(BusType.SYSTEM, "io.mainframe.shopsystem.Config", "/io/mainframe/shopsystem/config");
+
+ var datapath = cfg.get_string("GENERAL", "datapath");
+ var datadir = Path.build_filename(datapath, "curses-ui");
+ ui = new CursesUI(datadir);
} catch(IOError e) {
error(_("IO Error: %s\n"), e.message);
+ } catch(DBusError e) {
+ error(_("DBus Error: %s\n"), e.message);
+ } catch(KeyFileError e) {
+ error(_("KeyFile Error: %s\n"), e.message);
}
- string binarylocation = File.new_for_path(args[0]).get_parent().get_path();
-
- ui = new CursesUI(binarylocation);
-
Log.set_default_handler(log_handler);
scanner.msg.connect(msg_handler);