changeset 30196:813b7827c5f8

Remove "position" argument from file dialog functions (bug #60980). * libinterp/corefcn/event-manager.cc (F__event_manager_file_dialog__), libinterp/dldfcn/__fltk_uigetfile (F__fltk_uigetfile__): Remove unused argument "position". * scripts/gui/uigetdir.m, scripts/gui/uigetfile.m, scripts/gui/uiputfile.m, scripts/gui/private/__uigetdir_fltk__.m, scripts/gui/private/__uigetfile_fltk__.m, scripts/gui/private/__uiputfile_fltk__.m: Remove handling argument "position".
author Markus Mützel <markus.muetzel@gmx.de>
date Sun, 19 Sep 2021 17:06:26 +0200
parents a7981aa5822b
children f692ecc135d6
files libinterp/corefcn/event-manager.cc libinterp/dldfcn/__fltk_uigetfile__.cc scripts/gui/private/__uigetdir_fltk__.m scripts/gui/private/__uigetfile_fltk__.m scripts/gui/private/__uiputfile_fltk__.m scripts/gui/uigetdir.m scripts/gui/uigetfile.m scripts/gui/uiputfile.m
diffstat 8 files changed, 37 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/event-manager.cc	Sun Sep 19 15:36:19 2021 +0200
+++ b/libinterp/corefcn/event-manager.cc	Sun Sep 19 17:06:26 2021 +0200
@@ -306,11 +306,11 @@
 
 DEFMETHOD (__event_manager_file_dialog__, interp, args, ,
            doc: /* -*- texinfo -*-
-@deftypefn {} {} __event_manager_file_dialog__ (@var{filterlist}, @var{title}, @var{filename}, @var{size} @var{multiselect}, @var{pathname})
+@deftypefn {} {} __event_manager_file_dialog__ (@var{filterlist}, @var{title}, @var{filename}, @var{multiselect}, @var{pathname})
 Undocumented internal function.
 @end deftypefn */)
 {
-  if (args.length () != 6)
+  if (args.length () != 5)
     return ovl ();
 
   octave_value_list retval (3);
@@ -318,9 +318,8 @@
   const Array<std::string> flist = args(0).cellstr_value ();
   std::string title = args(1).string_value ();
   std::string filename = args(2).string_value ();
-  Matrix pos = args(3).matrix_value ();
-  std::string multi_on = args(4).string_value (); // on, off, create
-  std::string pathname = args(5).string_value ();
+  std::string multi_on = args(3).string_value (); // on, off, create
+  std::string pathname = args(4).string_value ();
 
   octave_idx_type nel;
 
--- a/libinterp/dldfcn/__fltk_uigetfile__.cc	Sun Sep 19 15:36:19 2021 +0200
+++ b/libinterp/dldfcn/__fltk_uigetfile__.cc	Sun Sep 19 17:06:26 2021 +0200
@@ -29,20 +29,20 @@
 
 #if defined (HAVE_FLTK)
 
-#if defined (WIN32)
-#  define WIN32_LEAN_AND_MEAN
-#endif
+#  if defined (WIN32)
+#    define WIN32_LEAN_AND_MEAN
+#  endif
 
-#include <string>
+#  include <string>
 
-#include <FL/Fl.H>
-#include <FL/Fl_File_Chooser.H>
+#  include <FL/Fl.H>
+#  include <FL/Fl_File_Chooser.H>
 
 // FLTK headers may include X11/X.h which defines Complex, and that
 // conflicts with Octave's Complex typedef.  We don't need the X11
 // Complex definition in this file, so remove it before including Octave
 // headers which may require Octave's Complex typedef.
-#undef Complex
+#  undef Complex
 
 #endif
 
@@ -69,20 +69,18 @@
   //   args(0) ... FileFilter in fltk format
   //   args(1) ... Title
   //   args(2) ... Default Filename
-  //   args(3) ... PositionValue [x,y]
-  //   args(4) ... SelectValue "on"/"off"/"dir"/"create"
+  //   args(3) ... SelectValue "on"/"off"/"dir"/"create"
 
   octave_value_list retval (3, octave_value (0));
 
   std::string file_filter = args(0).string_value ();
   std::string title = args(1).string_value ();
   std::string default_name = args(2).string_value ();
-  Matrix pos = args(3).matrix_value ();
 
   int multi_type = Fl_File_Chooser::SINGLE;
   std::string flabel = "Filename:";
 
-  std::string multi = args(4).string_value ();
+  std::string multi = args(3).string_value ();
   if (multi == "on")
     multi_type = Fl_File_Chooser::MULTI;
   else if (multi == "dir")
--- a/scripts/gui/private/__uigetdir_fltk__.m	Sun Sep 19 15:36:19 2021 +0200
+++ b/scripts/gui/private/__uigetdir_fltk__.m	Sun Sep 19 17:06:26 2021 +0200
@@ -34,7 +34,6 @@
     error ("uigetdir: fltk graphics toolkit required");
   endif
 
-  dirname = __fltk_uigetfile__ ("", dialog_title,
-                                start_path, [240, 120], "dir");
+  dirname = __fltk_uigetfile__ ("", dialog_title, start_path, "dir");
 
 endfunction
--- a/scripts/gui/private/__uigetfile_fltk__.m	Sun Sep 19 15:36:19 2021 +0200
+++ b/scripts/gui/private/__uigetfile_fltk__.m	Sun Sep 19 17:06:26 2021 +0200
@@ -24,11 +24,11 @@
 ########################################################################
 
 ## -*- texinfo -*-
-## @deftypefn {} {[@var{fname}, @var{fpath}, @var{fltidx}] =} __uigetfile_fltk__ (@var{filters}, @var{title}, @var{defval}, @var{position}, @var{multiselect}, @var{defdir})
+## @deftypefn {} {[@var{fname}, @var{fpath}, @var{fltidx}] =} __uigetfile_fltk__ (@var{filters}, @var{title}, @var{defval}, @var{multiselect}, @var{defdir})
 ## Undocumented internal function.
 ## @end deftypefn
 
-function [retval, retpath, retindex] = __uigetfile_fltk__ (filters, title, defval, position, multiselect, defdir)
+function [retval, retpath, retindex] = __uigetfile_fltk__ (filters, title, defval, multiselect, defdir)
 
   if (exist ("__fltk_uigetfile__") != 3)
     error ("uigetfile: fltk graphics toolkit required");
@@ -39,6 +39,6 @@
     defval = fullfile (defdir, defval);
   endif
   [retval, retpath, retindex] = ...
-    __fltk_uigetfile__ (filters, title, defval, position, multiselect);
+    __fltk_uigetfile__ (filters, title, defval, multiselect);
 
 endfunction
--- a/scripts/gui/private/__uiputfile_fltk__.m	Sun Sep 19 15:36:19 2021 +0200
+++ b/scripts/gui/private/__uiputfile_fltk__.m	Sun Sep 19 17:06:26 2021 +0200
@@ -28,7 +28,7 @@
 ## Undocumented internal function.
 ## @end deftypefn
 
-function [retval, retpath, retindex] = __uiputfile_fltk__ (filters, title, defval, position, tag, defdir)
+function [retval, retpath, retindex] = __uiputfile_fltk__ (filters, title, defval, tag, defdir)
 
   if (exist ("__fltk_uigetfile__") != 3)
     error ("uiputfile: fltk graphics toolkit required");
@@ -39,6 +39,6 @@
     defval = fullfile (defdir, defval);
   endif
   [retval, retpath, retindex] = ...
-    __fltk_uigetfile__ (filters, title, defval, position, tag);
+    __fltk_uigetfile__ (filters, title, defval, tag);
 
 endfunction
--- a/scripts/gui/uigetdir.m	Sun Sep 19 15:36:19 2021 +0200
+++ b/scripts/gui/uigetdir.m	Sun Sep 19 17:06:26 2021 +0200
@@ -52,13 +52,12 @@
   if (__event_manager_have_dialogs__ ())
     file_filter = cell (0, 2);
     default_file_name = "";
-    dialog_position = [240, 120];
     dialog_mode = "dir";
 
     [filename, dirname, filterindex] ...
       = __event_manager_file_dialog__ (file_filter, dialog_name,
-                                       default_file_name, dialog_position,
-                                       dialog_mode, init_path);
+                                       default_file_name, dialog_mode,
+                                       init_path);
   else
     funcname = __get_funcname__ (mfilename ());
     dirname = feval (funcname, init_path, dialog_name);
--- a/scripts/gui/uigetfile.m	Sun Sep 19 15:36:19 2021 +0200
+++ b/scripts/gui/uigetfile.m	Sun Sep 19 17:06:26 2021 +0200
@@ -28,7 +28,6 @@
 ## @deftypefnx {} {[@dots{}] =} uigetfile (@var{flt})
 ## @deftypefnx {} {[@dots{}] =} uigetfile (@var{flt}, @var{dialog_name})
 ## @deftypefnx {} {[@dots{}] =} uigetfile (@var{flt}, @var{dialog_name}, @var{default_file})
-## @deftypefnx {} {[@dots{}] =} uigetfile (@dots{}, "Position", [@var{px} @var{py}])
 ## @deftypefnx {} {[@dots{}] =} uigetfile (@dots{}, "MultiSelect", @var{mode})
 ##
 ## Open a GUI dialog for selecting a file and return the filename @var{fname},
@@ -74,11 +73,9 @@
 ## If @var{default_file} is given then it will be selected in the GUI dialog.
 ## If, in addition, a path is given it is also used as current path.
 ##
-## The screen position of the GUI dialog can be set using the
-## @qcode{"Position"} key and a 2-element vector containing the pixel
-## coordinates.  Two or more files can be selected when setting the
-## @qcode{"MultiSelect"} key to @qcode{"on"}.  In that case @var{fname} is a
-## cell array containing the files.
+## Two or more files can be selected when setting the @qcode{"MultiSelect"} key
+## to @qcode{"on"}.  In that case, @var{fname} is a cell array containing the
+## files.
 ##
 ## The outputs @var{fname} and @var{fpath} are strings returning the chosen
 ## name and path, respectively.  However, if the @samp{Cancel} button is
@@ -99,7 +96,6 @@
   outargs = {cell(0, 2),         # File Filter
              "Open File",        # Dialog Title
              "",                 # Default filename
-             [240, 120],         # Dialog Position (pixel x/y)
              "off",              # MultiSelect on/off
              pwd};               # Default directory
 
@@ -113,7 +109,13 @@
     endif
   endif
 
-  optidx = min ([idx1, idx2, nargin+1]);
+  if (! isempty (idx2))
+    ## FIXME: Remove handling the "position" property completely in Octave 9
+    warning (['uigetfile: The "position" argument is deprecated and will ', ...
+              "be ignored. Consider removing it from the function call."]);
+  endif
+
+  optidx = min ([idx1, nargin+1]);
 
   args = varargin(1:optidx-1);
 
@@ -121,7 +123,7 @@
   if (len > 0)
     [outargs{1}, outargs{3}, defdir] = __file_filter__ ("uigetfile", args{1});
     if (! isempty (defdir))
-      outargs{6} = defdir;
+      outargs{5} = defdir;
     endif
   else
     outargs{1} = __file_filter__ ("uigetfile", outargs{1});
@@ -146,7 +148,7 @@
         [fdir, fname, fext] = fileparts (varargin{3});
       endif
       if (! isempty (fdir))
-        outargs{6} = fdir;
+        outargs{5} = fdir;
       endif
       if (! isempty (fname) || ! isempty (fext))
         outargs{3} = [fname fext];
@@ -168,15 +170,12 @@
       prop = varargin{i};
       val = varargin{i + 1};
       if (strcmpi (prop, "position"))
-        if (! isnumeric (val) || length (val) != 2)
-          error ('uigetfile: "Position" must be a 2-element vector');
-        endif
-        outargs{4} = val;
+        ## FIXME: Remove handling this option in Octave 9.
       elseif (strcmpi (prop, "multiselect"))
         if (! ischar (val))
           error ('uigetfile: MultiSelect value must be a string ("on"/"off")');
         endif
-        outargs{5} = tolower (val);
+        outargs{4} = tolower (val);
       else
         error ("uigetfile: unknown argument '%s'", prop);
       endif
--- a/scripts/gui/uiputfile.m	Sun Sep 19 15:36:19 2021 +0200
+++ b/scripts/gui/uiputfile.m	Sun Sep 19 17:06:26 2021 +0200
@@ -76,7 +76,6 @@
   outargs = {cell(0, 2),     # File Filter
              "Save File",    # Dialog Title
              "",             # Default filename
-             [240, 120],     # Dialog Position (pixel x/y)
              "create",
              pwd};           # Default directory
 
@@ -84,7 +83,7 @@
     [outargs{1}, outargs{3}, defdir] = __file_filter__ ("uiputfile",
                                                         varargin{1});
     if (! isempty (defdir))
-      outargs{6} = defdir;
+      outargs{5} = defdir;
     endif
   else
     outargs{1} = __file_filter__ ("uiputfile", outargs{1});
@@ -107,7 +106,7 @@
         [fdir, fname, fext] = fileparts (varargin{3});
       endif
       if (! isempty (fdir))
-        outargs{6} = fdir;
+        outargs{5} = fdir;
       endif
       if (! isempty (fname) || ! isempty (fext))
         outargs{3} = [fname fext];