]> Creatis software - CreaPhase.git/blob - octave_packages/zenity-0.5.7/zenity_calendar.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / zenity-0.5.7 / zenity_calendar.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{d} = zenity_calendar(@var{title}, @var{day}, @var{month}, @var{year})
18 ## Displays a date selection window.
19 ## The variable @var{title} sets the title of the calendar.
20 ## The optional arguments @var{day}, @var{month}, and @var{year} changes
21 ## the standard selected date.
22 ##
23 ## @seealso{zenity_list, zenity_progress, zenity_entry, zenity_message,
24 ## zenity_text_info, zenity_file_selection, zenity_notification}
25 ## @end deftypefn
26
27 function d = zenity_calendar(title, day, month, year)
28   [Y, M, D] = datevec(date);
29   if (nargin < 1), title = "Select a date"; endif
30   if (nargin < 2), day   = D; endif
31   if (nargin < 3), month = M; endif
32   if (nargin < 4), year  = Y; endif
33   
34   cmd = sprintf(['zenity --calendar --title="%s" --text="%s" ', ...
35                  '--day=%d --month=%d --year=%d --date-format="%%m/%%d/%%Y"'],
36                  title, title, day, month, year);
37   [status, output] = system(cmd);
38   if (status == 0)
39     if (length(output) > 0 && output(end) == "\n")
40       output = output(1:end-1);
41     endif
42     d = datestr(output);
43   elseif (status == 1)
44     d = "";
45   else
46     error("zenity_calendar: %s", output);
47   endif
48 endfunction