X-Git-Url: http://git.nikiroo.be/?p=fanfix.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2Freader%2Ftui%2FTuiReaderApplication.java;h=f08b84ccbbf17328283b059fae0ec960fe29cee1;hp=8cd5c0b90ce99ed820ba16725e45fb9ced3530ad;hb=350bc060516184774f8116e61696a8c3c45ba85d;hpb=85493b380b07146e2b36c0ffe40d2dc17a4ebdf2 diff --git a/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java b/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java index 8cd5c0b..f08b84c 100644 --- a/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java +++ b/src/be/nikiroo/fanfix/reader/tui/TuiReaderApplication.java @@ -56,9 +56,8 @@ class TuiReaderApplication extends TApplication implements Reader { super(backend); init(reader); - MetaData meta = getMeta(); - if (meta != null) { - read(); + if (getMeta() != null) { + read(false); } } @@ -72,8 +71,8 @@ class TuiReaderApplication extends TApplication implements Reader { } @Override - public void read() throws IOException { - read(getStory(null)); + public void read(boolean sync) throws IOException { + read(getStory(null), sync); } @Override @@ -126,7 +125,20 @@ class TuiReaderApplication extends TApplication implements Reader { reader.setChapter(chapter); } - public void read(Story story) throws IOException { + /** + * Open the given {@link Story} for reading. This may or may not start an + * external program to read said {@link Story}. + * + * @param story + * the {@link Story} to read + * @param sync + * execute the process synchronously (wait until it is terminated + * before returning) + * + * @throws IOException + * in case of I/O errors + */ + public void read(Story story, boolean sync) throws IOException { if (story == null) { throw new IOException("No story to read"); } @@ -137,7 +149,7 @@ class TuiReaderApplication extends TApplication implements Reader { window.maximize(); } else { try { - openExternal(getLibrary(), story.getMeta().getLuid()); + openExternal(getLibrary(), story.getMeta().getLuid(), sync); } catch (IOException e) { messageBox("Error when trying to open the story", e.getMessage(), TMessageBox.Type.OK); @@ -230,7 +242,7 @@ class TuiReaderApplication extends TApplication implements Reader { try { openfile = fileOpenBox("."); reader.setMeta(BasicReader.getUrl(openfile), null); - read(); + read(false); } catch (IOException e) { // TODO: i18n error("Fail to open file" @@ -342,8 +354,9 @@ class TuiReaderApplication extends TApplication implements Reader { } @Override - public void openExternal(BasicLibrary lib, String luid) throws IOException { - reader.openExternal(lib, luid); + public void openExternal(BasicLibrary lib, String luid, boolean sync) + throws IOException { + reader.openExternal(lib, luid, sync); } /**