Mercurial > hg > octave-lyh
annotate scripts/plot/uigetdir.m @ 11295:75ff3db6a687
Simplify code for uimenu.m. Fix error messages for ui file functions.
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Thu, 25 Nov 2010 17:16:46 +0100 |
parents | f44c47959256 |
children | c776f063fefe |
rev | line source |
---|---|
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)) | |
11295
75ff3db6a687
Simplify code for uimenu.m. Fix error messages for ui file functions.
Kai Habel <kai.habel@gmx.de>
parents:
11289
diff
changeset
|
33 error ("uigetdir: expecting string arguments."); |
11283 | 34 endif |
35 | |
36 if (nargin > 2) | |
37 print_usage (); | |
38 endif | |
39 | |
40 if (any (cellfun(@(x)strcmp (x, "fltk"), available_backends))) | |
11289 | 41 if (!isdir (init_path)) |
42 init_path = fileparts (init_path); | |
43 endif | |
11283 | 44 retdir = __fltk_uigetfile__ ("", name, init_path, [240, 120], "dir"); |
45 else | |
11295
75ff3db6a687
Simplify code for uimenu.m. Fix error messages for ui file functions.
Kai Habel <kai.habel@gmx.de>
parents:
11289
diff
changeset
|
46 error ("uigetdir: fltk backend required."); |
11283 | 47 endif |
48 | |
49 endfunction | |
50 | |
51 %!demo | |
52 %! uigetdir(pwd, "Select Directory") |