Mercurial > octave
annotate scripts/gui/uigetfile.m @ 27918:b442ec6dda5c
use centralized file for copyright info for individual contributors
* COPYRIGHT.md: New file.
* In most other files, use "Copyright (C) YYYY-YYYY The Octave Project
Developers" instead of tracking individual names in separate source
files. The motivation is to reduce the effort required to update the
notices each year.
Until now, the Octave source files contained copyright notices that
list individual contributors. I adopted these file-scope copyright
notices because that is what everyone was doing 30 years ago in the
days before distributed version control systems. But now, with many
contributors and modern version control systems, having these
file-scope copyright notices causes trouble when we update copyright
years or refactor code.
Over time, the file-scope copyright notices may become outdated as new
contributions are made or code is moved from one file to
another. Sometimes people contribute significant patches but do not
add a line claiming copyright. Other times, people add a copyright
notice for their contribution but then a later refactoring moves part
or all of their contribution to another file and the notice is not
moved with the code. As a practical matter, moving such notices is
difficult -- determining what parts are due to a particular
contributor requires a time-consuming search through the project
history. Even managing the yearly update of copyright years is
problematic. We have some contributors who are no longer
living. Should we update the copyright dates for their contributions
when we release new versions? Probably not, but we do still want to
claim copyright for the project as a whole.
To minimize the difficulty of maintaining the copyright notices, I
would like to change Octave's sources to use what is described here:
https://softwarefreedom.org/resources/2012/ManagingCopyrightInformation.html
in the section "Maintaining centralized copyright notices":
The centralized notice approach consolidates all copyright
notices in a single location, usually a top-level file.
This file should contain all of the copyright notices
provided project contributors, unless the contribution was
clearly insignificant. It may also credit -- without a copyright
notice -- anyone who helped with the project but did not
contribute code or other copyrighted material.
This approach captures less information about contributions
within individual files, recognizing that the DVCS is better
equipped to record those details. As we mentioned before, it
does have one disadvantage as compared to the file-scope
approach: if a single file is separated from the distribution,
the recipient won't see the contributors' copyright notices.
But this can be easily remedied by including a single
copyright notice in each file's header, pointing to the
top-level file:
Copyright YYYY-YYYY The Octave Project Developers
See the COPYRIGHT file at the top-level directory
of this distribution or at https://octave.org/COPYRIGHT.html.
followed by the usual GPL copyright statement.
For more background, see the discussion here:
https://lists.gnu.org/archive/html/octave-maintainers/2020-01/msg00009.html
Most files in the following directories have been skipped intentinally
in this changeset:
doc
libgui/qterminal
liboctave/external
m4
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 15:38:17 -0500 |
parents | f658d41003e4 |
children | 1891570abac8 |
rev | line source |
---|---|
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27908
diff
changeset
|
1 ## Copyright (C) 2010-2019 The Octave Project Developers |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27908
diff
changeset
|
2 ## |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27908
diff
changeset
|
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27908
diff
changeset
|
4 ## or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27908
diff
changeset
|
5 ## |
11283 | 6 ## |
7 ## This file is part of Octave. | |
8 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
9 ## Octave is free software: you can redistribute it and/or modify it |
11283 | 10 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
11 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22359
diff
changeset
|
12 ## (at your option) any later version. |
11283 | 13 ## |
14 ## Octave is distributed in the hope that it will be useful, but | |
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22359
diff
changeset
|
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22359
diff
changeset
|
17 ## GNU General Public License for more details. |
11283 | 18 ## |
19 ## You should have received a copy of the GNU General Public License | |
20 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
21 ## <https://www.gnu.org/licenses/>. |
11283 | 22 |
23 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20778
diff
changeset
|
24 ## @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
|
25 ## @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
|
26 ## @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
|
27 ## @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
|
28 ## @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
|
29 ## @deftypefnx {} {[@dots{}] =} uigetfile (@dots{}, "MultiSelect", @var{mode}) |
11283 | 30 ## |
16580
adc150db1809
style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents:
16579
diff
changeset
|
31 ## 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
|
32 ## 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
|
33 ## |
11283 | 34 ## @var{flt} contains a (list of) file filter string(s) in one of the following |
35 ## formats: | |
36 ## | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
37 ## @table @asis |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16580
diff
changeset
|
38 ## @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
|
39 ## If a filename is given then the file extension is extracted and used as |
27831
b42e4b3dee5d
uigetfile.m, uiputfile.m: Add documentation for output arguments (bug #55419).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27263
diff
changeset
|
40 ## filter. In addition, the path is selected as current path in the dialog and |
b42e4b3dee5d
uigetfile.m, uiputfile.m: Add documentation for output arguments (bug #55419).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27263
diff
changeset
|
41 ## the filename is selected as default file. |
b42e4b3dee5d
uigetfile.m, uiputfile.m: Add documentation for output arguments (bug #55419).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27263
diff
changeset
|
42 ## Example: @code{uigetfile ("myfun.m")} |
11283 | 43 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16580
diff
changeset
|
44 ## @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
|
45 ## Example: @code{uigetfile ("*.ext")} |
11283 | 46 ## |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
47 ## @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
|
48 ## 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
|
49 ## the second column. |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
50 ## Example: @code{uigetfile (@{"*.ext", "My Description";"*.xyz", |
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
51 ## "XYZ-Format"@})} |
11583
c4c2cd67c440
Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents:
11576
diff
changeset
|
52 ## |
11283 | 53 ## The filter string can also contain a semicolon separated list of filter |
54 ## extensions. | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
55 ## 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
|
56 ## 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
|
57 ## |
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 ## @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
|
59 ## 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
|
60 ## 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
|
61 ## 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
|
62 ## 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
|
63 ## directory name and if that file or directory exists it will be highlighted. |
27831
b42e4b3dee5d
uigetfile.m, uiputfile.m: Add documentation for output arguments (bug #55419).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27263
diff
changeset
|
64 ## If the path name or directory name is entirely or partly nonexistent, the |
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
|
65 ## 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
|
66 ## No filter will be active. |
11283 | 67 ## @end table |
68 ## | |
69 ## @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
|
70 ## |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
71 ## 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
|
72 ## 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
|
73 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
16580
diff
changeset
|
74 ## 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
|
75 ## @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
|
76 ## 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
|
77 ## @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
|
78 ## cell array containing the files. |
27831
b42e4b3dee5d
uigetfile.m, uiputfile.m: Add documentation for output arguments (bug #55419).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27263
diff
changeset
|
79 ## |
27908
f658d41003e4
Document FLTIDX in uigetfile/uiputfile (bug #55419)
Rik <rik@octave.org>
parents:
27831
diff
changeset
|
80 ## @var{fname} and @var{fpath} return the chosen name and path, respectively. |
f658d41003e4
Document FLTIDX in uigetfile/uiputfile (bug #55419)
Rik <rik@octave.org>
parents:
27831
diff
changeset
|
81 ## @var{fltidx} is the index in the list of filter extensions @var{flt} that |
f658d41003e4
Document FLTIDX in uigetfile/uiputfile (bug #55419)
Rik <rik@octave.org>
parents:
27831
diff
changeset
|
82 ## was selected. |
27831
b42e4b3dee5d
uigetfile.m, uiputfile.m: Add documentation for output arguments (bug #55419).
Markus Mützel <markus.muetzel@gmx.de>
parents:
27263
diff
changeset
|
83 ## |
15532
95d7475a0a89
doc: Add seealso links between uigetfile, uiputfile, uigetdir.
Rik <rik@octave.org>
parents:
15467
diff
changeset
|
84 ## @seealso{uiputfile, uigetdir} |
11283 | 85 ## @end deftypefn |
86 | |
87 ## Author: Kai Habel | |
88 | |
89 function [retfile, retpath, retindex] = uigetfile (varargin) | |
90 | |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
91 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
|
92 error ("uigetfile: number of input arguments must be less than eight"); |
11283 | 93 endif |
94 | |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19799
diff
changeset
|
95 ## Preset default values |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19799
diff
changeset
|
96 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
|
97 "Open File", # Dialog Title |
20713
2469d78a1d8b
Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents:
20711
diff
changeset
|
98 "", # Default filename |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19799
diff
changeset
|
99 [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
|
100 "off", # MultiSelect on/off |
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19799
diff
changeset
|
101 pwd}; # Default directory |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
102 |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
103 idx1 = idx2 = []; |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
104 has_opts = false; |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
105 if (nargin > 0) |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
106 idx1 = find (strcmpi (varargin, "multiselect"), 1); |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
107 idx2 = find (strcmpi (varargin, "position"), 1); |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
108 if (idx1 || idx2) |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
109 has_opts = true; |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
110 endif |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
111 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
112 |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
113 optidx = min ([idx1, idx2, nargin+1]); |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
114 |
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
115 args = varargin(1:optidx-1); |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
116 |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
117 len = numel (args); |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
118 if (len > 0) |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
119 [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
|
120 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
|
121 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
|
122 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
123 else |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
124 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
|
125 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
126 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
127 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
|
128 if (ischar (args{2})) |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
129 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
|
130 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
|
131 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
132 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
|
133 print_usage (); |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
134 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
135 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
136 |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
137 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
|
138 if (ischar (args{3})) |
25781
e04c56bbbace
isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
139 if (isfolder (args{3})) |
19751
70380bb91b81
uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
140 fdir = args{3}; |
70380bb91b81
uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
141 fname = fext = ""; |
70380bb91b81
uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
142 else |
70380bb91b81
uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
143 [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
|
144 endif |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
145 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
|
146 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
|
147 endif |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
148 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
|
149 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
|
150 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
151 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
|
152 print_usage (); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13215
diff
changeset
|
153 endif |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
154 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
155 |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
156 if (has_opts) |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19799
diff
changeset
|
157 ## string arguments ("position" or "multiselect") |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
158 |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
159 ## 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
|
160 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
|
161 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
|
162 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
163 |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
164 for i = optidx : 2 : nargin |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
165 prop = varargin{i}; |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
166 val = varargin{i + 1}; |
17405
3f0ed69d21c6
Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
167 if (strcmpi (prop, "position")) |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
168 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
|
169 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
|
170 endif |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
171 outargs{4} = val; |
17408
266fafd1ffc1
fix 2 strcmp<->strncmp issues from 3f0ed69d21c6
Andreas Weber <andreas.weber@hs-offenburg.de>
parents:
17405
diff
changeset
|
172 elseif (strcmpi (prop, "multiselect")) |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
173 if (! ischar (val)) |
20711
7b608fadc663
Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
174 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
|
175 endif |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
176 outargs{5} = tolower (val); |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
177 else |
21843
f7a57b07c81d
Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents:
21178
diff
changeset
|
178 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
|
179 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
180 endfor |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
181 endif |
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
182 |
27263
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
183 if (__event_manager_enabled__ ()) |
99aa1bcb8848
rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
184 [retfile, retpath, retindex] = __event_manager_file_dialog__ (outargs{:}); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
185 else |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19799
diff
changeset
|
186 funcname = __get_funcname__ (mfilename ()); |
16579
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
187 [retfile, retpath, retindex] = feval (funcname, outargs{:}); |
7f8db1942dc0
Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents:
15532
diff
changeset
|
188 endif |
12522
33bbae85769a
Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12183
diff
changeset
|
189 |
11283 | 190 endfunction |
191 | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14225
diff
changeset
|
192 |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11583
diff
changeset
|
193 %!demo |
14245
4506eade9f04
Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
194 %! uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'}); |
13215 | 195 |
196 ## 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
|
197 %!assert (1) |