Mercurial > octave-nkf
annotate scripts/plot/private/__file_filter__.m @ 14138:72c96de7a403 stable
maint: update copyright notices for 2012
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Jan 2012 14:25:41 -0500 |
parents | 0f8ff98929b2 |
children | 5d3a684236b0 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13697
diff
changeset
|
1 ## Copyright (C) 2010-2012 Kai Habel |
13697
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
2 ## |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
4 ## |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
9 ## |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
14 ## |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
18 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
20 ## @deftypefn {Function File} {} __file_filter__ (@var{file_filter}) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
21 ## Undocumented internal function. |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
22 ## @end deftypefn |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
23 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
24 ## Author: Kai Habel |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
25 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
26 function [retval, defname, defdir] = __file_filter__ (file_filter, name) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
27 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
28 revtal = {}; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
29 defname = ""; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
30 defdir = ""; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
31 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
32 if (iscell (file_filter)) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
33 [r, c] = size (file_filter); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
34 if (c != 1 && c != 2) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
35 error ("%s: invalid filter specification", name); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
36 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
37 if (c == 1) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
38 retval = cell (r, 2); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
39 for i = 1:r |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
40 retval{i, 1} = file_filter{i}; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
41 retval{i, 2} = __default_filtername__ (file_filter{i}); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
42 endfor |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
43 else |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
44 retval = file_filter; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
45 for i = 1:r |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
46 if (isempty (retval{i, 2})) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
47 retval{i, 2} = __default_filtername__ (retval{i, 1}); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
48 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
49 endfor |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
50 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
51 elseif (ischar (file_filter)) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
52 [defdir, fname, fext] = fileparts (file_filter); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
53 if (! strcmp (fname, "*")) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
54 defname = strcat (fname, fext); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
55 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
56 if (length (fext) > 0) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
57 fext = strcat ("*", fext); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
58 retval = {fext, __default_filtername__(fext)}; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
59 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
60 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
61 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
62 retval(end+1,:) = {"*", __default_filtername__("*")}; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
63 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
64 endfunction |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
65 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
66 function name = __default_filtername__ (filterext) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
67 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
68 name = ""; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
69 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
70 switch (filterext) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
71 case "*" |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
72 name = "All Files"; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
73 case "*.m" |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
74 name = "Octave Source Files"; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
75 case "*.c" |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
76 name = "C Source Files"; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
77 case {"*.cc" "*.c++" "*.cpp"} |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
78 name = "C++ Source Files"; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
79 case "*.oct" |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
80 name = "Octave Compiled Files"; |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
81 endswitch |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
82 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
83 if (isempty (name)) |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
84 extlist = strsplit(filterext, ";"); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
85 extlist = strrep (extlist, "*.", ""); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
86 extlist = toupper (extlist); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
87 extlist(end+1, :) = repmat ({","}, 1, length (extlist)); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
88 extlist = strcat (extlist{:}); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
89 extlist = extlist(1:end-1); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
90 name = strcat (extlist, "-Files"); |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
91 endif |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
92 |
0f8ff98929b2
Allow a toolkit to provide its own version of UI dialogs.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
diff
changeset
|
93 endfunction |