annotate gui/src/octave-gui.cc @ 15155:9e62d5a3a45e gui

partial cleanup of include files in gui sources * symbol-information.cc, octave-adapter/octave-event.cc: New files. * documentation-dockwidget.h, history-dockwidget.cc, m-editor/file-editor.h, octave-event.cc, octave-event.h, octave-link.cc, octave-link.h, octave-main-thread.cc, octave-gui.cc, symbol-information.cc, symbol-information.h, workspace-model.cc: Avoid including unnecssary header files.
author John W. Eaton <jwe@octave.org>
date Sat, 11 Aug 2012 11:02:12 -0400
parents bfc220d1de67
children bc801a44bb1f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13504
13e3d60aff2d Replaced Quint with OctaveGUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13501
diff changeset
1 /* OctaveGUI - A graphical user interface for Octave
13674
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13672
diff changeset
2 * Copyright (C) 2011 Jacob Dawid (jacob.dawid@googlemail.com)
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
3 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
4 * This program is free software: you can redistribute it and/or modify
14290
faece6b2ab90 Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
5 * it under the terms of the GNU General Public License as
13674
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13672
diff changeset
6 * published by the Free Software Foundation, either version 3 of the
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13672
diff changeset
7 * License, or (at your option) any later version.
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
8 *
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14290
faece6b2ab90 Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
12 * GNU General Public License for more details.
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
13 *
14290
faece6b2ab90 Corrected license headers in all files to GPL.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13674
diff changeset
14 * You should have received a copy of the GNU General Public License
13674
c0e66d6e3dc8 Updated license headers and moved to AGPLv3.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13672
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
16 */
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
17
15155
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
18 #ifdef HAVE_CONFIG_H
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
19 #include <config.h>
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
20 #endif
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
21
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
22 #include <QtGui/QApplication>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
23 #include <QTranslator>
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
24 #include <QSettings>
15155
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
25
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
26 #include <iostream>
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
27
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
28 #include <syswait.h>
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
29
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
30 #include "welcome-wizard.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
31 #include "resource-manager.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
32 #include "main-window.h"
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
33 #include "octave-gui.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
34
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
35 // 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
36
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
37 static void
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
38 dissociate_terminal (void)
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 #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
41
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
42 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
43
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
44 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
45 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
46 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
47 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
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 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
50 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
51 // 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
52
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 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
54 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
55 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
56 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
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 }
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 else
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
60 {
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
61 // Parent
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
62
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
63 int status;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
64
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
65 waitpid (pid, &status, 0);
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
66
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
67 exit (WIFEXITED (status) ? WEXITSTATUS (status) : 127);
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
68 }
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
69
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
70 #endif
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
71 }
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
72
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
73 int
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
74 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
75 {
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
76 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
77
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
78 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
79
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
80 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
81 {
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
82 if (resource_manager::instance ()->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
83 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
84 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
85 welcomeWizard.exec ();
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
86 resource_manager::instance ()->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
87 }
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
88 else
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
89 {
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
90 QSettings *settings = resource_manager::instance ()->get_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
91 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
92
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
93 QString translatorFile = resource_manager::instance ()->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
94 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
95 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
96 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
97
14712
5cb54cca8a06 Completion of code reformatting.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14709
diff changeset
98 resource_manager::instance ()->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
99
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
100 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
101 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
102 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
103 }
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
104 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
105 }