gui: better app exit
[fanfix.git] / src / be / nikiroo / fanfix / reader / ui / GuiReader.java
index 02f153cdf82d47dc8f2486f7e3a72cff94a75903..9f2fd3dad1056c6ba4635a70856e2983f330fad0 100644 (file)
@@ -168,14 +168,15 @@ class GuiReader extends BasicReader {
                                try {
                                        GuiReaderFrame gui = new GuiReaderFrame(GuiReader.this,
                                                        typeFinal);
-                                       gui.setVisible(true);
                                        gui.addWindowListener(new WindowAdapter() {
                                                @Override
-                                               public void windowClosed(WindowEvent e) {
-                                                       super.windowClosed(e);
+                                               public void windowClosing(WindowEvent e) {
+                                                       super.windowClosing(e);
                                                        done[0] = true;
                                                }
                                        });
+
+                                       gui.setVisible(true);
                                } catch (Exception e) {
                                        Instance.getTraceHandler().error(e);
                                        done[0] = true;
@@ -292,4 +293,38 @@ class GuiReader extends BasicReader {
                        Instance.getTraceHandler().error(e);
                }
        }
+
+       /**
+        * Change the title of the given {@link Story}.
+        * 
+        * @param luid
+        *            the luid of the {@link Story} to change
+        * @param newTitle
+        *            the new title
+        */
+       void changeTitle(String luid, String newTitle) {
+               try {
+                       cacheLib.changeTitle(luid, newTitle, null);
+               } catch (IOException e) {
+                       Instance.getTraceHandler().error(e);
+               }
+       }
+
+       /**
+        * Change the author of the given {@link Story}.
+        * <p>
+        * The author can be a new one, it needs not exist before hand.
+        * 
+        * @param luid
+        *            the luid of the {@link Story} to change
+        * @param newAuthor
+        *            the new author
+        */
+       void changeAuthor(String luid, String newAuthor) {
+               try {
+                       cacheLib.changeAuthor(luid, newAuthor, null);
+               } catch (IOException e) {
+                       Instance.getTraceHandler().error(e);
+               }
+       }
 }