annotate scripts/gui/uigetfile.m @ 23220:092078913d54

maint: Merge stable to default.
author John W. Eaton <jwe@octave.org>
date Wed, 22 Feb 2017 12:58:07 -0500
parents ef4d915df748 3ac9f9ecfae5
children 194eb4bd202b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
1 ## Copyright (C) 2010-2017 Kai Habel
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
2 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
3 ## This file is part of Octave.
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
4 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22359
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22359
diff changeset
8 ## (at your option) any later version.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
9 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22359
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22359
diff changeset
13 ## GNU General Public License for more details.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
14 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
18
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
20 ## @deftypefn {} {[@var{fname}, @var{fpath}, @var{fltidx}] =} uigetfile ()
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
21 ## @deftypefnx {} {[@dots{}] =} uigetfile (@var{flt})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
22 ## @deftypefnx {} {[@dots{}] =} uigetfile (@var{flt}, @var{dialog_name})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
23 ## @deftypefnx {} {[@dots{}] =} uigetfile (@var{flt}, @var{dialog_name}, @var{default_file})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
24 ## @deftypefnx {} {[@dots{}] =} uigetfile (@dots{}, "Position", [@var{px} @var{py}])
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
25 ## @deftypefnx {} {[@dots{}] =} uigetfile (@dots{}, "MultiSelect", @var{mode})
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
26 ##
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
27 ## Open a GUI dialog for selecting a file and return the filename @var{fname},
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
28 ## the path to this file @var{fpath}, and the filter index @var{fltidx}.
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
29 ##
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
30 ## @var{flt} contains a (list of) file filter string(s) in one of the following
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
31 ## formats:
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
32 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
33 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
34 ## @item @qcode{"/path/to/filename.ext"}
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
35 ## If a filename is given then the file extension is extracted and used as
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
36 ## filter. In addition, the path is selected as current path and the filename
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
37 ## is selected as default file. Example: @code{uigetfile ("myfun.m")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
38 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
39 ## @item A single file extension @qcode{"*.ext"}
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
40 ## Example: @code{uigetfile ("*.ext")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
41 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
42 ## @item A 2-column cell array
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
43 ## containing a file extension in the first column and a brief description in
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
44 ## the second column.
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
45 ## Example: @code{uigetfile (@{"*.ext", "My Description";"*.xyz",
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
46 ## "XYZ-Format"@})}
11583
c4c2cd67c440 Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
47 ##
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
48 ## The filter string can also contain a semicolon separated list of filter
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
49 ## extensions.
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
50 ## Example: @code{uigetfile (@{"*.gif;*.png;*.jpg", "Supported Picture
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
51 ## Formats"@})}
22359
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
52 ##
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
53 ## @item A directory name or path name
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
54 ## If the folder name of path name contains a trailing file separator, the
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
55 ## contents of that folder will be displayed. If no trailing file separator
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
56 ## is present the parent directory is listed. The substring to the right of
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
57 ## the rightmost file separator (if any) will be interpreted as a file or
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
58 ## directory name and if that file or directory exists it will be highlighted.
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
59 ## If the path name or directory name is wholly or partly nonexistent, the
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
60 ## current working directory will be displayed.
929a1500907e uigetfile.m: fix type and allow path names as input arg (bug #48828)
Philip Nienhuis <prnienhuis@users.sf.net>
parents: 22323
diff changeset
61 ## No filter will be active.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
62 ## @end table
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
63 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
64 ## @var{dialog_name} can be used to customize the dialog title.
20173
777f26aa8e3e doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19848
diff changeset
65 ##
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
66 ## If @var{default_file} is given then it will be selected in the GUI dialog.
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
67 ## If, in addition, a path is given it is also used as current path.
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
68 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
69 ## The screen position of the GUI dialog can be set using the
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
70 ## @qcode{"Position"} key and a 2-element vector containing the pixel
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
71 ## coordinates. Two or more files can be selected when setting the
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
72 ## @qcode{"MultiSelect"} key to @qcode{"on"}. In that case @var{fname} is a
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
73 ## cell array containing the files.
15532
95d7475a0a89 doc: Add seealso links between uigetfile, uiputfile, uigetdir.
Rik <rik@octave.org>
parents: 15467
diff changeset
74 ## @seealso{uiputfile, uigetdir}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
75 ## @end deftypefn
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
76
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
77 ## Author: Kai Habel
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
78
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
79 function [retfile, retpath, retindex] = uigetfile (varargin)
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
80
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
81 if (nargin > 7)
11295
75ff3db6a687 Simplify code for uimenu.m. Fix error messages for ui file functions.
Kai Habel <kai.habel@gmx.de>
parents: 11284
diff changeset
82 error ("uigetfile: number of input arguments must be less than eight");
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
83 endif
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
84
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
85 ## Preset default values
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
86 outargs = {cell(0, 2), # File Filter
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
87 "Open File", # Dialog Title
20713
2469d78a1d8b Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents: 20711
diff changeset
88 "", # Default filename
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
89 [240, 120], # Dialog Position (pixel x/y)
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
90 "off", # MultiSelect on/off
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
91 pwd}; # Default directory
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
92
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
93 idx1 = idx2 = [];
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
94 has_opts = false;
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
95 if (nargin > 0)
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
96 idx1 = find (strcmpi (varargin, "multiselect"), 1);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
97 idx2 = find (strcmpi (varargin, "position"), 1);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
98 if (idx1 || idx2)
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
99 has_opts = true;
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
100 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
101 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
102
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
103 optidx = min ([idx1, idx2, nargin+1]);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
104
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
105 args = varargin(1:optidx-1);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
106
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
107 len = numel (args);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
108 if (len > 0)
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
109 [outargs{1}, outargs{3}, defdir] = __file_filter__ ("uigetfile", args{1});
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
110 if (! isempty (defdir))
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
111 outargs{6} = defdir;
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
112 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
113 else
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
114 outargs{1} = __file_filter__ ("uigetfile", outargs{1});
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
115 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
116
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
117 if (len > 1)
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
118 if (ischar (args{2}))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
119 if (! isempty (args{2}))
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
120 outargs{2} = args{2};
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
121 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
122 elseif (! isempty (args{2}))
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
123 print_usage ();
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
124 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
125 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
126
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
127 if (len > 2)
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
128 if (ischar (args{3}))
19751
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
129 if (isdir (args{3}))
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
130 fdir = args{3};
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
131 fname = fext = "";
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
132 else
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
133 [fdir, fname, fext] = fileparts (varargin{3});
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
134 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
135 if (! isempty (fdir))
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
136 outargs{6} = fdir;
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
137 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
138 if (! isempty (fname) || ! isempty (fext))
20778
8513c84a13cb Use parser string concatenation rather than strcat() for performance in m-files.
Rik <rik@octave.org>
parents: 20713
diff changeset
139 outargs{3} = [fname fext];
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
140 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
141 elseif (! isempty (args{3}))
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
142 print_usage ();
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
143 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
144 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
145
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
146 if (has_opts)
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
147 ## string arguments ("position" or "multiselect")
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
148
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
149 ## check for even number of remaining arguments, prop/value pair(s)
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
150 if (rem (nargin - optidx + 1, 2))
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20173
diff changeset
151 error ("uigetfile: PROPERTY/VALUE arguments must occur in pairs");
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
152 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
153
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
154 for i = optidx : 2 : nargin
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
155 prop = varargin{i};
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
156 val = varargin{i + 1};
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17281
diff changeset
157 if (strcmpi (prop, "position"))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
158 if (! isnumeric (val) || length (val) != 2)
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20173
diff changeset
159 error ('uigetfile: "Position" must be a 2-element vector');
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
160 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
161 outargs{4} = val;
17408
266fafd1ffc1 fix 2 strcmp<->strncmp issues from 3f0ed69d21c6
Andreas Weber <andreas.weber@hs-offenburg.de>
parents: 17405
diff changeset
162 elseif (strcmpi (prop, "multiselect"))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
163 if (! ischar (val))
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20173
diff changeset
164 error ('uigetfile: MultiSelect value must be a string ("on"/"off")');
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
165 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
166 outargs{5} = tolower (val);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
167 else
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
168 error ("uigetfile: unknown argument '%s'", prop);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
169 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
170 endfor
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
171 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
172
19848
9b7ca334a104 Backout cset a9952a647d52 and use __octave_link_enabled__ rather than isguirunning.
Rik <rik@octave.org>
parents: 19833
diff changeset
173 if (__octave_link_enabled__ ())
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
174 [retfile, retpath, retindex] = __octave_link_file_dialog__ (outargs{:});
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
175 else
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
176 funcname = __get_funcname__ (mfilename ());
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
177 [retfile, retpath, retindex] = feval (funcname, outargs{:});
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
178 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
179
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
180 endfunction
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
181
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14225
diff changeset
182
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
183 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
184 %! uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'});
13215
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
185
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
186 ## Remove from test statistics. No real tests possible.
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
187 %!assert (1)