annotate scripts/gui/uigetfile.m @ 30196:813b7827c5f8

Remove "position" argument from file dialog functions (bug #60980). * libinterp/corefcn/event-manager.cc (F__event_manager_file_dialog__), libinterp/dldfcn/__fltk_uigetfile (F__fltk_uigetfile__): Remove unused argument "position". * scripts/gui/uigetdir.m, scripts/gui/uigetfile.m, scripts/gui/uiputfile.m, scripts/gui/private/__uigetdir_fltk__.m, scripts/gui/private/__uigetfile_fltk__.m, scripts/gui/private/__uiputfile_fltk__.m: Remove handling argument "position".
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 19 Sep 2021 17:06:26 +0200
parents a7981aa5822b
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 28022
diff changeset
3 ## Copyright (C) 2010-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 27908
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
7 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
8 ## This file is part of Octave.
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
11 ## 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
12 ## 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
13 ## (at your option) any later version.
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 ## 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
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22359
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22359
diff changeset
18 ## GNU General Public License for more details.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
19 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
20 ## 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
21 ## 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
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
25
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20778
diff changeset
27 ## @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
28 ## @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
29 ## @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
30 ## @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
31 ## @deftypefnx {} {[@dots{}] =} uigetfile (@dots{}, "MultiSelect", @var{mode})
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
32 ##
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
33 ## 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
34 ## 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
35 ##
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
36 ## @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
37 ## formats:
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
38 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
39 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
40 ## @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
41 ## 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
42 ## 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
43 ## 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
44 ## Example: @code{uigetfile ("myfun.m")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
45 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
46 ## @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
47 ## Example: @code{uigetfile ("*.ext")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
48 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
49 ## @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
50 ## 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
51 ## the second column.
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
52 ## Example: @code{uigetfile (@{"*.ext", "My Description";"*.xyz",
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
53 ## "XYZ-Format"@})}
11583
c4c2cd67c440 Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
54 ##
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
55 ## 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
56 ## extensions.
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
57 ## 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
58 ## 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
59 ##
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 ## @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
61 ## 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
62 ## 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
63 ## 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
64 ## 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
65 ## 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
66 ## 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
67 ## 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
68 ## No filter will be active.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
69 ## @end table
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
70 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
71 ## @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
72 ##
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
73 ## 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
74 ## 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
75 ##
30196
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
76 ## Two or more files can be selected when setting the @qcode{"MultiSelect"} key
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
77 ## to @qcode{"on"}. In that case, @var{fname} is a cell array containing the
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
78 ## 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 ##
28022
306df6825dd9 doc: Document return values for uigetdir/uigetfil when 'Cancel' button used (bug #57670).
Rik <rik@octave.org>
parents: 27978
diff changeset
80 ## The outputs @var{fname} and @var{fpath} are strings returning the chosen
306df6825dd9 doc: Document return values for uigetdir/uigetfil when 'Cancel' button used (bug #57670).
Rik <rik@octave.org>
parents: 27978
diff changeset
81 ## name and path, respectively. However, if the @samp{Cancel} button is
306df6825dd9 doc: Document return values for uigetdir/uigetfil when 'Cancel' button used (bug #57670).
Rik <rik@octave.org>
parents: 27978
diff changeset
82 ## clicked the outputs are of type double with a value of @code{0}.
27908
f658d41003e4 Document FLTIDX in uigetfile/uiputfile (bug #55419)
Rik <rik@octave.org>
parents: 27831
diff changeset
83 ## @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
84 ## 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
85 ##
15532
95d7475a0a89 doc: Add seealso links between uigetfile, uiputfile, uigetdir.
Rik <rik@octave.org>
parents: 15467
diff changeset
86 ## @seealso{uiputfile, uigetdir}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
87 ## @end deftypefn
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
88
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
89 function [retfile, retpath, retindex] = uigetfile (varargin)
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
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
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
93 endif
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
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 "off", # MultiSelect on/off
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
100 pwd}; # Default directory
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
101
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
102 idx1 = idx2 = [];
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
103 has_opts = false;
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
104 if (nargin > 0)
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
105 idx1 = find (strcmpi (varargin, "multiselect"), 1);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
106 idx2 = find (strcmpi (varargin, "position"), 1);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
107 if (idx1 || idx2)
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
108 has_opts = true;
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
109 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
110 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
111
30196
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
112 if (! isempty (idx2))
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
113 ## FIXME: Remove handling the "position" property completely in Octave 9
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
114 warning (['uigetfile: The "position" argument is deprecated and will ', ...
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
115 "be ignored. Consider removing it from the function call."]);
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
116 endif
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
117
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
118 optidx = min ([idx1, nargin+1]);
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
119
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
120 args = varargin(1:optidx-1);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
121
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
122 len = numel (args);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
123 if (len > 0)
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
124 [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
125 if (! isempty (defdir))
30196
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
126 outargs{5} = defdir;
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
127 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
128 else
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
129 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
130 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
131
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
132 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
133 if (ischar (args{2}))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
134 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
135 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
136 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
137 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
138 print_usage ();
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
139 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
140 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
141
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
142 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
143 if (ischar (args{3}))
25781
e04c56bbbace isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents: 25054
diff changeset
144 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
145 fdir = args{3};
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
146 fname = fext = "";
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
147 else
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
148 [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
149 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
150 if (! isempty (fdir))
30196
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
151 outargs{5} = fdir;
13697
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
152 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
153 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
154 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
155 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
156 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
157 print_usage ();
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
158 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
159 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
160
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
161 if (has_opts)
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
162 ## string arguments ("position" or "multiselect")
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
163
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
164 ## 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
165 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
166 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
167 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
168
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
169 for i = optidx : 2 : nargin
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
170 prop = varargin{i};
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
171 val = varargin{i + 1};
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17281
diff changeset
172 if (strcmpi (prop, "position"))
30196
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
173 ## FIXME: Remove handling this option in Octave 9.
17408
266fafd1ffc1 fix 2 strcmp<->strncmp issues from 3f0ed69d21c6
Andreas Weber <andreas.weber@hs-offenburg.de>
parents: 17405
diff changeset
174 elseif (strcmpi (prop, "multiselect"))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
175 if (! ischar (val))
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20173
diff changeset
176 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
177 endif
30196
813b7827c5f8 Remove "position" argument from file dialog functions (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30195
diff changeset
178 outargs{4} = tolower (val);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
179 else
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
180 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
181 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
182 endfor
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
183 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
184
30195
a7981aa5822b event-manager: Add function to signal valid implementation of GUI dialogs (bug #60980).
Markus Mützel <markus.muetzel@gmx.de>
parents: 29358
diff changeset
185 if (__event_manager_have_dialogs__ ())
27263
99aa1bcb8848 rename octave_link and octave_link_events classes, move inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
186 [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
187 else
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
188 funcname = __get_funcname__ (mfilename ());
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
189 [retfile, retpath, retindex] = feval (funcname, outargs{:});
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
190 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
191
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
192 endfunction
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
193
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14225
diff changeset
194
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
195 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
196 %! uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'});
13215
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
197
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
198 ## 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
199 %!assert (1)