annotate scripts/gui/uigetfile.m @ 30195:a7981aa5822b

event-manager: Add function to signal valid implementation of GUI dialogs (bug #60980). The event-manager is also enabled when starting with --no-gui-libs. But not all implementations of the event-manager have dialogs (only Qt at the moment which isn't used when starting with --no-gui-libs). Add functions that return if the event-manager has implemented dialogs. * libinterp/corefcn/event-manager.h (interpreter_events::have_dialogs, event_manager::have_dialogs): Add new function "have_dialogs". (event_manager::file_dialog, event_manager::input_dialog, event_manager::list_dialog, event_manager::question_dialog): Guard with "have_dialogs". * libinterp/corefcn/event-manager.cc (F__event_manager_have_dialogs__): Add new function. * libgui/src/qt-interpreter-events.h (qt_interpreter_events::have_dialogs): Add new function. * scripts/gui/inputdlg.m, scripts/gui/listdlg.m, scripts/gui/msgbox.m, scripts/gui/questdlg.m, scripts/gui/uigetdir.m, scripts/gui/uigetfile.m, scripts/gui/uiputfile.m: Check "____event_manager_have_dialogs__" instead of "__event_manager_enabled__". * scripts/gui/private/__get_funcname__.m: Try to use dialog functions specific to the current graphics toolkit if the event-manager doesn't have implemented dialogs.
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 19 Sep 2021 15:36:19 +0200
parents 0a5b15007766
children 813b7827c5f8
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{}, "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
32 ## @deftypefnx {} {[@dots{}] =} uigetfile (@dots{}, "MultiSelect", @var{mode})
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
33 ##
16580
adc150db1809 style fixes for uigetfile changes
John W. Eaton <jwe@octave.org>
parents: 16579
diff changeset
34 ## 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
35 ## 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
36 ##
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
37 ## @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
38 ## formats:
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
39 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
40 ## @table @asis
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
41 ## @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
42 ## 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
43 ## 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
44 ## 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
45 ## Example: @code{uigetfile ("myfun.m")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
46 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
47 ## @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
48 ## Example: @code{uigetfile ("*.ext")}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
49 ##
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
50 ## @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
51 ## 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
52 ## the second column.
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
53 ## Example: @code{uigetfile (@{"*.ext", "My Description";"*.xyz",
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
54 ## "XYZ-Format"@})}
11583
c4c2cd67c440 Fixes for ui file functions, bug#32190
Kai Habel <kai.habel@gmx.de>
parents: 11576
diff changeset
55 ##
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
56 ## 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
57 ## extensions.
11563
3c6e8aaa9555 Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
58 ## 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
59 ## 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
60 ##
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 ## @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
62 ## 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
63 ## 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
64 ## 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
65 ## 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
66 ## 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
67 ## 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
68 ## 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
69 ## No filter will be active.
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
70 ## @end table
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
71 ##
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
72 ## @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
73 ##
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
74 ## 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
75 ## 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
76 ##
17281
bc924baa2c4e doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents: 16580
diff changeset
77 ## 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
78 ## @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
79 ## 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
80 ## @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
81 ## 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
82 ##
28022
306df6825dd9 doc: Document return values for uigetdir/uigetfil when 'Cancel' button used (bug #57670).
Rik <rik@octave.org>
parents: 27978
diff changeset
83 ## 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
84 ## 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
85 ## 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
86 ## @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
87 ## 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
88 ##
15532
95d7475a0a89 doc: Add seealso links between uigetfile, uiputfile, uigetdir.
Rik <rik@octave.org>
parents: 15467
diff changeset
89 ## @seealso{uiputfile, uigetdir}
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
90 ## @end deftypefn
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
91
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
92 function [retfile, retpath, retindex] = uigetfile (varargin)
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
93
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
94 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
95 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
96 endif
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
97
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
98 ## Preset default values
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
99 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
100 "Open File", # Dialog Title
20713
2469d78a1d8b Consistently use 'filename' rather than 'file name' throughout code base.
Rik <rik@octave.org>
parents: 20711
diff changeset
101 "", # Default filename
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
102 [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
103 "off", # MultiSelect on/off
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
104 pwd}; # Default directory
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
105
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
106 idx1 = idx2 = [];
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
107 has_opts = false;
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
108 if (nargin > 0)
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
109 idx1 = find (strcmpi (varargin, "multiselect"), 1);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
110 idx2 = find (strcmpi (varargin, "position"), 1);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
111 if (idx1 || idx2)
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
112 has_opts = true;
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
113 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
114 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
115
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
116 optidx = min ([idx1, idx2, nargin+1]);
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
117
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
118 args = varargin(1:optidx-1);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
119
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
120 len = numel (args);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
121 if (len > 0)
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
122 [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
123 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
124 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
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 else
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
127 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
128 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
129
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
130 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
131 if (ischar (args{2}))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
132 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
133 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
134 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
135 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
136 print_usage ();
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
137 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
138 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
139
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
140 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
141 if (ischar (args{3}))
25781
e04c56bbbace isdir.m: Make m-file a legacy function (bug #54489)
Rik <rik@octave.org>
parents: 25054
diff changeset
142 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
143 fdir = args{3};
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
144 fname = fext = "";
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
145 else
70380bb91b81 uigetfile.m: Don't start in directory one above the requested directory.
Rik <rik@octave.org>
parents: 19697
diff changeset
146 [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
147 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
148 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
149 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
150 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
151 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
152 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
153 endif
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
154 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
155 print_usage ();
0f8ff98929b2 Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents: 13215
diff changeset
156 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
157 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
158
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
159 if (has_opts)
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
160 ## string arguments ("position" or "multiselect")
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
161
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
162 ## 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
163 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
164 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
165 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
166
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
167 for i = optidx : 2 : nargin
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
168 prop = varargin{i};
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
169 val = varargin{i + 1};
17405
3f0ed69d21c6 Replace unnecessary instances of strncmp with strcmp.
Rik <rik@octave.org>
parents: 17281
diff changeset
170 if (strcmpi (prop, "position"))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
171 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
172 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
173 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
174 outargs{4} = val;
17408
266fafd1ffc1 fix 2 strcmp<->strncmp issues from 3f0ed69d21c6
Andreas Weber <andreas.weber@hs-offenburg.de>
parents: 17405
diff changeset
175 elseif (strcmpi (prop, "multiselect"))
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
176 if (! ischar (val))
20711
7b608fadc663 Make error messages more specific about the variable and problem encountered.
Rik <rik@octave.org>
parents: 20173
diff changeset
177 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
178 endif
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
179 outargs{5} = tolower (val);
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
180 else
21843
f7a57b07c81d Overhaul uigetfile, uiputfile, __file_filter__ (bug #48183).
Rik <rik@octave.org>
parents: 21178
diff changeset
181 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
182 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
183 endfor
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
184 endif
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
185
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
186 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
187 [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
188 else
19833
9fc020886ae9 maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents: 19799
diff changeset
189 funcname = __get_funcname__ (mfilename ());
16579
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
190 [retfile, retpath, retindex] = feval (funcname, outargs{:});
7f8db1942dc0 Add Qt link uigetfile dialog implementation.
John Donoghue <john.donoghue@ieee.org>
parents: 15532
diff changeset
191 endif
12522
33bbae85769a Add uimenu, uigetdir, uigetfile, and uiputfile to documentation.
Rik <octave@nomad.inbox5.com>
parents: 12183
diff changeset
192
11283
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
193 endfunction
58f175d39a7a GUI file functions
Kai Habel <kai.habel@gmx.de>
parents:
diff changeset
194
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14225
diff changeset
195
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11583
diff changeset
196 %!demo
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
197 %! uigetfile ({'*.gif;*.png;*.jpg', 'Supported Picture Formats'});
13215
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
198
cb8fd692b600 Add tests for scripts/plot
Kai Habel <kai.habel@gmx.de>
parents: 12642
diff changeset
199 ## 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
200 %!assert (1)