Mercurial > hg > octave-lyh
changeset 11295:75ff3db6a687
Simplify code for uimenu.m. Fix error messages for ui file functions.
author | Kai Habel <kai.habel@gmx.de> |
---|---|
date | Thu, 25 Nov 2010 17:16:46 +0100 |
parents | e2a4f3478b7c |
children | 2bbea68c8abc |
files | scripts/ChangeLog scripts/plot/uigetdir.m scripts/plot/uigetfile.m scripts/plot/uimenu.m scripts/plot/uiputfile.m |
diffstat | 5 files changed, 25 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-11-25 Kai Habel <kai.habel@gmx.de> + + * (plot/uimenu.m): Simplify code, add further check. + * (plot/uigetdir.m, plot/uigetfile.m, plot/uiputfile.m): Fix error messages. + 2010-11-25 John W. Eaton <jwe@octave.org> * time/datetick.m: Add missing semicolon.
--- a/scripts/plot/uigetdir.m +++ b/scripts/plot/uigetdir.m @@ -30,7 +30,7 @@ function [retdir] = uigetdir (init_path = pwd, name = "Choose directory?") if (!ischar(init_path) || !ischar(name)) - error ("Expecting string arguments."); + error ("uigetdir: expecting string arguments."); endif if (nargin > 2) @@ -43,7 +43,7 @@ endif retdir = __fltk_uigetfile__ ("", name, init_path, [240, 120], "dir"); else - error ("uigetdir requires fltk backend."); + error ("uigetdir: fltk backend required."); endif endfunction
--- a/scripts/plot/uigetfile.m +++ b/scripts/plot/uigetfile.m @@ -121,7 +121,7 @@ ## check for even number of remaining arguments, prop/value pair(s) if (rem (nargin - stridx + 1, 2)) - error ("expecting property/value pairs"); + error ("uigetfile: expecting property/value pairs"); endif for i = stridx : 2 : nargin @@ -131,27 +131,27 @@ if (ismatrix (val) && length(val) == 2) outargs{4} = val; else - error ("expecting 2-element vector for position argument") + error ("uigetfile: expecting 2-element vector for position argument") endif elseif (strncmp (tolower (prop), "multiselect", 11)) if (ischar (val)) outargs{5} = tolower (val); else - error ("expecting string argument (on/off) for multiselect") + error ("uigetfile: expecting string argument (on/off) for multiselect") endif else - error ("unknown argument"); + error ("uigetfile: unknown argument"); endif endfor endif else - error ("number of input arguments must be less than eight"); + error ("uigetfile: number of input arguments must be less than eight"); endif if (any (cellfun(@(x)strcmp (x, "fltk"), available_backends))) [retfile, retpath, retindex] = __fltk_uigetfile__ (outargs{:}); else - error ("uigetfile requires fltk backend."); + error ("uigetfile: fltk backend required."); endif
--- a/scripts/plot/uimenu.m +++ b/scripts/plot/uimenu.m @@ -79,24 +79,18 @@ function hui = uimenu (varargin) args = varargin; - if (nargin == 0) + + if (ishandle (args{1})) + h = args{1}; + args(1) = []; + else h = gcf (); - elseif (nargin == 1) - if (ishandle (args{1})) - h = args{1}; - args(1) = []; - else - error ("expected handle as first argument"); - endif - else - if (ishandle (args{1})) - h = args{1}; - args(1) = []; - else - h = gcf (); - endif endif - + + if (rem (length (args), 2)) + error ("uimenu: expecting property/value pairs"); + endif + tmp = __go_uimenu__ (h, args{:}); if (nargout > 0)
--- a/scripts/plot/uiputfile.m +++ b/scripts/plot/uiputfile.m @@ -86,13 +86,13 @@ endif else - error ("Number of input arguments must be less than four."); + error ("uiputfile: number of input arguments must be less than four."); endif if (any (cellfun(@(x)strcmp (x, "fltk"), available_backends))) [retfile, retpath, retindex] = __fltk_uigetfile__ (outargs{:}); else - error ("uiputfile requires fltk backend."); + error ("uiputfile: fltk backend required."); endif endfunction