annotate libgui/src/octave-gui.cc @ 15972:22ab4fe661d7

gui: selectable language in settings dialog * octave-gui.cc(octave_start_gu): install translators for gui and qt strings * resource-manager.cc(get_gui_translation_dir): new function returning the directory of the translator files * resource-manager.cc(config_translators): new function replacing find_trnaslator_file and configuring the translators for gui and qt strings * resource-manager.h: declaration of new function in resource-manager.cc * settings-dialog.ui: new combo box for selecting the desired language * settings-dialog.cc(settings_dialog): look for available translator files and the actual language setting and fill the language combo box * settings-dialog.cc(write_changed_settings): get the selected element from the language combo box and write the selection into the settings file
author Torsten <ttl@justmail.de>
date Sat, 19 Jan 2013 16:21:55 +0100
parents 916ef285522a
children 47a4c92924a7
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>
15155
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
29
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
30 #include <iostream>
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
31
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15209
diff changeset
32 #include "lo-utils.h"
15597
9046ee786fe1 Use octave_env instead of setenv.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 15425
diff changeset
33 #include "oct-env.h"
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15209
diff changeset
34 #include "syswait.h"
15155
9e62d5a3a45e partial cleanup of include files in gui sources
John W. Eaton <jwe@octave.org>
parents: 15139
diff changeset
35
14707
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
36 #include "welcome-wizard.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
37 #include "resource-manager.h"
674740c44c09 Changed various files to matche file naming conventions.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14703
diff changeset
38 #include "main-window.h"
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
39 #include "octave-gui.h"
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
40
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
41 // 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
42
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
43 static void
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
44 dissociate_terminal (void)
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
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 #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
47
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
48 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
49
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 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
51 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
52 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
53 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
54 }
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 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
56 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
57 // 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
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 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
60 {
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
61 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
62 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
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 }
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
65 else
15139
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 // Parent
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 int status;
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
70
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
71 waitpid (pid, &status, 0);
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
72
15368
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15209
diff changeset
73 exit (octave_wait::ifexited (status)
36ececf69385 avoid some GCC warnings in the libgui code
John W. Eaton <jwe@octave.org>
parents: 15209
diff changeset
74 ? octave_wait::exitstatus (status) : 127);
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
75 }
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
76
15137
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
77 #endif
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
78 }
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
79
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
80 int
15139
bfc220d1de67 include gui in default Octave binary
John W. Eaton <jwe@octave.org>
parents: 15137
diff changeset
81 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
82 {
16a6b0a6855d GUI: support for octave arguments and integrate with run-octave.
John W. Eaton <jwe@octave.org>
parents: 15081
diff changeset
83 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
84
13506
c70511cf64ee Reformatted to GNU Style.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13504
diff changeset
85 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
86
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 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
88 {
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
89 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
90 {
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
91 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
92 welcomeWizard.exec ();
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
93 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
94 }
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
95 else
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
96 {
15972
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
97 // install translators for the gui and qt text
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
98 QTranslator gui_translator, qt_translator;
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
99 resource_manager::config_translators (&gui_translator,&qt_translator);
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
100 application.installTranslator (&qt_translator);
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
101 application.installTranslator (&gui_translator);
13613
8728061cd0ec Icons are now maintained by the ResourceManager.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13607
diff changeset
102
15972
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
103 // update network-settings
15164
bc801a44bb1f follow Octave pattern for resource_manager singleton
John W. Eaton <jwe@octave.org>
parents: 15155
diff changeset
104 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
105
15972
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
106 // create main window, read settings, and show window
14709
f50591409306 Started to rename class names and methods from camel case to underscore-
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 14707
diff changeset
107 main_window w;
15972
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
108 w.read_settings (); // get widget settings after construction
22ab4fe661d7 gui: selectable language in settings dialog
Torsten <ttl@justmail.de>
parents: 15708
diff changeset
109 // but before showing
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
110 w.show ();
15209
a3c8a3c2dbda set initial keyboard focus in command window (bug #36955)
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
111 w.focus_command_window ();
a3c8a3c2dbda set initial keyboard focus in command window (bug #36955)
John W. Eaton <jwe@octave.org>
parents: 15204
diff changeset
112
13668
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
113 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
114 }
421afeae929b Added a settings wizard that appears at first startup of Octave GUI.
Jacob Dawid <jacob.dawid@googlemail.com>
parents: 13658
diff changeset
115 }
13501
86d6c3b90ad7 Added new gui files.
Jacob Dawid <jacob.dawid@googlemail.com>
parents:
diff changeset
116 }