11283
|
1 ## Copyright (C) 2010 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 (@var{init_path}, @var{dialog_name}) |
|
21 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}) |
|
22 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir () |
|
23 ## Open a GUI dialog to select a directory. If @var{init_path} is not given |
|
24 ## the working directory is taken. @var{dialog_name} can be used to |
|
25 ## customize the dialog title. |
|
26 ## @end deftypefn |
|
27 |
|
28 ## Author: Kai Habel |
|
29 |
|
30 function [retdir] = uigetdir (init_path = pwd, name = "Choose directory?") |
|
31 |
|
32 if (!ischar(init_path) || !ischar(name)) |
|
33 error ("Expecting string arguments."); |
|
34 endif |
|
35 |
|
36 if (nargin > 2) |
|
37 print_usage (); |
|
38 endif |
|
39 |
|
40 if (any (cellfun(@(x)strcmp (x, "fltk"), available_backends))) |
|
41 init_path = fileparts (init_path); |
|
42 retdir = __fltk_uigetfile__ ("", name, init_path, [240, 120], "dir"); |
|
43 else |
|
44 error ("uigetdir requires fltk backend."); |
|
45 endif |
|
46 |
|
47 endfunction |
|
48 |
|
49 %!demo |
|
50 %! uigetdir(pwd, "Select Directory") |