Файловый менеджер - Редактировать - /var/www/html/UI.zip
Ðазад
PK ! 5��C) C) Dialog.podnu ��6�$ =head1 NAME UI::Dialog - wrapper for various dialog applications. =head1 SYNOPSIS use UI::Dialog; my $d = new UI::Dialog ( backtitle => 'Demo', title => 'Default', height => 20, width => 65 , listheight => 5, order => [ 'zenity', 'xdialog' ] ); # Either a Zenity or Xdialog msgbox widget should popup, # with a preference for Zenity. $d->msgbox( title => 'Welcome!', text => 'Welcome one and all!' ); =head1 ABSTRACT UI::Dialog is a OOPerl wrapper for the various dialog applications. These dialog backends are currently supported: Zenity, XDialog, GDialog, KDialog, CDialog, and Whiptail. There is also an ASCII backend provided as a last resort interface for the console based dialog variants. UI::Dialog is a class that provides a strict interface to these various backend modules. By using UI:Dialog (with it's imposed limitations on the widgets) you can ensure that your Perl program will function with any available interfaces. =head1 DESCRIPTION UI::Dialog supports priority ordering of the backend detection process. So if you'd prefer that Xdialog should be used first if available, simply designate the desired order when creating the new object. The default order for detecting and utilization of the backends are as follows: (with DISPLAY env): Zenity, GDialog, XDialog, KDialog (without DISPLAY): CDialog, Whiptail, ASCII UI::Dialog is the result of a complete re-write of the UDPM CPAN module. This was done to break away from the bad choice of name (UserDialogPerlModule) and to implement a cleaner, more detached, OOPerl interface. =head1 EXPORT =over 2 None =back =head1 INHERITS =over 2 None =back =head1 CONSTRUCTOR =head2 new( @options ) =over 4 =item EXAMPLE =over 6 my $d = new( title => 'Default Title', backtitle => 'Backtitle', width => 65, height => 20, listheight => 5, order => [ 'zenity', 'xdialog', 'gdialog' ] ); =back =item DESCRIPTION =over 6 This is the Class Constructor method. It accepts a list of key => value pairs and uses them as the defaults when interacting with the various widgets. =back =item RETURNS =over 6 A blessed object reference of the UI::Dialog class. =back =item OPTIONS The (...)'s after each option indicate the default for the option. An * denotes support by all the widget methods on a per-use policy defaulting to the values decided during object creation. =over 6 =item B<debug = 0,1,2> (0) =item B<order = [ zenity, xdialog, gdialog, kdialog, cdialog, whiptail, ascii ]> (as indicated) =item B<PATH = [ /bin, /usr/bin, /usr/local/bin, /opt/bin ]> (as indicated) =item B<backtitle = "backtitle"> ('') * =item B<title = "title"> ('') * =item B<beepbefore = 0,1> (0) * =item B<beepafter = 0,1> (0) * =item B<height = \d+> (20) * =item B<width = \d+> (65) * =item B<listheight = \d+> (5) * =item B<trust-input = 0,1> (0) * =back =back =head1 STATE METHODS =head2 state( ) =over 4 =item EXAMPLE =over 6 if ($d->state() eq "OK") { $d->msgbox( text => "that went well" ); } =back =item DESCRIPTION =over 6 Returns the state of the last dialog widget command. The value can be one of "OK", "CANCEL", "ESC". The return data is based on the exit codes (return value) of the last widget displayed. =back =item RETURNS =over 6 a single SCALAR. =back =back =head2 ra( ) =over 4 =item EXAMPLE =over 6 my @array = $d->ra(); =back =item DESCRIPTION =over 6 Returns the last widget's data as an array. =back =item RETURNS =over 6 an ARRAY. =back =back =head2 rs( ) =over 4 =item EXAMPLE =over 6 my $string = $d->rs(); =back =item DESCRIPTION =over 6 Returns the last widget's data as a (possibly multiline) string. =back =item RETURNS =over 6 a SCALAR. =back =back =head2 rv( ) =over 4 =item EXAMPLE =over 6 my $string = $d->rv(); =back =item DESCRIPTION =over 6 Returns the last widget's exit status, aka: return value. =back =item RETURNS =over 6 a SCALAR. =back =back =head1 WIDGET METHODS =head2 yesno( ) =over 4 =item EXAMPLE =over 6 if ($d->yesno( text => 'A binary type question?') ) { # user pressed yes } else { # user pressed no or cancel } =back =item DESCRIPTION =over 6 Present the end user with a message box that has two buttons, yes and no. =back =item RETURNS =over 6 TRUE (1) for a response of YES or FALSE (0) for anything else. =back =back =head2 msgbox( ) =over 4 =item EXAMPLE =over 6 $d->msgbox( text => 'A simple message' ); =back =item DESCRIPTION =over 6 Pesent the end user with a message box that has an OK button. =back =item RETURNS =over 6 TRUE (1) for a response of OK or FALSE (0) for anything else. =back =back =head2 inputbox( ) =over 4 =item EXAMPLE =over 6 my $string = $d->inputbox( text => 'Please enter some text...', entry => 'this is the input field' ); =back =item DESCRIPTION =over 6 Present the end user with a text input field and a message. =back =item RETURNS =over 6 a SCALAR if the response is OK and FALSE (0) for anything else. =back =back =head2 password( ) =over 4 =item EXAMPLE =over 6 my $string = $d->password( text => 'Enter some hidden text.' ); =back =item DESCRIPTION =over 6 Present the end user with a text input field, that has hidden input, and a message. Note that the GDialog backend will provide a regular inputbox instead of a password box because gdialog doesn't support passwords. GDialog is on it's way to the proverbial software heaven so this isn't a real problem. Use Zenity instead :) =back =item RETURNS =over 6 a SCALAR if the response is OK and FALSE (0) for anything else. =back =back =head2 textbox( ) =over 4 =item EXAMPLE =over 6 $d->textbox( path => '/path/to/a/text/file' ); =back =item DESCRIPTION =over 6 Present the end user with a simple scrolling box containing the contents of the given text file. =back =item RETURNS =over 6 TRUE (1) if the response is OK and FALSE (0) for anything else. =back =back =head2 menu( ) =over 4 =item EXAMPLE =over 6 my $selection1 = $d->menu( text => 'Select one:', list => [ 'tag1', 'item1', 'tag2', 'item2', 'tag3', 'item3' ] ); =back =item DESCRIPTION =over 6 Present the user with a selectable list. =back =item RETURNS =over 6 a SCALAR of the chosen tag if the response is OK and FALSE (0) for anything else. =back =back =head2 checklist( ) =over 4 =item EXAMPLE =over 6 my @selection1 = $d->checklist( text => 'Select one:', list => [ 'tag1', [ 'item1', 0 ], 'tag2', [ 'item2', 1 ], 'tag3', [ 'item3', 1 ] ] ); =back =item DESCRIPTION =over 6 Present the user with a selectable checklist. =back =item RETURNS =over 6 an ARRAY of the chosen tags if the response is OK and FALSE (0) for anything else. =back =back =head2 radiolist( ) =over 4 =item EXAMPLE =over 6 my $selection1 = $d->radiolist( text => 'Select one:', list => [ 'tag1', [ 'item1', 0 ], 'tag2', [ 'item2', 1 ], 'tag3', [ 'item3', 0 ] ] ); =back =item DESCRIPTION =over 6 Present the user with a selectable radiolist. =back =item RETURNS =over 6 a SCALAR of the chosen tag if the response is OK and FALSE (0) for anything else. =back =back =head2 fselect( ) =over 4 =item EXAMPLE =over 6 my $text = $d->fselect( path => '/path/to/a/file/or/directory' ); =back =item DESCRIPTION =over 6 Present the user with a file selection widget preset with the given path. =back =item RETURNS =over 6 a SCALAR if the response is OK and FALSE (0) for anything else. =back =back =head2 dselect( ) =over 4 =item EXAMPLE =over 6 my $text = $d->dselect( path => '/path/to/a/file/or/directory' ); =back =item DESCRIPTION =over 6 Present the user with a file selection widget preset with the given path. Unlike fselect() this widget will only return a directory selection. =back =item RETURNS =over 6 a SCALAR if the response is OK and FALSE (0) for anything else. =back =back =head1 SEE ALSO =over 2 =item PERLDOC UI::Dialog::GNOME UI::Dialog::KDE UI::Dialog::Console UI::Dialog::Backend UI::Dialog::Backend::ASCII UI::Dialog::Backend::CDialog UI::Dialog::Backend::GDialog UI::Dialog::Backend::KDialog UI::Dialog::Backend::Nautilus UI::Dialog::Backend::Whiptail UI::Dialog::Backend::XDialog UI::Dialog::Backend::XOSD UI::Dialog::Backend::Zenity =back =over 2 =item MAN FILES dialog(1), whiptail(1), zenity(1), gdialog(1), Xdialog(1), osd_cat(1), kdialog(1) and nautilus(1) =back =head1 SECURITY While UI::Dialog tries to be secure on your behalf, this is not an easy task and it is advised that you never trust user input when dealing with any libraries (not just UI::Dialog). UI::Dialog does not allow for strings with shell command substitutions by default. This is achived by replacing all instances of back-tick B<`> characters with single-quotes B<'> and if any B<$()> constructs are found, the dollar sign is removed. To disable this behaviour, pass 'trust-input'=>1 into the module constructor or into any dialog function (such as B<menu>). See the B<examples/trust-input.pl> sample code for a demonstration. =head1 BUGS Please email the author with any bug reports. Include the name of the module in the subject line. =head1 AUTHOR Kevin C. Krinke, E<lt>kevin@krinke.caE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =cut PK ! ���;b b Dialog/GNOME.podnu ��6�$ =head1 NAME UI::Dialog::GNOME - GNOME GUI meta-class for UI::Dialog. =head1 SYNOPSIS use UI::Dialog::GNOME; my $d = new UI::Dialog::GNOME ( title => 'Default title', height => 20, width => 65 , listheight => 5, order => [ 'zenity', 'xdialog' ] ); # Either a Zenity or Xdialog msgbox widget should popup, # with a preference for Zenity. $d->msgbox( title => 'Welcome!', text => 'Welcome one and all!' ); =head1 ABSTRACT UI::Dialog::GNOME is simply another meta-class for UI::Dialog. This class simply has a different order of priority than UI::Dialog and no console support. =head1 DESCRIPTION This class is simply a nice way to try and ensure a GNOME based widget set. The editbox() widget is also provided in addition to the standard widgets as both the XDialog and Zenity backends effectively support it's usage. If you are still using GDialog and not Zenity (which provides a very nice gdialog wrapper) the editbox() widget will cause your application to die with a "missing method editbox()" error. =head1 EXPORT =over 2 None =back =head1 INHERITS =over 2 UI::Dialog =back =head1 CONSTRUCTOR =head2 new( @options ) =over 4 =item EXAMPLE =over 6 my $d = new( title => 'Default Title', backtitle => 'Backtitle', width => 65, height => 20, listheight => 5, order => [ 'zenity', 'xdialog', 'gdialog' ] ); =back =item DESCRIPTION =over 6 This is the Class Constructor method. It accepts a list of key => value pairs and uses them as the defaults when interacting with the various widgets. =back =item RETURNS =over 6 A blessed object reference of the UI::Dialog::GNOME class. =back =item OPTIONS The (...)'s after each option indicate the default for the option. =over 6 =item B<debug = 0,1,2> (0) =item B<order = [ zenity, xdialog, gdialog ]> (as indicated) =item B<PATH = [ /bin, /usr/bin, /usr/local/bin, /opt/bin ]> (as indicated) =item B<backtitle = "backtitle"> ('') =item B<title = "title"> ('') =item B<beepbefore = 0,1> (0) =item B<beepafter = 0,1> (0) =item B<height = \d+> (20) =item B<width = \d+> (65) =item B<listheight = \d+> (5) =back =back =head1 WIDGET METHODS =head2 editbox( ) =over 4 =item EXAMPLE =over 6 $d->editbox( path => '/path/to/a/text/file' ); =back =item DESCRIPTION =over 6 Present the end user with an editable textbox containing the contents of the given text file. =back =item RETURNS =over 6 A SCALAR containing the edited text if the response is OK and FALSE (0) for anything else. =back =back =head1 SEE ALSO =over 2 =item PERLDOC UI::Dialog UI::Dialog::Backend UI::Dialog::Backend::GDialog UI::Dialog::Backend::Nautilus UI::Dialog::Backend::XDialog UI::Dialog::Backend::XOSD UI::Dialog::Backend::Zenity =back =over 2 =item MAN FILES zenity(1), gdialog(1), Xdialog(1), osd_cat(1) and nautilus(1) =back =head1 BUGS Please email the author with any bug reports. Include the name of the module in the subject line. =head1 AUTHOR Kevin C. Krinke, E<lt>kevin@krinke.caE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =cut PK ! *�m�� � Dialog/Gauged.pmnu ��6�$ package UI::Dialog::Gauged; ############################################################################### # Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### use 5.006; use strict; use warnings; use Carp; BEGIN { use vars qw($VERSION); $VERSION = '1.21'; } #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #: Constructor Method #: sub new { my $proto = shift(); my $class = ref($proto) || $proto; my $cfg = {@_} || {}; my $self = {}; bless($self, $class); $self->{'debug'} = $cfg->{'debug'} || 0; #: Dynamic path discovery... my $CFG_PATH = $cfg->{'PATH'}; if ($CFG_PATH) { if (ref($CFG_PATH) eq "ARRAY") { $self->{'PATHS'} = $CFG_PATH; } elsif ($CFG_PATH =~ m!:!) { $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ]; } elsif (-d $CFG_PATH) { $self->{'PATHS'} = [ $CFG_PATH ]; } } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; } else { $self->{'PATHS'} = ''; } if (not $cfg->{'order'} and ($ENV{'DISPLAY'} && length($ENV{'DISPLAY'}) > 0)) { #: Pick a GUI mode 'cause a DISPLAY was detected if ($ENV{'TERM'} =~ /^dumb$/i) { # we're running free of a terminal $cfg->{'order'} = [ 'zenity', 'xdialog' ]; } else { # we're running in a terminal $cfg->{'order'} = [ 'zenity', 'xdialog', 'cdialog', 'whiptail' ]; } } # verify and repair the order $cfg->{'order'} = ((ref($cfg->{'order'}) eq "ARRAY") ? $cfg->{'order'} : ($cfg->{'order'}) ? [ $cfg->{'order'} ] : [ 'cdialog', 'whiptail' ]); $self->_debug("ENV->UI_DIALOGS: ".($ENV{'UI_DIALOGS'}||'NULL'),2); $cfg->{'order'} = [ split(/\:/,$ENV{'UI_DIALOGS'}) ] if $ENV{'UI_DIALOGS'}; $self->_debug("ENV->UI_DIALOG: ".($ENV{'UI_DIALOG'}||'NULL'),2); unshift(@{$cfg->{'order'}},$ENV{'UI_DIALOG'}) if $ENV{'UI_DIALOG'}; $cfg->{'trust-input'} = ( exists $cfg->{'trust-input'} && $cfg->{'trust-input'}==1 ) ? 1 : 0; my @opts = (); foreach my $opt (keys(%$cfg)) { push(@opts,$opt,$cfg->{$opt}); } $self->_debug("order: @{$cfg->{'order'}}",2); if (ref($cfg->{'order'}) eq "ARRAY") { foreach my $try (@{$cfg->{'order'}}) { if ($try =~ /^zenity$/i) { $self->_debug("trying zenity",2); if (eval "require UI::Dialog::Backend::Zenity; 1" && $self->_has_variant('zenity')) { require UI::Dialog::Backend::Zenity; $self->{'_ui_dialog'} = new UI::Dialog::Backend::Zenity (@opts); $self->_debug("using zenity",2); last; } else { next; } } elsif ($try =~ /^(?:xdialog|X)$/i) { $self->_debug("trying xdialog",2); if (eval "require UI::Dialog::Backend::XDialog; 1" && $self->_has_variant('Xdialog')) { require UI::Dialog::Backend::XDialog; $self->{'_ui_dialog'} = new UI::Dialog::Backend::XDialog (@opts,'XDIALOG_HIGH_DIALOG_COMPAT',1); $self->_debug("using xdialog",2); last; } else { next; } } elsif ($try =~ /^(?:dialog|cdialog)$/i) { $self->_debug("trying cdialog",2); if (eval "require UI::Dialog::Backend::CDialog; 1" && $self->_has_variant('dialog')) { require UI::Dialog::Backend::CDialog; $self->{'_ui_dialog'} = new UI::Dialog::Backend::CDialog (@opts); $self->_debug("using cdialog",2); last; } else { next; } } elsif ($try =~ /^whiptail$/i) { $self->_debug("trying whiptail",2); if (eval "require UI::Dialog::Backend::Whiptail; 1" && $self->_has_variant('whiptail')) { require UI::Dialog::Backend::Whiptail; $self->{'_ui_dialog'} = new UI::Dialog::Backend::Whiptail (@opts); $self->_debug("using whiptail",2); last; } else { next; } } else { # we don't know what they're asking for... try UI::Dialog... if (eval "require UI::Dialog; 1") { require UI::Dialog; $self->{'_ui_dialog'} = new UI::Dialog (@opts); $self->_debug(ref($self)." unknown backend: '".$try."', using UI::Dialog instead.",2); last; } else { next; } } } } else { carp("Failed to load any suitable dialog variant backend."); } ref($self->{'_ui_dialog'}) or croak("unable to load suitable backend."); return($self); } #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #: Private Methods #: #: purely internal usage sub _debug { my $self = $_[0]; my $mesg = $_[1] || 'null error message given!'; my $rate = $_[2] || 1; return() unless $self->{'debug'} and $self->{'debug'} >= $rate; chomp($mesg); print STDERR "Debug: ".$mesg."\n"; } sub _has_variant { my $self = $_[0]; my $variant = $_[1]; $self->{'PATHS'} = ((ref($self->{'PATHS'}) eq "ARRAY") ? $self->{'PATHS'} : ($self->{'PATHS'}) ? [ $self->{'PATHS'} ] : [ '/bin', '/usr/bin', '/usr/local/bin', '/opt/bin' ]); foreach my $PATH (@{$self->{'PATHS'}}) { return($PATH . '/' . $variant) unless not -x $PATH . '/' . $variant; } return(0); } #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #: Public Methods #: #: dialog variant state methods: sub state { return(shift()->{'_ui_dialog'}->state(@_)); } sub ra { return(shift()->{'_ui_dialog'}->ra(@_)); } sub rs { return(shift()->{'_ui_dialog'}->rs(@_)); } sub rv { return(shift()->{'_ui_dialog'}->rv(@_)); } #: Frills #: all backends support nautilus scripts. sub nautilus { return(shift()->{'_ui_dialog'}->nautilus(@_)); } #: same with osd_cat (aka: xosd). sub xosd { return(shift()->{'_ui_dialog'}->xosd(@_)); } #: Beep & Clear may have no affect when using GUI backends sub beep { return(shift()->{'_ui_dialog'}->beep(@_)); } sub clear { return(shift()->{'_ui_dialog'}->clear(@_)); } #: widget methods: sub yesno { return(shift()->{'_ui_dialog'}->yesno(@_)); } sub msgbox { return(shift()->{'_ui_dialog'}->msgbox(@_)); } sub inputbox { return(shift()->{'_ui_dialog'}->inputbox(@_)); } sub password { return(shift()->{'_ui_dialog'}->password(@_)); } sub textbox { return(shift()->{'_ui_dialog'}->textbox(@_)); } sub menu { return(shift()->{'_ui_dialog'}->menu(@_)); } sub checklist { return(shift()->{'_ui_dialog'}->checklist(@_)); } sub radiolist { return(shift()->{'_ui_dialog'}->radiolist(@_)); } sub fselect { return(shift()->{'_ui_dialog'}->fselect(@_)); } sub dselect { return(shift()->{'_ui_dialog'}->dselect(@_)); } # gauge methods sub gauge_start { return(shift()->{'_ui_dialog'}->gauge_start(@_)); } sub gauge_stop { return(shift()->{'_ui_dialog'}->gauge_stop(@_)); } sub gauge_inc { return(shift()->{'_ui_dialog'}->gauge_inc(@_)); } sub gauge_dec { return(shift()->{'_ui_dialog'}->gauge_dec(@_)); } sub gauge_set { return(shift()->{'_ui_dialog'}->gauge_set(@_)); } sub gauge_text { return(shift()->{'_ui_dialog'}->gauge_text(@_)); } 1; PK ! u��!� � Dialog/Console.podnu ��6�$ =head1 NAME UI::Dialog::Console - console meta-class for UI::Dialog. =head1 SYNOPSIS use UI::Dialog::Console; my $d = new UI::Dialog::Console ( title => 'Default', height => 20, width => 65, listheight => 5 ); # Either a CDialog, Whiptail or ASCII msgbox widget should be displayed # with a preference for CDialog. $d->msgbox( title => 'Welcome!', text => 'Welcome one and all!' ); =head1 ABSTRACT UI::Dialog::Console is simply another meta-class for UI::Dialog. This class simply has a different order of priority than UI::Dialog and no GUI support. =head1 DESCRIPTION This class is simply a nice way to try and ensure a Console based widget set. =head1 EXPORT =over 2 None =back =head1 INHERITS =over 2 UI::Dialog =back =head1 CONSTRUCTOR =head2 new( @options ) =over 4 =item EXAMPLE =over 6 my $d = new( title => 'Default Title', backtitle => 'Backtitle', width => 65, height => 20, listheight => 5, order => [ 'cdialog', 'whiptail', 'ascii' ] ); =back =item DESCRIPTION =over 6 This is the Class Constructor method. It accepts a list of key => value pairs and uses them as the defaults when interacting with the various widgets. =back =item RETURNS =over 6 A blessed object reference of the UI::Dialog::Console class. =back =item OPTIONS The (...)'s after each option indicate the default for the option. =over 6 =item B<debug = 0,1,2> (0) =item B<order = [ kdialog, xdialog ]> (as indicated) =item B<PATH = [ /bin, /usr/bin, /usr/local/bin, /opt/bin ]> (as indicated) =item B<backtitle = "backtitle"> ('') =item B<title = "title"> ('') =item B<beepbefore = 0,1> (0) =item B<beepafter = 0,1> (0) =item B<height = \d+> (20) =item B<width = \d+> (65) =item B<listheight = \d+> (5) =back =back =head1 SEE ALSO =over 2 =item PERLDOC UI::Dialog UI::Dialog::Backend UI::Dialog::Backend::ASCII UI::Dialog::Backend::CDialog UI::Dialog::Backend::Whiptail =back =over 2 =item MAN FILES dialog(1), whiptail(1) =back =head1 BUGS Please email the author with any bug reports. Include the name of the module in the subject line. =head1 AUTHOR Kevin C. Krinke, E<lt>kevin@krinke.caE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =cut PK ! �w�� � Dialog/Gauged.podnu ��6�$ =head1 NAME UI::Dialog::Gauged - wrapper support of gauge related functions. =head1 SYNOPSIS use UI::Dialog::Gauged; my $d = new UI::Dialog::Gauged ( title => 'Default title', height => 20, width => 65 , listheight => 5, order => [ 'zenity', 'xdialog' ] ); # Either a Zenity or Xdialog msgbox widget should popup, # with a preference for Zenity. $d->msgbox( title => 'Welcome!', text => 'Welcome one and all!' ); =head1 ABSTRACT UI::Dialog::Gauged is simply another meta-class for UI::Dialog. This class simply has a different order of priority than UI::Dialog and only uses backends that support a standard set of gauge related functions. =head1 DESCRIPTION This class is simply a nice way to try and ensure a GNOME based widget set. =head1 EXPORT =over 2 None =back =head1 INHERITS =over 2 UI::Dialog =back =head1 CONSTRUCTOR =head2 new( @options ) =over 4 =item EXAMPLE =over 6 my $d = new( title => 'Default Title', backtitle => 'Backtitle', width => 65, height => 20, listheight => 5, order => [ 'zenity', 'xdialog' ] ); =back =item DESCRIPTION =over 6 This is the Class Constructor method. It accepts a list of key => value pairs and uses them as the defaults when interacting with the various widgets. =back =item RETURNS =over 6 A blessed object reference of the UI::Dialog::Gauged class. =back =item OPTIONS The (...)'s after each option indicate the default for the option. =over 6 =item B<debug = 0,1,2> (0) =item B<order = [ zenity, xdialog, cdialog, whiptail ]> (as indicated) =item B<PATH = [ /bin, /usr/bin, /usr/local/bin, /opt/bin ]> (as indicated) =item B<backtitle = "backtitle"> ('') =item B<title = "title"> ('') =item B<beepbefore = 0,1> (0) =item B<beepafter = 0,1> (0) =item B<height = \d+> (20) =item B<width = \d+> (65) =item B<listheight = \d+> (5) =back =back =head1 WIDGET METHODS =head2 gauge_start( ) =over 4 =item EXAMPLE =over 6 $d->gauge_start( text => 'gauge...', percentage => 1 ); =back =item DESCRIPTION =over 6 Display a meter bar to the user. This get's the widget realized but requires the use of the other gauge_*() methods for functionality. =back =item RETURNS =over 6 TRUE (1) if the widget loaded fine and FALSE (0) for anything else. =back =back =head2 gauge_inc( ) =over 4 =item EXAMPLE =over 6 $d->gauge_inc( 1 ); =back =item DESCRIPTION =over 6 Increment the meter by the given amount. =back =item RETURNS =over 6 TRUE (1) if the widget incremented fine and FALSE (0) for anything else. =back =back =head2 gauge_set( ) =over 4 =item EXAMPLE =over 6 $d->gauge_set( 99 ); =back =item DESCRIPTION =over 6 Set the meter bar to the given amount. =back =item RETURNS =over 6 TRUE (1) if the widget set fine and FALSE (0) for anything else. =back =back =head2 gauge_text( ) =over 4 =item EXAMPLE =over 6 $d->gauge_text( 'string' ); =back =item DESCRIPTION =over 6 Set the meter bar message to the given string. =back =item RETURNS =over 6 TRUE (1) if the widget set fine and FALSE (0) for anything else. =back =back =head2 gauge_stop( ) =over 4 =item EXAMPLE =over 6 $d->gauge_stop(); =back =item DESCRIPTION =over 6 End the meter bar widget process. One of the flaws with gdialog is that the gauge widget does not close properly and requies the end user to close the gauge window when 100% has been reached. This is the second reason why I'm glad gdialog is going the way of the dodo. =back =item RETURNS =over 6 TRUE (1) if the widget closed fine and FALSE (0) for anything else. =back =back =head1 SEE ALSO =over 2 =item PERLDOC UI::Dialog UI::Dialog::Backend UI::Dialog::Backend::CDialog UI::Dialog::Backend::Nautilus UI::Dialog::Backend::Whiptail UI::Dialog::Backend::XDialog UI::Dialog::Backend::XOSD UI::Dialog::Backend::Zenity =back =over 2 =item MAN FILES zenity(1), Xdialog(1), dialog(1), whiptail(1), osd_cat(1) and nautilus(1) =back =head1 BUGS Please email the author with any bug reports. Include the name of the module in the subject line. =head1 AUTHOR Kevin C. Krinke, E<lt>kevin@krinke.caE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =cut PK ! ����� � Dialog/Console.pmnu ��6�$ package UI::Dialog::Console; ############################################################################### # Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### use 5.006; use strict; use warnings; use Carp; use UI::Dialog; BEGIN { use vars qw( $VERSION @ISA ); @ISA = qw( UI::Dialog ); $VERSION = '1.21'; } #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #: Constructor Method #: sub new { my $proto = shift(); my $class = ref($proto) || $proto; my $cfg = {@_} || {}; my $self = {}; bless($self, $class); $self->{'debug'} = $cfg->{'debug'} || 0; #: Dynamic path discovery... my $CFG_PATH = $cfg->{'PATH'}; if ($CFG_PATH) { if (ref($CFG_PATH) eq "ARRAY") { $self->{'PATHS'} = $CFG_PATH; } elsif ($CFG_PATH =~ m!:!) { $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ]; } elsif (-d $CFG_PATH) { $self->{'PATHS'} = [ $CFG_PATH ]; } } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; } else { $self->{'PATHS'} = ''; } $cfg->{'order'} ||= [ 'dialog', 'whiptail', 'ascii' ]; $self->_debug("ENV->UI_DIALOGS: ".($ENV{'UI_DIALOGS'}||'NULL'),2); $cfg->{'order'} = [ split(/\:/,$ENV{'UI_DIALOGS'}) ] if $ENV{'UI_DIALOGS'}; $self->_debug("ENV->UI_DIALOG: ".($ENV{'UI_DIALOG'}||'NULL'),2); unshift(@{$cfg->{'order'}},$ENV{'UI_DIALOG'}) if $ENV{'UI_DIALOG'}; $cfg->{'trust-input'} = ( exists $cfg->{'trust-input'} && $cfg->{'trust-input'}==1 ) ? 1 : 0; my @opts = (); foreach my $opt (keys(%$cfg)) { push(@opts,$opt,$cfg->{$opt}); } foreach my $try (@{$cfg->{'order'}}) { if ($try =~ /^(?:cdialog||dialog)$/i) { $self->_debug("trying cdialog",2); if (eval "require UI::Dialog::Backend::CDialog; 1" && $self->_has_variant('dialog')) { require UI::Dialog::Backend::CDialog; $self->{'_ui_dialog'} = new UI::Dialog::Backend::CDialog (@opts); $self->_debug("using cdialog",2); last; } else { next; } } elsif ($try =~ /^(?:gdialog||gdialog\.real)$/i) { $self->_debug("trying gdialog",2); if (eval "require UI::Dialog::Backend::GDialog; 1" && ($self->_has_variant('gdialog.real') || $self->_has_variant('gdialog'))) { require UI::Dialog::Backend::GDialog; $self->{'_ui_dialog'} = new UI::Dialog::Backend::GDialog (@opts); $self->_debug("using gdialog",2); last; } else { next; } } elsif ($try =~ /^whiptail$/i) { $self->_debug("trying whiptail",2); if (eval "require UI::Dialog::Backend::Whiptail; 1" && $self->_has_variant('Whiptail')) { require UI::Dialog::Backend::Whiptail; $self->{'_ui_dialog'} = new UI::Dialog::Backend::Whiptail (@opts); $self->_debug("using whiptail",2); last; } else { next; } } elsif ($try =~ /^(?:ascii||native)$/i) { $self->_debug("trying ascii",2); if (eval "require UI::Dialog::Backend::ASCII; 1") { require UI::Dialog::Backend::ASCII; $self->{'_ui_dialog'} = new UI::Dialog::Backend::ASCII (@opts); $self->_debug("using ascii",2); last; } else { next; } } else { # we don't know what they're asking for... try UI::Dialog... if (eval "require UI::Dialog; 1") { require UI::Dialog; $self->{'_ui_dialog'} = new UI::Dialog (@opts); $self->_debug(ref($self)." unknown backend: '".$try."', using UI::Dialog instead.",2); last; } else { next; } } } ref($self->{'_ui_dialog'}) or croak("unable to load suitable backend."); return($self); } 1; PK ! � ܙ~D ~D Dialog/Backend.podnu ��6�$ =head1 NAME UI::Dialog::Backend - simply a collection of primarily internal methods. =head1 SYNOPSIS use UI::Dialog::Backend; BEGIN { use vars qw( @ISA ); @ISA = qw( UI::Dialog::Backend ); } =head1 ABSTRACT UI::Dialog::Backend is simply a collection of primarily internal methods. =head1 DESCRIPTION While this module is inherited by all UI::Dialog backend modules, this module itself is not meant for direct usage. The "STATE METHODS" and "UTILITY METHODS" documentation is applicable to all backends thus rendering the POD for this class more important to the end-programmer than the usage of the class itself. =head1 EXPORT =over 2 None =back =head1 INHERITS =over 2 None =back =head1 BACKEND EXTENSIONS =head2 nautilus =over 4 =item EXAMPLE =over 6 my @paths = $d->nautilus->paths(); =back =item DESCRIPTION =over 6 This method gives access to the UI::Dialog::Backend::Nautilus class. This will automagically try to load the UI::Dialog::Backend::Nautilus module or it will silently fail. =back =back =head2 xosd =over 4 =item EXAMPLE =over 6 $d->xosd->line( "a line of text on your screen" ); =back =item DESCRIPTION =over 6 This method gives access to the UI::Dialog::Backend::XOSD class. This will automagically try to load the UI::Dialog::Backend::XOSD module or it will silently fail. =back =back =head2 notify_send =over 4 =item EXAMPLE =over 6 $d->notify_send->notify_send( "a line of text on your screen" ); =back =item DESCRIPTION =over 6 This method gives access to the UI::Dialog::Backend::NotifySend class. This will automagically try to load the UI::Dialog::Backend::NotifySend module or it will silently fail. =back =back =head1 STATE METHODS =head2 attr( ) =over 4 =item EXAMPLE =over 6 my $value = $self->attr('listheight'); my $new_value = $d->attr('listheight',5); =back =item DESCRIPTION =over 6 Either sets and returns the value of the desired attribute, or just returns the value of the desired attribute. =back =item RETURNS =over 6 a single SCALAR. =back =back =head2 state( ) =over 4 =item EXAMPLE =over 6 if ($d->state() eq "OK") { # the last user response was "OK" } else { # something other than an "OK" response } =back =item DESCRIPTION =over 6 Returns the state of the last dialog widget command. The value can be one of "OK", "CANCEL" or "ESC". The return data is based on the exit codes (return value) of the last widget displayed. Some backends also support other exit values than the standard few and these are represented as "EXTRA" (3), "HELP" (2), and "ERROR" (255). =back =item RETURNS =over 6 a single SCALAR. =back =back =head2 ra( ) =over 4 =item EXAMPLE =over 6 my @array = $d->ra(); =back =item DESCRIPTION =over 6 Returns the last widget's data as an array. =back =item RETURNS =over 6 an ARRAY. =back =back =head2 rs( ) =over 4 =item EXAMPLE =over 6 my $string = $d->rs(); =back =item DESCRIPTION =over 6 Returns the last widget's data as a (possibly multiline) string. =back =item RETURNS =over 6 a SCALAR. =back =back =head2 rv( ) =over 4 =item EXAMPLE =over 6 my $string = $d->rv(); =back =item DESCRIPTION =over 6 Returns the last widget's exit status, aka: return value. This is the value used when determining the state() of a widget. =back =item RETURNS =over 6 a SCALAR. =back =back =head1 CALLBACK FUNCTIONS =head2 PRE =over 4 =item EXAMPLE =over 6 sub CB_PRE { my $widget_args = shift(); print "Caller: ".$args->{'caller'}."\n"; } my $d = new UI::Dialog ( callbacks => { PRE => \&CB_PRE } ); =back =item DESCRIPTION =over 6 This function recieves a hasref of the current argument values and is called before any widget performs any operations. =back =back =head2 POST =over 4 =item EXAMPLE =over 6 sub CB_POST { my $widget_args = shift(); my $state = shift(); print "Caller: ".$args->{'caller'}.", State: ".$state."\n"; } my $d = new UI::Dialog ( callbacks => { POST => \&CB_POST } ); =back =item DESCRIPTION =over 6 This function recieves a hasref of the current argument values and the one word state indicator (as reported by state()) and is called after all widget operations have been performed (including other callback functions). =back =back =head2 OK =over 4 =item EXAMPLE =over 6 sub CB_OK_FUNC { my $widget_args = shift(); print "Widget caller: ".$args->{'caller'}."\n"; } my $d = new UI::Dialog ( callbacks => { OK => \&CB_OK_FUNC } ); =back =item DESCRIPTION =over 6 This function recieves a hasref of the current argument values and is called when any widget finishes with a state() of "OK" but before the POST callback. =back =back =head2 CANCEL =over 4 =item EXAMPLE =over 6 sub CB_CANCEL { my $widget_args = shift(); print "Caller: ".$args->{'caller'}."\n"; } my $d = new UI::Dialog ( callbacks => { CANCEL => \&CB_CANCEL } ); =back =item DESCRIPTION =over 6 This function recieves a hasref of the current argument values and is called when any widget finishes with a state() of "CANCEL" but before the POST callback. Be forewarned that with respect to the yesno() type widgets, a user response of "NO" is interpreted as "CANCEL" and will execute this function. =back =back =head2 ESC =over 4 =item EXAMPLE =over 6 sub CB_ESC { my $widget_args = shift(); print "Caller: ".$args->{'caller'}."\n"; } my $d = new UI::Dialog ( callbacks => { ESC => \&CB_ESC } ); =back =item DESCRIPTION =over 6 This function recieves a hasref of the current argument values and is called when any widget finishes with a state() of "ESC" but before the POST callback. =back =back =head2 HELP =over 4 =item EXAMPLE =over 6 sub CB_HELP { my $widget_args = shift(); print "Caller: ".$args->{'caller'}."\n"; } my $d = new UI::Dialog ( callbacks => { HELP => \&CB_HELP } ); =back =item DESCRIPTION =over 6 This function recieves a hasref of the current argument values and is called when any widget finishes with a state() of "HELP" but before the POST callback. The user response of "HELP" is not supported by all backends. =back =back =head2 EXTRA =over 4 =item EXAMPLE =over 6 sub CB_EXTRA { my $widget_args = shift(); print "Caller: ".$args->{'caller'}."\n"; } my $d = new UI::Dialog ( callbacks => { EXTRA => \&CB_EXTRA } ); =back =item DESCRIPTION =over 6 This function recieves a hasref of the current argument values and is called when any widget finishes with a state() of "EXTRA" but before the POST callback. The user response of "EXTRA" is not supported by all backends. =back =back =head1 UTILITY METHODS =head2 beep( ) =over 4 =item EXAMPLE =over 6 $d->beep(); =back =item DESCRIPTION =over 6 If the beep(1) application can be found, use it to make a beep sound. Otherwise print "\a" to STDERR which normally is good enough to make some noise. =back =item RETURNS =over 6 TRUE (1) regardless of result. =back =back =head2 clear( ) =over 4 =item EXAMPLE =over 6 $d->clear(); =back =item DESCRIPTION =over 6 Clear the terminal screen via STDOUT and the `clear` command. This method is technically useless for any GUI based dialog variants. =back =item RETURNS =over 6 TRUE (1) regardless of result. =back =back =head2 word_wrap( ) =over 4 =item EXAMPLE =over 6 my @wrapped_text = $d->word_wrap($cols,$indent,$sub_indent,@text); =back =item DESCRIPTION =over 6 Using the Text::Wrap::wrap function, wrap the words in a string (or array of strings). This is primarily used within the _organize_text() method but may be of use to the end-programmer. =back =item RETURNS =over 6 A word-wrapped version of the given text data. =back =back =head2 gen_tempfile_name( ) =over 4 =item EXAMPLE =over 6 my $tempfile = $d->gen_tempfile_name(); =back =item DESCRIPTION =over 6 This method returns a temporary file name generated using one of the following (in order): the File::Temp perl module if detected, the program "mktemp" or an extremely simplistic built-in name generator. =back =item RETURNS =over 6 A temporary file name. =back =back =head2 gen_random_string( ) =over 4 =item EXAMPLE =over 6 my $random_string = $d->gen_random_string(5); =back =item DESCRIPTION =over 6 This will return a string of random (printable) characters of an arbitrary user-definable length (defaults to 5); =back =item RETURNS =over 6 A string of random ASCII characters. =back =back =head1 WIDGET WRAPPER METHODS These methods are common methods to most backends as they do not have native support for the functionality, yet the functionality is achievable by utilizing existing compatible methods. =head2 fselect( ) =over 4 =item EXAMPLE =over 6 my $path = $self->fselect( path => $start_path ); =back =item DESCRIPTION =over 6 Using the menu() and msgbox() widgets we can simulate a file browser interface. Note: to select a directory, go into it and then pick the '.' entry. =back =item RETURNS =over 6 a SCALAR for positive results and FALSE (0) for everything else. =back =back =head2 dselect( ) =over 4 =item EXAMPLE =over 6 my $path = $self->dselect( path => $start_path ); =back =item DESCRIPTION =over 6 Using the fselect() widget we can simulate a directory browser interface. Note: to select a directory, go into it and then pick the '.' entry. =back =item RETURNS =over 6 a SCALAR for positive results and FALSE (0) for everything else. =back =back =head1 BACKEND METHODS These methods are only necessary for someone wishing to create more UI::Dialog::Backend:: Modules. These are never needed to be directly used but are none the less documented here for reference purposes. =head2 command_state( ) =over 4 =item EXAMPLE =over 6 if ($self->command_state("/some/shell/command")) { #: command succeeded } else { #: command failed } =back =item DESCRIPTION =over 6 This will execute the given command and send STDOUT and STDERR to /dev/null then analyse the exit code and return accordingly. =back =item RETURNS =over 6 TRUE (1) for positive results and FALSE (0) for anything else. =back =back =head2 command_string( ) =over 4 =item EXAMPLE =over 6 my ($rv,$scalar) = $self->command_string("/some/shell/command"); if ($rv >= 1) { #: command failed } else { #: command succeeded print "The command results: ".$scalar."\n"; } =back =item DESCRIPTION =over 6 This will execute the given command, catch STDOUT and STDERR, then return the SCALAR data. =back =item RETURNS =over 6 a SCALAR for positive results and FALSE (0) for anything else. =back =back =head2 command_array( ) =over 4 =item EXAMPLE =over 6 my ($rv,@array) = $self->command_array("/some/shell/command"); if ($rv >= 1) { #: command failed } else { #: command succeeded foreach my $line_of_output (@array) { print "The command results: ".$line_of_output."\n"; } } =back =item DESCRIPTION =over 6 This will execute the given command, catch STDOUT and STDERR, then return the data, split by newlines, as an ARRAY. =back =item RETURNS =over 6 an ARRAY for positive results and FALSE (0) for anything else. =back =back =head2 _pre( ) =over 4 =item EXAMPLE =over 6 my $args = $self->_pre(@_); =back =item DESCRIPTION =over 6 This will use _merge_attrs(), perform any pre-widget-exec things and then return the current argument list as a hashref. This is used in every widget before anything is actually done in the widget and is responsible for running the optional callback function labelled "PRE". =back =item RETURNS =over 6 a HASHREF. =back =back =head2 _post( ) =over 4 =item EXAMPLE =over 6 $self->_post( $args ); =back =item DESCRIPTION =over 6 This method is used in every widget after all operations (for the immediate widget call) are complete but before the widget actually returns anything. This method is responsible for running the optional callback funcions labelled "OK", "ESC", "CANCEL" and "POST" with "POST" being executed absolutely last. =back =item RETURNS =over 6 Nothing. =back =back =head2 _merge_attrs( ) =over 4 =item EXAMPLE =over 6 my $args = $self->_merge_attrs(@_); =back =item DESCRIPTION =over 6 This will apply the arguments passed in with the defaults stored in $self->{'_opts'} (which was instantiated upon object construction). The return result is the "current" options as defined by the defaults with the argument options overriding them. =back =item RETURNS =over 6 a HASHREF. =back =back =head2 _find_bin( ) =over 4 =item EXAMPLE =over 6 my $ZenityBinaryPath = $self->_find_bin('zenity'); =back =item DESCRIPTION =over 6 This will look in the default path directories for the program of the given name. The default PATH list is: /bin, /usr/bin, /usr/local/bin, /opt/bin. =back =item RETURNS =over 6 a SCALAR. =back =back =head2 _esc_text( ) =over 4 =item EXAMPLE =over 6 my $escaped_text = $self->_esc_text( $raw_text ); =back =item DESCRIPTION =over 6 This will escape the following with a prefixing '\' character: Character -> Escaped " \" ` \` ( \( ) \) [ \[ ] \] { \} } \} $ \$ < \< > \> =back =item RETURNS =over 6 an SCALAR for positive results and FALSE (0) for anything else. =back =back =head2 _strip_text( ) =over 4 =item EXAMPLE =over 6 my $clean_text = $self->_strip_text( $text_with_markup ); =back =item DESCRIPTION =over 6 This will strip various markup sequences from within the given argument data. =back =item RETURNS =over 6 an SCALAR for positive results and FALSE (0) for anything else. =back =back =head2 _organize_text( ) =over 4 =item EXAMPLE =over 6 my $final_text1 = $self->_organize_text( $text_with_markup ); my $final_text2 = $self->_organize_text( \@text_with_markup ); =back =item DESCRIPTION =over 6 This will strip various markup sequences from within the given argument data. =back =item RETURNS =over 6 a SCALAR for positive results and FALSE (0) for anything else. =back =back =head2 _is_bsd( ) =over 4 =item EXAMPLE =over 6 if ($self->_is_bsd()) { # do something with BSD specific characteristics } else { # do something with general perl characteristics } =back =item DESCRIPTION =over 6 This simply checks (case-insensitively) the perlvar $^0 for the string "bsd". =back =item RETURNS =over 6 TRUE (1) for positive results and FALSE (0) for anything else. =back =back =head2 _list_dir( ) =over 4 =item EXAMPLE =over 6 my $menu_list = $self->_list_dir( '/some/path/to/a/directory', [ 'optional', 'prefix', 'items' ] ); =back =item DESCRIPTION =over 6 Gather a list of the contents of a directory and forumlate a list suitable for use with most (if not all) file/path selection dialog variant widgets. An optional array reference will have all elements prefixing the directory list. =back =item RETURNS =over 6 an ARRAYREF for positive results and FALSE (0) for anything else. =back =back =head2 _debug( ) =over 4 =item EXAMPLE =over 6 $self->_debug( $debuging_message_string, $debuging_level ); =back =item DESCRIPTION =over 6 This method will print to STDERR the debugging message provided if and only if the debuging level is greater than or equal to the $debuging_level. The debugging level argument is optional and defaults to a level of 1. =back =item RETURNS =over 6 TRUE (1) for positive results and FALSE (0) for anything else. =back =back =head2 _error( ) =over 4 =item EXAMPLE =over 6 $self->_error( $error_message_string ); =back =item DESCRIPTION =over 6 This method will print to STDERR the error message provided regardless of debugging level. =back =item RETURNS =over 6 TRUE (1) for positive results and FALSE (0) for anything else. =back =back =head1 SEE ALSO =over 2 =item PERLDOC UI::Dialog UI::Dialog::Console UI::Dialog::GNOME UI::Dialog::KDE UI::Dialog::Backend::ASCII UI::Dialog::Backend::CDialog UI::Dialog::Backend::GDialog UI::Dialog::Backend::KDialog UI::Dialog::Backend::Nautilus UI::Dialog::Backend::Whiptail UI::Dialog::Backend::XDialog UI::Dialog::Backend::XOSD UI::Dialog::Backend::Zenity =back =over 2 =item MAN FILES dialog(1), whiptail(1), zenity(1), gdialog(1), Xdialog(1), kdialog(1), nautilus(1) and osd_cat(1). =back =head1 BUGS Please email the author with any bug reports. Include the name of the module in the subject line. =head1 AUTHOR Kevin C. Krinke, E<lt>kevin@krinke.caE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =cut PK ! Y��� � Dialog/GNOME.pmnu ��6�$ package UI::Dialog::GNOME; ############################################################################### # Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library 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 # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ############################################################################### use 5.006; use strict; use warnings; use Carp; use UI::Dialog; BEGIN { use vars qw( $VERSION @ISA ); @ISA = qw( UI::Dialog ); $VERSION = '1.21'; } #:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: #: Constructor Method #: sub new { my $proto = shift(); my $class = ref($proto) || $proto; my $cfg = {@_} || {}; my $self = {}; bless($self, $class); $self->{'debug'} = $cfg->{'debug'} || 0; #: Dynamic path discovery... my $CFG_PATH = $cfg->{'PATH'}; if ($CFG_PATH) { if (ref($CFG_PATH) eq "ARRAY") { $self->{'PATHS'} = $CFG_PATH; } elsif ($CFG_PATH =~ m!:!) { $self->{'PATHS'} = [ split(/:/,$CFG_PATH) ]; } elsif (-d $CFG_PATH) { $self->{'PATHS'} = [ $CFG_PATH ]; } } elsif ($ENV{'PATH'}) { $self->{'PATHS'} = [ split(/:/,$ENV{'PATH'}) ]; } else { $self->{'PATHS'} = ''; } $cfg->{'order'} ||= [ 'zenity', 'xdialog', 'gdialog' ]; $self->_debug("ENV->UI_DIALOGS: ".($ENV{'UI_DIALOGS'}||'NULL'),2); $cfg->{'order'} = [ split(/\:/,$ENV{'UI_DIALOGS'}) ] if $ENV{'UI_DIALOGS'}; $self->_debug("ENV->UI_DIALOG: ".($ENV{'UI_DIALOG'}||'NULL'),2); unshift(@{$cfg->{'order'}},$ENV{'UI_DIALOG'}) if $ENV{'UI_DIALOG'}; $cfg->{'trust-input'} = ( exists $cfg->{'trust-input'} && $cfg->{'trust-input'}==1 ) ? 1 : 0; my @opts = (); foreach my $opt (keys(%$cfg)) { push(@opts,$opt,$cfg->{$opt}); } foreach my $try (@{$cfg->{'order'}}) { if ($try =~ /^zenity$/i) { $self->_debug("trying zenity",2); if (eval "require UI::Dialog::Backend::Zenity; 1" && $self->_has_variant('zenity')) { require UI::Dialog::Backend::Zenity; $self->{'_ui_dialog'} = new UI::Dialog::Backend::Zenity (@opts); $self->_debug("using zenity",2); last; } else { next; } } elsif ($try =~ /^(?:gdialog|gdialog\.real)$/i) { $self->_debug("trying gdialog",2); if (eval "require UI::Dialog::Backend::GDialog; 1" && ($self->_has_variant('gdialog.real') || $self->_has_variant('gdialog'))) { require UI::Dialog::Backend::GDialog; $self->{'_ui_dialog'} = new UI::Dialog::Backend::GDialog (@opts); $self->_debug("using gdialog",2); last; } else { next; } } elsif ($try =~ /^(?:xdialog|X)$/i) { $self->_debug("trying xdialog",2); if (eval "require UI::Dialog::Backend::XDialog; 1" && $self->_has_variant('Xdialog')) { require UI::Dialog::Backend::XDialog; $self->{'_ui_dialog'} = new UI::Dialog::Backend::XDialog (@opts,'XDIALOG_HIGH_DIALOG_COMPAT',1); $self->_debug("using xdialog",2); last; } else { next; } } else { # we don't know what they're asking for... try UI::Dialog... if (eval "require UI::Dialog; 1") { require UI::Dialog; $self->{'_ui_dialog'} = new UI::Dialog (@opts); $self->_debug(ref($self)." unknown backend: '".$try."', using UI::Dialog instead.",2); last; } else { next; } } } ref($self->{'_ui_dialog'}) or croak("unable to load suitable backend."); return($self); } sub editbox { return(shift()->{'_ui_dialog'}->editbox(@_)); } 1; PK ! ��$7 7 Dialog/KDE.podnu ��6�$ =head1 NAME UI::Dialog::KDE - KDE GUI meta-class for UI::Dialog. =head1 SYNOPSIS use UI::Dialog::KDE; my $d = new UI::Dialog::KDE ( backtitle => 'Demo', title => 'Default', height => 20, width => 65 , listheight => 5 ); # Either a KDialog or Xdialog msgbox widget should popup, # with a preference for KDialog. $d->msgbox( title => 'Welcome!', text => 'Welcome one and all!' ); =head1 ABSTRACT UI::Dialog::KDE is simply another meta-class for UI::Dialog. This class simply has a different order of priority than UI::Dialog and no console support. =head1 DESCRIPTION This class is simply a nice way to try and ensure a KDE based widget set. KDialog is the only kde dialog variant and as such, XDialog is the only alternative. =head1 EXPORT =over 2 None =back =head1 INHERITS =over 2 UI::Dialog =back =head1 CONSTRUCTOR =head2 new( @options ) =over 4 =item EXAMPLE =over 6 my $d = new( title => 'Default Title', backtitle => 'Backtitle', width => 65, height => 20, listheight => 5, order => [ 'kdialog', 'xdialog' ] ); =back =item DESCRIPTION =over 6 This is the Class Constructor method. It accepts a list of key => value pairs and uses them as the defaults when interacting with the various widgets. =back =item RETURNS =over 6 A blessed object reference of the UI::Dialog::KDE class. =back =item OPTIONS The (...)'s after each option indicate the default for the option. =over 6 =item B<debug = 0,1,2> (0) =item B<order = [ kdialog, xdialog ]> (as indicated) =item B<PATH = [ /bin, /usr/bin, /usr/local/bin, /opt/bin ]> (as indicated) =item B<backtitle = "backtitle"> ('') =item B<title = "title"> ('') =item B<beepbefore = 0,1> (0) =item B<beepafter = 0,1> (0) =item B<height = \d+> (20) =item B<width = \d+> (65) =item B<listheight = \d+> (5) =back =back =head1 SEE ALSO =over 2 =item PERLDOC UI::Dialog UI::Dialog::Backend UI::Dialog::Backend::KDialog UI::Dialog::Backend::XDialog UI::Dialog::Backend::XOSD =back =over 2 =item MAN FILES kdialog(1), osd_cat(1) and Xdialog(1) =back =head1 BUGS Please email the author with any bug reports. Include the name of the module in the subject line. =head1 AUTHOR Kevin C. Krinke, E<lt>kevin@krinke.caE<gt> =head1 COPYRIGHT AND LICENSE Copyright (C) 2004-2016 Kevin C. Krinke <kevin@krinke.ca> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA =cut PK ! �9"T'