]> Creatis software - CreaPhase.git/blob - octave_packages/m/plot/private/__fltk_file_filter__.m
update packages
[CreaPhase.git] / octave_packages / m / plot / private / __fltk_file_filter__.m
1 ## Copyright (C) 2012 Michael Goffioul
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify it
6 ## under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
9 ##
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 ## General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING.  If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn {Function File} {@var{filterspec} =} __fltk_file_filter__ (@var{filter})
21 ## Undocumented internal function.
22 ## @end deftypefn
23
24 ## Author: Michael Goffioul
25
26 function retval = __fltk_file_filter__ (file_filter)
27
28   retval = "";
29   [r, c] = size (file_filter);
30   if ((c == 0) || (c > 2))
31     error ("expecting 1 or to 2 columns for file filter cell");
32   endif
33   fltk_str = "";
34   for idx = 1 : r
35
36     curr_ext = file_filter{idx, 1};
37     curr_ext = strsplit (curr_ext, ";");
38
39     if (length (curr_ext) > 1)
40       curr_ext = regexprep (curr_ext, '\*\.', ',');
41       curr_ext = strcat (curr_ext{:})(2 : end);
42       curr_ext = strcat ("*.{", curr_ext, "}");
43     else
44       curr_ext = curr_ext{:};
45     endif
46
47     curr_desc = strcat (curr_ext(3:end), "-Files");
48
49     if (c == 2)
50       curr_desc = file_filter{idx, 2};
51       curr_desc = regexprep (curr_desc, '\(', '<');
52       curr_desc = regexprep (curr_desc, '\)', '>');
53     endif
54
55     if (length (fltk_str) > 0)
56       fltk_str = strcat (fltk_str, "\t", curr_desc, " (", curr_ext, ")");
57     else
58       fltk_str = strcat (curr_desc, " (", curr_ext, ")");
59     endif
60
61   endfor
62   retval = fltk_str;
63
64 endfunction