1 ## Copyright (C) 2006 Søren Hauberg
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.
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.
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/>.
17 ## @deftypefn {Function File} @var{h} = zenity_progress(@var{title}, @var{option1}, @var{option2})
18 ## @deftypefnx {Function File} zenity_progress(@var{h}, @var{progress})
19 ## @deftypefnx {Function File} zenity_progress(@var{h}, @var{progress}, @var{text})
20 ## Displays a graphical progress bar.
21 ## If the first argument is either non-present or a string, a new progress bar is
22 ## created and a handle is returned. If the first argument is a string it will be
23 ## used as the title of the progress bar. The two optional arguments @var{option1}
24 ## and @var{option2} can be
27 ## The progress bar will be closed when it reaches 100.
29 ## The progress bar will pulsate.
32 ## If the first argument is a handle to a progress bar and the second
33 ## argument is an integer, the progress bar will set its current value
34 ## to the given integer. If the second argument is a string, the text
35 ## of the progress bar will be set to the given string.
36 ## It is possible to pass both an integer and a string to the function
37 ## in one function call.
39 ## @seealso{zenity_calendar, zenity_list, zenity_entry, zenity_message,
40 ## zenity_text_info, zenity_file_selection, zenity_notification}
43 function pid = zenity_progress(h, progress, text)
44 ## Create a progress bar?
45 if (nargin == 0 || (nargin >= 1 && ischar(h)))
49 title = sprintf('--title="%s" --text="%s"', h, h);
52 if (nargin > 1 && ischar(progress))
53 if (strcmpi(progress, "auto-close"))
54 options = sprintf("%s --auto-close", options);
55 elseif (strcmpi(progress, "pulsate"))
56 options = sprintf("%s --pulsate", options);
59 if (nargin > 2 && ischar(text))
60 if (strcmpi(text, "auto-close"))
61 options = sprintf("%s --auto-close", options);
62 elseif (strcmpi(text, "pulsate"))
63 options = sprintf("%s --pulsate", options);
67 pid = popen(["zenity --progress ", title, " ", options], "w");
68 ## Handle an existing process
69 elseif (nargin > 0 && isnumeric(h))
71 if (nargin > 1 && isnumeric(progress))
72 out = sprintf("%s\n%d\n", out, progress);
74 if (nargin > 1 && ischar(progress))
75 out = sprintf("%s\n#%s\n", out, progress);
77 if (nargin > 2 && isnumeric(text))
78 out = sprintf("%s\n%d\n", out, text);
80 if (nargin > 2 && ischar(text))
81 out = sprintf("%s\n#%s\n", out, text);