]> Creatis software - CreaPhase.git/blob - octave_packages/m/plot/uigetdir.m
update packages
[CreaPhase.git] / octave_packages / m / plot / uigetdir.m
1 ## Copyright (C) 2010-2012 Kai Habel
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn  {Function File} {@var{dirname} =} uigetdir ()
21 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path})
22 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}, @var{dialog_name})
23 ## Open a GUI dialog for selecting a directory.  If @var{init_path} is not
24 ## given the current working directory is used.  @var{dialog_name} may be
25 ## used to customize the dialog title.
26 ## @seealso{uigetfile}
27 ## @end deftypefn
28
29 ## Author: Kai Habel
30
31 function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open")
32
33   defaulttoolkit = get (0, "defaultfigure__graphics_toolkit__");
34   funcname = ["__uigetdir_", defaulttoolkit, "__"];
35   functype = exist (funcname);
36   if (! __is_function__ (funcname))
37     funcname = "__uigetdir_fltk__";
38     if (! __is_function__ (funcname))
39       error ("uigetdir: fltk graphics toolkit required");
40     elseif (! strcmp (defaulttoolkit, "gnuplot"))
41       warning ("uigetdir: no implementation for toolkit `%s', using `fltk' instead",
42                defaulttoolkit);
43     endif
44   endif
45
46   if (nargin > 2)
47     print_usage ();
48   endif
49
50   if (!ischar (init_path) || !ischar (dialog_name))
51     error ("uigetdir: INIT_PATH and DIALOG_NAME must be string arguments");
52   endif
53
54   if (!isdir (init_path))
55     init_path = fileparts (init_path);
56   endif
57   dirname = feval (funcname, init_path, dialog_name);
58
59 endfunction
60
61 %!demo
62 %! uigetdir(pwd, "Select Directory")
63
64 ## Remove from test statistics.  No real tests possible.
65 %!test
66 %! assert (1);