Mercurial > hg > octave-nkf
changeset 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 | edce7d75597b |
children | 1407aac91bee |
files | libinterp/octave.cc |
diffstat | 1 files changed, 36 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/octave.cc +++ b/libinterp/octave.cc @@ -171,6 +171,9 @@ // If TRUE, don't exit after evaluating code given by --eval option. static bool persist = false; +// If TRUE, the GUI should be started. +static bool start_gui = false; + // Long options. See the comments in getopt.h for the meanings of the // fields in this structure. #define BUILT_IN_DOCSTRINGS_FILE_OPTION 1 @@ -1030,11 +1033,8 @@ return 0; } -// Return int instead of bool because this function is declared -// extern "C". - -int -octave_starting_gui (void) +static bool +check_starting_gui (void) { if (no_window_system || ! display_info::display_available ()) return false; @@ -1069,6 +1069,37 @@ return true; } +// Return int instead of bool because this function is declared +// extern "C". + +int +octave_starting_gui (void) +{ + start_gui = check_starting_gui (); + return start_gui; +} + +DEFUN (isguirunning, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} isguirunning ()\n\ +Return true if Octave is running in GUI mode and false otherwise.\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () == 0) + retval = start_gui; + else + print_usage (); + + return retval; +} + +/* +%!assert (islogical (isguirunning ())) +%!error isguirunning (1) +*/ + DEFUN (argv, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} argv ()\n\