changeset 18970:bb2a03f9ed20

Fix uigetdir, uigetfile, uiputfile. Remove check for nonexistent return value * uigetfile.m: Don't check for existence of fltk script files. They are always distributed, even when built without FLTK. This function failed after moving the helper functions to ./private. * uigetdir.m, uiputfile: same as uigetfile.m * __is_function__.m: Remove comparison with impossible exist return value.
author Andreas Weber <andy.weber.aw@gmail.com>
date Wed, 30 Jul 2014 23:34:14 +0200
parents 0257a936dc4a
children f084aab05cd9
files scripts/gui/private/__is_function__.m scripts/gui/uigetdir.m scripts/gui/uigetfile.m scripts/gui/uiputfile.m
diffstat 4 files changed, 16 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/gui/private/__is_function__.m	Tue Jul 29 21:13:03 2014 +0200
+++ b/scripts/gui/private/__is_function__.m	Wed Jul 30 23:34:14 2014 +0200
@@ -26,7 +26,7 @@
 function result = __is_function__ (func)
 
   existval = exist (func);
-  result = (existval == 2 || existval == 3 || existval == 5 || existval == 6);
+  result = (existval == 2 || existval == 3 || existval == 5);
 
 endfunction
 
--- a/scripts/gui/uigetdir.m	Tue Jul 29 21:13:03 2014 +0200
+++ b/scripts/gui/uigetdir.m	Wed Jul 30 23:34:14 2014 +0200
@@ -31,18 +31,12 @@
 function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open")
 
   if (! __octave_link_enabled__ ())
-    defaulttoolkit = get (0, "defaultfigure__graphics_toolkit__");
-    funcname = ["__uigetdir_", defaulttoolkit, "__"];
-    functype = exist (funcname);
-    if (! __is_function__ (funcname))
-      funcname = "__uigetdir_fltk__";
-      if (! __is_function__ (funcname))
-        error ("uigetdir: fltk graphics toolkit required");
-      elseif (! strcmp (defaulttoolkit, "gnuplot"))
-        warning ("uigetdir: no implementation for toolkit '%s', using 'fltk' instead",
-                 defaulttoolkit);
-      endif
+    tk = graphics_toolkit ();
+    funcname = ["uigetdir", tk, "__"];
+    if (numel (tk) > 0 && ! __is_function__ (funcname))
+      warning ("uigetdir: no implementation for toolkit '%s', using 'fltk' instead", tk);
     endif
+    funcname = "__uigetdir_fltk__";
   endif
 
   if (nargin > 2)
--- a/scripts/gui/uigetfile.m	Tue Jul 29 21:13:03 2014 +0200
+++ b/scripts/gui/uigetfile.m	Wed Jul 30 23:34:14 2014 +0200
@@ -67,18 +67,12 @@
 function [retfile, retpath, retindex] = uigetfile (varargin)
 
   if (! __octave_link_enabled__ ())
-    defaulttoolkit = get (0, "defaultfigure__graphics_toolkit__");
-    funcname = ["__uigetfile_", defaulttoolkit, "__"];
-    functype = exist (funcname);
-    if (! __is_function__ (funcname))
-      funcname = "__uigetfile_fltk__";
-      if (! __is_function__ (funcname))
-        error ("uigetfile: fltk graphics toolkit required");
-      elseif (! strcmp (defaulttoolkit, "gnuplot"))
-        warning ("uigetfile: no implementation for toolkit '%s', using 'fltk' instead",
-               defaulttoolkit);
-      endif
+    tk = graphics_toolkit ();
+    funcname = ["__uigetfile_", tk, "__"];
+    if (numel (tk) > 0 && ! __is_function__ (funcname))
+      warning ("uigetfile: no implementation for toolkit '%s', using 'fltk' instead", tk);
     endif
+    funcname = "__uigetfile_fltk__";
   endif
   
   if (nargin > 7)
--- a/scripts/gui/uiputfile.m	Tue Jul 29 21:13:03 2014 +0200
+++ b/scripts/gui/uiputfile.m	Wed Jul 30 23:34:14 2014 +0200
@@ -57,18 +57,12 @@
 function [retfile, retpath, retindex] = uiputfile (varargin)
 
   if (! __octave_link_enabled__ ())
-    defaulttoolkit = get (0, "defaultfigure__graphics_toolkit__");
-    funcname = ["__uiputfile_", defaulttoolkit, "__"];
-    functype = exist (funcname);
-    if (! __is_function__ (funcname))
-      funcname = "__uiputfile_fltk__";
-      if (! __is_function__ (funcname))
-        error ("uiputfile: fltk graphics toolkit required");
-      elseif (! strcmp (defaulttoolkit, "gnuplot"))
-        warning ("uiputfile: no implementation for toolkit '%s', using 'fltk' instead",
-               defaulttoolkit);
-      endif
+    tk = graphics_toolkit ();
+    funcname = ["uiputfile", tk, "__"];
+    if (numel (tk) > 0 && ! __is_function__ (funcname))
+      warning ("uiputfile: no implementation for toolkit '%s', using 'fltk' instead", tk);
     endif
+    funcname = "__uiputfile_fltk__";
   endif
 
   if (nargin > 3)