| 1 | package UI::Dialog::Backend::XDialog; | ||
| 2 | ############################################################################### | ||
| 3 | # Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> | ||
| 4 | # | ||
| 5 | # This library is free software; you can redistribute it and/or | ||
| 6 | # modify it under the terms of the GNU Lesser General Public | ||
| 7 | # License as published by the Free Software Foundation; either | ||
| 8 | # version 2.1 of the License, or (at your option) any later version. | ||
| 9 | # | ||
| 10 | # This library is distributed in the hope that it will be useful, | ||
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 13 | # Lesser General Public License for more details. | ||
| 14 | # | ||
| 15 | # You should have received a copy of the GNU Lesser General Public | ||
| 16 | # License along with this library; if not, write to the Free Software | ||
| 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 18 | ############################################################################### | ||
| 19 | use 5.006; | ||
| 20 | use strict; | ||
| 21 | use warnings; | ||
| 22 | use Carp; | ||
| 23 | use FileHandle; | ||
| 24 | use File::Basename; | ||
| 25 | use Cwd qw( abs_path ); | ||
| 26 | use UI::Dialog::Backend; | ||
| 27 | |||
| 28 | BEGIN { | ||
| 29 | use vars qw( $VERSION @ISA ); | ||
| 30 | @ISA = qw( UI::Dialog::Backend ); | ||
| 31 | $VERSION = '1.14'; | ||
| 32 | } | ||
| 33 | |||
| 34 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
| 35 | #: Constructor Method | ||
| 36 | #: | ||
| 37 | |||
| 38 | sub new { | ||
| 39 | my $proto = shift(); | ||
| 40 | my $class = ref($proto) || $proto; | ||
| 41 | my $cfg = ((ref($_[0]) eq "HASH") ? $_[0] : (@_) ? { @_ } : {}); | ||
| 42 | my $self = {}; | ||
| 43 | bless($self, $class); | ||
| 44 | $self->{'_state'} = {}; | ||
| 45 | $self->{'_opts'} = {}; | ||
| 46 | |||
| 47 | #: Dynamic path discovery... | ||
| 48 | my $CFG_PATH = $cfg->{'PATH'}; | ||
| 49 | if ($CFG_PATH) { | ||
| 50 | if (ref($CFG_PATH) eq "ARRAY") { | ||
| 51 | $self->{'PATHS'} = $CFG_PATH; | ||
| 52 | } | ||
| 53 | elsif ($CFG_PATH =~ m!:!) { | ||
| 54 | $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ]; | ||
| 55 | } | ||
| 56 | elsif (-d $CFG_PATH) { | ||
| 57 | $self->{'PATHS'} = [ $CFG_PATH ]; | ||
| 58 | } | ||
| 59 | } | ||
| 60 | elsif ($ENV{'PATH'}) { | ||
| 61 | $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; | ||
| 62 | } | ||
| 63 | else { | ||
| 64 | $self->{'PATHS'} = ''; | ||
| 65 | } | ||
| 66 | |||
| 67 | $self->{'_opts'}->{'debug'} = $cfg->{'debug'} || undef(); | ||
| 68 | |||
| 69 | $self->{'_opts'}->{'literal'} = $cfg->{'literal'} || 0; | ||
| 70 | |||
| 71 | $self->{'_opts'}->{'XDIALOG_HIGH_DIALOG_COMPAT'} = 1 | ||
| 72 | unless not $cfg->{'XDIALOG_HIGH_DIALOG_COMPAT'}; | ||
| 73 | |||
| 74 | $self->{'_opts'}->{'callbacks'} = $cfg->{'callbacks'} || undef(); | ||
| 75 | # --wmclass <name> | ||
| 76 | $self->{'_opts'}->{'wmclass'} = $cfg->{'wmclass'} || undef(); | ||
| 77 | # --rc-file <gtkrc filename> | ||
| 78 | $self->{'_opts'}->{'rcfile'} = $cfg->{'rcfile'} || undef(); | ||
| 79 | # --backtitle <backtitle> | ||
| 80 | $self->{'_opts'}->{'backtitle'} = $cfg->{'backtitle'} || undef(); | ||
| 81 | # --title <title> | ||
| 82 | $self->{'_opts'}->{'title'} = $cfg->{'title'} || undef(); | ||
| 83 | # --allow-close | --no-close | ||
| 84 | $self->{'_opts'}->{'allowclose'} = $cfg->{'allowclose'} || 0; | ||
| 85 | $self->{'_opts'}->{'noclose'} = $cfg->{'noclose'} || 0; | ||
| 86 | # --screen-center | --under-mouse | --auto-placement | ||
| 87 | $self->{'_opts'}->{'screencenter'} = $cfg->{'screencenter'} || 0; | ||
| 88 | $self->{'_opts'}->{'undermouse'} = $cfg->{'undermouse'} || 0; | ||
| 89 | $self->{'_opts'}->{'autoplacement'} = $cfg->{'autoplacement'} || 0; | ||
| 90 | # --center | --right | --left | --fill | ||
| 91 | $self->{'_opts'}->{'center'} = $cfg->{'center'} || 0; | ||
| 92 | $self->{'_opts'}->{'right'} = $cfg->{'right'} || 0; | ||
| 93 | $self->{'_opts'}->{'left'} = $cfg->{'left'} || 0; | ||
| 94 | $self->{'_opts'}->{'fill'} = $cfg->{'fill'} || 0; | ||
| 95 | # --no-wrap | --wrap | ||
| 96 | $self->{'_opts'}->{'nowrap'} = $cfg->{'nowrap'} || 0; | ||
| 97 | $self->{'_opts'}->{'wrap'} = $cfg->{'wrap'} || 0; | ||
| 98 | # --cr-wrap | --no-cr-wrap | ||
| 99 | $self->{'_opts'}->{'crwrap'} = $cfg->{'crwrap'} || 0; | ||
| 100 | $self->{'_opts'}->{'nocrwrap'} = $cfg->{'nocrwrap'} || 0; | ||
| 101 | # --buttons-style default|icon|text | ||
| 102 | $self->{'_opts'}->{'buttonsstyle'} = $cfg->{'buttonsstyle'} || 'default'; | ||
| 103 | # --fixed-font (tailbox, textbox, and editbox) | ||
| 104 | $self->{'_opts'}->{'fixedfont'} = $cfg->{'fixedfont'} || 0; | ||
| 105 | # --editable (combobox) | ||
| 106 | $self->{'_opts'}->{'editable'} = $cfg->{'editable'} || 0; | ||
| 107 | # --time-stamp | --date-stamp (logbox) | ||
| 108 | $self->{'_opts'}->{'timestamp'} = $cfg->{'timestamp'} || 0; | ||
| 109 | $self->{'_opts'}->{'datestamp'} = $cfg->{'datestamp'} || 0; | ||
| 110 | # --reverse (logbox) | ||
| 111 | $self->{'_opts'}->{'reverse'} = $cfg->{'reverse'} || 0; | ||
| 112 | # --keep-colors (logbox) | ||
| 113 | $self->{'_opts'}->{'keepcolors'} = $cfg->{'keepcolours'} || $cfg->{'keepcolors'} || 0; | ||
| 114 | # --interval <timeout> (input(s) boxes, combo box, range(s) boxes, spin(s) boxes, list boxes, menu box, treeview, calendar, timebox) | ||
| 115 | $self->{'_opts'}->{'interval'} = $cfg->{'interval'} || 0; | ||
| 116 | # --no-tags (menubox, checklist and radiolist) | ||
| 117 | $self->{'_opts'}->{'notags'} = $cfg->{'notags'} || 0; | ||
| 118 | # --item-help (menubox, checklist, radiolist, buildlist and treeview) | ||
| 119 | $self->{'_opts'}->{'itemhelp'} = $cfg->{'itemhelp'} || 0; | ||
| 120 | # --default-item <tag> (menubox) | ||
| 121 | $self->{'_opts'}->{'defaultitem'} = $cfg->{'defaultitem'} || undef(); | ||
| 122 | # --icon <xpm filename> (textbox, editbox, tailbox, logbox, fselect and dselect) | ||
| 123 | $self->{'_opts'}->{'icon'} = $cfg->{'icon'} || undef(); | ||
| 124 | # --no-ok (tailbox and logbox) | ||
| 125 | $self->{'_opts'}->{'nook'} = $cfg->{'nook'} || 0; | ||
| 126 | # --no-cancel (infobox, gauge and progress) | ||
| 127 | $self->{'_opts'}->{'nocancel'} = $cfg->{'nocancel'} || 0; | ||
| 128 | # --no-buttons (textbox, tailbox, logbox, infobox fselect and dselect) | ||
| 129 | $self->{'_opts'}->{'nobuttons'} = $cfg->{'nobuttons'} || 0; | ||
| 130 | # --default-no !(wizard) | ||
| 131 | $self->{'_opts'}->{'defaultno'} = $cfg->{'defaultno'} || 0; | ||
| 132 | # --wizard !(msgbox, infobox, gauge and progress) | ||
| 133 | $self->{'_opts'}->{'wizard'} = $cfg->{'wizard'} || 0; | ||
| 134 | # --help <help> (infobox, gauge and progress) | ||
| 135 | $self->{'_opts'}->{'help'} = $cfg->{'help'} || undef(); | ||
| 136 | # --print <printer> (textbox, editbox and tailbox) | ||
| 137 | $self->{'_opts'}->{'print'} = $cfg->{'print'} || undef(); | ||
| 138 | # --check <label> !(infobox, gauge and progress) | ||
| 139 | $self->{'_opts'}->{'check'} = $cfg->{'check'} || undef(); | ||
| 140 | # --ok-label <label> !(wizard) | ||
| 141 | $self->{'_opts'}->{'oklabel'} = $cfg->{'oklabel'} || undef(); | ||
| 142 | # --cancel-label <label> !(wizard) | ||
| 143 | $self->{'_opts'}->{'cancellabel'} = $cfg->{'cancellabel'} || undef(); | ||
| 144 | # --beep | --beep-after (all) | ||
| 145 | $self->{'_opts'}->{'beepbin'} = $cfg->{'beepbin'} || $self->_find_bin('beep') || '/usr/bin/beep'; | ||
| 146 | $self->{'_opts'}->{'beepbefore'} = $cfg->{'beepbefore'} || 0; | ||
| 147 | $self->{'_opts'}->{'beepafter'} = $cfg->{'beepafter'} || 0; | ||
| 148 | # --begin <Yorg> <Xorg> (all) | ||
| 149 | $self->{'_opts'}->{'begin'} = $cfg->{'begin'} || undef(); #: 'begin' => [$y,$x] | ||
| 150 | # --ignore-eof (infobox and gauge) | ||
| 151 | $self->{'_opts'}->{'ignoreeof'} = $cfg->{'ignoreeof'} || 0; | ||
| 152 | # --smooth (tailbox and logbox) | ||
| 153 | $self->{'_opts'}->{'smooth'} = $cfg->{'smooth'} || 0; | ||
| 154 | |||
| 155 | #: \/we handle these internally\/ | ||
| 156 | # --stderr | --stdout | ||
| 157 | # --separator <character> | --separate-output | ||
| 158 | #: ^^we handle these internally^^ | ||
| 159 | |||
| 160 | $self->{'_opts'}->{'bin'} ||= $self->_find_bin('Xdialog'); | ||
| 161 | unless (-x $self->{'_opts'}->{'bin'}) { | ||
| 162 | croak("the Xdialog binary could not be found."); | ||
| 163 | } | ||
| 164 | |||
| 165 | #: to determin upper limits use: | ||
| 166 | # --print-maxsize | ||
| 167 | #: STDOUT| MaxSize: \d+(width), \d+(height) | ||
| 168 | $self->{'_opts'}->{'width'} = $cfg->{'width'} || 0; | ||
| 169 | $self->{'_opts'}->{'height'} = $cfg->{'height'} || 0; | ||
| 170 | $self->{'_opts'}->{'listheight'} = $cfg->{'listheight'} || $cfg->{'menuheight'} || 5; | ||
| 171 | $self->{'_opts'}->{'percentage'} = $cfg->{'percentage'} || 1; | ||
| 172 | |||
| 173 | $self->{'_opts'}->{'autoclear'} = $cfg->{'autoclear'} || 0; | ||
| 174 | $self->{'_opts'}->{'clearbefore'} = $cfg->{'clearbefore'} || 0; | ||
| 175 | $self->{'_opts'}->{'clearafter'} = $cfg->{'clearafter'} || 0; | ||
| 176 | $self->{'_opts'}->{'timeout'} = $cfg->{'timeout'} || 0; | ||
| 177 | $self->{'_opts'}->{'wait'} = $cfg->{'wait'} || 0; | ||
| 178 | |||
| 179 | $self->{'_opts'}->{'trust-input'} = | ||
| 180 | ( exists $cfg->{'trust-input'} | ||
| 181 | && $cfg->{'trust-input'}==1 | ||
| 182 | ) ? 1 : 0; | ||
| 183 | |||
| 184 | return($self); | ||
| 185 | } | ||
| 186 | |||
| 187 | |||
| 188 | |||
| 189 | |||
| 190 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
| 191 | #: Private Methods | ||
| 192 | #: | ||
| 193 | my $SIG_CODE = {'PROGRESS'=>{},'GAUGE'=>{}}; | ||
| 194 | sub _del_progress { | ||
| 195 | my $CODE = $SIG_CODE->{'PROGRESS'}->{$$}; | ||
| 196 | unless (not ref($CODE)) { | ||
| 197 | delete($CODE->{'_PROGRESS'}); | ||
| 198 | $CODE->rv('1'); | ||
| 199 | $CODE->rs('null'); | ||
| 200 | $CODE->ra('null'); | ||
| 201 | $SIG_CODE->{$$} = ""; | ||
| 202 | } | ||
| 203 | } | ||
| 204 | sub _del_gauge { | ||
| 205 | my $CODE = $SIG_CODE->{'GAUGE'}->{$$}; | ||
| 206 | unless (not ref($CODE)) { | ||
| 207 | delete($CODE->{'_GAUGE'}); | ||
| 208 | $CODE->rv('1'); | ||
| 209 | $CODE->rs('null'); | ||
| 210 | $CODE->ra('null'); | ||
| 211 | $SIG_CODE->{$$} = ""; | ||
| 212 | } | ||
| 213 | } | ||
| 214 | |||
| 215 | sub append_format_base { | ||
| 216 | my ($self,$args,$fmt) = @_; | ||
| 217 | $fmt = $self->append_format_check($args,$fmt,'title','--title {{title}}'); | ||
| 218 | $fmt = 'XDIALOG_HIGH_DIALOG_COMPAT="1" ' . $fmt | ||
| 219 | if $args->{'XDIALOG_HIGH_DIALOG_COMPAT'}; | ||
| 220 | |||
| 221 | $fmt->append_format_check($args,$fmt,"editable","--editable"); | ||
| 222 | $fmt->append_format_check($args,$fmt,"center","--center"); | ||
| 223 | $fmt->append_format_check($args,$fmt,"right","--right"); | ||
| 224 | $fmt->append_format_check($args,$fmt,"left","--left"); | ||
| 225 | $fmt->append_format_check($args,$fmt,"fill","--fill"); | ||
| 226 | $fmt->append_format_check($args,$fmt,"wrap","--wrap"); | ||
| 227 | $fmt->append_format_check($args,$fmt,"crwrap","--crwrap"); | ||
| 228 | $fmt->append_format_check($args,$fmt,"nocrwrap","--nocrwrap"); | ||
| 229 | $fmt->append_format_check($args,$fmt,"reverse","--reverse"); | ||
| 230 | $fmt->append_format_check($args,$fmt,"wizard","--wizard"); | ||
| 231 | $fmt->append_format_check($args,$fmt,"smooth","--smooth"); | ||
| 232 | |||
| 233 | $args->{'no-wrap'} ||= $args->{'nowrap'}; | ||
| 234 | $fmt->append_format_check($args,$fmt,"no-wrap","--no-wrap"); | ||
| 235 | $args->{'allow-close'} ||= $args->{'allowclose'}; | ||
| 236 | $fmt->append_format_check($args,$fmt,"allow-close","--allow-close"); | ||
| 237 | $args->{'no-close'} ||= $args->{'noclose'}; | ||
| 238 | $fmt->append_format_check($args,$fmt,"no-close","--no-close"); | ||
| 239 | $args->{'screen-center'} ||= $args->{'screencenter'}; | ||
| 240 | $fmt->append_format_check($args,$fmt,"screen-center","--screen-center"); | ||
| 241 | $args->{'under-mouse'} ||= $args->{'undermouse'}; | ||
| 242 | $fmt->append_format_check($args,$fmt,"under-mouse","--under-mouse"); | ||
| 243 | $args->{'auto-placement'} ||= $args->{'autoplacement'}; | ||
| 244 | $fmt->append_format_check($args,$fmt,"auto-placement","--auto-placement"); | ||
| 245 | $args->{'fixed-font'} ||= $args->{'fixedfont'}; | ||
| 246 | $fmt->append_format_check($args,$fmt,"fixed-font","--fixed-font"); | ||
| 247 | $args->{'time-stamp'} ||= $args->{'timestamp'}; | ||
| 248 | $fmt->append_format_check($args,$fmt,"time-stamp","--time-stamp"); | ||
| 249 | $args->{'date-stamp'} ||= $args->{'datestamp'}; | ||
| 250 | $fmt->append_format_check($args,$fmt,"date-stamp","--date-stamp"); | ||
| 251 | $args->{'keep-colors'} ||= $args->{'keep-colours'} || $args->{'keepcolors'} || $args->{'keepcolours'}; | ||
| 252 | $fmt->append_format_check($args,$fmt,"keep-colors","--keep-colors"); | ||
| 253 | $args->{'no-tags'} ||= $args->{'notags'}; | ||
| 254 | $fmt->append_format_check($args,$fmt,"no-tags","--no-tags"); | ||
| 255 | $args->{'item-help'} ||= $args->{'itemhelp'}; | ||
| 256 | $fmt->append_format_check($args,$fmt,"item-help","--item-help"); | ||
| 257 | $args->{'no-ok'} ||= $args->{'nook'}; | ||
| 258 | $fmt->append_format_check($args,$fmt,"no-ok","--no-ok"); | ||
| 259 | $args->{'no-cancel'} ||= $args->{'nocancel'}; | ||
| 260 | $fmt->append_format_check($args,$fmt,"no-cancel","--no-cancel"); | ||
| 261 | $args->{'no-buttons'} ||= $args->{'nobuttons'}; | ||
| 262 | $fmt->append_format_check($args,$fmt,"no-buttons","--no-buttons"); | ||
| 263 | $args->{'default-no'} ||= $args->{'defaultno'}; | ||
| 264 | $fmt->append_format_check($args,$fmt,"default-no","--default-no"); | ||
| 265 | $args->{'ignore-eof'} ||= $args->{'ignoreeof'}; | ||
| 266 | $fmt->append_format_check($args,$fmt,"ignore-eof","--ignore-eof"); | ||
| 267 | |||
| 268 | $fmt->append_format_check($args,$fmt,"wmclass","--wmclass {{wmclass}}"); | ||
| 269 | $fmt->append_format_check($args,$fmt,"title","--title {{title}}"); | ||
| 270 | $fmt->append_format_check($args,$fmt,"backtitle","--backtitle {{backtitle}}"); | ||
| 271 | $fmt->append_format_check($args,$fmt,"interval","--interval {{interval}}"); | ||
| 272 | $fmt->append_format_check($args,$fmt,"icon","--icon {{icon}}"); | ||
| 273 | $fmt->append_format_check($args,$fmt,"help","--help {{help}}"); | ||
| 274 | $fmt->append_format_check($args,$fmt,"print","--print {{print}}"); | ||
| 275 | $fmt->append_format_check($args,$fmt,"check",'--check {{check}}'); | ||
| 276 | |||
| 277 | $args->{'rc-file'} ||= $args->{'rcfile'}; | ||
| 278 | $fmt->append_format($fmt,'--rc-file "'.$args->{'rc-file'}.'"') | ||
| 279 | unless not -r $args->{'rc-file'}; | ||
| 280 | |||
| 281 | $args->{'button-style'} ||= $args->{'buttonsstyle'}; | ||
| 282 | $fmt->append_format_check($args,$fmt,"button-style",'--button-style "'.$args->{'button-style'}.'"'); | ||
| 283 | $args->{'default-item'} ||= $args->{'defaultitem'}; | ||
| 284 | $fmt->append_format_check($args,$fmt,"default-item",'--default-item "'.$args->{'default-item'}.'"'); | ||
| 285 | $args->{'ok-label'} ||= $args->{'oklabel'}; | ||
| 286 | $fmt->append_format_check($args,$fmt,"ok-label",'--ok-label "'.$args->{'ok-label'}.'"'); | ||
| 287 | $args->{'cancel-label'} ||= $args->{'cancellabel'}; | ||
| 288 | $fmt->append_format_check($args,$fmt,"cancel-label",'--cancel-label "'.$args->{'cancel-label'}.'"'); | ||
| 289 | |||
| 290 | if (exists $args->{'begin'}) { | ||
| 291 | my $begin = $args->{'begin'}; | ||
| 292 | if (ref($begin) eq "ARRAY") { | ||
| 293 | $fmt = $self->append_format($fmt,'--begin '.$begin->[0].' '.$begin->[1]); | ||
| 294 | } | ||
| 295 | } | ||
| 296 | |||
| 297 | return $fmt; | ||
| 298 | } | ||
| 299 | |||
| 300 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
| 301 | #: State Methods (override inherited) | ||
| 302 | #: | ||
| 303 | |||
| 304 | #: report on the state of the last widget. | ||
| 305 | sub state { | ||
| 306 | my $self = shift(); | ||
| 307 | my $rv = $self->rv() || 0; | ||
| 308 | $self->_debug((join(" | ",(caller())))." > state() > is: ".($rv||'NULL'),2); | ||
| 309 | if ($rv == 1 or $rv == 129) { | ||
| 310 | return("CANCEL"); | ||
| 311 | } | ||
| 312 | elsif ($rv == 2) { | ||
| 313 | return("HELP"); | ||
| 314 | } | ||
| 315 | elsif ($rv == 3) { | ||
| 316 | return("PREVIOUS"); | ||
| 317 | } | ||
| 318 | elsif ($rv == 254) { | ||
| 319 | return("ERROR"); | ||
| 320 | } | ||
| 321 | elsif ($rv == 255) { | ||
| 322 | return("ESC"); | ||
| 323 | } | ||
| 324 | elsif (not $rv or $rv =~ /^null$/i) { | ||
| 325 | return("OK"); | ||
| 326 | } | ||
| 327 | else { | ||
| 328 | return("UNKNOWN(".$rv.")"); | ||
| 329 | } | ||
| 330 | } | ||
| 331 | |||
| 332 | |||
| 333 | #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: | ||
| 334 | #: Public Methods | ||
| 335 | #: | ||
| 336 | |||
| 337 | # --combobox <text> <height> <width> <item1> ... <itemN> | ||
| 338 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 339 | #: display a dropdown list that's editable | ||
| 340 | sub combobox { | ||
| 341 | my $self = shift(); | ||
| 342 | my $caller = (caller(1))[3] || 'main'; | ||
| 343 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 344 | if ($_[0] && $_[0] eq 'caller') { | ||
| 345 | shift(); $caller = shift(); | ||
| 346 | } | ||
| 347 | my $args = $self->_pre($caller,@_); | ||
| 348 | |||
| 349 | my $fmt = $self->prepare_format($args); | ||
| 350 | $fmt = $self->append_format_base($args,$fmt); | ||
| 351 | $fmt = $self->append_format($fmt,'--separate-output --combobox {{text}} {{height}} {{width}} {{list}}'); | ||
| 352 | my $command = $self->prepare_command | ||
| 353 | ( $args, $fmt, | ||
| 354 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 355 | ); | ||
| 356 | |||
| 357 | my ($rv,$selected) = $self->command_string($command); | ||
| 358 | |||
| 359 | $self->rv($rv||'null'); | ||
| 360 | $self->ra('null'); | ||
| 361 | $self->rs('null'); | ||
| 362 | my $this_rv; | ||
| 363 | if ($rv && $rv >= 1) { | ||
| 364 | $this_rv = 0; | ||
| 365 | } | ||
| 366 | else { | ||
| 367 | $self->ra($selected); | ||
| 368 | $self->rs($selected); | ||
| 369 | $this_rv = $selected; | ||
| 370 | } | ||
| 371 | $self->_post($args); | ||
| 372 | return($this_rv); | ||
| 373 | } | ||
| 374 | |||
| 375 | |||
| 376 | # --rangebox <text> <height> <width> <min value> <max value> [<default value>] | ||
| 377 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 378 | #: display a slider bar with a preset range. | ||
| 379 | sub rangebox { | ||
| 380 | my $self = shift(); | ||
| 381 | my $caller = (caller(1))[3] || 'main'; | ||
| 382 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 383 | if ($_[0] && $_[0] eq 'caller') { | ||
| 384 | shift(); $caller = shift(); | ||
| 385 | } | ||
| 386 | my $args = $self->_pre($caller,@_); | ||
| 387 | |||
| 388 | |||
| 389 | my $fmt = $self->prepare_format($args); | ||
| 390 | $fmt = $self->append_format_base($args,$fmt); | ||
| 391 | $fmt = $self->append_format($fmt,'--rangebox {{text}} {{height}} {{width}} {{min}} {{max}} {{def}}'); | ||
| 392 | my $command = $self->prepare_command | ||
| 393 | ( $args, $fmt, | ||
| 394 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 395 | min => $self->make_kvl($args,($args->{'min'}||'0')), | ||
| 396 | max => $self->make_kvl($args,($args->{'max'}||'100')), | ||
| 397 | def => $self->make_kvl($args,($args->{'def'}||'0')), | ||
| 398 | ); | ||
| 399 | |||
| 400 | my ($rv,$selected) = $self->command_string($command); | ||
| 401 | |||
| 402 | $self->rv($rv||'null'); | ||
| 403 | $self->ra('null'); | ||
| 404 | $self->rs('null'); | ||
| 405 | my $this_rv; | ||
| 406 | if ($rv && $rv >= 1) { | ||
| 407 | $this_rv = 0; | ||
| 408 | } | ||
| 409 | else { | ||
| 410 | $self->ra($selected); | ||
| 411 | $self->rs($selected); | ||
| 412 | $this_rv = $selected; | ||
| 413 | } | ||
| 414 | $self->_post($args); | ||
| 415 | return($this_rv); | ||
| 416 | } | ||
| 417 | |||
| 418 | # --2rangesbox <text> <height> <width> <label1> <min1> <max1> <def1> <label2> <min2> <max2> <def2> | ||
| 419 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 420 | #: display two slider bars with preset ranges and labels | ||
| 421 | sub rangesbox2 { | ||
| 422 | my $self = shift(); | ||
| 423 | my $caller = (caller(1))[3] || 'main'; | ||
| 424 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 425 | if ($_[0] && $_[0] eq 'caller') { | ||
| 426 | shift(); $caller = shift(); | ||
| 427 | } | ||
| 428 | my $args = $self->_pre($caller,@_); | ||
| 429 | |||
| 430 | my $fmt = $self->prepare_format($args); | ||
| 431 | $fmt = $self->append_format_base($args,$fmt); | ||
| 432 | $fmt = $self->append_format($fmt,'--separate-output --2rangesbox {{text}} {{height}} {{width}}'); | ||
| 433 | $fmt = $self->append_format($fmt,'{{label1}} {{min1}} {{max1}} {{def1}}'); | ||
| 434 | $fmt = $self->append_format($fmt,'{{label2}} {{min2}} {{max2}} {{def2}}'); | ||
| 435 | my $command = $self->prepare_command | ||
| 436 | ( $args, $fmt, | ||
| 437 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 438 | label1 => $self->make_kvl($args,($args->{'label1'}||'')), | ||
| 439 | min1 => $self->make_kvl($args,($args->{'min1'}||'0')), | ||
| 440 | max1 => $self->make_kvl($args,($args->{'max1'}||'100')), | ||
| 441 | def1 => $self->make_kvl($args,($args->{'def1'}||'0')), | ||
| 442 | label2 => $self->make_kvl($args,($args->{'label2'}||'')), | ||
| 443 | min2 => $self->make_kvl($args,($args->{'min2'}||'0')), | ||
| 444 | max2 => $self->make_kvl($args,($args->{'max2'}||'100')), | ||
| 445 | def2 => $self->make_kvl($args,($args->{'def2'}||'0')), | ||
| 446 | ); | ||
| 447 | |||
| 448 | my ($rv,$selected) = $self->command_array($command); | ||
| 449 | |||
| 450 | $self->rv($rv||'null'); | ||
| 451 | $self->rs('null'); | ||
| 452 | $self->ra('null'); | ||
| 453 | my $this_rv; | ||
| 454 | if ($rv && $rv >= 1) { | ||
| 455 | $this_rv = 0; | ||
| 456 | } | ||
| 457 | else { | ||
| 458 | $self->ra(@$selected); | ||
| 459 | $self->rs(join("\n",@$selected)); | ||
| 460 | $this_rv = $selected; | ||
| 461 | } | ||
| 462 | $self->_post($args); | ||
| 463 | return($this_rv) unless ref($this_rv) eq "ARRAY"; | ||
| 464 | return(@{$this_rv}); | ||
| 465 | } | ||
| 466 | |||
| 467 | # --3rangesbox <text> <height> <width> <label1> <min1> <max1> <def1> <label2> <min2> <max2> <def2> <label3> <min3> <max3> <def3> | ||
| 468 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 469 | #: display three slider bars with preset ranges and labels | ||
| 470 | sub rangesbox3 { | ||
| 471 | my $self = shift(); | ||
| 472 | my $caller = (caller(1))[3] || 'main'; | ||
| 473 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 474 | if ($_[0] && $_[0] eq 'caller') { | ||
| 475 | shift(); $caller = shift(); | ||
| 476 | } | ||
| 477 | my $args = $self->_pre($caller,@_); | ||
| 478 | |||
| 479 | my $fmt = $self->prepare_format($args); | ||
| 480 | $fmt = $self->append_format_base($args,$fmt); | ||
| 481 | $fmt = $self->append_format($fmt,'--separate-output --3rangesbox {{text}} {{height}} {{width}}'); | ||
| 482 | $fmt = $self->append_format($fmt,'{{label1}} {{min1}} {{max1}} {{def1}}'); | ||
| 483 | $fmt = $self->append_format($fmt,'{{label2}} {{min2}} {{max2}} {{def2}}'); | ||
| 484 | $fmt = $self->append_format($fmt,'{{label3}} {{min3}} {{max3}} {{def3}}'); | ||
| 485 | my $command = $self->prepare_command | ||
| 486 | ( $args, $fmt, | ||
| 487 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 488 | label1 => $self->make_kvl($args,($args->{'label1'}||'')), | ||
| 489 | min1 => $self->make_kvl($args,($args->{'min1'}||'0')), | ||
| 490 | max1 => $self->make_kvl($args,($args->{'max1'}||'100')), | ||
| 491 | def1 => $self->make_kvl($args,($args->{'def1'}||'0')), | ||
| 492 | label2 => $self->make_kvl($args,($args->{'label2'}||'')), | ||
| 493 | min2 => $self->make_kvl($args,($args->{'min2'}||'0')), | ||
| 494 | max2 => $self->make_kvl($args,($args->{'max2'}||'100')), | ||
| 495 | def2 => $self->make_kvl($args,($args->{'def2'}||'0')), | ||
| 496 | label3 => $self->make_kvl($args,($args->{'label3'}||'')), | ||
| 497 | min3 => $self->make_kvl($args,($args->{'min3'}||'0')), | ||
| 498 | max3 => $self->make_kvl($args,($args->{'max3'}||'100')), | ||
| 499 | def3 => $self->make_kvl($args,($args->{'def3'}||'0')), | ||
| 500 | ); | ||
| 501 | |||
| 502 | my ($rv,$selected) = $self->command_array($command); | ||
| 503 | |||
| 504 | $self->rv($rv||'null'); | ||
| 505 | $self->ra('null'); | ||
| 506 | $self->rs('null'); | ||
| 507 | my $this_rv; | ||
| 508 | if ($rv && $rv >= 1) { | ||
| 509 | $this_rv = 0; | ||
| 510 | } | ||
| 511 | else { | ||
| 512 | $self->ra(@$selected); | ||
| 513 | $self->rs(join("\n",@$selected)); | ||
| 514 | $this_rv = $selected; | ||
| 515 | } | ||
| 516 | $self->_post($args); | ||
| 517 | return($this_rv) unless ref($this_rv) eq "ARRAY"; | ||
| 518 | return(@{$this_rv}); | ||
| 519 | } | ||
| 520 | |||
| 521 | # --spinbox <text> <height> <width> <min> <max> <def> <label> | ||
| 522 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 523 | #: display a spin box (a number with up/down buttons) with preset ranges | ||
| 524 | sub spinbox { | ||
| 525 | my $self = shift(); | ||
| 526 | my $caller = (caller(1))[3] || 'main'; | ||
| 527 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 528 | if ($_[0] && $_[0] eq 'caller') { | ||
| 529 | shift(); $caller = shift(); | ||
| 530 | } | ||
| 531 | my $args = $self->_pre($caller,@_); | ||
| 532 | |||
| 533 | $self->{'min'} ||= $self->{'min1'}; | ||
| 534 | $self->{'max'} ||= $self->{'max1'}; | ||
| 535 | $self->{'def'} ||= $self->{'def1'}; | ||
| 536 | $self->{'label'} ||= $self->{'label1'}; | ||
| 537 | my $fmt = $self->prepare_format($args); | ||
| 538 | $fmt = $self->append_format_base($args,$fmt); | ||
| 539 | $fmt = $self->append_format($fmt,'--separate-output --spinbox {{text}} {{height}} {{width}}'); | ||
| 540 | $fmt = $self->append_format($fmt,'{{min}} {{max}} {{def}} {{label}}'); | ||
| 541 | my $command = $self->prepare_command | ||
| 542 | ( $args, $fmt, | ||
| 543 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 544 | min => $self->make_kvl($args,($args->{'min'}||'0')), | ||
| 545 | max => $self->make_kvl($args,($args->{'max'}||'100')), | ||
| 546 | def => $self->make_kvl($args,($args->{'def'}||'0')), | ||
| 547 | label => $self->make_kvl($args,($args->{'label'}||'')), | ||
| 548 | ); | ||
| 549 | |||
| 550 | my ($rv,$selected) = $self->command_string($command); | ||
| 551 | |||
| 552 | $self->rv($rv||'null'); | ||
| 553 | $self->ra('null'); | ||
| 554 | $self->rs('null'); | ||
| 555 | my $this_rv; | ||
| 556 | if ($rv && $rv >= 1) { | ||
| 557 | $this_rv = 0; | ||
| 558 | } | ||
| 559 | else { | ||
| 560 | $self->ra($selected); | ||
| 561 | $self->rs($selected); | ||
| 562 | $this_rv = $selected; | ||
| 563 | } | ||
| 564 | $self->_post($args); | ||
| 565 | return($this_rv); | ||
| 566 | } | ||
| 567 | |||
| 568 | # --2spinsbox <text> <height> <width> <min1> <max1> <def1> <label1> <min2> <max2> <def2> <label2> | ||
| 569 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 570 | #: display two spin boxes with preset ranges and labels | ||
| 571 | sub spinsbox2 { | ||
| 572 | my $self = shift(); | ||
| 573 | my $caller = (caller(1))[3] || 'main'; | ||
| 574 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 575 | if ($_[0] && $_[0] eq 'caller') { | ||
| 576 | shift(); $caller = shift(); | ||
| 577 | } | ||
| 578 | my $args = $self->_pre($caller,@_); | ||
| 579 | |||
| 580 | my $fmt = $self->prepare_format($args); | ||
| 581 | $fmt = $self->append_format_base($args,$fmt); | ||
| 582 | $fmt = $self->append_format($fmt,'--separate-output --2spinsbox {{text}} {{height}} {{width}}'); | ||
| 583 | $fmt = $self->append_format($fmt,'{{min1}} {{max1}} {{def1}} {{label1}}'); | ||
| 584 | $fmt = $self->append_format($fmt,'{{min2}} {{max2}} {{def2}} {{label2}}'); | ||
| 585 | my $command = $self->prepare_command | ||
| 586 | ( $args, $fmt, | ||
| 587 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 588 | label1 => $self->make_kvl($args,($args->{'label1'}||'')), | ||
| 589 | min1 => $self->make_kvl($args,($args->{'min1'}||'0')), | ||
| 590 | max1 => $self->make_kvl($args,($args->{'max1'}||'100')), | ||
| 591 | def1 => $self->make_kvl($args,($args->{'def1'}||'0')), | ||
| 592 | label2 => $self->make_kvl($args,($args->{'label2'}||'')), | ||
| 593 | min2 => $self->make_kvl($args,($args->{'min2'}||'0')), | ||
| 594 | max2 => $self->make_kvl($args,($args->{'max2'}||'100')), | ||
| 595 | def2 => $self->make_kvl($args,($args->{'def2'}||'0')), | ||
| 596 | ); | ||
| 597 | |||
| 598 | my ($rv,$selected) = $self->command_array($command); | ||
| 599 | |||
| 600 | $self->rv($rv||'null'); | ||
| 601 | $self->ra('null'); | ||
| 602 | $self->rs('null'); | ||
| 603 | my $this_rv; | ||
| 604 | if ($rv && $rv >= 1) { | ||
| 605 | $this_rv = 0; | ||
| 606 | } | ||
| 607 | else { | ||
| 608 | $self->ra(@$selected); | ||
| 609 | $self->rs(join("\n",@$selected)); | ||
| 610 | $this_rv = $selected; | ||
| 611 | } | ||
| 612 | $self->_post($args); | ||
| 613 | return($this_rv) unless ref($this_rv) eq "ARRAY"; | ||
| 614 | return(@{$this_rv}); | ||
| 615 | } | ||
| 616 | |||
| 617 | # --3spinsbox <text> <height> <width> <text> <height> <width> <min1> <max1> <def1> <label1> <min2> <max2> <def2> <label2> <min3> <max3> <def3> <label3> | ||
| 618 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 619 | #: display three spin boxes with preset ranges and labels | ||
| 620 | sub spinsbox3 { | ||
| 621 | my $self = shift(); | ||
| 622 | my $caller = (caller(1))[3] || 'main'; | ||
| 623 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 624 | if ($_[0] && $_[0] eq 'caller') { | ||
| 625 | shift(); $caller = shift(); | ||
| 626 | } | ||
| 627 | my $args = $self->_pre($caller,@_); | ||
| 628 | |||
| 629 | my $fmt = $self->prepare_format($args); | ||
| 630 | $fmt = $self->append_format_base($args,$fmt); | ||
| 631 | $fmt = $self->append_format($fmt,'--separate-output --3spinsbox {{text}} {{height}} {{width}}'); | ||
| 632 | $fmt = $self->append_format($fmt,'{{min1}} {{max1}} {{def1}} {{label1}}'); | ||
| 633 | $fmt = $self->append_format($fmt,'{{min2}} {{max2}} {{def2}} {{label2}}'); | ||
| 634 | $fmt = $self->append_format($fmt,'{{min3}} {{max3}} {{def3}} {{label3}}'); | ||
| 635 | my $command = $self->prepare_command | ||
| 636 | ( $args, $fmt, | ||
| 637 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 638 | label1 => $self->make_kvl($args,($args->{'label1'}||'')), | ||
| 639 | min1 => $self->make_kvl($args,($args->{'min1'}||'0')), | ||
| 640 | max1 => $self->make_kvl($args,($args->{'max1'}||'100')), | ||
| 641 | def1 => $self->make_kvl($args,($args->{'def1'}||'0')), | ||
| 642 | label2 => $self->make_kvl($args,($args->{'label2'}||'')), | ||
| 643 | min2 => $self->make_kvl($args,($args->{'min2'}||'0')), | ||
| 644 | max2 => $self->make_kvl($args,($args->{'max2'}||'100')), | ||
| 645 | def2 => $self->make_kvl($args,($args->{'def2'}||'0')), | ||
| 646 | label3 => $self->make_kvl($args,($args->{'label3'}||'')), | ||
| 647 | min3 => $self->make_kvl($args,($args->{'min3'}||'0')), | ||
| 648 | max3 => $self->make_kvl($args,($args->{'max3'}||'100')), | ||
| 649 | def3 => $self->make_kvl($args,($args->{'def3'}||'0')), | ||
| 650 | ); | ||
| 651 | |||
| 652 | my ($rv,$selected) = $self->command_array($command); | ||
| 653 | |||
| 654 | $self->rv($rv||'null'); | ||
| 655 | $self->rs('null'); | ||
| 656 | $self->ra('null'); | ||
| 657 | my $this_rv; | ||
| 658 | if ($rv && $rv >= 1) { | ||
| 659 | $this_rv = 0; | ||
| 660 | } | ||
| 661 | else { | ||
| 662 | $self->ra(@$selected); | ||
| 663 | $self->rs(join("\n",@$selected)); | ||
| 664 | $this_rv = $selected; | ||
| 665 | } | ||
| 666 | $self->_post($args); | ||
| 667 | return($this_rv) unless ref($this_rv) eq "ARRAY"; | ||
| 668 | return(@{$this_rv}); | ||
| 669 | } | ||
| 670 | |||
| 671 | # --buildlist <text> <height> <width> <list height> <tag1> <item1> <status1> {<help1>}... | ||
| 672 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 673 | #: display a two paned box by which the user can organize a list of items | ||
| 674 | sub buildlist { | ||
| 675 | my $self = shift(); | ||
| 676 | my $caller = (caller(1))[3] || 'main'; | ||
| 677 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 678 | if ($_[0] && $_[0] eq 'caller') { | ||
| 679 | shift(); $caller = shift(); | ||
| 680 | } | ||
| 681 | my $args = $self->_pre($caller,@_); | ||
| 682 | |||
| 683 | $self->{'buildlist'} ||= 'buildlist'; | ||
| 684 | $self->{'listheight'} ||= $self->{'menuheight'}; | ||
| 685 | |||
| 686 | my $fmt = $self->prepare_format($args); | ||
| 687 | $fmt = $self->append_format_base($args,$fmt); | ||
| 688 | $fmt = $self->append_format($fmt,'--separate-output --'.$self->{'buildlist'}); | ||
| 689 | $fmt = $self->append_format('{{text}} {{height}} {{width}} {{listheight}} {{list}}'); | ||
| 690 | my $command = $self->prepare_command | ||
| 691 | ( $args, $fmt, | ||
| 692 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 693 | ); | ||
| 694 | |||
| 695 | my ($rv,$selected) = $self->command_array($command); | ||
| 696 | |||
| 697 | $self->rv($rv||'null'); | ||
| 698 | $self->rs('null'); | ||
| 699 | $self->ra('null'); | ||
| 700 | my $this_rv; | ||
| 701 | if ($rv && $rv >= 1) { | ||
| 702 | $this_rv = 0; | ||
| 703 | } | ||
| 704 | else { | ||
| 705 | $self->ra(@$selected); | ||
| 706 | $self->rs(join("\n",@$selected)); | ||
| 707 | $this_rv = $selected; | ||
| 708 | } | ||
| 709 | $self->_post($args); | ||
| 710 | return($this_rv) unless ref($this_rv) eq "ARRAY"; | ||
| 711 | return(@{$this_rv}); | ||
| 712 | } | ||
| 713 | |||
| 714 | # --treeview <text> <height> <width> <list height> <tag1> <item1> <status1> <item_depth1> {<help1>}... | ||
| 715 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 716 | #: display a tree view of items | ||
| 717 | sub treeview { | ||
| 718 | my $self = shift(); | ||
| 719 | my $caller = (caller(1))[3] || 'main'; | ||
| 720 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 721 | if ($_[0] && $_[0] eq 'caller') { | ||
| 722 | shift(); $caller = shift(); | ||
| 723 | } | ||
| 724 | my $args = $self->_pre($caller,@_); | ||
| 725 | |||
| 726 | $self->{'treeview'} ||= 'treeview'; | ||
| 727 | $self->{'listheight'} ||= $self->{'menuheight'}; | ||
| 728 | |||
| 729 | my $fmt = $self->prepare_format($args); | ||
| 730 | $fmt = $self->append_format_base($args,$fmt); | ||
| 731 | $fmt = $self->append_format($fmt,'--separate-output --'.$self->{'treeview'}); | ||
| 732 | $fmt = $self->append_format('{{text}} {{height}} {{width}} {{listheight}} {{list}}'); | ||
| 733 | my $command = $self->prepare_command | ||
| 734 | ( $args, $fmt, | ||
| 735 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 736 | ); | ||
| 737 | |||
| 738 | my ($rv,$selected) = $self->command_string($command); | ||
| 739 | |||
| 740 | $self->rv($rv||'null'); | ||
| 741 | $self->ra('null'); | ||
| 742 | $self->rs('null'); | ||
| 743 | my $this_rv; | ||
| 744 | if ($rv && $rv >= 1) { | ||
| 745 | $this_rv = 0; | ||
| 746 | } | ||
| 747 | else { | ||
| 748 | $self->ra($selected); | ||
| 749 | $self->rs($selected); | ||
| 750 | $this_rv = $selected; | ||
| 751 | } | ||
| 752 | $self->_post($args); | ||
| 753 | return($this_rv); | ||
| 754 | } | ||
| 755 | |||
| 756 | # --calendar <text> <height> <width> <day> <month> <year> | ||
| 757 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 758 | #: display a calendar with a preset date | ||
| 759 | sub calendar { | ||
| 760 | my $self = shift(); | ||
| 761 | my $caller = (caller(1))[3] || 'main'; | ||
| 762 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 763 | if ($_[0] && $_[0] eq 'caller') { | ||
| 764 | shift(); $caller = shift(); | ||
| 765 | } | ||
| 766 | my $args = $self->_pre($caller,@_); | ||
| 767 | $args->{'day'} ||= '1'; | ||
| 768 | $args->{'month'} ||= '1'; | ||
| 769 | $args->{'year'} ||= '1970'; | ||
| 770 | |||
| 771 | my $fmt = $self->prepare_format($args); | ||
| 772 | $fmt = $self->append_format_base($args,$fmt); | ||
| 773 | $fmt = $self->append_format($fmt,'--separate-output --calendar {{text}} {{height}} {{width}} {{day}} {{month}} {{year}}'); | ||
| 774 | my $command = $self->prepare_command | ||
| 775 | ( $args, $fmt, | ||
| 776 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 777 | ); | ||
| 778 | |||
| 779 | my ($rv,$selected) = $self->command_string($command); | ||
| 780 | $self->rv($rv||'null'); | ||
| 781 | $self->ra('null'); | ||
| 782 | $self->rs('null'); | ||
| 783 | my $this_rv; | ||
| 784 | if ($rv && $rv >= 1) { | ||
| 785 | $this_rv = 0; | ||
| 786 | } | ||
| 787 | else { | ||
| 788 | chomp($selected); | ||
| 789 | $self->ra(split(/\//,$selected)); | ||
| 790 | $self->rs($selected); | ||
| 791 | $this_rv = $selected; | ||
| 792 | } | ||
| 793 | $self->_post($args); | ||
| 794 | return($this_rv); | ||
| 795 | } | ||
| 796 | |||
| 797 | # --timebox <text> <height> <width> | ||
| 798 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 799 | #: display a time box | ||
| 800 | sub timebox { | ||
| 801 | my $self = shift(); | ||
| 802 | my $caller = (caller(1))[3] || 'main'; | ||
| 803 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 804 | if ($_[0] && $_[0] eq 'caller') { | ||
| 805 | shift(); $caller = shift(); | ||
| 806 | } | ||
| 807 | my $args = $self->_pre($caller,@_); | ||
| 808 | |||
| 809 | my $fmt = $self->prepare_format($args); | ||
| 810 | $fmt = $self->append_format_base($args,$fmt); | ||
| 811 | $fmt = $self->append_format($fmt,'--separate-output --timebox {{text}} {{height}} {{width}}'); | ||
| 812 | my $command = $self->prepare_command | ||
| 813 | ( $args, $fmt, | ||
| 814 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 815 | ); | ||
| 816 | |||
| 817 | my ($rv,$selected) = $self->command_string($command); | ||
| 818 | |||
| 819 | $self->rv($rv||'null'); | ||
| 820 | $self->ra('null'); | ||
| 821 | $self->rs('null'); | ||
| 822 | my $this_rv; | ||
| 823 | if ($rv && $rv >= 1) { | ||
| 824 | $this_rv = 0; | ||
| 825 | } | ||
| 826 | else { | ||
| 827 | $self->ra(split(/\:/,$selected)); | ||
| 828 | $self->rs($selected); | ||
| 829 | $this_rv = $selected; | ||
| 830 | } | ||
| 831 | $self->_post($args); | ||
| 832 | return($this_rv); | ||
| 833 | } | ||
| 834 | |||
| 835 | # --yesno <text> <height> <width> | ||
| 836 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 837 | #: Ask a binary question (Yes/No) | ||
| 838 | sub yesno { | ||
| 839 | my $self = shift(); | ||
| 840 | my $caller = (caller(1))[3] || 'main'; | ||
| 841 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 842 | if ($_[0] && $_[0] eq 'caller') { | ||
| 843 | shift(); $caller = shift(); | ||
| 844 | } | ||
| 845 | my $args = $self->_pre($caller,@_); | ||
| 846 | |||
| 847 | my $fmt = $self->prepare_format($args); | ||
| 848 | $fmt = $self->append_format_base($args,$fmt); | ||
| 849 | $fmt = $self->append_format($fmt,'--yesno {{text}} {{height}} {{width}}'); | ||
| 850 | my $command = $self->prepare_command | ||
| 851 | ( $args, $fmt, | ||
| 852 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 853 | ); | ||
| 854 | |||
| 855 | my $rv = $self->command_state($command); | ||
| 856 | |||
| 857 | $self->rv($rv||'null'); | ||
| 858 | my $this_rv; | ||
| 859 | if ($rv && $rv >= 1) { | ||
| 860 | $self->ra("NO"); | ||
| 861 | $self->rs("NO"); | ||
| 862 | $this_rv = 0; | ||
| 863 | } | ||
| 864 | else { | ||
| 865 | $self->ra("YES"); | ||
| 866 | $self->rs("YES"); | ||
| 867 | $this_rv = 1; | ||
| 868 | } | ||
| 869 | $self->_post($args); | ||
| 870 | return($this_rv); | ||
| 871 | } | ||
| 872 | |||
| 873 | # --inputbox <text> <height> <width> [<init>] | ||
| 874 | # --2inputsbox <text> <height> <width> <label1> <init1> <label2> <init2> | ||
| 875 | # --3inputsbox <text> <height> <width> <label1> <init1> <label2> <init2> <label3> <init3> | ||
| 876 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 877 | #: Text entry | ||
| 878 | sub inputbox { | ||
| 879 | my $self = shift(); | ||
| 880 | my $caller = (caller(1))[3] || 'main'; | ||
| 881 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 882 | if ($_[0] && $_[0] eq 'caller') { | ||
| 883 | shift(); $caller = shift(); | ||
| 884 | } | ||
| 885 | my $args = $self->_pre($caller,@_); | ||
| 886 | my $val = $args->{'inputs'} || $args->{'password'} || 1; | ||
| 887 | |||
| 888 | my $fmt = $self->prepare_format($args); | ||
| 889 | $fmt = $self->append_format_base($args,$fmt); | ||
| 890 | if ($val > 1) { | ||
| 891 | $fmt = $self->append_format($fmt,'--separate-output'); | ||
| 892 | } | ||
| 893 | $fmt = $self->append_format_check($args,$fmt,'password','--password'); | ||
| 894 | $fmt = $self->append_format_check($args,$fmt,'password','--password') if $val > 1; | ||
| 895 | $fmt = $self->append_format_check($args,$fmt,'password','--password') if $val > 2; | ||
| 896 | |||
| 897 | my $opbox = '--inputbox'; | ||
| 898 | $opbox = '--2inputsbox' if $val == 2; | ||
| 899 | $opbox = '--3inputsbox' if $val == 3; | ||
| 900 | |||
| 901 | $fmt = $self->append_format($fmt,$opbox.' {{text}} {{height}} {{width}}'); | ||
| 902 | $fmt = $self->append_format($fmt,'"'.($args->{'entry'}||$args->{'init'}).'"') if $val == 1; | ||
| 903 | $fmt = $self->append_format($fmt,'"'.($args->{'label1'}||'').'"') if $val > 1; | ||
| 904 | $fmt = $self->append_format($fmt,'"'.($args->{'input1'}||'').'"') if $val > 1; | ||
| 905 | $fmt = $self->append_format($fmt,'"'.($args->{'label2'}||'').'"') if $val >= 2; | ||
| 906 | $fmt = $self->append_format($fmt,'"'.($args->{'input2'}||'').'"') if $val >= 2; | ||
| 907 | $fmt = $self->append_format($fmt,'"'.($args->{'label3'}||'').'"') if $val >= 3; | ||
| 908 | $fmt = $self->append_format($fmt,'"'.($args->{'input3'}||'').'"') if $val >= 3; | ||
| 909 | |||
| 910 | my $command = $self->prepare_command | ||
| 911 | ( $args, $fmt, | ||
| 912 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 913 | ); | ||
| 914 | |||
| 915 | my ($rv,$text); | ||
| 916 | if ($val == 1) { | ||
| 917 | ($rv,$text) = $self->command_string($command); | ||
| 918 | } | ||
| 919 | else { | ||
| 920 | ($rv,$text) = $self->command_array($command); | ||
| 921 | } | ||
| 922 | |||
| 923 | $self->rv($rv||'null'); | ||
| 924 | $self->ra('null'); | ||
| 925 | $self->rs('null'); | ||
| 926 | my $this_rv; | ||
| 927 | if ($rv && $rv >= 1) { | ||
| 928 | $this_rv = 0; | ||
| 929 | } | ||
| 930 | else { | ||
| 931 | if ($val == 1) { | ||
| 932 | $self->ra($text); | ||
| 933 | $self->rs($text); | ||
| 934 | } | ||
| 935 | else { | ||
| 936 | $self->ra(@$text); | ||
| 937 | $self->rs(join("\n",@$text)); | ||
| 938 | } | ||
| 939 | $this_rv = $text; | ||
| 940 | } | ||
| 941 | $self->_post($args); | ||
| 942 | return($this_rv) unless ref($this_rv) eq "ARRAY"; | ||
| 943 | return(@{$this_rv}); | ||
| 944 | } | ||
| 945 | sub inputsbox2 { | ||
| 946 | my $self = shift(); | ||
| 947 | return($self->inputbox('caller',((caller(1))[3]||'main'),@_,'inputs',2)); | ||
| 948 | } | ||
| 949 | sub inputsbox3 { | ||
| 950 | my $self = shift(); | ||
| 951 | return($self->inputbox('caller',((caller(1))[3]||'main'),@_,'inputs',3)); | ||
| 952 | } | ||
| 953 | sub password { | ||
| 954 | my $self = shift(); | ||
| 955 | return($self->inputbox('caller',((caller(1))[3]||'main'),@_,'password',1,'inputs',1)); | ||
| 956 | } | ||
| 957 | sub passwords2 { | ||
| 958 | my $self = shift(); | ||
| 959 | return($self->inputbox('caller',((caller(1))[3]||'main'),@_,'password',1,'inputs',2)); | ||
| 960 | } | ||
| 961 | sub passwords3 { | ||
| 962 | my $self = shift(); | ||
| 963 | return($self->inputbox('caller',((caller(1))[3]||'main'),@_,'password',1,'inputs',3)); | ||
| 964 | } | ||
| 965 | |||
| 966 | # --msgbox <text> <height> <width> | ||
| 967 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 968 | #: Text box | ||
| 969 | sub msgbox { | ||
| 970 | my $self = shift(); | ||
| 971 | my $caller = (caller(1))[3] || 'main'; | ||
| 972 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 973 | if ($_[0] && $_[0] eq 'caller') { | ||
| 974 | shift(); $caller = shift(); | ||
| 975 | } | ||
| 976 | my $args = $self->_pre($caller,@_); | ||
| 977 | |||
| 978 | $args->{'msgbox'} ||= 'msgbox'; | ||
| 979 | |||
| 980 | my $fmt = $self->prepare_format($args); | ||
| 981 | $fmt = $self->append_format_base($args,$fmt); | ||
| 982 | $fmt = $self->append_format($fmt,'--'.$args->{'msgbox'}); | ||
| 983 | $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}}'); | ||
| 984 | my $wait = ($args->{'wait'} ? $args->{'wait'}*1000 : ($args->{'timeout'}||'5000')); | ||
| 985 | $fmt = $self->append_format($fmt,'"'.$wait.'"') if $args->{'msgbox'} eq 'infobox'; | ||
| 986 | my $command = $self->prepare_command | ||
| 987 | ( $args, $fmt, | ||
| 988 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 989 | ); | ||
| 990 | |||
| 991 | my $rv = $self->command_state($command); | ||
| 992 | |||
| 993 | $self->rv($rv||'null'); | ||
| 994 | $self->ra('null'); | ||
| 995 | $self->rs('null'); | ||
| 996 | my $this_rv; | ||
| 997 | if ($rv && $rv >= 1) { | ||
| 998 | $this_rv = 0; | ||
| 999 | } | ||
| 1000 | else { | ||
| 1001 | $this_rv = 1; | ||
| 1002 | } | ||
| 1003 | $self->_post($args); | ||
| 1004 | return($this_rv); | ||
| 1005 | } | ||
| 1006 | |||
| 1007 | # --infobox <text> <height> <width> [<timeout>] | ||
| 1008 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1009 | #: same as msgbox but destroy's itself with timeout... | ||
| 1010 | sub infobox { | ||
| 1011 | my $self = shift(); | ||
| 1012 | return($self->msgbox('caller',((caller(1))[3]||'main'),@_,'msgbox','infobox')); | ||
| 1013 | } | ||
| 1014 | |||
| 1015 | # --editbox <file> <height> <width> | ||
| 1016 | # --tailbox <file> <height> <width> | ||
| 1017 | # --logbox <file> <height> <width> | ||
| 1018 | # --textbox <file> <height> <width> | ||
| 1019 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1020 | #: File box | ||
| 1021 | sub textbox { | ||
| 1022 | my $self = shift(); | ||
| 1023 | my $caller = (caller(1))[3] || 'main'; | ||
| 1024 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1025 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1026 | shift(); $caller = shift(); | ||
| 1027 | } | ||
| 1028 | my $args = $self->_pre($caller,@_); | ||
| 1029 | |||
| 1030 | $args->{'textbox'} ||= 'textbox'; | ||
| 1031 | $args->{'filename'} ||= $args->{'path'}; | ||
| 1032 | |||
| 1033 | my $fmt = $self->prepare_format($args); | ||
| 1034 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1035 | $fmt = $self->append_format($fmt,'--'.$args->{'textbox'}); | ||
| 1036 | $fmt = $self->append_format($fmt,'{{filename}} {{height}} {{width}}'); | ||
| 1037 | my $command = $self->prepare_command | ||
| 1038 | ( $args, $fmt, | ||
| 1039 | filename => $self->make_kvl($args,$args->{'filename'}), | ||
| 1040 | ); | ||
| 1041 | |||
| 1042 | my ($rv,$text) = $self->command_string($command); | ||
| 1043 | |||
| 1044 | $self->rv($rv||'null'); | ||
| 1045 | $self->ra('null'); | ||
| 1046 | $self->rs('null'); | ||
| 1047 | my $this_rv; | ||
| 1048 | if ($rv && $rv >= 1) { | ||
| 1049 | $this_rv = 0; | ||
| 1050 | } | ||
| 1051 | else { | ||
| 1052 | $self->ra(($text) ? [ $text ] : 'null'); | ||
| 1053 | $self->rs($text||'null'); | ||
| 1054 | $this_rv = $text || 1; | ||
| 1055 | } | ||
| 1056 | $self->_post($args); | ||
| 1057 | return($this_rv); | ||
| 1058 | } | ||
| 1059 | sub editbox { | ||
| 1060 | my $self = shift(); | ||
| 1061 | return($self->textbox('caller',((caller(1))[3]||'main'),@_,'textbox','editbox')); | ||
| 1062 | } | ||
| 1063 | sub logbox { | ||
| 1064 | my $self = shift(); | ||
| 1065 | return($self->textbox('caller',((caller(1))[3]||'main'),@_,'textbox','logbox')); | ||
| 1066 | } | ||
| 1067 | sub tailbox { | ||
| 1068 | my $self = shift(); | ||
| 1069 | return($self->textbox('caller',((caller(1))[3]||'main'),@_,'textbox','tailbox')); | ||
| 1070 | } | ||
| 1071 | |||
| 1072 | # --menubox <text> <height> <width> <menu height> <tag1> <item1> {<help1>}... | ||
| 1073 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1074 | #: Lists | ||
| 1075 | sub menu { | ||
| 1076 | my $self = shift(); | ||
| 1077 | my $caller = (caller(1))[3] || 'main'; | ||
| 1078 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1079 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1080 | shift(); $caller = shift(); | ||
| 1081 | } | ||
| 1082 | my $args = $self->_pre($caller,@_); | ||
| 1083 | |||
| 1084 | my $fmt = $self->prepare_format($args); | ||
| 1085 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1086 | $fmt = $self->append_format($fmt,'--separate-output --menu'); | ||
| 1087 | $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{listheight}} {{list}}'); | ||
| 1088 | my $command = $self->prepare_command | ||
| 1089 | ( $args, $fmt, | ||
| 1090 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 1091 | ); | ||
| 1092 | |||
| 1093 | my ($rv,$selected) = $self->command_string($command); | ||
| 1094 | |||
| 1095 | $self->rv($rv||'null'); | ||
| 1096 | $self->ra('null'); | ||
| 1097 | $self->rs('null'); | ||
| 1098 | my $this_rv; | ||
| 1099 | if ($rv && $rv >= 1) { | ||
| 1100 | $this_rv = 0; | ||
| 1101 | } | ||
| 1102 | else { | ||
| 1103 | $self->ra($selected); | ||
| 1104 | $self->rs($selected); | ||
| 1105 | $this_rv = $selected; | ||
| 1106 | } | ||
| 1107 | $self->_post($args); | ||
| 1108 | return($this_rv); | ||
| 1109 | } | ||
| 1110 | |||
| 1111 | # --checklist <text> <height> <width> <list height> <tag1> <item1> <status1> {<help1>}... | ||
| 1112 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1113 | #: multiple selection list via checkbox widgets | ||
| 1114 | sub checklist { | ||
| 1115 | my $self = shift(); | ||
| 1116 | my $caller = (caller(1))[3] || 'main'; | ||
| 1117 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1118 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1119 | shift(); $caller = shift(); | ||
| 1120 | } | ||
| 1121 | my $args = $self->_pre($caller,@_); | ||
| 1122 | |||
| 1123 | $self->{'checklist'} ||= 'checklist'; | ||
| 1124 | |||
| 1125 | my $fmt = $self->prepare_format($args); | ||
| 1126 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1127 | $fmt = $self->append_format($fmt,'--separate-output --'.$self->{'checklist'}); | ||
| 1128 | $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{listheight}} {{list}}'); | ||
| 1129 | my $command = $self->prepare_command | ||
| 1130 | ( $args, $fmt, | ||
| 1131 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 1132 | ); | ||
| 1133 | |||
| 1134 | my ($rv,$selected) = $self->command_array($command); | ||
| 1135 | |||
| 1136 | $self->rv($rv||'null'); | ||
| 1137 | $self->rs('null'); | ||
| 1138 | $self->ra('null'); | ||
| 1139 | my $this_rv; | ||
| 1140 | if ($rv && $rv >= 1) { | ||
| 1141 | $this_rv = 0; | ||
| 1142 | } | ||
| 1143 | else { | ||
| 1144 | $self->ra(@$selected); | ||
| 1145 | $self->rs(join("\n",@$selected)); | ||
| 1146 | $this_rv = $selected; | ||
| 1147 | } | ||
| 1148 | $self->_post($args); | ||
| 1149 | return($this_rv) unless ref($this_rv) eq "ARRAY"; | ||
| 1150 | return(@{$this_rv}); | ||
| 1151 | } | ||
| 1152 | |||
| 1153 | # --radiolist <text> <height> <width> <list height> <tag1> <item1> <status1> {<help1>}... | ||
| 1154 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1155 | #: display a list via the radiolist widget | ||
| 1156 | sub radiolist { | ||
| 1157 | my $self = shift(); | ||
| 1158 | my $caller = (caller(1))[3] || 'main'; | ||
| 1159 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1160 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1161 | shift(); $caller = shift(); | ||
| 1162 | } | ||
| 1163 | my $args = $self->_pre($caller,@_); | ||
| 1164 | |||
| 1165 | $self->{'radiolist'} ||= 'radiolist'; | ||
| 1166 | |||
| 1167 | my $fmt = $self->prepare_format($args); | ||
| 1168 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1169 | $fmt = $self->append_format($fmt,'--separate-output --'.$self->{'radiolist'}); | ||
| 1170 | $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{listheight}} {{list}}'); | ||
| 1171 | my $command = $self->prepare_command | ||
| 1172 | ( $args, $fmt, | ||
| 1173 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 1174 | ); | ||
| 1175 | |||
| 1176 | my ($rv,$selected) = $self->command_string($command); | ||
| 1177 | |||
| 1178 | $self->rv($rv||'null'); | ||
| 1179 | $self->ra('null'); | ||
| 1180 | $self->rs('null'); | ||
| 1181 | my $this_rv; | ||
| 1182 | if ($rv && $rv >= 1) { | ||
| 1183 | $this_rv = 0; | ||
| 1184 | } | ||
| 1185 | else { | ||
| 1186 | $self->ra($selected); | ||
| 1187 | $self->rs($selected); | ||
| 1188 | $this_rv = $selected; | ||
| 1189 | } | ||
| 1190 | $self->_post($args); | ||
| 1191 | return($this_rv); | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | # --fselect <file> <height> <width> | ||
| 1195 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1196 | #: file select | ||
| 1197 | sub fselect { | ||
| 1198 | my $self = shift(); | ||
| 1199 | my $caller = (caller(1))[3] || 'main'; | ||
| 1200 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1201 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1202 | shift(); $caller = shift(); | ||
| 1203 | } | ||
| 1204 | my $args = $self->_pre($caller,@_); | ||
| 1205 | $args->{'path'} ||= abs_path(); | ||
| 1206 | |||
| 1207 | my $fmt = $self->prepare_format($args); | ||
| 1208 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1209 | $fmt = $self->append_format($fmt,'--fselect'); | ||
| 1210 | $fmt = $self->append_format($fmt,'{{path}} {{height}} {{width}}'); | ||
| 1211 | my $command = $self->prepare_command | ||
| 1212 | ( $args, $fmt, | ||
| 1213 | path => $self->make_kvl($args,$args->{'path'}), | ||
| 1214 | ); | ||
| 1215 | |||
| 1216 | my ($rv,$file) = $self->command_string($command); | ||
| 1217 | |||
| 1218 | $self->rv($rv||'null'); | ||
| 1219 | $self->ra('null'); | ||
| 1220 | $self->rs('null'); | ||
| 1221 | my $this_rv; | ||
| 1222 | if ($rv && $rv >= 1) { | ||
| 1223 | $this_rv = 0; | ||
| 1224 | } | ||
| 1225 | else { | ||
| 1226 | $self->ra($file); | ||
| 1227 | $self->rs($file); | ||
| 1228 | $this_rv = $file; | ||
| 1229 | } | ||
| 1230 | $self->_post($args); | ||
| 1231 | return($this_rv); | ||
| 1232 | } | ||
| 1233 | |||
| 1234 | # --dselect <directory> <height> <width> | ||
| 1235 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1236 | #: directory selector | ||
| 1237 | sub dselect { | ||
| 1238 | my $self = shift(); | ||
| 1239 | my $caller = (caller(1))[3] || 'main'; | ||
| 1240 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1241 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1242 | shift(); $caller = shift(); | ||
| 1243 | } | ||
| 1244 | my $args = $self->_pre($caller,@_); | ||
| 1245 | $args->{'path'} ||= abs_path(); | ||
| 1246 | |||
| 1247 | my $fmt = $self->prepare_format($args); | ||
| 1248 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1249 | $fmt = $self->append_format($fmt,'--dselect'); | ||
| 1250 | $fmt = $self->append_format($fmt,'{{path}} {{height}} {{width}}'); | ||
| 1251 | my $command = $self->prepare_command | ||
| 1252 | ( $args, $fmt, | ||
| 1253 | path => $self->make_kvl($args,$args->{'path'}), | ||
| 1254 | ); | ||
| 1255 | |||
| 1256 | my ($rv,$file) = $self->command_string($command); | ||
| 1257 | |||
| 1258 | $self->rv($rv||'null'); | ||
| 1259 | $self->ra('null'); | ||
| 1260 | $self->rs('null'); | ||
| 1261 | my $this_rv; | ||
| 1262 | if ($rv && $rv >= 1) { | ||
| 1263 | $this_rv = 0; | ||
| 1264 | } | ||
| 1265 | else { | ||
| 1266 | $self->ra($file); | ||
| 1267 | $self->rs($file); | ||
| 1268 | $this_rv = $file; | ||
| 1269 | } | ||
| 1270 | $self->_post($args); | ||
| 1271 | return($this_rv); | ||
| 1272 | } | ||
| 1273 | |||
| 1274 | # --gauge <text> <height> <width> [<percent>] | ||
| 1275 | # --progress <text> <height> <width> [<maxdots> [[-]<msglen>]] | ||
| 1276 | #:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | ||
| 1277 | #: progress meter | ||
| 1278 | sub progress_start { | ||
| 1279 | my $self = shift(); | ||
| 1280 | my $caller = (caller(1))[3] || 'main'; | ||
| 1281 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1282 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1283 | shift(); $caller = shift(); | ||
| 1284 | } | ||
| 1285 | my $args = $self->_pre($caller,@_); | ||
| 1286 | |||
| 1287 | $self->{'_PROGRESS'} ||= {}; | ||
| 1288 | $self->{'_PROGRESS'}->{'ARGS'} = $args; | ||
| 1289 | |||
| 1290 | if (defined $self->{'_PROGRESS'}->{'FH'}) { | ||
| 1291 | $self->rv(129); | ||
| 1292 | $self->_post($args); | ||
| 1293 | return(0); | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | my $fmt = $self->prepare_format($args); | ||
| 1297 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1298 | $fmt = $self->append_format($fmt,'--progress'); | ||
| 1299 | $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}}'); | ||
| 1300 | $fmt = $self->append_format($fmt,'"'.($args->{'maxdots'}||'').'"') if $args->{'maxdots'} or $args->{'msglen'}; | ||
| 1301 | $fmt = $self->append_format($fmt,'"'.($args->{'msglen'}||'').'"') if $args->{'msglen'}; | ||
| 1302 | my $command = $self->prepare_command | ||
| 1303 | ( $args, $fmt, | ||
| 1304 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 1305 | ); | ||
| 1306 | |||
| 1307 | $self->{'_PROGRESS'}->{'PERCENT'} = ($args->{'percentage'} || '0'); | ||
| 1308 | |||
| 1309 | $self->_debug("command: ".$command,2); | ||
| 1310 | $self->{'_PROGRESS'}->{'FH'} = new FileHandle; | ||
| 1311 | $self->{'_PROGRESS'}->{'FH'}->open("| $command"); | ||
| 1312 | my $rv = $? >> 8; | ||
| 1313 | $self->{'_PROGRESS'}->{'FH'}->autoflush(1); | ||
| 1314 | $self->rv($rv||'null'); | ||
| 1315 | $self->ra('null'); | ||
| 1316 | $self->rs('null'); | ||
| 1317 | my $this_rv; | ||
| 1318 | if ($rv && $rv >= 1) { | ||
| 1319 | $this_rv = 0; | ||
| 1320 | } | ||
| 1321 | else { | ||
| 1322 | $this_rv = 1; | ||
| 1323 | } | ||
| 1324 | return($this_rv); | ||
| 1325 | } | ||
| 1326 | sub gauge_start { | ||
| 1327 | my $self = shift(); | ||
| 1328 | my $caller = (caller(1))[3] || 'main'; | ||
| 1329 | $caller = ($caller =~ /^UI\:\:Dialog\:\:Backend\:\:/) ? ((caller(2))[3]||'main') : $caller; | ||
| 1330 | if ($_[0] && $_[0] eq 'caller') { | ||
| 1331 | shift(); $caller = shift(); | ||
| 1332 | } | ||
| 1333 | my $args = $self->_pre($caller,@_); | ||
| 1334 | |||
| 1335 | $self->{'_GAUGE'} ||= {}; | ||
| 1336 | $self->{'_GAUGE'}->{'ARGS'} = $args; | ||
| 1337 | |||
| 1338 | if (defined $self->{'_GAUGE'}->{'FH'}) { | ||
| 1339 | $self->rv(129); | ||
| 1340 | $self->_post($args); | ||
| 1341 | return(0); | ||
| 1342 | } | ||
| 1343 | my $fmt = $self->prepare_format($args); | ||
| 1344 | $fmt = $self->append_format_base($args,$fmt); | ||
| 1345 | $fmt = $self->append_format($fmt,'--progress'); | ||
| 1346 | $fmt = $self->append_format($fmt,'{{text}} {{height}} {{width}} {{percentage}}'); | ||
| 1347 | $fmt = $self->append_format($fmt,'"'.($args->{'msglen'}||'').'"') if $args->{'msglen'}; | ||
| 1348 | my $command = $self->prepare_command | ||
| 1349 | ( $args, $fmt, | ||
| 1350 | text => $self->make_kvt($args,$args->{'text'}), | ||
| 1351 | percentage => $self->make_kvl($args,($args->{'percentage'}||'0')), | ||
| 1352 | ); | ||
| 1353 | |||
| 1354 | $self->{'_GAUGE'}->{'PERCENT'} = ($args->{'percentage'} || '0'); | ||
| 1355 | |||
| 1356 | $self->_debug("command: ".$command,2); | ||
| 1357 | |||
| 1358 | $self->{'_GAUGE'}->{'FH'} = new FileHandle; | ||
| 1359 | $self->{'_GAUGE'}->{'FH'}->open("| $command"); | ||
| 1360 | my $rv = $? >> 8; | ||
| 1361 | $self->{'_GAUGE'}->{'FH'}->autoflush(1); | ||
| 1362 | $self->rv($rv||'null'); | ||
| 1363 | $self->ra('null'); | ||
| 1364 | $self->rs('null'); | ||
| 1365 | my $this_rv; | ||
| 1366 | if ($rv && $rv >= 1) { | ||
| 1367 | $this_rv = 0; | ||
| 1368 | } | ||
| 1369 | else { | ||
| 1370 | $this_rv = 1; | ||
| 1371 | } | ||
| 1372 | return($this_rv); | ||
| 1373 | } | ||
| 1374 | sub progress_inc { | ||
| 1375 | my $self = $_[0]; | ||
| 1376 | my $incr = $_[1] || 1; | ||
| 1377 | |||
| 1378 | return(0) unless defined $self->{'_PROGRESS'}->{'FH'}; | ||
| 1379 | |||
| 1380 | my $fh = $self->{'_PROGRESS'}->{'FH'}; | ||
| 1381 | $self->{'_PROGRESS'}->{'PERCENT'} += $incr; | ||
| 1382 | $SIG_CODE->{'PROGRESS'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_progress; | ||
| 1383 | print $fh $self->{'_PROGRESS'}->{'PERCENT'}."\n"; | ||
| 1384 | return(((defined $self->{'_PROGRESS'}->{'FH'}) ? 1 : 0)); | ||
| 1385 | } | ||
| 1386 | sub gauge_inc { | ||
| 1387 | my $self = $_[0]; | ||
| 1388 | my $incr = $_[1] || 1; | ||
| 1389 | |||
| 1390 | return(0) unless defined $self->{'_GAUGE'}->{'FH'}; | ||
| 1391 | |||
| 1392 | my $fh = $self->{'_GAUGE'}->{'FH'}; | ||
| 1393 | $self->{'_GAUGE'}->{'PERCENT'} += $incr; | ||
| 1394 | $SIG_CODE->{'GAUGE'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | ||
| 1395 | print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n"; | ||
| 1396 | return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0)); | ||
| 1397 | } | ||
| 1398 | sub progress_dec { | ||
| 1399 | my $self = $_[0]; | ||
| 1400 | my $decr = $_[1] || 1; | ||
| 1401 | |||
| 1402 | return(0) unless defined $self->{'_PROGRESS'}->{'FH'}; | ||
| 1403 | |||
| 1404 | my $fh = $self->{'_PROGRESS'}->{'FH'}; | ||
| 1405 | $self->{'_PROGRESS'}->{'PERCENT'} -= $decr; | ||
| 1406 | $SIG_CODE->{'PROGRESS'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_progress; | ||
| 1407 | print $fh $self->{'_PROGRESS'}->{'PERCENT'}."\n"; | ||
| 1408 | return(((defined $self->{'_PROGRESS'}->{'FH'}) ? 1 : 0)); | ||
| 1409 | } | ||
| 1410 | sub gauge_dec { | ||
| 1411 | my $self = $_[0]; | ||
| 1412 | my $decr = $_[1] || 1; | ||
| 1413 | |||
| 1414 | return(0) unless defined $self->{'_GAUGE'}->{'FH'}; | ||
| 1415 | |||
| 1416 | my $fh = $self->{'_GAUGE'}->{'FH'}; | ||
| 1417 | $self->{'_GAUGE'}->{'PERCENT'} -= $decr; | ||
| 1418 | $SIG_CODE->{'GAUGE'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | ||
| 1419 | print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n"; | ||
| 1420 | return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0)); | ||
| 1421 | } | ||
| 1422 | sub progress_set { | ||
| 1423 | my $self = $_[0]; | ||
| 1424 | my $perc = $_[1] || $self->{'_PROGRESS'}->{'PERCENT'} || 1; | ||
| 1425 | |||
| 1426 | return(0) unless defined $self->{'_PROGRESS'}->{'FH'}; | ||
| 1427 | |||
| 1428 | my $fh = $self->{'_PROGRESS'}->{'FH'}; | ||
| 1429 | $self->{'_PROGRESS'}->{'PERCENT'} = $perc; | ||
| 1430 | $SIG_CODE->{'PROGRESS'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_progress; | ||
| 1431 | print $fh $self->{'_PROGRESS'}->{'PERCENT'}."\n"; | ||
| 1432 | return(((defined $self->{'_PROGRESS'}->{'FH'}) ? 1 : 0)); | ||
| 1433 | } | ||
| 1434 | sub gauge_set { | ||
| 1435 | my $self = $_[0]; | ||
| 1436 | my $perc = $_[1] || $self->{'_GAUGE'}->{'PERCENT'} || 1; | ||
| 1437 | |||
| 1438 | return(0) unless defined $self->{'_GAUGE'}->{'FH'}; | ||
| 1439 | |||
| 1440 | my $fh = $self->{'_GAUGE'}->{'FH'}; | ||
| 1441 | $self->{'_GAUGE'}->{'PERCENT'} = $perc; | ||
| 1442 | $SIG_CODE->{'GAUGE'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | ||
| 1443 | print $fh $self->{'_GAUGE'}->{'PERCENT'}."\n"; | ||
| 1444 | return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0)); | ||
| 1445 | } | ||
| 1446 | sub gauge_text { | ||
| 1447 | my $self = $_[0]; | ||
| 1448 | my $mesg = $_[1] || return(0); | ||
| 1449 | |||
| 1450 | return(0) unless defined $self->{'_GAUGE'}->{'FH'}; | ||
| 1451 | |||
| 1452 | my $fh = $self->{'_GAUGE'}->{'FH'}; | ||
| 1453 | $SIG_CODE->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | ||
| 1454 | print $fh "\nXXX\n\n".$mesg."\n\nXXX\n\n".$self->{'_GAUGE'}->{'PERCENT'}."\n"; | ||
| 1455 | return(((defined $self->{'_GAUGE'}->{'FH'}) ? 1 : 0)); | ||
| 1456 | } | ||
| 1457 | sub progress_stop { | ||
| 1458 | my $self = $_[0]; | ||
| 1459 | |||
| 1460 | return(0) unless defined $self->{'_PROGRESS'}->{'FH'}; | ||
| 1461 | |||
| 1462 | my $args = $self->{'_PROGRESS'}->{'ARGS'}; | ||
| 1463 | my $fh = $self->{'_PROGRESS'}->{'FH'}; | ||
| 1464 | $SIG_CODE->{'PROGRESS'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_progress; | ||
| 1465 | $self->{'_PROGRESS'}->{'FH'}->close(); | ||
| 1466 | delete($self->{'_PROGRESS'}->{'FH'}); | ||
| 1467 | delete($self->{'_PROGRESS'}->{'PERCENT'}); | ||
| 1468 | delete($self->{'_PROGRESS'}->{'ARGS'}); | ||
| 1469 | delete($self->{'_PROGRESS'}); | ||
| 1470 | $self->rv('null'); | ||
| 1471 | $self->rs('null'); | ||
| 1472 | $self->ra('null'); | ||
| 1473 | $self->_post($args); | ||
| 1474 | return(1); | ||
| 1475 | } | ||
| 1476 | sub gauge_stop { | ||
| 1477 | my $self = $_[0]; | ||
| 1478 | |||
| 1479 | return(0) unless defined $self->{'_GAUGE'}->{'FH'}; | ||
| 1480 | |||
| 1481 | my $args = $self->{'_GAUGE'}->{'ARGS'}; | ||
| 1482 | my $fh = $self->{'_GAUGE'}->{'FH'}; | ||
| 1483 | $SIG_CODE->{'GAUGE'}->{$$} = $self; local $SIG{'PIPE'} = \&_del_gauge; | ||
| 1484 | $self->{'_GAUGE'}->{'FH'}->close(); | ||
| 1485 | delete($self->{'_GAUGE'}->{'FH'}); | ||
| 1486 | delete($self->{'_GAUGE'}->{'PERCENT'}); | ||
| 1487 | delete($self->{'_GAUGE'}->{'ARGS'}); | ||
| 1488 | delete($self->{'_GAUGE'}); | ||
| 1489 | $self->rv('null'); | ||
| 1490 | $self->rs('null'); | ||
| 1491 | $self->ra('null'); | ||
| 1492 | $self->_post($args); | ||
| 1493 | return(1); | ||
| 1494 | } | ||
| 1495 | |||
| 1496 | |||
| 1497 | 1; |