X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=octave_packages%2Fzenity-0.5.7%2Fzenity_scale.m;fp=octave_packages%2Fzenity-0.5.7%2Fzenity_scale.m;h=1194cc609db120a22d8da773021235bd600621bb;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hp=0000000000000000000000000000000000000000;hpb=1705066eceaaea976f010f669ce8e972f3734b05;p=CreaPhase.git diff --git a/octave_packages/zenity-0.5.7/zenity_scale.m b/octave_packages/zenity-0.5.7/zenity_scale.m new file mode 100644 index 0000000..1194cc6 --- /dev/null +++ b/octave_packages/zenity-0.5.7/zenity_scale.m @@ -0,0 +1,71 @@ +## Copyright (C) 2006 Muthiah Annamalai +## +## This program 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 2 of the License, or +## (at your option) any later version. +## +## This program 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 this program; If not, see . + +## -*- texinfo -*- +## @deftypefn {Function File} @var{output} = zenity_scale(@var{title},@var{text}, @var{value}, @var{minval}, @var{maxval},@var{step},@var{print_partial},@var{hideval}) +## Displays a selection scale (range widget) window. +## Allows the user to choose a parameter within the set ranges, and sets +## default value, and step sizes. +## The variable @var{title} sets the title of the window. +## The variable @var{text} sets the label of the range widget. +## The other arguments @var{value}, @var{minval},@var{maxval}, +## @var{step}, @var{print_partial}, and @var{hideval}. +## The range widget can be used to select anywhere from @var{minval} to +## @var{maxval} values in increments of @var{step}. The variable +## @var{print_partial} and @var{hideval} are boolean flags to partial +## and hidden views of the value on the range widget. +## The first 3 parameters are essential, while the remaining parameters +## @var{minval}, @var{maxval},@var{step},@var{print_partial},@var{hideval} if +## not specified take on default values of 0,100,1,false,false +## respectively. +## @seealso{zenity_list, zenity_progress, zenity_entry, zenity_message, +## zenity_text_info, zenity_file_selection, zenity_notification} +## @end deftypefn + +function output = zenity_scale(title,text, value, minval, maxval, step, print_partial, hideval) + + if (nargin < 1), title="Adjust the scale value"; endif + if (nargin < 2), text=""; endif + if (nargin < 3), value=0; endif + if (nargin < 4), minval= 0; endif + if (nargin < 5), maxval= 100; endif + if (nargin < 6), step = 1; endif + if (nargin < 7), print_partial = false; endif + if (nargin < 8), hideval = false; endif + + ppartial=""; + hvalue=""; + + if(length(title)==0), title="Adjust the scale value"; endif + if(print_partial), ppartial="--print-partial"; endif + if(hideval), hvalue="--hide-value"; endif + + cmd = sprintf(['zenity --scale --title="%s" --text="%s" ', ... + '--value=%d --min-value=%d --max-value=%d --step=%d ',... + '%s %s '],title, text, value, minval,maxval,step,ppartial,hvalue); + [status, output] = system(cmd); + if (status == 0) + output = str2num(output); + elseif (status == 1) + output = value; ##default when user kills it. + else + error("zenity_scale: %s", output); ##kill -9 + endif +endfunction +% +%(Shamelessly copied from Søren Hauberg's zenity_calendar). +%zenity --scale --text 'What is in your Wallet' --value 10 --min-value 0 --max-value 100 --step 5 +%zenity_scale('','What is in your Wallet',10,0,100,5) +% \ No newline at end of file