]> Creatis software - CreaPhase.git/blob - octave_packages/zenity-0.5.7/zenity_text_info.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / zenity-0.5.7 / zenity_text_info.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} @var{s} = zenity_text_info(@var{title}, @var{text}, @var{editable})
18 ## Display a large amount of text in a graphical display.
19 ## The title of the display window is set with the variable @var{title},
20 ## and the actual text ti display is set with the variable @var{text}.
21 ## If the optional argument @var{editable} is given the displayed text
22 ## is editable. In this case the altered text is returned from the function.
23 ##
24 ## @seealso{zenity_calendar, zenity_list, zenity_progress, zenity_entry, zenity_message,
25 ## zenity_file_selection, zenity_notification}
26 ## @end deftypefn
27
28 function s = zenity_text_info(title, text, editable)
29   if (nargin < 2 || !ischar(title) || !ischar(text))
30     print_usage();
31   endif
32
33   if (nargin < 3)
34     editable = "--editable";
35   else
36     editable = "";
37   endif
38   
39   filename = tmpnam();
40   fid = fopen(filename, "w");
41   fprintf(fid, "%s", text);
42   fclose(fid);
43   
44   cmd = sprintf('zenity --text-info --title="%s" --filename="%s" %s', title, filename, editable);
45   [status, output] = system(cmd);
46   unlink(filename);
47   if (status == 0)
48     s = output;
49   elseif (status == 1)
50     s = "";
51   else
52     error("zenity_text_info: %s", output);
53   endif
54 endfunction