]> Creatis software - CreaPhase.git/blob - octave_packages/zenity-0.5.7/zenity_message.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / zenity-0.5.7 / zenity_message.m
1 ## Copyright (C) 2006  Søren Hauberg
2 ## 
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
7 ## 
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
12 ## 
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn  {Function File} zenity_message(@var{text}, @var{type})
18 ## Displays a graphical message dialog.
19 ## The variable @var{text} sets the message of the dialog, and the
20 ## optional variable @var{type} sets the type of the message.
21 ## @var{type} must be one of the following strings @code{error},
22 ## @code{info}, @code{question}, and @code{warning}. The default
23 ## value of @var{type} is @code{info}. Retuns the value @code{status}
24 ## which is 0 for 'Ok' and 1 for 'Cancel' button selection; a value 
25 ## of -1 indicates a failure of dialog box.
26 ##
27 ## @seealso{zenity_calendar, zenity_list, zenity_progress, zenity_entry,
28 ## zenity_text_info, zenity_file_selection, zenity_notification}
29 ## @end deftypefn
30
31 function status=zenity_message(text, type)
32   if (nargin == 0 || !ischar(text)), print_usage(); endif
33   if (nargin < 2), type = "info"; endif
34   if !(ischar(type) && any(strcmp(type, {"error", "info", "question", "warning"})))
35     error("zenity_message: unsupported message type: %s", type);
36   endif
37   
38   cmd = sprintf('zenity --%s --text="%s"', type, text);
39   [status, output] = system(cmd);
40   if (status == -1)
41     error("zenity_message: %s", output);
42   endif
43 endfunction