# HG changeset patch # User Andreas Weber # Date 1406757836 -7200 # Node ID f084aab05cd915999de8aeb4c12059f3dff67db5 # Parent bb2a03f9ed204e129861c50c746451f9cbf13bfb Move checks for graphics_toolkit GUI functions to own script. * __get_funcname__.m: New function to buid the function name from basename and graphics_toolkit. * uigetdir.m, uigetfile.m, uiputfile.m: Adapt to use __get_funcname__ with basename = mfilename () diff -r bb2a03f9ed20 -r f084aab05cd9 scripts/gui/private/__get_funcname__.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/gui/private/__get_funcname__.m Thu Jul 31 00:03:56 2014 +0200 @@ -0,0 +1,42 @@ +## Copyright (C) 2014 Andreas Weber +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{funcname} =} __get_funcname__ (@var{basename}) +## Internal function. +## +## Build function name for the current graphics toolkit according to schema +## __[basename]_[graphics_toolkit]__, use fltk as default. +## @end deftypefn + +## Author: Andreas Weber + +function funcname = __get_funcname__ (basename) + + if (! __octave_link_enabled__ ()) + tk = graphics_toolkit (); + funcname = strcat ("__", basename, "_", tk, "__"); + if ((numel (tk) > 0) && (! strcmp(tk, "fltk")) && (! __is_function__ (funcname))) + warning ("%s: no implementation for toolkit '%s', using 'fltk' instead",basename, tk); + endif + funcname = strcat ("__", basename, "_fltk__"); + else + funcname = ""; + endif + +endfunction diff -r bb2a03f9ed20 -r f084aab05cd9 scripts/gui/uigetdir.m --- a/scripts/gui/uigetdir.m Wed Jul 30 23:34:14 2014 +0200 +++ b/scripts/gui/uigetdir.m Thu Jul 31 00:03:56 2014 +0200 @@ -30,14 +30,7 @@ function dirname = uigetdir (init_path = pwd, dialog_name = "Select Directory to Open") - if (! __octave_link_enabled__ ()) - 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 + funcname = __get_funcname__ (mfilename ()); if (nargin > 2) print_usage (); diff -r bb2a03f9ed20 -r f084aab05cd9 scripts/gui/uigetfile.m --- a/scripts/gui/uigetfile.m Wed Jul 30 23:34:14 2014 +0200 +++ b/scripts/gui/uigetfile.m Thu Jul 31 00:03:56 2014 +0200 @@ -66,15 +66,8 @@ function [retfile, retpath, retindex] = uigetfile (varargin) - if (! __octave_link_enabled__ ()) - 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 - + funcname = __get_funcname__ (mfilename ()); + if (nargin > 7) error ("uigetfile: number of input arguments must be less than eight"); endif diff -r bb2a03f9ed20 -r f084aab05cd9 scripts/gui/uiputfile.m --- a/scripts/gui/uiputfile.m Wed Jul 30 23:34:14 2014 +0200 +++ b/scripts/gui/uiputfile.m Thu Jul 31 00:03:56 2014 +0200 @@ -56,14 +56,7 @@ function [retfile, retpath, retindex] = uiputfile (varargin) - if (! __octave_link_enabled__ ()) - 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 + funcname = __get_funcname__ (mfilename ()); if (nargin > 3) print_usage ();