# HG changeset patch # User Mike Miller # Date 1354250361 18000 # Node ID 534b6f7108b7d593cb0c67bdf789b624654296da # Parent edce7d75597b8c60c774e52258dc95e9b473d0e0 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. diff -r edce7d75597b -r 534b6f7108b7 libinterp/octave.cc --- a/libinterp/octave.cc Thu Oct 25 14:06:35 2012 -0700 +++ b/libinterp/octave.cc Thu Nov 29 23:39:21 2012 -0500 @@ -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\