]> Creatis software - CreaPhase.git/blob - octave_packages/zenity-0.5.7/zenity_entry.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / zenity-0.5.7 / zenity_entry.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_entry(@var{text}, @var{entry_text}, @var{password})
18 ## Displays a text entry dialog.
19 ## The variable @var{text} sets the title of the dialog, and the
20 ## @var{entry_text} variable sets the default value of the text
21 ## entry field. If the @var{password} variable is non-empty the
22 ## value of the text entry field will not be displayed on the screen.
23 ## All arguments are optional.
24 ##
25 ## @seealso{zenity_calendar, zenity_list, zenity_progress, zenity_message,
26 ## zenity_text_info, zenity_file_selection, zenity_notification}
27 ## @end deftypefn
28
29 function s = zenity_entry(text, entrytext, password)
30   if (nargin < 1), text      = ""; endif
31   if (nargin < 2), entrytext = ""; endif
32   if (nargin < 3), password  = ""; endif
33
34   if (!isempty(text)), text = sprintf('--text="%s" --title="%s"', text, text); endif
35   if (!isempty(entrytext)), entrytext = sprintf('--entry-text="%s"', entrytext); endif
36   if (!isempty(password)), password = "--hide-text"; endif
37   
38   cmd = sprintf('zenity --entry %s %s %s', text, entrytext, password);
39   [status, output] = system(cmd);
40   if (status == 0)
41     if (output(end) == "\n") output = output(1:end-1); endif
42     s = output;
43   elseif (status == 1)
44     s = "";
45   else
46     error("zenity_entry: %s", output);
47   endif
48 endfunction