annotate libgui/src/octave-gui.cc @ 15204:359098ad343e

update copyright notices in libgui directory * documentation-dockwidget.cc, documentation-dockwidget.h, files-dockwidget.cc, files-dockwidget.h, history-dockwidget.cc, history-dockwidget.h, m-editor/file-editor-interface.h, m-editor/file-editor-tab.cc, m-editor/file-editor-tab.h, m-editor/file-editor.cc, m-editor/file-editor.h, m-editor/lexer-octave-gui.cc, m-editor/lexer-octave-gui.h, main-window.cc, main-window.h, octave-adapter/octave-event-listener.h, octave-adapter/octave-event-observer.h, octave-adapter/octave-event.cc, octave-adapter/octave-event.h, octave-adapter/octave-link.cc, octave-adapter/octave-link.h, octave-adapter/octave-main-thread.cc, octave-adapter/octave-main-thread.h, octave-gui.cc, octave-qt-event-listener.cc, octave-qt-event-listener.h, resource-manager.cc, resource-manager.h, settings-dialog.cc, settings-dialog.h, symbol-information.cc, symbol-information.h, terminal-dockwidget.cc, terminal-dockwidget.h, welcome-wizard.cc, welcome-wizard.h, workspace-model.cc, workspace-model.h, workspace-view.cc, workspace-view.h: Use copyright notice format that is consistent with other files in Octave.
author John W. Eaton <jwe@octave.org>
date Mon, 20 Aug 2012 14:02:08 -0400
parents 017f0b2e6933
children a3c8a3c2dbda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15204
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
1 /*
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
2
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
3 Copyright (C) 2011-2012 Jacob Dawid
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
4
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
5 This file is part of Octave.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
6
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
8 under the terms of the GNU General Public License as published by the
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
10 option) any later version.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
11
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
15 for more details.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
16
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
17 You should have received a copy of the GNU General Public License
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
18 along with Octave; see the file COPYING. If not, see
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
19 <http://www.gnu.org/licenses/>.
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
20
359098ad343e update copyright notices in libgui directory
John W. Eaton <jwe@octave.org>
parents: 15196
diff changeset
21 */
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22
15155
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
23 #ifdef HAVE_CONFIG_H
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
24 #include <config.h>
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
25 #endif
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
26
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
27 #include <QtGui/QApplication>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
28 #include <QTranslator>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
29 #include <QSettings>
15155
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
30
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
31 #include <iostream>
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
32
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
33 #include <syswait.h>
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
34
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
35 #include "welcome-wizard.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
36 #include "resource-manager.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
37 #include "main-window.h"
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
38 #include "octave-gui.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
39
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
40 // Dissociate from the controlling terminal, if any.
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
41
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
42 static void
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
43 dissociate_terminal (void)
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
44 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
45 #if ! defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN)
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
46
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
47 pid_t pid = fork ();
14878
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
48
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
49 if (pid < 0)
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
50 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
51 std::cerr << "fork failed!" << std::endl;;
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
52 exit (1);
14878
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
53 }
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
54 else if (pid == 0)
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
55 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
56 // Child.
14878
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
57
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
58 if (setsid () < 0)
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
59 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
60 std::cerr << "setsid error" << std::endl;
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
61 exit (1);
14878
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
62 }
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
63 }
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
64 else
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
65 {
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
66 // Parent
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
67
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
68 int status;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
69
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
70 waitpid (pid, &status, 0);
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
71
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
72 exit (WIFEXITED (status) ? WEXITSTATUS (status) : 127);
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
73 }
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
74
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
75 #endif
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
76 }
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
77
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
78 int
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
79 octave_start_gui (int argc, char *argv[])
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
80 {
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
81 dissociate_terminal ();
14878
a6c44c28dabe Added patch from jwe that forks the GUI process in order to have less work.
Jacob Dawid <jacob.dawid@gmail.com>
parents: 14804
diff changeset
82
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
83 QApplication application (argc, argv);
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
84
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
85 while (true)
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
86 {
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
87 if (resource_manager::is_first_run ())
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
88 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
89 welcome_wizard welcomeWizard;
14804
a565c560e654 Replaced a lot of terminal interaction with events: Clearing, loading and saving workspace, running a file. Default location for saving a new file is now the current working directory. Fixed bad settings with a fresh installation of the GUI by providing a file with default settings and installing it when appropriate.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14712
diff changeset
90 welcomeWizard.exec ();
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
91 resource_manager::reload_settings ();
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
92 }
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
93 else
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
94 {
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
95 QSettings *settings = resource_manager::get_settings ();
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
96
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
97 // FIXME -- what should happen if settings is 0?
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
98
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
99 QString language = settings->value ("language").toString ();
13613
8728061cd0ec Icons are now maintained by the ResourceManager.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13607
diff changeset
100
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
101 QString translatorFile = resource_manager::find_translator_file (language);
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
102 QTranslator translator;
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
103 translator.load (translatorFile);
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
104 application.installTranslator (&translator);
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
105
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
106 resource_manager::update_network_settings ();
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
107
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
108 main_window w;
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
109 w.show ();
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
110 return application.exec ();
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
111 }
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
112 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
113 }