Skip to content

Commit

Permalink
Move Install methods into Install, added more phpdoc
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/PEAR_Frontend_Gtk/trunk@84367 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
roojs committed Jun 2, 2002
1 parent b2272d7 commit fc1d4d8
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 54 deletions.
53 changes: 2 additions & 51 deletions Gtk.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,63 +383,14 @@ function _callbackShowConfig() {
$this->_widget_pages->set_page(2);
}
/*-------------------------------------Downloading --------------------------------*/
/**
* size of current file being downloaded
* @var int
* @access private
*/
var $_activeDownloadSize =0;
/**
* Total number of files that are being downloaded
* @var int
* @access private
*/

var $_downloadTotal=1;
/**
* How many files have been downloaded in this 'session'
* @var int
* @access private
*/
var $_downloadPos=0;

/*
/*
* PEAR_Command Callback - used by downloader
* @param string message type
* @param string message data
*/

function _downloadCallback($msg, $params) {

switch ($msg) {
case 'setup':
return;
case 'saveas':
$this->_widget_downloading_filename->set_text("Downloading {$params}");
$this->_widget_downloading_total_progressbar->set_percentage($this->_downloadPos/$this->_downloadTotal);
$this->_downloadPos++;
$this->_widget_downloading_total->set_text("Total {$this->_downloadPos}/{$this->_downloadTotal}");
while(gtk::events_pending()) gtk::main_iteration();

return;
case 'start':
$this->_activeDownloadSize = $params;
$this->_widget_downloading_file_progressbar->set_percentage(0);
while(gtk::events_pending()) gtk::main_iteration();
return;
case 'bytesread':
$this->_widget_downloading_file_progressbar->set_percentage($params / $this->_activeDownloadSize);
while(gtk::events_pending()) gtk::main_iteration();
return;
case 'done':

$this->_widget_downloading_total_progressbar->set_percentage($this->_downloadPos/$this->_downloadTotal);

default:
if (is_object($params)) $params="OBJECT";
echo "MSG: $msg ". serialize($params) . "\n";
}

$this->_install->_downloadCallback($msg, $params);
}


Expand Down
84 changes: 81 additions & 3 deletions Gtk/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@


class PEAR_Frontend_Gtk_Install {

/**
* The Main User interface object
* @var object PEAR_Frontend_Gtk
*/
var $ui; // main interface

/*
* Gtk Installer Constructor
*
* #TODO: most of this can be moved to the glade file!?
* @param object PEAR_Frontend_Gtk
*/

function PEAR_Frontend_Gtk_Install(&$ui) {
// connect buttons?
Expand All @@ -43,7 +52,11 @@ function PEAR_Frontend_Gtk_Install(&$ui) {
$this->ui->_widget_download_list->set_column_auto_resize(2,TRUE);
$this->ui->_widget_done_button->connect('pressed',array(&$this,'_callbackDone'));
}

/*
* Start the download process (recievs a list of package 'associative arrays'
* #TODO : recieve list of package objects to install/remove!
*
*/
function start($list) {

$this->ui->_widget_pages->set_page(1);
Expand Down Expand Up @@ -72,12 +85,77 @@ function start($list) {


}
/*
* GUI Callback - user presses the 'done button'
*/
function _callbackDone() {
$this->ui->_package_list->loadList();
$this->ui->_widget_pages->set_page(0);
}

/**
* size of current file being downloaded
* @var int
* @access private
*/
var $_activeDownloadSize =0;
/**
* Total number of files that are being downloaded
* @var int
* @access private
*/

var $_downloadTotal=1;
/**
* How many files have been downloaded in this 'session'
* @var int
* @access private
*/
var $_downloadPos=0;

/*
* PEAR_Command Callback (relayed) - used by downloader
* @param string message type
* @param string message data
*/

function _downloadCallback($msg, $params) {

switch ($msg) {
case 'setup':
return;

case 'saveas':
$this->ui->_widget_downloading_filename->set_text("Downloading {$params}");
$this->ui->_widget_downloading_total_progressbar->set_percentage(
(float) ($this->_downloadPos/$this->_downloadTotal));
$this->_downloadPos++;
$this->ui->_widget_downloading_total->set_text("Total {$this->_downloadPos}/{$this->_downloadTotal}");
while(gtk::events_pending()) gtk::main_iteration();
return;

case 'start':
$this->_activeDownloadSize = $params;
$this->ui->_widget_downloading_file_progressbar->set_percentage(0);
while(gtk::events_pending()) gtk::main_iteration();
return;

case 'bytesread':
$this->ui->_widget_downloading_file_progressbar->set_percentage(
(float) ($params / $this->_activeDownloadSize));
while(gtk::events_pending()) gtk::main_iteration();
return;

case 'done':
$this->ui->_widget_downloading_total_progressbar->set_percentage(
(float) ($this->_downloadPos/$this->_downloadTotal));

default: // debug - what calls this?
if (is_object($params)) $params="OBJECT";
echo "MSG: $msg ". serialize($params) . "\n";
}
}


}


Expand Down

0 comments on commit fc1d4d8

Please sign in to comment.