PEAR_Frontend_Gtk
[ class tree: PEAR_Frontend_Gtk ] [ index: PEAR_Frontend_Gtk ] [ all elements ]

Source for file Install.php

Documentation is available at Install.php

  1. <?php
  2.  
  3. /*
  4.   +----------------------------------------------------------------------+
  5.   | PHP Version 4                                                        |
  6.   +----------------------------------------------------------------------+
  7.   | Copyright (c) 1997-2003 The PHP Group                                |
  8.   +----------------------------------------------------------------------+
  9.   | This source file is subject to version 2.02 of the PHP license,      |
  10.   | that is bundled with this package in the file LICENSE, and is        |
  11.   | available at through the world-wide-web at                           |
  12.   | http://www.php.net/license/2_02.txt.                                 |
  13.   | If you did not receive a copy of the PHP license and are unable to   |
  14.   | obtain it through the world-wide-web, please send a note to          |
  15.   | license@php.net so we can mail you a copy immediately.               |
  16.   +----------------------------------------------------------------------+
  17.   | Author: Alan Knowles <alan@akbkhome.com>                             |
  18.   +----------------------------------------------------------------------+
  19.  
  20.   $Id: Install.php,v 1.11 2005/02/01 15:33:55 cellog Exp $
  21. */
  22.  
  23. /**
  24.  * Gtk Frontend -This class deals with the installing of packages
  25.  * 
  26.  * #TODO : Add remove methods, move to new 'InstallQueue/RemoveQueue API'
  27.  *
  28.  * @author Alan Knowles <alan@akbkhome.com>
  29.  */
  30.  
  31.  
  32. class PEAR_Frontend_Gtk_Install {
  33.     /**
  34.     * The Main User interface object
  35.     * @var object PEAR_Frontend_Gtk 
  36.     */
  37.     var $ui// main interface
  38.     
  39.     /*
  40.     * Gtk Installer Constructor
  41.     *
  42.     * #TODO: most of this can be moved to the glade file!?
  43.     * @param object PEAR_Frontend_Gtk
  44.     */
  45.     
  46.     function PEAR_Frontend_Gtk_Install(&$ui{
  47.      
  48.         // connect buttons?
  49.         $this->ui &$ui;
  50.         
  51.         
  52.     }
  53.     
  54.     /**
  55.     * The ProgressBar for total files
  56.     * @var object GtkProgressBar 
  57.     */
  58.     var $totalProgressBar
  59.     /**
  60.     * The ProgressBar for single download
  61.     * @var object GtkProgressBar 
  62.     */
  63.     var $fileProgressBar
  64.      /**
  65.     * The Label for Downloading File XXX
  66.     * @var object GtkLabel 
  67.     */
  68.     var $fileDownloadLabel;
  69.     /**
  70.     * The Label for Total XXX/XXX
  71.     * @var object GtkLabel 
  72.     */
  73.     var $totalDownloadLabel;
  74.     /**
  75.     * The list of packages to be added/removed
  76.     * @var object GtkList 
  77.     */
  78.     var $downloadList;
  79.     
  80.     /* 
  81.     * Start the download process (recievs a list of package 'associative arrays'
  82.     * #TODO : recieve list of package objects to install/remove!
  83.     *
  84.     */
  85.     function start({
  86.        
  87.         $this->downloadList->set_column_auto_resize(0,TRUE);
  88.         $this->downloadList->set_column_auto_resize(1,TRUE);
  89.         $this->downloadList->set_column_auto_resize(2,TRUE);
  90.         $this->downloadList->set_column_auto_resize(3,TRUE);
  91.         $this->downloadList->set_row_height(18);
  92.         $this->ui->_widget_pages->set_page(1);
  93.         $this->ui->_widget_done_button->set_sensitive(0);
  94.         // load up the list into the download list..
  95.         $this->downloadList->clear();
  96.         $i=0;
  97.         
  98.         $queue $this->ui->_packages->getQueue();
  99.         foreach ($queue as $package{
  100.             
  101.             $this->downloadList->append(array('','',$package->name,$package->summary));
  102.             if ($package->QueueInstall{
  103.                 $this->downloadList->set_pixmap($i,0,
  104.                     $this->ui->_pixmaps['package.xpm'][0],
  105.                     $this->ui->_pixmaps['package.xpm'][1]
  106.                 );
  107.             else {
  108.                 $this->downloadList->set_pixmap($i,0,
  109.                     $this->ui->_pixmaps['stock_delete-16.xpm'][0],
  110.                     $this->ui->_pixmaps['stock_delete-16.xpm'][1]
  111.                 );
  112.             }
  113.             $lines[$package->name$i;
  114.             $i++;
  115.             
  116.         }
  117.          
  118.         
  119.         
  120.         $this->totalProgressBar->set_percentage(0);
  121.         $this->fileProgressBar->set_percentage(0);
  122.         $this->totalProgressBar->set_percentage(0);
  123.         while(gtk::events_pending()) gtk::main_iteration();
  124.  
  125.             $j=0;
  126.         $this->totalDownloadLabel->set_text("Total 0/{$i}");
  127.             
  128.          
  129.             foreach ($queue as $package{
  130.                 $this->fileDownloadLabel->set_text("Downloading {$package->name}");
  131.                 while(gtk::events_pending()) gtk::main_iteration();
  132.                 $package->doQueue();
  133.                  
  134.                 $this->downloadList->set_pixmap($j,1,
  135.                     $this->ui->_pixmaps['check_yes.xpm'][0],
  136.                     $this->ui->_pixmaps['check_yes.xpm'][1]
  137.                 )
  138.                 $j++;
  139.                 $this->totalProgressBar->set_percentage((float) ($j/$i));
  140.                 $this->totalDownloadLabel->set_text("Total {$j}/{$i}");
  141.                 while(gtk::events_pending()) gtk::main_iteration();
  142.                
  143.                 
  144.             }    
  145.         
  146.         
  147.         $this->totalProgressBar->set_percentage(1.0);
  148.         $this->ui->_packages->_loadLocalPackages();
  149.         $this->ui->_packages->_mergePackages();
  150.         $this->ui->_packages->loadPackageList();
  151.         
  152.         $this->ui->_widget_done_button->set_sensitive(1);
  153.         
  154.     }
  155.     /* 
  156.     * GUI Callback - user presses the 'done button' 
  157.     */
  158.     function callbackDone({
  159.         $this->ui->_widget_pages->set_page(0);
  160.     }
  161.     /**
  162.     * size of current file being downloaded
  163.     * @var int 
  164.     * @access private
  165.     */
  166.     var $_activeDownloadSize =0;
  167.     
  168.     
  169.     /*
  170.     * PEAR_Command Callback (relayed) - used by downloader
  171.     * @param string message type
  172.     * @param string message data
  173.     */
  174.     
  175.     function _downloadCallback($msg,  $params{
  176.         
  177.         switch ($msg{
  178.             case 'setup':
  179.             case 'done':    
  180.             case 'saveas':
  181.                 while(gtk::events_pending()) gtk::main_iteration();
  182.                 return;
  183.                 
  184.             case 'start':
  185.                 $this->_activeDownloadSize $params[1];
  186.                 $this->fileProgressBar->set_percentage(0);
  187.                 while(gtk::events_pending()) gtk::main_iteration();
  188.                 return;
  189.                 
  190.             case 'bytesread':
  191.                 $this->fileProgressBar->set_percentage(
  192.                     (float) ($params $this->_activeDownloadSize));
  193.                 while(gtk::events_pending()) gtk::main_iteration();
  194.                 return;
  195.                 
  196.              ;
  197.             default: // debug - what calls this?
  198.                 if (is_object($params)) $params="OBJECT";
  199.                 echo "MSG: $msg ". serialize($params"\n";
  200.         }
  201.     }
  202.     
  203.     function uninstallOutputData($msg{
  204.         return;
  205.     }
  206.     
  207.  
  208. }
  209.  
  210.  
  211. ?>

Documentation generated on Mon, 11 Mar 2019 14:28:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.