From cce1953eb1f8fe8c927a1720c95caed45b71ef1d Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 29 Jun 2018 21:05:46 +0200 Subject: 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. --- src/curses-ui/main.vala | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/curses-ui/main.vala') 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); -- cgit v1.2.3