1 ## Copyright (C) 2010-2012 Kai Habel
3 ## This file is part of Octave.
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.
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.
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/>.
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}
31 function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open")
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",
50 if (!ischar (init_path) || !ischar (dialog_name))
51 error ("uigetdir: INIT_PATH and DIALOG_NAME must be string arguments");
54 if (!isdir (init_path))
55 init_path = fileparts (init_path);
57 dirname = feval (funcname, init_path, dialog_name);
62 %! uigetdir(pwd, "Select Directory")
64 ## Remove from test statistics. No real tests possible.