# HG changeset patch
# User John Donoghue <john.donoghue@ieee.org>
# Date 1383838770 18000
#      Thu Nov 07 10:39:30 2013 -0500
# Node ID 7d73e3c921a3b8e4d54c35aea0c87188c7bd0d1f
# Parent  7d9a4eef802223499b227b1e3a21925c4c8f9245
GUI: allow only one release notes windows to be open

* libgui/src/main-window.h
  (class main-window): Added release_notes_window variable.

* libgui/src/main-window.cpp
  (main-window::mainwindow): Initialize release_notes_window variable.
  (main-window::~mainwindow): call delete on release_notes_window variable.
  (main_window::display_release_notes): Create release_notes_window only if not already created, and always unminimize/show it.

diff -r 7d9a4eef8022 -r 7d73e3c921a3 libgui/src/main-window.cc
--- a/libgui/src/main-window.cc	Thu Nov 07 02:46:30 2013 -0500
+++ b/libgui/src/main-window.cc	Thu Nov 07 10:39:30 2013 -0500
@@ -78,6 +78,7 @@
     editor_window (create_default_editor (this)),
     workspace_window (new workspace_view (this)),
     find_files_dlg (0),
+    release_notes_window(0),
     _octave_main_thread (0),
     _octave_qt_link (0),
     _clipboard (QApplication::clipboard ()),
@@ -108,6 +109,11 @@
       delete find_files_dlg;
       find_files_dlg = 0;
     }
+  if (release_notes_window)
+    {
+      delete release_notes_window;
+      release_notes_window = 0;
+    }
   delete _octave_main_thread;
   delete _octave_qt_link;
   delete _cmd_queue;
@@ -254,43 +260,51 @@
 void
 main_window::display_release_notes (void)
 {
-  std::string news_file = Voct_etc_dir + "/NEWS";
+  if (release_notes_window == 0)
+    {
+      std::string news_file = Voct_etc_dir + "/NEWS";
 
-  QString news;
+      QString news;
 
-  QFile *file = new QFile (QString::fromStdString (news_file));
-  if (file->open (QFile::ReadOnly))
-    {
-      QTextStream *stream = new QTextStream (file);
-      news = stream->readAll ();
-      if (! news.isEmpty ())
+      QFile *file = new QFile (QString::fromStdString (news_file));
+      if (file->open (QFile::ReadOnly))
         {
-          news.prepend ("<pre>");
-          news.append ("</pre>");
+          QTextStream *stream = new QTextStream (file);
+          news = stream->readAll ();
+          if (! news.isEmpty ())
+            {
+              news.prepend ("<pre>");
+              news.append ("</pre>");
+            }
+          else
+            news = (tr ("The release notes file '%1' is empty.")
+                    . arg (QString::fromStdString (news_file)));
         }
       else
-        news = (tr ("The release notes file '%1' is empty.")
+        news = (tr ("The release notes file '%1' cannot be read.")
                 . arg (QString::fromStdString (news_file)));
+
+
+      release_notes_window = new QWidget;
+
+      QTextBrowser *browser = new QTextBrowser (release_notes_window);
+      browser->setText (news);
+
+      QVBoxLayout *vlayout = new QVBoxLayout;
+      vlayout->addWidget (browser);
+
+      release_notes_window->setLayout (vlayout);
+      release_notes_window->setWindowTitle (tr ("Octave Release Notes"));
+      release_notes_window->setWindowIcon (QIcon (_release_notes_icon));
     }
-  else
-    news = (tr ("The release notes file '%1' cannot be read.")
-            . arg (QString::fromStdString (news_file)));
 
+  if (! release_notes_window->isVisible ())
+    release_notes_window->show ();
+  else if (release_notes_window->isMinimized ())
+    release_notes_window->showNormal ();
 
-  QWidget *w = new QWidget;
-
-  QTextBrowser *browser = new QTextBrowser (w);
-  browser->setText (news);
-
-  QVBoxLayout *vlayout = new QVBoxLayout;
-  vlayout->addWidget (browser);
-
-  w->setLayout (vlayout);
-  w->setWindowTitle (tr ("Octave Release Notes"));
-  w->setWindowIcon (QIcon (_release_notes_icon));
-  w->show ();
-  w->raise ();
-  w->activateWindow ();
+  release_notes_window->raise ();
+  release_notes_window->activateWindow ();
 }
 
 void
diff -r 7d9a4eef8022 -r 7d73e3c921a3 libgui/src/main-window.h
--- a/libgui/src/main-window.h	Thu Nov 07 02:46:30 2013 -0500
+++ b/libgui/src/main-window.h	Thu Nov 07 10:39:30 2013 -0500
@@ -323,6 +323,9 @@
   // Find files dialog
   find_files_dialog * find_files_dlg;
 
+  // release notes window
+  QWidget * release_notes_window;
+
   octave_main_thread *_octave_main_thread;
 
   octave_qt_link *_octave_qt_link;
