Mercurial > hg > octave-lyh
comparison libinterp/octave.cc @ 15702:534b6f7108b7
Add isguirunning function to query whether the GUI is running
* libinterp/octave.cc (octave_starting_gui): Move functionality to
check_starting_gui and save the result.
(Fisguirunning): New function.
author | Mike Miller <mtmiller@ieee.org> |
---|---|
date | Thu, 29 Nov 2012 23:39:21 -0500 |
parents | dbc6b6b18286 |
children | 009984ecf419 9ede91b3872b |
comparison
equal
deleted
inserted
replaced
15701:edce7d75597b | 15702:534b6f7108b7 |
---|---|
168 // The code to evaluate at startup (--eval CODE) | 168 // The code to evaluate at startup (--eval CODE) |
169 static std::string code_to_eval; | 169 static std::string code_to_eval; |
170 | 170 |
171 // If TRUE, don't exit after evaluating code given by --eval option. | 171 // If TRUE, don't exit after evaluating code given by --eval option. |
172 static bool persist = false; | 172 static bool persist = false; |
173 | |
174 // If TRUE, the GUI should be started. | |
175 static bool start_gui = false; | |
173 | 176 |
174 // Long options. See the comments in getopt.h for the meanings of the | 177 // Long options. See the comments in getopt.h for the meanings of the |
175 // fields in this structure. | 178 // fields in this structure. |
176 #define BUILT_IN_DOCSTRINGS_FILE_OPTION 1 | 179 #define BUILT_IN_DOCSTRINGS_FILE_OPTION 1 |
177 #define DOC_CACHE_FILE_OPTION 2 | 180 #define DOC_CACHE_FILE_OPTION 2 |
1028 clean_up_and_exit (retval); | 1031 clean_up_and_exit (retval); |
1029 | 1032 |
1030 return 0; | 1033 return 0; |
1031 } | 1034 } |
1032 | 1035 |
1033 // Return int instead of bool because this function is declared | 1036 static bool |
1034 // extern "C". | 1037 check_starting_gui (void) |
1035 | |
1036 int | |
1037 octave_starting_gui (void) | |
1038 { | 1038 { |
1039 if (no_window_system || ! display_info::display_available ()) | 1039 if (no_window_system || ! display_info::display_available ()) |
1040 return false; | 1040 return false; |
1041 | 1041 |
1042 if (force_gui_option) | 1042 if (force_gui_option) |
1066 if (! code_to_eval.empty () || remaining_args > 0) | 1066 if (! code_to_eval.empty () || remaining_args > 0) |
1067 return false; | 1067 return false; |
1068 | 1068 |
1069 return true; | 1069 return true; |
1070 } | 1070 } |
1071 | |
1072 // Return int instead of bool because this function is declared | |
1073 // extern "C". | |
1074 | |
1075 int | |
1076 octave_starting_gui (void) | |
1077 { | |
1078 start_gui = check_starting_gui (); | |
1079 return start_gui; | |
1080 } | |
1081 | |
1082 DEFUN (isguirunning, args, , | |
1083 "-*- texinfo -*-\n\ | |
1084 @deftypefn {Built-in Function} {} isguirunning ()\n\ | |
1085 Return true if Octave is running in GUI mode and false otherwise.\n\ | |
1086 @end deftypefn") | |
1087 { | |
1088 octave_value retval; | |
1089 | |
1090 if (args.length () == 0) | |
1091 retval = start_gui; | |
1092 else | |
1093 print_usage (); | |
1094 | |
1095 return retval; | |
1096 } | |
1097 | |
1098 /* | |
1099 %!assert (islogical (isguirunning ())) | |
1100 %!error isguirunning (1) | |
1101 */ | |
1071 | 1102 |
1072 DEFUN (argv, args, , | 1103 DEFUN (argv, args, , |
1073 "-*- texinfo -*-\n\ | 1104 "-*- texinfo -*-\n\ |
1074 @deftypefn {Built-in Function} {} argv ()\n\ | 1105 @deftypefn {Built-in Function} {} argv ()\n\ |
1075 Return the command line arguments passed to Octave. For example,\n\ | 1106 Return the command line arguments passed to Octave. For example,\n\ |