]> Creatis software - CreaPhase.git/blob - octave_packages/zenity-0.5.7/zenity_scale.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / zenity-0.5.7 / zenity_scale.m
1 ## Copyright (C) 2006 Muthiah Annamalai
2 ## 
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
7 ## 
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
12 ## 
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; If not, see <http://www.gnu.org/licenses/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn  {Function File} @var{output} = zenity_scale(@var{title},@var{text}, @var{value}, @var{minval}, @var{maxval},@var{step},@var{print_partial},@var{hideval})
18 ## Displays a selection scale (range widget) window.
19 ## Allows the user to choose a parameter within the set ranges, and sets
20 ## default value, and step sizes.
21 ## The variable @var{title} sets the title of the window.
22 ## The variable @var{text} sets the label of the range widget.
23 ## The other arguments @var{value}, @var{minval},@var{maxval},
24 ## @var{step}, @var{print_partial}, and @var{hideval}.
25 ## The range widget can be used to select anywhere from @var{minval} to
26 ## @var{maxval} values in increments of @var{step}. The variable
27 ## @var{print_partial} and @var{hideval} are boolean flags to partial
28 ## and hidden views of the value on the range widget.
29 ## The first 3 parameters are essential, while the remaining parameters
30 ## @var{minval}, @var{maxval},@var{step},@var{print_partial},@var{hideval} if
31 ## not specified take on default values of 0,100,1,false,false
32 ## respectively.
33 ## @seealso{zenity_list, zenity_progress, zenity_entry, zenity_message,
34 ## zenity_text_info, zenity_file_selection, zenity_notification}
35 ## @end deftypefn
36
37 function output = zenity_scale(title,text, value, minval, maxval, step, print_partial, hideval)
38
39   if (nargin < 1), title="Adjust the scale value"; endif
40   if (nargin < 2), text=""; endif
41   if (nargin < 3), value=0; endif
42   if (nargin < 4), minval= 0; endif
43   if (nargin < 5), maxval= 100; endif
44   if (nargin < 6), step  = 1; endif
45   if (nargin < 7), print_partial = false; endif
46   if (nargin < 8), hideval = false; endif
47
48   ppartial="";
49   hvalue="";
50
51   if(length(title)==0), title="Adjust the scale value"; endif
52   if(print_partial), ppartial="--print-partial"; endif
53   if(hideval), hvalue="--hide-value"; endif
54   
55   cmd = sprintf(['zenity --scale --title="%s" --text="%s" ', ...
56                  '--value=%d --min-value=%d --max-value=%d --step=%d ',...
57                  '%s %s '],title, text, value, minval,maxval,step,ppartial,hvalue);
58   [status, output] = system(cmd);
59   if (status == 0)
60     output = str2num(output);
61   elseif (status == 1)
62     output = value; ##default when user kills it.
63   else
64     error("zenity_scale: %s", output); ##kill -9 
65   endif
66 endfunction
67 %
68 %(Shamelessly copied from Søren Hauberg's zenity_calendar).
69 %zenity --scale --text 'What is in your Wallet' --value 10 --min-value 0 --max-value 100 --step 5
70 %zenity_scale('','What is in your Wallet',10,0,100,5)
71 %