Mercurial > hg > octave-lyh
annotate scripts/plot/uigetdir.m @ 16933:e39f00a32dc7
maint: Use parentheses around condition for switch(),while(),if() statements.
* libinterp/corefcn/dirfns.cc, libinterp/octave-value/ov-fcn-handle.cc,
liboctave/array/Sparse.cc, scripts/image/rgb2ind.m, scripts/io/importdata.m,
scripts/io/strread.m, scripts/optimization/fminbnd.m,
scripts/optimization/sqp.m, scripts/plot/graphics_toolkit.m,
scripts/plot/hdl2struct.m, scripts/plot/legend.m, scripts/plot/print.m,
scripts/plot/printd.m, scripts/plot/private/__contour__.m,
scripts/plot/private/__go_draw_axes__.m, scripts/plot/struct2hdl.m,
scripts/polynomial/polyeig.m, scripts/sparse/bicg.m, scripts/specfun/ellipke.m,
scripts/special-matrix/gallery.m, scripts/ui/errordlg.m, scripts/ui/helpdlg.m,
scripts/ui/inputdlg.m, scripts/ui/listdlg.m, scripts/ui/questdlg.m,
scripts/ui/warndlg.m: Use parentheses around condition for
switch(),while(),if() statements.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 09 Jul 2013 14:04:05 -0700 |
parents | 8fa0b416f465 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13697
diff
changeset
|
1 ## Copyright (C) 2010-2012 Kai Habel |
11283 | 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 -*- | |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11295
diff
changeset
|
20 ## @deftypefn {Function File} {@var{dirname} =} uigetdir () |
11283 | 21 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11295
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{dirname} =} uigetdir (@var{init_path}, @var{dialog_name}) |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
12522
diff
changeset
|
23 ## Open a GUI dialog for selecting a directory. If @var{init_path} is not |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
24 ## given the current working directory is used. @var{dialog_name} may be |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
25 ## used to customize the dialog title. |
15532
95d7475a0a89
doc: Add seealso links between uigetfile, uiputfile, uigetdir.
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
26 ## @seealso{uigetfile, uiputfile} |
11283 | 27 ## @end deftypefn |
28 | |
29 ## Author: Kai Habel | |
30 | |
13697
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
31 function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open") |
11283 | 32 |
16654
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
33 if (! __octave_link_enabled__ ()) |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
34 defaulttoolkit = get (0, "defaultfigure__graphics_toolkit__"); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
35 funcname = ["__uigetdir_", defaulttoolkit, "__"]; |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
36 functype = exist (funcname); |
13697
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
37 if (! __is_function__ (funcname)) |
16654
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
38 funcname = "__uigetdir_fltk__"; |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
39 if (! __is_function__ (funcname)) |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
40 error ("uigetdir: fltk graphics toolkit required"); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
41 elseif (! strcmp (defaulttoolkit, "gnuplot")) |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
42 warning ("uigetdir: no implementation for toolkit '%s', using 'fltk' instead", |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
43 defaulttoolkit); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
44 endif |
13697
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
45 endif |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
46 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
47 |
11283 | 48 if (nargin > 2) |
49 print_usage (); | |
50 endif | |
51 | |
12183
b4d26c65e7e6
Allow ui file function to work if gnuplot is the selected toolkit and fltk is available
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
52 if (!ischar (init_path) || !ischar (dialog_name)) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11295
diff
changeset
|
53 error ("uigetdir: INIT_PATH and DIALOG_NAME must be string arguments"); |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
11295
diff
changeset
|
54 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11583
diff
changeset
|
55 |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
56 if (!isdir (init_path)) |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
57 init_path = fileparts (init_path); |
11283 | 58 endif |
59 | |
16654
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
60 if (__octave_link_enabled__ ()) |
16655
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
61 file_filter = cell (0, 2); |
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
62 default_file_name = ""; |
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
63 dialog_position = [240, 120]; |
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
64 dialog_mode = "dir"; |
16654
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
65 |
16655
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
66 [filename, dirname, filterindex] ... |
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
67 = __octave_link_file_dialog__ (file_filter, dialog_name, |
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
68 default_file_name, dialog_position, |
8fa0b416f465
* uigetdir.m: Eliminate unnecessary cell array for function args.
John W. Eaton <jwe@octave.org>
parents:
16654
diff
changeset
|
69 dialog_mode, init_path); |
16654
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
70 else |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
71 dirname = feval (funcname, init_path, dialog_name); |
510b711f4e31
Added uigetdir to octave_link
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
72 endif |
11283 | 73 endfunction |
74 | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
75 |
11583
c4c2cd67c440
Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents:
11576
diff
changeset
|
76 %!demo |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
77 %! uigetdir (pwd, 'Select Directory'); |
13215 | 78 |
79 ## Remove from test statistics. No real tests possible. | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
80 %!assert (1) |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
81 |