cvs: pear /PEAR_Frontend_Gtk Gtk.php /PEAR_Frontend_Gtk/Gtk Config.php DirSelect.php Info.php Install.php PackageData.php Packages.php Summary.php
installer.glade
| From: | Alan Knowles | Date: | Mon, 03 Jun 2002 10:10:45 +0000 |
| Subject: | cvs: pear /PEAR_Frontend_Gtk Gtk.php /PEAR_Frontend_Gtk/Gtk Config.php DirSelect.php Info.php Install.php PackageData.php Packages.php Summary.php installer.glade |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4386@lists.php.net to get a copy of this message | ||
alan_k Mon Jun 3 06:10:45 2002 EDT
Added files:
/pear/PEAR_Frontend_Gtk/Gtk Config.php DirSelect.php Info.php
Modified files:
/pear/PEAR_Frontend_Gtk Gtk.php
/pear/PEAR_Frontend_Gtk/Gtk Install.php PackageData.php
Packages.php Summary.php
installer.glade
Log:
Package Install/Remove Queuing now working, Moved Config,Directory Selection into seperate
classes, Added Dialog Box for messages
Index: pear/PEAR_Frontend_Gtk/Gtk.php diff -u pear/PEAR_Frontend_Gtk/Gtk.php:1.12 pear/PEAR_Frontend_Gtk/Gtk.php:1.13 --- pear/PEAR_Frontend_Gtk/Gtk.php:1.12 Sun Jun 2 11:58:58 2002 +++ pear/PEAR_Frontend_Gtk/Gtk.php Mon Jun 3 06:10:45 2002 @@ -16,14 +16,16 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Gtk.php,v 1.12 2002/06/02 15:58:58 alan_k Exp $ + $Id: Gtk.php,v 1.13 2002/06/03 10:10:45 alan_k Exp $ */ require_once "PEAR.php"; require_once "PEAR/Frontend/Gtk/Packages.php"; require_once "PEAR/Frontend/Gtk/Summary.php"; require_once "PEAR/Frontend/Gtk/Install.php"; - +require_once "PEAR/Frontend/Gtk/Config.php"; +require_once "PEAR/Frontend/Gtk/DirSelect.php"; +require_once "PEAR/Frontend/Gtk/Info.php"; /** * Core Gtk Frontend Class @@ -77,6 +79,13 @@ dl('php_gtk.' . (OS_WINDOWS ? 'dll' : 'so')); } //echo "LOADED?"; + $this->config = &PEAR_Config::singleton('',''); + $this->_summary = &new PEAR_Frontend_Gtk_Summary($this); + $this->_install = &new PEAR_Frontend_Gtk_Install($this); + $this->_packages = &new PEAR_Frontend_Gtk_Packages($this); + $this->_config = &new PEAR_Frontend_Gtk_Config($this); + $this->_dirselect = &new PEAR_Frontend_Gtk_DirSelect($this); + $this->_info = &new PEAR_Frontend_Gtk_Info($this); $this->_loadGlade(); $this->_initInterface(); } @@ -101,16 +110,35 @@ $this->_glade = &new GladeXML($file); $data = implode('',file($file)); preg_match_all('/\<name\>([^\<]+)\<\/name\>/',$data,$items); - foreach ($items[1] as $widgetname) { + foreach ($items[1] as $widgetname) { + $args = array(); + if (preg_match('/^(_install|_packages|_summary|_config|_dirselect|_info)_(.*)$/',$widgetname,$args)) { + $obj = $args[1]; + $varname= $args[2]; + //echo "ASSIGN $obj $varname to $widgetname\n"; + $this->$obj->$varname = $this->_glade->get_widget($widgetname); + continue; + } $varname = "_widget_".$widgetname; $this->$varname = $this->_glade->get_widget($widgetname); } $items = array(); preg_match_all('/\<handler\>([^\<]+)\<\/handler\>/',$data,$items); //print_r($items[1]); - foreach ($items[1] as $handler) + foreach ($items[1] as $handler) { + $args = array(); + if (preg_match('/^(_install|_packages|_summary|_config|_dirselect|_info)_(.*)$/',$handler,$args)) { + $obj = $args[1]; + $method= $args[2]; + //echo "CONNECT $obj $method to $handler\n"; + if (!method_exists($this->$obj,$method)) + exit; // programming error! + $this->_glade->signal_connect($handler ,array(&$this->$obj,$method)); + continue; + } if (method_exists($this,$handler)) $this->_glade->signal_connect( $handler ,array(&$this,$handler)); + } @@ -135,20 +163,36 @@ */ var $_install; /** + * the class manages config tahs + * @var object PEAR_Frontend_Gtk_Config + * @access private + */ + var $_install; + /** + * the class manages directory selection + * @var object PEAR_Frontend_Gtk_DirSelect + * @access private + */ + var $_dirselect; + + /** + * the class manages simple info prompts + * @var object PEAR_Frontend_Gtk_Info + * @access private + */ + var $_info; + + /** * Load and initialize the sub modules * * @access private */ + + function _initInterface() { // must be a better way - still needs to read -c -C optss - $this->config = &PEAR_Config::singleton('',''); - // initialize child objects - - $this->_packages = &new PEAR_Frontend_Gtk_Packages($this); - $this->_summary = &new PEAR_Frontend_Gtk_Summary($this); - $this->_install = &new PEAR_Frontend_Gtk_Install($this); - + $this->_widget_window->connect_after('realize',array(&$this,'_callbackWindowConfigure')); $this->_widget_window->connect_after('configure_event',array(&$this,'_callbackWindowConfigure')); @@ -184,12 +228,16 @@ $this->_setStyle('config_button','#000000','#7b7d7a'); $this->_setStyle('documentation_button','#000000','#7b7d7a'); + /* package stuff */ + + $this->_packages->loadPackageList(); + $this->_setStyle('black_bg1','#FFFFFF','#000000',TRUE); $this->_setStyle('black_bg2','#FFFFFF','#000000',TRUE); $this->_setStyle('black_bg3','#FFFFFF','#000000',TRUE); $this->_setStyle('black_bg4','#FFFFFF','#000000',TRUE); - $this->_setStyle('download_list','#000000','#FFFFFF',TRUE); + //$this->_setStyle('download_list','#000000','#FFFFFF',TRUE); $this->_setStyle('close_details','#FFFFFF','#000000',FALSE); // sort out the text. @@ -236,7 +284,7 @@ /* configuration loading */ - $this->_loadConfig(); + $this->_config->loadConfig(); $this->_setStyle('config_logo','#000000','#339900',TRUE); $this->_setStyle('config_logo_text','#FFFFFF','#339900'); @@ -259,7 +307,7 @@ */ function _loadButton($widgetname, $icon) { - echo $widgetname; + //echo $widgetname; $widget_fullname = "_widget_". $widgetname; $widget = &$this->$widget_fullname; @@ -297,7 +345,7 @@ * @access private */ function _setStyle($widgetname,$fgcolor='',$bgcolor='',$copy=FALSE) { - echo "SET: $widgetname: $fgcolor/$bgcolor ". ((int) $copy) . "\n"; + //echo "SET: $widgetname: $fgcolor/$bgcolor ". ((int) $copy) . "\n"; $widget_fullname = "_widget_". $widgetname; $widget = &$this->$widget_fullname; if ($copy) { @@ -366,22 +414,11 @@ } } - /* - * Menu Callback - expand all - */ - function on_expand_all_activate() { - $this->_packages->widget->expand_recursive(); - } - /* - * Menu Callback - colllapse all - */ - function on_collapse_all_activate() { - $this->_packages->widget->collapse_recursive(); - } + /* * Menu Callback - Exit/Quit */ - function on_quit() { + function _onQuit() { gtk::main_quit(); exit; } @@ -409,374 +446,9 @@ $this->_install->_downloadCallback($msg, $params); } - - /*---------------- Configuration Building stuff -----------------------*/ - - /** - * Build the widgets based on the return 'data' array from config-show - * - * @param array see config-show for more details. - */ - function _buildConfig(&$array) { - if (!$array) return; - foreach ($array as $group=>$items) - foreach ($items as $v) { - $this->_buildConfigItem($v[1],$v[2]); - } - - } - /** - * Build the widgets for a configuration item - * - * @param string configuration 'key' - * @param string configuration 'value' - */ - function _buildConfigItem($k,$v) { - echo "BUIDLING CONF ITME $k $v\n"; - $group = $this->config->getGroup($k); - $gtktable = $this->_getConfigTab($group); - $prompt = $this->config->getPrompt($k); - $gtklabel = &new GtkLabel(); - $gtklabel->set_text($prompt); - $gtklabel->set_justify(GTK_JUSTIFY_LEFT); - $gtklabel->set_alignment(0.0, 0.5); - $gtklabel->show(); - $r = $gtktable->nrows; - $gtktable->attach($gtklabel, 0, 1, $r, $r+1, GTK_FILL,GTK_FILL); - if ($v == '<not set>') - $v = ''; - - $type = $this->config->getType($k); - switch ($type) { - case 'string': - case 'password': - case 'int': // umask: should really be checkboxes.. - $gtkentry = &new GtkEntry(); - $gtkentry->set_text($v); - - $gtkentry->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - $gtkentry->connect_object_after('changed', array(&$this,'_ActivateConfigSave')); - if ($type == 'password') - $gtkentry->set_visibility(FALSE); - $gtkentry->show(); - $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - break; - case 'directory': - $gtkentry = &new GtkEntry(); - $gtkentry->set_text($v); - $gtkentry->set_editable(FALSE); - $gtkentry->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - // store in object data the configuration tag - $gtkentry->set_data('key',$k); - $gtkentry->show(); - $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - $gtkbutton = &new GtkButton('...'); - $gtkbutton->connect_object_after('clicked', array(&$this,'_onDirSelect'),$gtkentry); - $gtkbutton->show(); - $gtktable->attach($gtkbutton, 2, 3, $r, $r+1, GTK_SHRINK,GTK_SHRINK); - break; - case 'set': - $options = $this->config->getSetValues($k); - $gtkmenu = &new GtkMenu(); - $items = array(); - $sel = 0; - foreach($options as $i=>$option) { - $items[$i] = &new GtkMenuItem($option); - //$items[$i]->connect('activate', 'echo_activated', $labels[$i], $pos[$i], - $gtkmenu->append($items[$i]); - if ($option == $v) - $sel = $i; - } - $gtkmenu->set_active($sel); - $gtkmenu->show_all(); - $gtkoptionmenu = &new GtkOptionMenu(); - $gtkoptionmenu->set_menu($gtkmenu); - $gtkoptionmenu->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - - $gtkoptionmenu->show(); - $gtktable->attach($gtkoptionmenu, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - break; - // debug: shourd really be - case 'integer': // debug : should really be a set? - $gtkadj = &new GtkAdjustment($v, 0.0, 3.0, 1.0, 1.0, 0.0); - $gtkspinbutton = &new GtkSpinButton($gtkadj); - $gtkspinbutton->show(); - $gtkspinbutton->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - - $gtktable->attach($gtkspinbutton, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - break; - default: - echo "$prompt : ". $this->config->getType($k) . "\n"; - } - - } - /** - * Show the help text for a widget - * - * @param object gtkevent name of group tab - * @param string help text - */ - function _setConfigHelp($event,$string) { - $this->_widget_config_help->set_text($string); - } - /** - * The GtkTables relating to the groups - * - * @var array associative array of groupname -> gtktable - * @access private - */ - var $_configTabs = array(); // associative array of configGroup -> GtkTable - /** - * Get (or Make) A 'Group' Config Tab on the config notebook - * - * @param string name of group tab - * @param string no idea yet! - * @return object GtkTable table which config elements are added to. - */ - function &_getConfigTab($group) { - if (@$this->_configTabs[$group]) - return $this->_configTabs[$group]; - $this->_configTabs[$group] = &new GtkTable(); - $this->_configTabs[$group]->set_row_spacings(10); - $this->_configTabs[$group]->set_col_spacings(10); - $this->_configTabs[$group]->set_border_width(15); - $this->_configTabs[$group]->show(); - $gtklabel = &new GtkLabel($group); - - $gtklabel->show(); - $this->_widget_config_notebook->append_page($this->_configTabs[$group],$gtklabel); - return $this->_configTabs[$group]; - } - /** - * Load Configuration into widgets (Initialize) - * - * Clear current config tabs, and calls the Command Show-config - * - * @param object getbutton from the reset button! - * @param string no idea yet! - */ - function _loadConfig($widget=NULL,$what=NULL) { - if ($this->_configTabs) - foreach (array_keys($this->_configTabs) as $k) { - $page = $this->_widget_config_notebook->page_num($this->_configTabs[$k]); - $this->_widget_config_notebook->remove_page($page); - $this->_configTabs[$k]->destroy(); - } - - // delete any other pages; - if ($widget = $this->_widget_config_notebook->get_nth_page(0)) { - $this->_widget_config_notebook->remove_page(0); - $widget->destroy(); - } - $this->_configTabs = array(); - $cmd = PEAR_Command::factory('config-show',$this->config); - $cmd->ui = &$this; - $cmd->run('config-show' ,'', array()); - $this->_widget_config_save->set_sensitive(FALSE); - $this->_widget_config_reset->set_sensitive(FALSE); - } - - - /** - * Make the Save and reset buttons pressable. - * - * @access private - */ - function _ActivateConfigSave() { - $this->_widget_config_save->set_sensitive(TRUE); - $this->_widget_config_reset->set_sensitive(TRUE); - } - - /*---------------- Dir Seleciton stuff -----------------------*/ - - /** - * Currently active widget to save result into (eg. gtkentry) - * - * @var object gtkentry - * @access private - */ - var $_DirSelectActiveWidget = NULL; - /** - * Display the Directory selection dialog - * - * Displays the directory dialog, fills in the data etc. - * - * @param object gtkentry The text entry to fill in on closing - * - */ - function _onDirSelect($widget) { - // set the title!! - $this->_DirSelectActiveWidget = &$widget; - $prompt = 'xxx'; - $prompt = $this->config->getPrompt($widget->get_data('key')); - $this->_widget_dir_selection->set_title($prompt); - - $curvalue = $widget->get_text(); - // load the pulldown - $this->_DirSelectSetDir(dirname($curvalue), basename($curvalue)); - $this->_widget_dir_selection_entry->set_text($curvalue); - $this->_widget_dir_selection->show(); - } - - /** - * Associated array of Row -> directory name - * - * It could be possible to get the row string using gtk calls...... - * - * @var array - * @access private - */ - var $_DirSelectRows = array(); - - /** - * Load the directories into the directory list/pulldown etc. - * - * Loads the information into the popup / list of directories - * TODO: Windows A:D: etc. drive support - * - * @param string $directory name of directory to browse - * @param string $file name of file to select in list. - * - */ - function _DirSelectSetDir($directory, $file='.') { - $parts = explode(DIRECTORY_SEPARATOR, $directory); - $disp = array(); - $i=0; - $items = array(); - $gtkmenu = &new GtkMenu(); - foreach($parts as $dirpart) { - $disp[] = $dirpart; - $dir = implode(DIRECTORY_SEPARATOR,$disp); - if (!$dir && DIRECTORY_SEPARATOR == '/') $dir = '/'; - if (!$dir) continue; - $items[$i] = &new GtkMenuItem($dir); - $items[$i]->connect_object_after('activate', array(&$this,'_DirSelectSetDir'),$dir); - $gtkmenu->append($items[$i]); - $i++; - } - $gtkmenu->set_active($i-1); - $gtkmenu->show_all(); - $this->_widget_dir_selection_optionmenu->set_menu($gtkmenu); - $base = $directory; - - $this->_widget_dir_selection_clist->select_row(0,0); - $this->_widget_dir_selection_clist->freeze(); - $this->_widget_dir_selection_clist->clear(); - - clearstatcache(); - $dh = opendir($base); - $dirs = array(); - while (($dir = readdir($dh)) !== FALSE) { - if (!is_dir($base.DIRECTORY_SEPARATOR.$dir)) continue; - $dirs[] = $dir; - } - sort($dirs); - $this->_DirSelectRows = array(); - $sel =0; - $i=0; - foreach($dirs as $dir) { - $this->_widget_dir_selection_clist->append(array($dir)); - $this->_DirSelectRows[] = realpath($base.DIRECTORY_SEPARATOR.$dir); - if ($dir == $file) - $sel = $i; - $i++; - } - $this->_widget_dir_selection_clist->thaw(); - if ($file != '.') { - - $this->_widget_dir_selection_clist->select_row($sel,0); - $this->_widget_dir_selection_clist->moveto($i,0,0,0); - $this->_widget_dir_selection_entry->set_text($directory); - } else { - - $this->_DirListBlockSel = TRUE; - $this->_widget_dir_selection_clist->select_row(0,0); - $this->_DirListBlockSel = TRUE; - } - - - } - /** - * Flag to block reselecting of current row after update - * - * Introduced to attempt to fix problem that when you double click to open a - * Directory, after refresh, the clist recieves a select signal on the same rows - * and hence attemps to select the wrong directory.. - * - * @var boolean - * @access private - */ - var $_DirListBlockSel = FALSE; - /** - * Initial Select Row (not double click) - * - * Makes this selected item the 'active directory' - * - * @param string $directory name of directory to browse - * @param string $row selected line - * - */ - function _onDirListSelectRow($widget,$row) { - - if ($this->_DirListBlockSel) { - - $this->_DirListBlockSel = FALSE; - $widget->select_row(0,0); - return; - } - if ($row < 0) return; - $this->_widget_dir_selection_entry->set_text($this->_DirSelectRows[$row]); - } - - /** - * Callback when the list of directories is clicked - * - * Used to find the double click to open it. - * - * @param object gtkclist - * @param object gdkevent - * - */ - - function _onDirListClick($widget,$event) { - if ($event->type != 5) return; - $this->_DirSelectSetDir($this->_widget_dir_selection_entry->get_text()); - } - /** - * Callback when the cancel/destroy window is pressed - * - * has to return TRUE (see the gtk tutorial on destroy events) - * - * - */ - function _onDirSelectionCancel() { - $this->_widget_dir_selection->hide(); - return TRUE; - } - /** - * Callback when the OK btn is pressed - * - * hide window and update original widget. - * - */ + /*---------------- Dir Seleciton stuff -----------------------*/ - function _onDirSelectionOk() { - if (!$this->_DirSelectActiveWidget) return; - $new= $this->_widget_dir_selection_entry->get_text(); - $old= $this->_DirSelectActiveWidget->get_text(); - - if ($new != $old) { - $this->_DirSelectActiveWidget->set_text($new); - $this->_ActivateConfigSave(); - } - - $this->_DirSelectActiveWidget = NULL; - $this->_widget_dir_selection->hide(); - } + //-------------------------- BASE Installer methods -------------------------- /** @@ -789,28 +461,32 @@ function outputData($data,$command ){ switch ($command) { case 'config-show': - $this->_buildConfig($data['data']); + $this->_config->buildConfig($data['data']); break; + case 'uninstall': + $this->_install->uninstallOutputData($data); + return; default: echo "COMMAND : $command\n"; echo "DATA: ".serialize($data)."\n"; } } - function log($msg) { - echo "LOG $msg"; + function log($msg,$command) { + + return $this->_info->show("LOG: $msg: $command"); } // {{{ displayLine(text) - function displayLine($text) + function displayLine($msg,$args) { - echo "$text\n"; + return $this->_info->show("DISPLAYLINE: $msg: $args"); } - function display($text) + function display($text,$command='') { - echo "$text\n"; + return $this->_info->show("TEXT: $text: $command"); } // }}} @@ -818,7 +494,8 @@ function displayError($eobj) { - return $this->displayLine($eobj->getMessage()); + //echo "ERROR: ".$eobj->getMessage(); + return $this->_info->show("ERROR: ". $eobj->getMessage()); } @@ -827,7 +504,7 @@ function displayFatalError($eobj) { - $this->displayError($eobj); + return $this->_info->show("FATAL ERROR: ". $eobj->getMessage()); //exit(1); } @@ -843,7 +520,8 @@ function userDialog($prompt, $type = 'text', $default = '') { - echo "Dialog?" . $prompt; + + echo "Dialog?" . $prompt; } // }}} @@ -851,7 +529,7 @@ function userConfirm($prompt, $default = 'yes') { - echo "Confirm?" . $prompt; + echo "\nConfirm?" . $prompt; } // }}} @@ -880,6 +558,7 @@ function bold($text) { + echo "\nBOLD?" . $prompt; } // }}} Index: pear/PEAR_Frontend_Gtk/Gtk/Install.php diff -u pear/PEAR_Frontend_Gtk/Gtk/Install.php:1.5 pear/PEAR_Frontend_Gtk/Gtk/Install.php:1.6 --- pear/PEAR_Frontend_Gtk/Gtk/Install.php:1.5 Sat Jun 1 23:16:51 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/Install.php Mon Jun 3 06:10:45 2002 @@ -17,7 +17,7 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Install.php,v 1.5 2002/06/02 03:16:51 alan_k Exp $ + $Id: Install.php,v 1.6 2002/06/03 10:10:45 alan_k Exp $ */ /** @@ -44,51 +44,118 @@ */ function PEAR_Frontend_Gtk_Install(&$ui) { + // connect buttons? $this->ui = &$ui; - $this->ui->_widget_download_list->set_column_auto_resize(0,TRUE); - $this->ui->_widget_download_list->set_column_auto_resize(1,TRUE); - $this->ui->_widget_download_list->set_column_auto_resize(2,TRUE); - $this->ui->_widget_done_button->connect('pressed',array(&$this,'_callbackDone')); + + } + + /** + * The ProgressBar for total files + * @var object GtkProgressBar + */ + var $totalProgressBar; + /** + * The ProgressBar for single download + * @var object GtkProgressBar + */ + var $fileProgressBar; + /** + * The Label for Downloading File XXX + * @var object GtkLabel + */ + var $fileDownloadLabel; + /** + * The Label for Total XXX/XXX + * @var object GtkLabel + */ + var $totalDownloadLabel; + /** + * The list of packages to be added/removed + * @var object GtkList + */ + var $downloadList; + /* * Start the download process (recievs a list of package 'associative arrays' * #TODO : recieve list of package objects to install/remove! * */ - function start($list) { - + function start() { + + $this->downloadList->set_column_auto_resize(0,TRUE); + $this->downloadList->set_column_auto_resize(1,TRUE); + $this->downloadList->set_column_auto_resize(2,TRUE); + $this->downloadList->set_column_auto_resize(3,TRUE); + $this->downloadList->set_row_height(18); $this->ui->_widget_pages->set_page(1); $this->ui->_widget_done_button->set_sensitive(0); // load up the list into the download list.. - $this->ui->_widget_download_list->clear(); + $this->downloadList->clear(); $i=0; - $install = array(); - if ($list) foreach ($list as $package) { - print_r($package); - $this->ui->_widget_download_list->append(array('',$package['package'],$package['summary'])); - $this->ui->_widget_download_list->set_pixmap($i,0, - $this->ui->_pixmaps['package.xpm'][0], - $this->ui->_pixmaps['package.xpm'][1] - ); + + $queue = $this->ui->_packages->getQueue(); + foreach ($queue as $package) { + + $this->downloadList->append(array('','',$package->name,$package->summary)); + if ($package->QueueInstall) { + $this->downloadList->set_pixmap($i,0, + $this->ui->_pixmaps['package.xpm'][0], + $this->ui->_pixmaps['package.xpm'][1] + ); + } else { + $this->downloadList->set_pixmap($i,0, + $this->ui->_pixmaps['stock_delete-16.xpm'][0], + $this->ui->_pixmaps['stock_delete-16.xpm'][1] + ); + } + $lines[$package->name] = $i; $i++; - $install[] = $package['package']; + } + + + + $this->totalProgressBar->set_percentage(0); + $this->fileProgressBar->set_percentage(0); + $this->totalProgressBar->set_percentage(0); while(gtk::events_pending()) gtk::main_iteration(); - $this->ui->_downloadTotal = $i; + + $j=0; + $this->totalDownloadLabel->set_text("Total 0/{$i}"); + + + foreach ($queue as $package) { + $this->fileDownloadLabel->set_text("Downloading {$package->name}"); + while(gtk::events_pending()) gtk::main_iteration(); + $package->doQueue(); + + $this->downloadList->set_pixmap($j,1, + $this->ui->_pixmaps['check_yes.xpm'][0], + $this->ui->_pixmaps['check_yes.xpm'][1] + ); + $j++; + $this->totalProgressBar->set_percentage((float) ($j/$i)); + $this->totalDownloadLabel->set_text("Total {$j}/{$i}"); + while(gtk::events_pending()) gtk::main_iteration(); + + + } - $this->ui->_downloadPos=0; - $cmd = PEAR_Command::factory('install',$this->ui->config); - $cmd->run('install' ,'', $install); - $this->ui->_widget_done_button->set_sensitive(1); + $this->totalProgressBar->set_percentage(1.0); + $this->ui->_packages->_loadLocalPackages(); + $this->ui->_packages->_mergePackages(); + $this->ui->_packages->loadPackageList(); + + $this->ui->_widget_done_button->set_sensitive(1); } /* * GUI Callback - user presses the 'done button' */ - function _callbackDone() { - $this->ui->_package_list->loadList(); + function callbackDone() { $this->ui->_widget_pages->set_page(0); } /** @@ -97,19 +164,7 @@ * @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 @@ -121,37 +176,32 @@ switch ($msg) { case 'setup': - return; - + case 'done': 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); + $this->fileProgressBar->set_percentage(0); while(gtk::events_pending()) gtk::main_iteration(); return; case 'bytesread': - $this->ui->_widget_downloading_file_progressbar->set_percentage( + $this->fileProgressBar->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"; } + } + + function uninstallOutputData($msg) { + return; } Index: pear/PEAR_Frontend_Gtk/Gtk/PackageData.php diff -u pear/PEAR_Frontend_Gtk/Gtk/PackageData.php:1.1 pear/PEAR_Frontend_Gtk/Gtk/PackageData.php:1.2 --- pear/PEAR_Frontend_Gtk/Gtk/PackageData.php:1.1 Sun Jun 2 03:19:38 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/PackageData.php Mon Jun 3 06:10:45 2002 @@ -9,7 +9,8 @@ class PEAR_Frontend_Gtk_PackageData { - + + var $ui; // the User interface object /* data from remote-list */ var $name; // name -- wel actually not there, but lets use it anyway var $category = ""; // eg. XML @@ -52,12 +53,116 @@ /* data not available yet!!! */ var $dependancies; // list of packages that this depends on. - var $gtkrow; // gtk row that contains the row data.. + var $gtknode; // gtk node for this package - function staticNewFromArray($array) { + function &staticNewFromArray($array) { + $t = new PEAR_Frontend_Gtk_PackageData; - foreach(array as $k=>$v) + foreach($array as $k=>$v) { + + //echo "SETTING $k to $v\n"; $t->$k = $v; + } + return $t; + } + + + function merge($object) { + foreach(get_object_vars($object) as $k=>$v) { + if (!$v) continue; + //echo "SET $k -> $v\n"; + $this->$k = $v; + } } + /* + * create Node + * + * creates a node - current format is: + * Name (Tree), Trash, Installed Version, Latest Version, Add, Info Icon, Summary + * + * + * @params object GtkNode Parent in tree + */ + + function createNode(&$parent) { + + $this->gtknode = $this->ui->_packages->widget->insert_node( + $parent, NULL, //parent, sibling + array($this->name, '','','' ), + 5, + $this->ui->_pixmaps['package.xpm'][0], + $this->ui->_pixmaps['package.xpm'][1], + $this->ui->_pixmaps['package.xpm'][0], + $this->ui->_pixmaps['package.xpm'][1], + false,true + ); + $this->_setIcon(3,'info_icon.xpm',$this->summary); + $this->ui->_packages->widget->node_set_row_data( $this->gtknode, $this->name); + $this->_showDelete(); + $this->_showInstall(); + } + + function _setIcon($col,$name,$string='') { + $ui = PEAR_Command::getFrontendObject(); + $this->ui->_packages->widget->node_set_pixtext( + $this->gtknode, $col,$string,0, + $this->ui->_pixmaps[$name][0], + $this->ui->_pixmaps[$name][1] + ); + } + + function _showDelete() { + if (!$this->version) return; + + $icon = "stock_delete-outline-16.xpm"; + if ($this->QueueRemove) + $icon = "stock_delete-16.xpm"; + $this->_setIcon(1,$icon,' '.$this->version); + } + + function _showInstall() { + if ($this->version == $this->stable) return; + + //foreach(get_object_vars($this) as $k=>$v) echo "$k=>$v\n"; + $icon = "check_no.xpm"; + if ($this->QueueInstall) + $icon = "check_yes.xpm"; + $this->_setIcon(2,$icon, ' '.$this->stable); + } + function toggleRemove() { + if (!$this->version) return; + + $this->QueueRemove = !$this->QueueRemove; + if ($this->QueueRemove) + $this->QueueInstall = FALSE; + + $this->_showDelete(); + $this->_showInstall(); + + } + function toggleInstall() { + if ($this->version == $this->stable) return; + + $this->QueueInstall = !$this->QueueInstall; + if ($this->QueueInstall) + $this->QueueRemove = FALSE; + $this->_showInstall(); + $this->_showDelete(); + } + + function doQueue() { + $cmd = PEAR_Command::factory('install',$this->ui->config); + if ($this->QueueInstall && !$this->isInstalled) { + $cmd->run('install' ,'', array($this->name)); + return; + } else if ($this->QueueInstall) { + $cmd->run('upgrade' ,'', array($this->name)); + return; + } + if (!$this->QueueRemove) return; + $cmd->run('uninstall' ,'', array($this->name)); + + } + } ?> Index: pear/PEAR_Frontend_Gtk/Gtk/Packages.php diff -u pear/PEAR_Frontend_Gtk/Gtk/Packages.php:1.9 pear/PEAR_Frontend_Gtk/Gtk/Packages.php:1.10 --- pear/PEAR_Frontend_Gtk/Gtk/Packages.php:1.9 Sun Jun 2 10:18:31 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/Packages.php Mon Jun 3 06:10:45 2002 @@ -16,7 +16,7 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Packages.php,v 1.9 2002/06/02 14:18:31 alan_k Exp $ + $Id: Packages.php,v 1.10 2002/06/03 10:10:45 alan_k Exp $ */ require('PEAR/Frontend/Gtk/PackageData.php'); /** @@ -35,226 +35,34 @@ function PEAR_Frontend_Gtk_Packages(&$ui) { $this->ui = &$ui; - $this->_loadPackageData(); - $cols = array('Package','Version','','','Summary'); - $this->widget = &new GtkCTree(5,0,$cols); - $this->widget->set_usize(300,20); - $this->widget->set_selection_mode(GTK_SELECTION_BROWSE); - $this->widget->set_expander_style(GTK_CTREE_EXPANDER_TRIANGLE); - $this->widget->set_line_style( GTK_CTREE_LINES_NONE); - $this->widget->connect_after('realize', array(&$this, '_callbackRealize')); - $this->widget->connect_object('tree-select-row', array(&$this, '_callbackSelectRow')); - foreach($cols as $i=>$name) - $this->widget->set_column_auto_resize($i,TRUE); - - $this->widget->show(); - $this->ui->_widget_package_list_holder->add($this->widget); - - $this->ui->_widget_packages_install->connect('pressed',array(&$this,'_callbackInstall')); - return; - //untested - $this->loadLocalPackages(); - $this->loadRemotePackages(); - $this->mergePackages(); - - - + $this->_loadLocalPackages(); + $this->_loadRemotePackages(); + $this->_mergePackages(); } - function _loadPackageData() { - $reg = new PEAR_Registry($this->ui->config->get('php_dir')); - $installed = $reg->packageInfo(); - - foreach ($installed as $i=>$package) - $this->_package_status[$package['package']] = &$installed[$i]; - - // get available - if (!$this->_available_packages) { - $r = new PEAR_Remote($this->ui->config); - $packages = $r->call('package.listAll', true); - if (PEAR::isError($packages)) { - $this->ui->displayFatalError($packages); - return; - } - $this->_available_packages = $packages; - } - - - // merge available - - foreach ($this->_available_packages as $name => $info) { - // installed already? - $info['package'] = $name; - if (@$this->_package_status[$name]) { - // newer - $v = $this->_package_status[$name]['version']; - $this->_package_status[$name] = $info; - $this->_package_status[$name]['version'] = $v; - $this->_package_status[$name]['installed'] = 1; - $this->_package_status[$name]['install'] = TRUE; - if (@$this->_package_status[$name]['version'] < $info['stable']) { - // blank out the 'stable' column (as it is the same! - $this->_package_status[$name]['install'] = FALSE; - } - } else { - $this->_package_status[$name] = $info; - } - } - ksort($this->_package_status); - - } - - - /* - - package info looks like this! - - [packageid] => 22 - [categoryid] => 22 - [category] => XML - [license] => PHP License - [summary] => RSS parser - [description] => Parser for Resource Description Framework (RDF) Site Summary (RSS) -documents. - [lead] => mj - [stable] => 0.9.1 - - - */ - + - var $_package_status; // associative array of packagename => package info - var $_available_packages = array(); // result of rpc call - - function _callbackRealize($widget) { - - $this->_initPixmaps($widget); - $this->loadList(); - } - - - function loadList() { - //while(gtk::events_pending()) gtk::main_iteration(); - $this->widget->clear(); - $this->widget->freeze(); - - - - - $this->_nodes = array(); - - foreach($this->_package_status as $name => $info) { - - $ar = explode('_',$name); - $s = trim($ar[0]); - $parent = NULL; - if ($s && @$this->_nodes[$s]) - $parent = $this->_nodes[$s]; - - if ($s && !$parent && ($ar[0] != $name)) { - // make a parent node - - - $this->_nodes[$s] = $this->widget->insert_node( - NULL, NULL, //parent, sibling - array($s, '','','','',''), - 5, $this->_pixmaps['folder_closed.xpm'][0], - $this->_pixmaps['folder_closed.xpm'][1], - $this->_pixmaps['folder_open.xpm'][0], - $this->_pixmaps['folder_open.xpm'][1], - false,true); - - $parent = $this->_nodes[$s]; - } - - $showversion = $info['stable']; - if (@$info['version'] && (@$info['version'] != $info['stable'])) - $showversion = "New:".$info['stable']; - //$showversion = "**".$info['version'] . "->".$info['stable']. "**"; - - $this->_nodes[$name] = $this->widget->insert_node( - $parent, NULL, //parent, sibling - array( - $name, - $showversion, - '', - '', - $info['summary'] - - ), - 5, - $this->_pixmaps['package.xpm'][0], - $this->_pixmaps['package.xpm'][1], - $this->_pixmaps['package.xpm'][0], - $this->_pixmaps['package.xpm'][1], - false,true); - - - - $this->widget->node_set_pixtext( - $this->_nodes[$name], 3,'',0, - $this->_pixmaps['info_icon.xpm'][0], - $this->_pixmaps['info_icon.xpm'][1] - ); - - - $this->widget->node_set_row_data( $this->_nodes[$name], $name); - $this->_setPackageStatus($this->_nodes[$name], @$this->_package_status[$name]['install']); - } - $this->widget->thaw(); - - } - - /* - * Array of pixmaps - * each pixmap object looks like - * $pixmap->closed, $pixmap->mask_closed, - * $pixmap->open, $pixmap->mask_open, - * - * @var array of StdClass objects - * - */ - var $pixmaps; - /* - * initialize the pixmaps - load the into $_pixmaps[name] ->object - * - */ - function _initPixmaps(&$window) { - - if (@$this->_pixmaps) return; - $dir = dirname(__FILE__).'/xpm'; - $dh = opendir($dir); - if (!$dh) return; - while (($file = readdir($dh)) !== FALSE) { - if (@$file{0} == '.') continue; - if (!preg_match('/\.xpm$/',$file)) continue; - - $this->_pixmaps[$file] = - Gdk::pixmap_create_from_xpm($window->window, NULL, "{$dir}/{$file}"); - - } - - } + /* * call back when a row is pressed - hide/show the details and check it's isntalled status * */ - function _callbackSelectRow($node,$col) { + function callbackSelectRow($widget,$node,$col) { + //echo "GOT CALLBACK?"; $package = $this->widget->node_get_row_data($node); - //if (!$package) return; + if (!$package) return; switch ($col) { - case 0: + case 1: + $this->ui->_summary->hide(); + $this->packages[$package]->toggleRemove(); + break; + case 0: case 2: // install/ toggled - //case 4: - $this->ui->_summary->hide(); - - if (!$package) return; - $this->_setPackageStatus(&$node, !$this->_package_status[$package]['install']); - + $this->packages[$package]->toggleInstall(); break; case 3: // info selected if (!$package) { @@ -262,10 +70,7 @@ return; } - if ($this->_moveto_flag) - $this->widget->node_moveto($node,0,0,0); - $this->_moveto_flag=FALSE; - $this->ui->_summary->toggle($this->_package_status[$package]); + $this->ui->_summary->toggle($this->packages[$package]); break; case -1: // startup! return; @@ -273,55 +78,26 @@ $this->ui->_summary->hide(); break; } + $packages = $this->getQueue(); + $this->ui->_widget_packages_install->set_sensitive(0); + if ($packages) $this->ui->_widget_packages_install->set_sensitive(1); - - } - var $_moveto_flag = FALSE; - function selectPackage($package) { - if (!$this->_nodes[$package]) return; - $this->_moveto_flag=TRUE; - $this->widget->select($this->_nodes[$package]); - - - - } - - function _setPackageStatus(&$node, $status=FALSE) { - $status_icon = 'check_no.xpm'; - if ($status) $status_icon = 'check_yes.xpm'; - - $this->widget->node_set_pixtext( - $node, 2,'',0, - $this->_pixmaps[$status_icon][0], - $this->_pixmaps[$status_icon][1] - ); - $package = $this->widget->node_get_row_data($node); - $this->_package_status[$package]['install'] = $status; + + + /* + * Menu Callback - expand all + */ + function expandAll() { + $this->widget->expand_recursive(); } - - - - function _callbackInstall() { - // send the installer a list of packages to install - // probably the command stuff eventually... - // this method is very chessy - need to work out a more 'consistent way to handle, remove,add etc' - $install = array(); - foreach($this->_package_status as $package) - if ($package['install'] & !$package['installed']) - $install[] = $package; - - $this->ui->_install->start($install); - - - - + /* + * Menu Callback - colllapse all + */ + function collapseAll() { + $this->widget->collapse_recursive(); } - - - /*------------------------------------- New Data stuff.. ----------------------*/ - var $_remotePackageCache; // array of remote packages. var $_localPackageCache; // array of local packages var $packages; // associative array of packagename : package @@ -332,21 +108,23 @@ * Load the local packages into this->_localPackageCache * */ - function loadLocalPackages () { + function _loadLocalPackages () { + clearstatcache(); $reg = new PEAR_Registry($this->ui->config->get('php_dir')); $installed = $reg->packageInfo(); - $this->_localPackagesCache = array(); + $this->_localPackageCache = array(); foreach($installed as $packagear) { $package = PEAR_Frontend_Gtk_PackageData::staticNewFromArray($packagear); $package->name = $package->package; - $this->_localPackagesCache[$package->name] = $package; + $this->_localPackageCache[] = $package; } + } /* * Load the remote packages into this->_remotePackageCache * */ - function loadRemotePackages () { + function _loadRemotePackages () { $r = new PEAR_Remote($this->ui->config); $remote = $r->call('package.listAll', true); if (PEAR::isError($remote)) { @@ -356,35 +134,39 @@ foreach ($remote as $name => $packagear) { $package = PEAR_Frontend_Gtk_PackageData::staticNewFromArray($packagear); $package->name = $name; - $this->_remotemotePackageCache[] = $package; + $this->_remotePackageCache[] = $package; } + } /* * Add local and remote together and store in this->packages * Not: remembers installation status. */ - function mergePackages () { // builds a mreged package list + function _mergePackages () { // builds a mreged package list // start with remote list. - $newpackages = array(); - foreach ($this->_remotePackageCache as $package) - $newpackages[$package->name] = $package; + //if (!$this->packages) + foreach ($this->_remotePackageCache as $package) + $this->packages[$package->name] = $package; + // merge local. - foreach ($this->_localPackageCache as $package) { - if (@$newpackages[$package->name]) { - $newpackages[$package->name]->merge($package); + foreach ($this->_localPackageCache as $package) { + if (@$this->packages[$package->name]) { + $this->packages[$package->name]->merge($package); } else { - $newpackages[$package->name] = $package; + $this->packages[$package->name] = $package; } - $newpackages[$name]->isInstalled = TRUE; + $this->packages[$package->name]->isInstalled = TRUE; } //merge existing status stuff.. - foreach ($this->packages as $name=>$package) { - $newpackages[$name]->QueueInstall = $package->QueueInstall; - $newpackages[$name]->QueueRemove = $package->QueueRemove; - } - ksort($newpackages); - $this->packages = $newpackages; + /*if ($this->packages) + foreach ($this->packages as $name=>$package) { + $this->packages[$name]->QueueInstall = $package->QueueInstall; + $this->packages[$name]->QueueRemove = $package->QueueRemove; + } + */ + ksort($this->packages); + } /* @@ -401,11 +183,15 @@ * *@return array array of PackageData objects */ - function &getInstallQueue() { + function &getQueue() { $ret = array(); foreach(array_keys($this->packages) as $packagename) { - if (!$this->packages[$packagename]->QueueInstall) continue; - $ret[] = &$this->packages[$packagename]; + if ($this->packages[$packagename]->QueueInstall) + $ret[] = &$this->packages[$packagename]; + } + foreach(array_keys($this->packages) as $packagename) { + if ($this->packages[$packagename]->QueueRemove) + $ret[] = &$this->packages[$packagename]; } return $ret; } @@ -414,14 +200,7 @@ * *@return array array of PackageData objects */ - function &getRemoveQueue() { - $ret = array(); - foreach(array_keys($this->packages) as $packagename) { - if (!$this->packages[$packagename]->QueueRemove) continue; - $ret[] = &$this->packages[$packagename]; - } - return $ret; - } + /* * Nodes in a CTreeNodes @@ -437,14 +216,25 @@ *@return array array of PackageData objects */ function loadPackageList() { + $this->ui->_widget_packages_install->set_sensitive(0); + $this->widget->set_row_height(18); + $this->widget->set_expander_style(GTK_CTREE_EXPANDER_TRIANGLE); + $this->widget->set_line_style( GTK_CTREE_LINES_NONE); + + for($i=0;$i<4;$i++) + $this->widget->set_column_auto_resize($i,TRUE); + //while(gtk::events_pending()) gtk::main_iteration(); $this->widget->clear(); $this->widget->freeze(); - + $this->_categoryNodes = array(); foreach (array_keys($this->packages) as $packagename) { + $package = &$this->packages[$packagename]; $parent = $this->_getCategoryNode($package); - $package->CreateNode($this->widget,$parent); + //echo serialize($parent); + $package->ui = &$this->ui; + $package->createNode($parent); } $this->widget->thaw(); @@ -456,19 +246,33 @@ */ function &_getCategoryNode(&$package) { $ret = NULL; - if ($package->category == $package->name) + + // work out category if it does not exist!!!! + $category = $package->name; + $parts = explode('_',$package->name); + if ($parts[0]) + $category = $parts[0]; + $categoryName = $category; + if ($package->category) + $categoryName = $package->category; + + + //echo "GOT: {$package->name}:$categoryName:$category:\n"; + + + if ($category == $package->name) return $ret; - if (@$this->_categoryNodes[$package->category]) - return $this->_categoryNodes[$package->category]; + if (@$this->_categoryNodes[$category]) + return $this->_categoryNodes[$category]; - if (@$this->packages[$package->category]) - return $this->packages[$package->category]->cTreeNode; + if (@$this->packages[$category]) + return $this->packages[$category]->gtknode; - $this->_CategoryNodes[$package->category] = $this->widget->insert_node( + $this->_categoryNodes[$category] = $this->widget->insert_node( NULL, NULL, //parent, sibling - array($package->category, '','','','',''),5, + array($categoryName, '','',''),5, $this->ui->_pixmaps['folder_closed.xpm'][0], $this->ui->_pixmaps['folder_closed.xpm'][1], $this->ui->_pixmaps['folder_open.xpm'][0], @@ -476,7 +280,7 @@ false,true ); - return $this->_categoryNodes[$package->category]; + return $this->_categoryNodes[$category]; } Index: pear/PEAR_Frontend_Gtk/Gtk/Summary.php diff -u pear/PEAR_Frontend_Gtk/Gtk/Summary.php:1.4 pear/PEAR_Frontend_Gtk/Gtk/Summary.php:1.5 --- pear/PEAR_Frontend_Gtk/Gtk/Summary.php:1.4 Sun Jun 2 03:19:38 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/Summary.php Mon Jun 3 06:10:45 2002 @@ -16,7 +16,7 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Summary.php,v 1.4 2002/06/02 07:19:38 alan_k Exp $ + $Id: Summary.php,v 1.5 2002/06/03 10:10:45 alan_k Exp $ */ /** @@ -38,7 +38,6 @@ function PEAR_Frontend_Gtk_Summary(&$ui) { $this->ui = &$ui; - $this->ui->_widget_close_details->connect_object('pressed',array(&$this,'hide')); } /* @@ -64,11 +63,11 @@ /* * show the details tab */ - function show(&$package_info) { + function show(&$package) { $this->ui->_widget_details_area->show(); - $this->active_package = $package_info; + $this->active_package = &$package; //$this->ui->_widget_install->set_sensitive(1); - foreach($package_info as $k=>$v) { + foreach(get_object_vars($package) as $k=>$v) { $v = str_replace("\r", '',$v); $var = "_widget_".strtolower($k); if (!is_object(@$this->ui->$var)) continue; @@ -85,13 +84,13 @@ } } - $this->_detailsVisableFlag = $package_info['package']; + $this->_detailsVisableFlag = $package->name; } - function toggle($package_info) { - if ($this->_detailsVisableFlag != $package_info['package']) { - $this->show($package_info); + function toggle(&$package) { + if ($this->_detailsVisableFlag != $package->name) { + $this->show($package); return; } $this->hide(); Index: pear/PEAR_Frontend_Gtk/Gtk/installer.glade diff -u pear/PEAR_Frontend_Gtk/Gtk/installer.glade:1.7 pear/PEAR_Frontend_Gtk/Gtk/installer.glade:1.8 --- pear/PEAR_Frontend_Gtk/Gtk/installer.glade:1.7 Sun Jun 2 11:58:58 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/installer.glade Mon Jun 3 06:10:45 2002 @@ -20,13 +20,13 @@ <visible>False</visible> <signal> <name>destroy</name> - <handler>on_quit</handler> - <last_modification_time>Wed, 29 May 2002 10:52:35 GMT</last_modification_time> + <handler>_onQuit</handler> + <last_modification_time>Mon, 03 Jun 2002 07:03:48 GMT</last_modification_time> </signal> <signal> <name>delete_event</name> - <handler>on_quit</handler> - <last_modification_time>Wed, 29 May 2002 10:52:17 GMT</last_modification_time> + <handler>_onQuit</handler> + <last_modification_time>Mon, 03 Jun 2002 07:04:16 GMT</last_modification_time> </signal> <title>PEAR Package Manager</title> <type>GTK_WINDOW_TOPLEVEL</type> @@ -111,8 +111,8 @@ </accelerator> <signal> <name>activate</name> - <handler>on_quit</handler> - <last_modification_time>Wed, 29 May 2002 10:51:12 GMT</last_modification_time> + <handler>_onQuit</handler> + <last_modification_time>Mon, 03 Jun 2002 07:04:11 GMT</last_modification_time> </signal> <label>_Quit</label> <right_justify>False</right_justify> @@ -140,8 +140,8 @@ </accelerator> <signal> <name>activate</name> - <handler>on_expand_all_activate</handler> - <last_modification_time>Mon, 27 May 2002 04:09:37 GMT</last_modification_time> + <handler>_packages_expandAll</handler> + <last_modification_time>Mon, 03 Jun 2002 07:01:02 GMT</last_modification_time> </signal> <label>Expand All</label> <right_justify>False</right_justify> @@ -149,7 +149,7 @@ <widget> <class>GtkMenuItem</class> - <name>expand_all</name> + <name>collapse_all</name> <accelerator> <modifiers>GDK_CONTROL_MASK</modifiers> <key>GDK_-</key> @@ -157,8 +157,8 @@ </accelerator> <signal> <name>activate</name> - <handler>on_collapse_all_activate</handler> - <last_modification_time>Wed, 29 May 2002 10:46:10 GMT</last_modification_time> + <handler>_packages_collapseAll</handler> + <last_modification_time>Mon, 03 Jun 2002 07:02:03 GMT</last_modification_time> </signal> <label>Collapse All</label> <right_justify>False</right_justify> @@ -267,8 +267,8 @@ <name>preferences</name> <signal> <name>activate</name> - <handler>on_preferences_activate</handler> - <last_modification_time>Mon, 27 May 2002 04:09:37 GMT</last_modification_time> + <handler>_callbackShowConfig</handler> + <last_modification_time>Mon, 03 Jun 2002 08:12:04 GMT</last_modification_time> </signal> <label>_Preferences</label> <right_justify>False</right_justify> @@ -533,7 +533,7 @@ <widget> <class>GtkScrolledWindow</class> - <name>package_list_holder</name> + <name>scrolledwindow16</name> <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy> <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> @@ -545,7 +545,71 @@ </child> <widget> - <class>Placeholder</class> + <class>GtkCTree</class> + <name>_packages_widget</name> + <can_focus>True</can_focus> + <signal> + <name>tree_select_row</name> + <handler>_packages_callbackSelectRow</handler> + <last_modification_time>Mon, 03 Jun 2002 05:49:10 GMT</last_modification_time> + </signal> + <columns>4</columns> + <column_widths>80,80,80,80</column_widths> + <selection_mode>GTK_SELECTION_BROWSE</selection_mode> + <show_titles>True</show_titles> + <shadow_type>GTK_SHADOW_IN</shadow_type> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label67</name> + <label>Package</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label68</name> + <label>Installed</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label69</name> + <label>New</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label70</name> + <label>Summary</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> </widget> </widget> @@ -722,6 +786,11 @@ <width>0</width> <height>0</height> <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_install_start</handler> + <last_modification_time>Mon, 03 Jun 2002 05:16:53 GMT</last_modification_time> + </signal> <label>Download And Install >></label> <relief>GTK_RELIEF_NORMAL</relief> </widget> @@ -851,7 +920,7 @@ <widget> <class>GtkScrolledWindow</class> - <name>scrolledwindow11</name> + <name>another_scrollwin</name> <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> @@ -864,10 +933,10 @@ <widget> <class>GtkCList</class> - <name>download_list</name> + <name>_install_downloadList</name> <can_focus>True</can_focus> - <columns>3</columns> - <column_widths>80,80,80</column_widths> + <columns>4</columns> + <column_widths>80,80,80,80</column_widths> <selection_mode>GTK_SELECTION_SINGLE</selection_mode> <show_titles>False</show_titles> <shadow_type>GTK_SHADOW_IN</shadow_type> @@ -875,8 +944,21 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label47</name> - <label>label47</label> + <name>label72</name> + <label>label72</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label73</name> + <label>label73</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -888,8 +970,8 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label48</name> - <label>label48</label> + <name>label74</name> + <label>label74</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -901,8 +983,8 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label49</name> - <label>label49</label> + <name>label75</name> + <label>label75</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -969,7 +1051,7 @@ <widget> <class>GtkLabel</class> - <name>downloading_filename</name> + <name>_install_fileDownloadLabel</name> <label>Downloading XXXXXXXX</label> <justify>GTK_JUSTIFY_LEFT</justify> <wrap>False</wrap> @@ -986,7 +1068,7 @@ <widget> <class>GtkProgressBar</class> - <name>downloading_file_progressbar</name> + <name>_install_fileProgressBar</name> <value>0</value> <lower>0</lower> <upper>100</upper> @@ -1006,7 +1088,7 @@ <widget> <class>GtkLabel</class> - <name>downloading_total</name> + <name>_install_totalDownloadLabel</name> <label>Total</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> @@ -1023,7 +1105,7 @@ <widget> <class>GtkProgressBar</class> - <name>downloading_total_progressbar</name> + <name>_install_totalProgressBar</name> <value>0</value> <lower>0</lower> <upper>100</upper> @@ -1063,6 +1145,11 @@ <sensitive>False</sensitive> <can_default>True</can_default> <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_install_callbackDone</handler> + <last_modification_time>Mon, 03 Jun 2002 05:41:04 GMT</last_modification_time> + </signal> <label>Done</label> <relief>GTK_RELIEF_NORMAL</relief> </widget> @@ -1210,7 +1297,7 @@ <widget> <class>GtkNotebook</class> - <name>config_notebook</name> + <name>_config_notebook</name> <can_focus>True</can_focus> <show_tabs>True</show_tabs> <show_border>True</show_border> @@ -1245,7 +1332,7 @@ <widget> <class>GtkLabel</class> - <name>config_help</name> + <name>_config_help</name> <height>40</height> <label>Help text</label> <justify>GTK_JUSTIFY_LEFT</justify> @@ -1279,13 +1366,13 @@ <widget> <class>GtkButton</class> - <name>config_reset</name> + <name>_config_reset</name> <can_default>True</can_default> <can_focus>True</can_focus> <signal> <name>clicked</name> - <handler>_loadConfig</handler> - <last_modification_time>Fri, 31 May 2002 06:13:05 GMT</last_modification_time> + <handler>_config_loadConfig</handler> + <last_modification_time>Mon, 03 Jun 2002 07:44:39 GMT</last_modification_time> </signal> <label>Reset</label> <relief>GTK_RELIEF_NORMAL</relief> @@ -1293,9 +1380,14 @@ <widget> <class>GtkButton</class> - <name>config_save</name> + <name>_config_save</name> <can_default>True</can_default> <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_config_saveConfig</handler> + <last_modification_time>Mon, 03 Jun 2002 07:44:59 GMT</last_modification_time> + </signal> <label>Save</label> <relief>GTK_RELIEF_NORMAL</relief> </widget> @@ -1331,19 +1423,19 @@ <widget> <class>GtkDialog</class> - <name>dir_selection</name> + <name>_dirselect_window</name> <width>200</width> <height>400</height> <visible>False</visible> <signal> <name>delete_event</name> - <handler>_onDirSelectionCancel</handler> - <last_modification_time>Fri, 31 May 2002 03:41:05 GMT</last_modification_time> + <handler>_dirselect_onCancel</handler> + <last_modification_time>Mon, 03 Jun 2002 07:41:07 GMT</last_modification_time> </signal> <signal> <name>destroy</name> - <handler>_onDirSelectionCancel</handler> - <last_modification_time>Fri, 31 May 2002 05:50:41 GMT</last_modification_time> + <handler>_dirselect_onCancel</handler> + <last_modification_time>Mon, 03 Jun 2002 07:41:00 GMT</last_modification_time> </signal> <title>dialog1</title> <type>GTK_WINDOW_DIALOG</type> @@ -1397,8 +1489,8 @@ <can_focus>True</can_focus> <signal> <name>clicked</name> - <handler>_onDirSelectionOk</handler> - <last_modification_time>Fri, 31 May 2002 03:43:58 GMT</last_modification_time> + <handler>_dirselect_onOk</handler> + <last_modification_time>Mon, 03 Jun 2002 07:40:54 GMT</last_modification_time> </signal> <label>OK</label> <relief>GTK_RELIEF_NORMAL</relief> @@ -1411,8 +1503,8 @@ <can_focus>True</can_focus> <signal> <name>clicked</name> - <handler>_onDirSelectionCancel</handler> - <last_modification_time>Fri, 31 May 2002 03:35:53 GMT</last_modification_time> + <handler>_dirselect_onCancel</handler> + <last_modification_time>Mon, 03 Jun 2002 07:40:43 GMT</last_modification_time> </signal> <label>Cancel</label> <relief>GTK_RELIEF_NORMAL</relief> @@ -1434,7 +1526,7 @@ <widget> <class>GtkOptionMenu</class> - <name>dir_selection_optionmenu</name> + <name>_dirselect_optionMenu</name> <border_width>5</border_width> <can_focus>True</can_focus> <items></items> @@ -1461,17 +1553,17 @@ <widget> <class>GtkCList</class> - <name>dir_selection_clist</name> + <name>_dirselect_cList</name> <can_focus>True</can_focus> <signal> <name>select_row</name> - <handler>_onDirListSelectRow</handler> - <last_modification_time>Fri, 31 May 2002 03:37:01 GMT</last_modification_time> + <handler>_dirselect_onDirListSelectRow</handler> + <last_modification_time>Mon, 03 Jun 2002 07:26:34 GMT</last_modification_time> </signal> <signal> <name>button_press_event</name> - <handler>_onDirListClick</handler> - <last_modification_time>Fri, 31 May 2002 03:37:34 GMT</last_modification_time> + <handler>_dirselect_onDirListClick</handler> + <last_modification_time>Mon, 03 Jun 2002 07:26:31 GMT</last_modification_time> </signal> <columns>1</columns> <column_widths>80</column_widths> @@ -1513,7 +1605,7 @@ <widget> <class>GtkEntry</class> - <name>dir_selection_entry</name> + <name>_dirselect_entry</name> <can_focus>True</can_focus> <editable>False</editable> <text_visible>True</text_visible> @@ -1523,6 +1615,128 @@ <padding>0</padding> <expand>False</expand> <fill>False</fill> + </child> + </widget> + </widget> + </widget> +</widget> + +<widget> + <class>GtkDialog</class> + <name>_info_window</name> + <visible>False</visible> + <signal> + <name>destroy</name> + <handler>_info_close</handler> + <last_modification_time>Mon, 03 Jun 2002 07:49:43 GMT</last_modification_time> + </signal> + <signal> + <name>delete_event</name> + <handler>_info_close</handler> + <last_modification_time>Mon, 03 Jun 2002 07:49:53 GMT</last_modification_time> + </signal> + <title>dialog1</title> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_MOUSE</position> + <modal>True</modal> + <allow_shrink>True</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + + <widget> + <class>GtkVBox</class> + <child_name>Dialog:vbox</child_name> + <name>dialog-vbox2</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkHBox</class> + <child_name>Dialog:action_area</child_name> + <name>dialog-action_area2</name> + <border_width>10</border_width> + <homogeneous>True</homogeneous> + <spacing>5</spacing> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkHButtonBox</class> + <name>hbuttonbox4</name> + <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style> + <spacing>30</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkButton</class> + <name>button21</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_info_close</handler> + <last_modification_time>Mon, 03 Jun 2002 07:49:22 GMT</last_modification_time> + </signal> + <label>OK</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + </widget> + </widget> + + <widget> + <class>GtkHBox</class> + <name>hbox11</name> + <border_width>23</border_width> + <homogeneous>False</homogeneous> + <spacing>8</spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkHBox</class> + <name>_info_iconholder</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>Placeholder</class> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <name>_info_label</name> + <label>Prompt</label> + <justify>GTK_JUSTIFY_LEFT</justify> + <wrap>True</wrap> + <xalign>0</xalign> + <yalign>0</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> </child> </widget> </widget> Index: pear/PEAR_Frontend_Gtk/Gtk/Config.php +++ pear/PEAR_Frontend_Gtk/Gtk/Config.php <? /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ $Id: Config.php,v 1.1 2002/06/03 10:10:45 alan_k Exp $ */ /** * Gtk Frontend - Configuration * * @author Alan Knowles <alan@akbkhome.com> */ class PEAR_Frontend_Gtk_Config { var $ui; // main interface /** * The GtkLabel that shows the help config * * @var object GtkLabel configuration help text * @access private */ var $help; /** * The GtkNotebook that has all the tabs * * @var object Gtknotebook * @access private */ var $notebook; /** * The Save GtkButton * * @var object GtkButton * @access private */ var $save; /** * The Reset GtkButton * * @var object GtkButton * @access private */ var $reset; /** * Constructor * * @param array see config-show for more details. */ function PEAR_Frontend_Gtk_Config(&$ui) { $this->ui = &$ui; } /** * Load Configuration into widgets (Initialize) * * Clear current config tabs, and calls the Command Show-config * * @param object getbutton from the reset button! * @param string no idea yet! */ function loadConfig($widget=NULL,$what=NULL) { if ($this->_configTabs) foreach (array_keys($this->_configTabs) as $k) { $page = $this->notebook->page_num($this->_configTabs[$k]); $this->notebook->remove_page($page); $this->_configTabs[$k]->destroy(); } // delete any other pages; if ($widget = $this->notebook->get_nth_page(0)) { $this->notebook->remove_page(0); $widget->destroy(); } $this->_configTabs = array(); $cmd = PEAR_Command::factory('config-show',$this->ui->config); $cmd->ui = &$this->ui; $cmd->run('config-show' ,'', array()); $this->save->set_sensitive(FALSE); $this->reset->set_sensitive(FALSE); } /** * Build the widgets based on the return 'data' array from config-show * * @param array see config-show for more details. */ function buildConfig(&$array) { if (!$array) return; foreach ($array as $group=>$items) foreach ($items as $v) { $this->_buildConfigItem($v[1],$v[2]); } } /** * Build the widgets for a configuration item * * @param string configuration 'key' * @param string configuration 'value' */ function _buildConfigItem($k,$v) { //echo "BUIDLING CONF ITME $k $v\n"; $group = $this->ui->config->getGroup($k); $gtktable = $this->_getConfigTab($group); $prompt = $this->ui->config->getPrompt($k); $gtklabel = &new GtkLabel(); $gtklabel->set_text($prompt); $gtklabel->set_justify(GTK_JUSTIFY_LEFT); $gtklabel->set_alignment(0.0, 0.5); $gtklabel->show(); $r = $gtktable->nrows; $gtktable->attach($gtklabel, 0, 1, $r, $r+1, GTK_FILL,GTK_FILL); if ($v == '<not set>') $v = ''; $type = $this->ui->config->getType($k); switch ($type) { case 'string': case 'password': case 'int': // umask: should really be checkboxes.. $gtkentry = &new GtkEntry(); $gtkentry->set_text($v); $gtkentry->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); $gtkentry->connect_object_after('changed', array(&$this,'_ActivateConfigSave')); if ($type == 'password') $gtkentry->set_visibility(FALSE); $gtkentry->show(); $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); break; case 'directory': $gtkentry = &new GtkEntry(); $gtkentry->set_text($v); $gtkentry->set_editable(FALSE); $gtkentry->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); // store in object data the configuration tag $gtkentry->set_data('key',$k); $gtkentry->show(); $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); $gtkbutton = &new GtkButton('...'); $gtkbutton->connect_object_after('clicked', array(&$this->ui->_dirselect,'onDirSelect'),$gtkentry); $gtkbutton->show(); $gtktable->attach($gtkbutton, 2, 3, $r, $r+1, GTK_SHRINK,GTK_SHRINK); break; case 'set': $options = $this->ui->config->getSetValues($k); $gtkmenu = &new GtkMenu(); $items = array(); $sel = 0; foreach($options as $i=>$option) { $items[$i] = &new GtkMenuItem($option); //$items[$i]->connect('activate', 'echo_activated', $labels[$i], $pos[$i], $gtkmenu->append($items[$i]); if ($option == $v) $sel = $i; } $gtkmenu->set_active($sel); $gtkmenu->show_all(); $gtkoptionmenu = &new GtkOptionMenu(); $gtkoptionmenu->set_menu($gtkmenu); $gtkoptionmenu->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); $gtkoptionmenu->show(); $gtktable->attach($gtkoptionmenu, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); break; // debug: shourd really be case 'integer': // debug : should really be a set? $gtkadj = &new GtkAdjustment($v, 0.0, 3.0, 1.0, 1.0, 0.0); $gtkspinbutton = &new GtkSpinButton($gtkadj); $gtkspinbutton->show(); $gtkspinbutton->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); $gtktable->attach($gtkspinbutton, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); break; default: echo "$prompt : ". $this->ui->config->getType($k) . "\n"; } } /** * Show the help text for a widget * * @param object gtkevent name of group tab * @param string help text */ function _setConfigHelp($event,$string) { $this->help->set_text($string); } /** * The GtkTables relating to the groups * * @var array associative array of groupname -> gtktable * @access private */ var $_configTabs = array(); // associative array of configGroup -> GtkTable /** * Get (or Make) A 'Group' Config Tab on the config notebook * * @param string name of group tab * @param string no idea yet! * @return object GtkTable table which config elements are added to. */ function &_getConfigTab($group) { if (@$this->_configTabs[$group]) return $this->_configTabs[$group]; $this->_configTabs[$group] = &new GtkTable(); $this->_configTabs[$group]->set_row_spacings(10); $this->_configTabs[$group]->set_col_spacings(10); $this->_configTabs[$group]->set_border_width(15); $this->_configTabs[$group]->show(); $gtklabel = &new GtkLabel($group); $gtklabel->show(); $this->notebook->append_page($this->_configTabs[$group],$gtklabel); return $this->_configTabs[$group]; } /** * Make the Save and reset buttons pressable. * */ function ActivateConfigSave() { $this->save->set_sensitive(TRUE); $this->reset->set_sensitive(TRUE); } function saveConfig() { //mmh now what :) } } ?> Index: pear/PEAR_Frontend_Gtk/Gtk/DirSelect.php +++ pear/PEAR_Frontend_Gtk/Gtk/DirSelect.php <? /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ $Id: DirSelect.php,v 1.1 2002/06/03 10:10:45 alan_k Exp $ */ /** * Gtk Frontend - Configuration * * @author Alan Knowles <alan@akbkhome.com> */ class PEAR_Frontend_Gtk_DirSelect { var $ui; // main interface /** * The GtkEntry that shows the currently seelcted directory * * @var object GtkEntry */ var $entry; /** * The GtkDialog of the window * * @var object GtkDialog */ var $window; /** * The Top pulldown * * @var object GtkOptionMenu */ var $optionMenu; /** * The full list of directories * * @var object GtkClist */ var $cList; /** * Constructor * * @param object PEAR_Frontend_Gtk */ function PEAR_Frontend_Gtk_DirSelect(&$ui) { $this->ui = &$ui; } /** * Currently active widget to save result into (eg. gtkentry) * * @var object gtkentry * @access private */ var $_DirSelectActiveWidget = NULL; /** * Display the Directory selection dialog * * Displays the directory dialog, fills in the data etc. * * @param object gtkentry The text entry to fill in on closing * */ function onDirSelect($widget) { // set the title!! $this->_DirSelectActiveWidget = &$widget; $prompt = 'xxx'; $prompt = $this->ui->config->getPrompt($widget->get_data('key')); $this->window->set_title($prompt); $curvalue = $widget->get_text(); // load the pulldown $this->_DirSelectSetDir(dirname($curvalue), basename($curvalue)); $this->entry->set_text($curvalue); $this->window->show(); } /** * Associated array of Row -> directory name * * It could be possible to get the row string using gtk calls...... * * @var array * @access private */ var $_DirSelectRows = array(); /** * Load the directories into the directory list/pulldown etc. * * Loads the information into the popup / list of directories * TODO: Windows A:D: etc. drive support * * @param string $directory name of directory to browse * @param string $file name of file to select in list. * */ function _DirSelectSetDir($directory, $file='.') { $parts = explode(DIRECTORY_SEPARATOR, $directory); $disp = array(); $i=0; $items = array(); $gtkmenu = &new GtkMenu(); foreach($parts as $dirpart) { $disp[] = $dirpart; $dir = implode(DIRECTORY_SEPARATOR,$disp); if (!$dir && DIRECTORY_SEPARATOR == '/') $dir = '/'; if (!$dir) continue; $items[$i] = &new GtkMenuItem($dir); $items[$i]->connect_object_after('activate', array(&$this,'_DirSelectSetDir'),$dir); $gtkmenu->append($items[$i]); $i++; } $gtkmenu->set_active($i-1); $gtkmenu->show_all(); $this->optionMenu->set_menu($gtkmenu); $base = $directory; $this->cList->select_row(0,0); $this->cList->freeze(); $this->cList->clear(); clearstatcache(); $dh = opendir($base); $dirs = array(); while (($dir = readdir($dh)) !== FALSE) { if (!is_dir($base.DIRECTORY_SEPARATOR.$dir)) continue; $dirs[] = $dir; } sort($dirs); $this->_DirSelectRows = array(); $sel =0; $i=0; foreach($dirs as $dir) { $this->cList->append(array($dir)); $this->_DirSelectRows[] = realpath($base.DIRECTORY_SEPARATOR.$dir); if ($dir == $file) $sel = $i; $i++; } $this->cList->thaw(); if ($file != '.') { $this->cList->select_row($sel,0); $this->cList->moveto($i,0,0,0); $this->entry->set_text($directory); } else { $this->_DirListBlockSel = TRUE; $this->cList->select_row(0,0); $this->_DirListBlockSel = TRUE; } } /** * Flag to block reselecting of current row after update * * Introduced to attempt to fix problem that when you double click to open a * Directory, after refresh, the clist recieves a select signal on the same rows * and hence attemps to select the wrong directory.. * * @var boolean * @access private */ var $_DirListBlockSel = FALSE; /** * Initial Select Row (not double click) * * Makes this selected item the 'active directory' * * @param string $directory name of directory to browse * @param string $row selected line * */ function onDirListSelectRow($widget,$row) { if ($this->_DirListBlockSel) { $this->_DirListBlockSel = FALSE; $widget->select_row(0,0); return; } if ($row < 0) return; $this->entry->set_text($this->_DirSelectRows[$row]); } /** * Callback when the list of directories is clicked * * Used to find the double click to open it. * * @param object gtkclist * @param object gdkevent * */ function onDirListClick($widget,$event) { if ($event->type != 5) return; $this->_DirSelectSetDir($this->entry->get_text()); } /** * Callback when the cancel/destroy window is pressed * * has to return TRUE (see the gtk tutorial on destroy events) * * */ function onCancel() { $this->window->hide(); return TRUE; } /** * Callback when the OK btn is pressed * * hide window and update original widget. * */ function onOk() { if (!$this->_DirSelectActiveWidget) return; $new= $this->entry->get_text(); $old= $this->_DirSelectActiveWidget->get_text(); if ($new != $old) { $this->_DirSelectActiveWidget->set_text($new); $this->ui->_config->ActivateConfigSave(); } $this->_DirSelectActiveWidget = NULL; $this->window->hide(); } } ?> Index: pear/PEAR_Frontend_Gtk/Gtk/Info.php +++ pear/PEAR_Frontend_Gtk/Gtk/Info.php <? /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ $Id: Info.php,v 1.1 2002/06/03 10:10:45 alan_k Exp $ */ /** * Gtk Frontend -Directory Selection * * @author Alan Knowles <alan@akbkhome.com> */ class PEAR_Frontend_Gtk_Info { var $ui; // main interface /** * holder for the icon * * @var object GtkVbox */ var $iconholder; /** * The text of the message * * @var object GtkLabel */ var $label; /** * The Top pulldown * * @var object GtkOptionMenu */ var $window; var $_message = ""; // the current message /** * Constructor * * @param object PEAR_Frontend_Gtk */ function PEAR_Frontend_Gtk_Info(&$ui) { $this->ui = &$ui; } function show($message) { $this->_message .= $message . "\n"; $this->window->set_title("MESSAGE"); $this->label->set_text($this->_message); $this->window->show(); $this->isShow = TRUE; } function close() { $this->window->hide(); $this->_message = ""; return TRUE; } } ?>
Index: pear/PEAR_Frontend_Gtk/Gtk.php diff -u pear/PEAR_Frontend_Gtk/Gtk.php:1.12 pear/PEAR_Frontend_Gtk/Gtk.php:1.13 --- pear/PEAR_Frontend_Gtk/Gtk.php:1.12 Sun Jun 2 11:58:58 2002 +++ pear/PEAR_Frontend_Gtk/Gtk.php Mon Jun 3 06:10:45 2002 @@ -16,14 +16,16 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Gtk.php,v 1.12 2002/06/02 15:58:58 alan_k Exp $ + $Id: Gtk.php,v 1.13 2002/06/03 10:10:45 alan_k Exp $ */ require_once "PEAR.php"; require_once "PEAR/Frontend/Gtk/Packages.php"; require_once "PEAR/Frontend/Gtk/Summary.php"; require_once "PEAR/Frontend/Gtk/Install.php"; - +require_once "PEAR/Frontend/Gtk/Config.php"; +require_once "PEAR/Frontend/Gtk/DirSelect.php"; +require_once "PEAR/Frontend/Gtk/Info.php"; /** * Core Gtk Frontend Class @@ -77,6 +79,13 @@ dl('php_gtk.' . (OS_WINDOWS ? 'dll' : 'so')); } //echo "LOADED?"; + $this->config = &PEAR_Config::singleton('',''); + $this->_summary = &new PEAR_Frontend_Gtk_Summary($this); + $this->_install = &new PEAR_Frontend_Gtk_Install($this); + $this->_packages = &new PEAR_Frontend_Gtk_Packages($this); + $this->_config = &new PEAR_Frontend_Gtk_Config($this); + $this->_dirselect = &new PEAR_Frontend_Gtk_DirSelect($this); + $this->_info = &new PEAR_Frontend_Gtk_Info($this); $this->_loadGlade(); $this->_initInterface(); } @@ -101,16 +110,35 @@ $this->_glade = &new GladeXML($file); $data = implode('',file($file)); preg_match_all('/\<name\>([^\<]+)\<\/name\>/',$data,$items); - foreach ($items[1] as $widgetname) { + foreach ($items[1] as $widgetname) { + $args = array(); + if (preg_match('/^(_install|_packages|_summary|_config|_dirselect|_info)_(.*)$/',$widgetname,$args)) { + $obj = $args[1]; + $varname= $args[2]; + //echo "ASSIGN $obj $varname to $widgetname\n"; + $this->$obj->$varname = $this->_glade->get_widget($widgetname); + continue; + } $varname = "_widget_".$widgetname; $this->$varname = $this->_glade->get_widget($widgetname); } $items = array(); preg_match_all('/\<handler\>([^\<]+)\<\/handler\>/',$data,$items); //print_r($items[1]); - foreach ($items[1] as $handler) + foreach ($items[1] as $handler) { + $args = array(); + if (preg_match('/^(_install|_packages|_summary|_config|_dirselect|_info)_(.*)$/',$handler,$args)) { + $obj = $args[1]; + $method= $args[2]; + //echo "CONNECT $obj $method to $handler\n"; + if (!method_exists($this->$obj,$method)) + exit; // programming error! + $this->_glade->signal_connect($handler ,array(&$this->$obj,$method)); + continue; + } if (method_exists($this,$handler)) $this->_glade->signal_connect( $handler ,array(&$this,$handler)); + } @@ -135,20 +163,36 @@ */ var $_install; /** + * the class manages config tahs + * @var object PEAR_Frontend_Gtk_Config + * @access private + */ + var $_install; + /** + * the class manages directory selection + * @var object PEAR_Frontend_Gtk_DirSelect + * @access private + */ + var $_dirselect; + + /** + * the class manages simple info prompts + * @var object PEAR_Frontend_Gtk_Info + * @access private + */ + var $_info; + + /** * Load and initialize the sub modules * * @access private */ + + function _initInterface() { // must be a better way - still needs to read -c -C optss - $this->config = &PEAR_Config::singleton('',''); - // initialize child objects - - $this->_packages = &new PEAR_Frontend_Gtk_Packages($this); - $this->_summary = &new PEAR_Frontend_Gtk_Summary($this); - $this->_install = &new PEAR_Frontend_Gtk_Install($this); - + $this->_widget_window->connect_after('realize',array(&$this,'_callbackWindowConfigure')); $this->_widget_window->connect_after('configure_event',array(&$this,'_callbackWindowConfigure')); @@ -184,12 +228,16 @@ $this->_setStyle('config_button','#000000','#7b7d7a'); $this->_setStyle('documentation_button','#000000','#7b7d7a'); + /* package stuff */ + + $this->_packages->loadPackageList(); + $this->_setStyle('black_bg1','#FFFFFF','#000000',TRUE); $this->_setStyle('black_bg2','#FFFFFF','#000000',TRUE); $this->_setStyle('black_bg3','#FFFFFF','#000000',TRUE); $this->_setStyle('black_bg4','#FFFFFF','#000000',TRUE); - $this->_setStyle('download_list','#000000','#FFFFFF',TRUE); + //$this->_setStyle('download_list','#000000','#FFFFFF',TRUE); $this->_setStyle('close_details','#FFFFFF','#000000',FALSE); // sort out the text. @@ -236,7 +284,7 @@ /* configuration loading */ - $this->_loadConfig(); + $this->_config->loadConfig(); $this->_setStyle('config_logo','#000000','#339900',TRUE); $this->_setStyle('config_logo_text','#FFFFFF','#339900'); @@ -259,7 +307,7 @@ */ function _loadButton($widgetname, $icon) { - echo $widgetname; + //echo $widgetname; $widget_fullname = "_widget_". $widgetname; $widget = &$this->$widget_fullname; @@ -297,7 +345,7 @@ * @access private */ function _setStyle($widgetname,$fgcolor='',$bgcolor='',$copy=FALSE) { - echo "SET: $widgetname: $fgcolor/$bgcolor ". ((int) $copy) . "\n"; + //echo "SET: $widgetname: $fgcolor/$bgcolor ". ((int) $copy) . "\n"; $widget_fullname = "_widget_". $widgetname; $widget = &$this->$widget_fullname; if ($copy) { @@ -366,22 +414,11 @@ } } - /* - * Menu Callback - expand all - */ - function on_expand_all_activate() { - $this->_packages->widget->expand_recursive(); - } - /* - * Menu Callback - colllapse all - */ - function on_collapse_all_activate() { - $this->_packages->widget->collapse_recursive(); - } + /* * Menu Callback - Exit/Quit */ - function on_quit() { + function _onQuit() { gtk::main_quit(); exit; } @@ -409,374 +446,9 @@ $this->_install->_downloadCallback($msg, $params); } - - /*---------------- Configuration Building stuff -----------------------*/ - - /** - * Build the widgets based on the return 'data' array from config-show - * - * @param array see config-show for more details. - */ - function _buildConfig(&$array) { - if (!$array) return; - foreach ($array as $group=>$items) - foreach ($items as $v) { - $this->_buildConfigItem($v[1],$v[2]); - } - - } - /** - * Build the widgets for a configuration item - * - * @param string configuration 'key' - * @param string configuration 'value' - */ - function _buildConfigItem($k,$v) { - echo "BUIDLING CONF ITME $k $v\n"; - $group = $this->config->getGroup($k); - $gtktable = $this->_getConfigTab($group); - $prompt = $this->config->getPrompt($k); - $gtklabel = &new GtkLabel(); - $gtklabel->set_text($prompt); - $gtklabel->set_justify(GTK_JUSTIFY_LEFT); - $gtklabel->set_alignment(0.0, 0.5); - $gtklabel->show(); - $r = $gtktable->nrows; - $gtktable->attach($gtklabel, 0, 1, $r, $r+1, GTK_FILL,GTK_FILL); - if ($v == '<not set>') - $v = ''; - - $type = $this->config->getType($k); - switch ($type) { - case 'string': - case 'password': - case 'int': // umask: should really be checkboxes.. - $gtkentry = &new GtkEntry(); - $gtkentry->set_text($v); - - $gtkentry->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - $gtkentry->connect_object_after('changed', array(&$this,'_ActivateConfigSave')); - if ($type == 'password') - $gtkentry->set_visibility(FALSE); - $gtkentry->show(); - $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - break; - case 'directory': - $gtkentry = &new GtkEntry(); - $gtkentry->set_text($v); - $gtkentry->set_editable(FALSE); - $gtkentry->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - // store in object data the configuration tag - $gtkentry->set_data('key',$k); - $gtkentry->show(); - $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - $gtkbutton = &new GtkButton('...'); - $gtkbutton->connect_object_after('clicked', array(&$this,'_onDirSelect'),$gtkentry); - $gtkbutton->show(); - $gtktable->attach($gtkbutton, 2, 3, $r, $r+1, GTK_SHRINK,GTK_SHRINK); - break; - case 'set': - $options = $this->config->getSetValues($k); - $gtkmenu = &new GtkMenu(); - $items = array(); - $sel = 0; - foreach($options as $i=>$option) { - $items[$i] = &new GtkMenuItem($option); - //$items[$i]->connect('activate', 'echo_activated', $labels[$i], $pos[$i], - $gtkmenu->append($items[$i]); - if ($option == $v) - $sel = $i; - } - $gtkmenu->set_active($sel); - $gtkmenu->show_all(); - $gtkoptionmenu = &new GtkOptionMenu(); - $gtkoptionmenu->set_menu($gtkmenu); - $gtkoptionmenu->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - - $gtkoptionmenu->show(); - $gtktable->attach($gtkoptionmenu, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - break; - // debug: shourd really be - case 'integer': // debug : should really be a set? - $gtkadj = &new GtkAdjustment($v, 0.0, 3.0, 1.0, 1.0, 0.0); - $gtkspinbutton = &new GtkSpinButton($gtkadj); - $gtkspinbutton->show(); - $gtkspinbutton->connect_object_after('enter_notify_event', - array(&$this,'_setConfigHelp'),$this->config->getDocs($k)); - - $gtktable->attach($gtkspinbutton, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); - break; - default: - echo "$prompt : ". $this->config->getType($k) . "\n"; - } - - } - /** - * Show the help text for a widget - * - * @param object gtkevent name of group tab - * @param string help text - */ - function _setConfigHelp($event,$string) { - $this->_widget_config_help->set_text($string); - } - /** - * The GtkTables relating to the groups - * - * @var array associative array of groupname -> gtktable - * @access private - */ - var $_configTabs = array(); // associative array of configGroup -> GtkTable - /** - * Get (or Make) A 'Group' Config Tab on the config notebook - * - * @param string name of group tab - * @param string no idea yet! - * @return object GtkTable table which config elements are added to. - */ - function &_getConfigTab($group) { - if (@$this->_configTabs[$group]) - return $this->_configTabs[$group]; - $this->_configTabs[$group] = &new GtkTable(); - $this->_configTabs[$group]->set_row_spacings(10); - $this->_configTabs[$group]->set_col_spacings(10); - $this->_configTabs[$group]->set_border_width(15); - $this->_configTabs[$group]->show(); - $gtklabel = &new GtkLabel($group); - - $gtklabel->show(); - $this->_widget_config_notebook->append_page($this->_configTabs[$group],$gtklabel); - return $this->_configTabs[$group]; - } - /** - * Load Configuration into widgets (Initialize) - * - * Clear current config tabs, and calls the Command Show-config - * - * @param object getbutton from the reset button! - * @param string no idea yet! - */ - function _loadConfig($widget=NULL,$what=NULL) { - if ($this->_configTabs) - foreach (array_keys($this->_configTabs) as $k) { - $page = $this->_widget_config_notebook->page_num($this->_configTabs[$k]); - $this->_widget_config_notebook->remove_page($page); - $this->_configTabs[$k]->destroy(); - } - - // delete any other pages; - if ($widget = $this->_widget_config_notebook->get_nth_page(0)) { - $this->_widget_config_notebook->remove_page(0); - $widget->destroy(); - } - $this->_configTabs = array(); - $cmd = PEAR_Command::factory('config-show',$this->config); - $cmd->ui = &$this; - $cmd->run('config-show' ,'', array()); - $this->_widget_config_save->set_sensitive(FALSE); - $this->_widget_config_reset->set_sensitive(FALSE); - } - - - /** - * Make the Save and reset buttons pressable. - * - * @access private - */ - function _ActivateConfigSave() { - $this->_widget_config_save->set_sensitive(TRUE); - $this->_widget_config_reset->set_sensitive(TRUE); - } - - /*---------------- Dir Seleciton stuff -----------------------*/ - - /** - * Currently active widget to save result into (eg. gtkentry) - * - * @var object gtkentry - * @access private - */ - var $_DirSelectActiveWidget = NULL; - /** - * Display the Directory selection dialog - * - * Displays the directory dialog, fills in the data etc. - * - * @param object gtkentry The text entry to fill in on closing - * - */ - function _onDirSelect($widget) { - // set the title!! - $this->_DirSelectActiveWidget = &$widget; - $prompt = 'xxx'; - $prompt = $this->config->getPrompt($widget->get_data('key')); - $this->_widget_dir_selection->set_title($prompt); - - $curvalue = $widget->get_text(); - // load the pulldown - $this->_DirSelectSetDir(dirname($curvalue), basename($curvalue)); - $this->_widget_dir_selection_entry->set_text($curvalue); - $this->_widget_dir_selection->show(); - } - - /** - * Associated array of Row -> directory name - * - * It could be possible to get the row string using gtk calls...... - * - * @var array - * @access private - */ - var $_DirSelectRows = array(); - - /** - * Load the directories into the directory list/pulldown etc. - * - * Loads the information into the popup / list of directories - * TODO: Windows A:D: etc. drive support - * - * @param string $directory name of directory to browse - * @param string $file name of file to select in list. - * - */ - function _DirSelectSetDir($directory, $file='.') { - $parts = explode(DIRECTORY_SEPARATOR, $directory); - $disp = array(); - $i=0; - $items = array(); - $gtkmenu = &new GtkMenu(); - foreach($parts as $dirpart) { - $disp[] = $dirpart; - $dir = implode(DIRECTORY_SEPARATOR,$disp); - if (!$dir && DIRECTORY_SEPARATOR == '/') $dir = '/'; - if (!$dir) continue; - $items[$i] = &new GtkMenuItem($dir); - $items[$i]->connect_object_after('activate', array(&$this,'_DirSelectSetDir'),$dir); - $gtkmenu->append($items[$i]); - $i++; - } - $gtkmenu->set_active($i-1); - $gtkmenu->show_all(); - $this->_widget_dir_selection_optionmenu->set_menu($gtkmenu); - $base = $directory; - - $this->_widget_dir_selection_clist->select_row(0,0); - $this->_widget_dir_selection_clist->freeze(); - $this->_widget_dir_selection_clist->clear(); - - clearstatcache(); - $dh = opendir($base); - $dirs = array(); - while (($dir = readdir($dh)) !== FALSE) { - if (!is_dir($base.DIRECTORY_SEPARATOR.$dir)) continue; - $dirs[] = $dir; - } - sort($dirs); - $this->_DirSelectRows = array(); - $sel =0; - $i=0; - foreach($dirs as $dir) { - $this->_widget_dir_selection_clist->append(array($dir)); - $this->_DirSelectRows[] = realpath($base.DIRECTORY_SEPARATOR.$dir); - if ($dir == $file) - $sel = $i; - $i++; - } - $this->_widget_dir_selection_clist->thaw(); - if ($file != '.') { - - $this->_widget_dir_selection_clist->select_row($sel,0); - $this->_widget_dir_selection_clist->moveto($i,0,0,0); - $this->_widget_dir_selection_entry->set_text($directory); - } else { - - $this->_DirListBlockSel = TRUE; - $this->_widget_dir_selection_clist->select_row(0,0); - $this->_DirListBlockSel = TRUE; - } - - - } - /** - * Flag to block reselecting of current row after update - * - * Introduced to attempt to fix problem that when you double click to open a - * Directory, after refresh, the clist recieves a select signal on the same rows - * and hence attemps to select the wrong directory.. - * - * @var boolean - * @access private - */ - var $_DirListBlockSel = FALSE; - /** - * Initial Select Row (not double click) - * - * Makes this selected item the 'active directory' - * - * @param string $directory name of directory to browse - * @param string $row selected line - * - */ - function _onDirListSelectRow($widget,$row) { - - if ($this->_DirListBlockSel) { - - $this->_DirListBlockSel = FALSE; - $widget->select_row(0,0); - return; - } - if ($row < 0) return; - $this->_widget_dir_selection_entry->set_text($this->_DirSelectRows[$row]); - } - - /** - * Callback when the list of directories is clicked - * - * Used to find the double click to open it. - * - * @param object gtkclist - * @param object gdkevent - * - */ - - function _onDirListClick($widget,$event) { - if ($event->type != 5) return; - $this->_DirSelectSetDir($this->_widget_dir_selection_entry->get_text()); - } - /** - * Callback when the cancel/destroy window is pressed - * - * has to return TRUE (see the gtk tutorial on destroy events) - * - * - */ - function _onDirSelectionCancel() { - $this->_widget_dir_selection->hide(); - return TRUE; - } - /** - * Callback when the OK btn is pressed - * - * hide window and update original widget. - * - */ + /*---------------- Dir Seleciton stuff -----------------------*/ - function _onDirSelectionOk() { - if (!$this->_DirSelectActiveWidget) return; - $new= $this->_widget_dir_selection_entry->get_text(); - $old= $this->_DirSelectActiveWidget->get_text(); - - if ($new != $old) { - $this->_DirSelectActiveWidget->set_text($new); - $this->_ActivateConfigSave(); - } - - $this->_DirSelectActiveWidget = NULL; - $this->_widget_dir_selection->hide(); - } + //-------------------------- BASE Installer methods -------------------------- /** @@ -789,28 +461,32 @@ function outputData($data,$command ){ switch ($command) { case 'config-show': - $this->_buildConfig($data['data']); + $this->_config->buildConfig($data['data']); break; + case 'uninstall': + $this->_install->uninstallOutputData($data); + return; default: echo "COMMAND : $command\n"; echo "DATA: ".serialize($data)."\n"; } } - function log($msg) { - echo "LOG $msg"; + function log($msg,$command) { + + return $this->_info->show("LOG: $msg: $command"); } // {{{ displayLine(text) - function displayLine($text) + function displayLine($msg,$args) { - echo "$text\n"; + return $this->_info->show("DISPLAYLINE: $msg: $args"); } - function display($text) + function display($text,$command='') { - echo "$text\n"; + return $this->_info->show("TEXT: $text: $command"); } // }}} @@ -818,7 +494,8 @@ function displayError($eobj) { - return $this->displayLine($eobj->getMessage()); + //echo "ERROR: ".$eobj->getMessage(); + return $this->_info->show("ERROR: ". $eobj->getMessage()); } @@ -827,7 +504,7 @@ function displayFatalError($eobj) { - $this->displayError($eobj); + return $this->_info->show("FATAL ERROR: ". $eobj->getMessage()); //exit(1); } @@ -843,7 +520,8 @@ function userDialog($prompt, $type = 'text', $default = '') { - echo "Dialog?" . $prompt; + + echo "Dialog?" . $prompt; } // }}} @@ -851,7 +529,7 @@ function userConfirm($prompt, $default = 'yes') { - echo "Confirm?" . $prompt; + echo "\nConfirm?" . $prompt; } // }}} @@ -880,6 +558,7 @@ function bold($text) { + echo "\nBOLD?" . $prompt; } // }}} Index: pear/PEAR_Frontend_Gtk/Gtk/Install.php diff -u pear/PEAR_Frontend_Gtk/Gtk/Install.php:1.5 pear/PEAR_Frontend_Gtk/Gtk/Install.php:1.6 --- pear/PEAR_Frontend_Gtk/Gtk/Install.php:1.5 Sat Jun 1 23:16:51 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/Install.php Mon Jun 3 06:10:45 2002 @@ -17,7 +17,7 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Install.php,v 1.5 2002/06/02 03:16:51 alan_k Exp $ + $Id: Install.php,v 1.6 2002/06/03 10:10:45 alan_k Exp $ */ /** @@ -44,51 +44,118 @@ */ function PEAR_Frontend_Gtk_Install(&$ui) { + // connect buttons? $this->ui = &$ui; - $this->ui->_widget_download_list->set_column_auto_resize(0,TRUE); - $this->ui->_widget_download_list->set_column_auto_resize(1,TRUE); - $this->ui->_widget_download_list->set_column_auto_resize(2,TRUE); - $this->ui->_widget_done_button->connect('pressed',array(&$this,'_callbackDone')); + + } + + /** + * The ProgressBar for total files + * @var object GtkProgressBar + */ + var $totalProgressBar; + /** + * The ProgressBar for single download + * @var object GtkProgressBar + */ + var $fileProgressBar; + /** + * The Label for Downloading File XXX + * @var object GtkLabel + */ + var $fileDownloadLabel; + /** + * The Label for Total XXX/XXX + * @var object GtkLabel + */ + var $totalDownloadLabel; + /** + * The list of packages to be added/removed + * @var object GtkList + */ + var $downloadList; + /* * Start the download process (recievs a list of package 'associative arrays' * #TODO : recieve list of package objects to install/remove! * */ - function start($list) { - + function start() { + + $this->downloadList->set_column_auto_resize(0,TRUE); + $this->downloadList->set_column_auto_resize(1,TRUE); + $this->downloadList->set_column_auto_resize(2,TRUE); + $this->downloadList->set_column_auto_resize(3,TRUE); + $this->downloadList->set_row_height(18); $this->ui->_widget_pages->set_page(1); $this->ui->_widget_done_button->set_sensitive(0); // load up the list into the download list.. - $this->ui->_widget_download_list->clear(); + $this->downloadList->clear(); $i=0; - $install = array(); - if ($list) foreach ($list as $package) { - print_r($package); - $this->ui->_widget_download_list->append(array('',$package['package'],$package['summary'])); - $this->ui->_widget_download_list->set_pixmap($i,0, - $this->ui->_pixmaps['package.xpm'][0], - $this->ui->_pixmaps['package.xpm'][1] - ); + + $queue = $this->ui->_packages->getQueue(); + foreach ($queue as $package) { + + $this->downloadList->append(array('','',$package->name,$package->summary)); + if ($package->QueueInstall) { + $this->downloadList->set_pixmap($i,0, + $this->ui->_pixmaps['package.xpm'][0], + $this->ui->_pixmaps['package.xpm'][1] + ); + } else { + $this->downloadList->set_pixmap($i,0, + $this->ui->_pixmaps['stock_delete-16.xpm'][0], + $this->ui->_pixmaps['stock_delete-16.xpm'][1] + ); + } + $lines[$package->name] = $i; $i++; - $install[] = $package['package']; + } + + + + $this->totalProgressBar->set_percentage(0); + $this->fileProgressBar->set_percentage(0); + $this->totalProgressBar->set_percentage(0); while(gtk::events_pending()) gtk::main_iteration(); - $this->ui->_downloadTotal = $i; + + $j=0; + $this->totalDownloadLabel->set_text("Total 0/{$i}"); + + + foreach ($queue as $package) { + $this->fileDownloadLabel->set_text("Downloading {$package->name}"); + while(gtk::events_pending()) gtk::main_iteration(); + $package->doQueue(); + + $this->downloadList->set_pixmap($j,1, + $this->ui->_pixmaps['check_yes.xpm'][0], + $this->ui->_pixmaps['check_yes.xpm'][1] + ); + $j++; + $this->totalProgressBar->set_percentage((float) ($j/$i)); + $this->totalDownloadLabel->set_text("Total {$j}/{$i}"); + while(gtk::events_pending()) gtk::main_iteration(); + + + } - $this->ui->_downloadPos=0; - $cmd = PEAR_Command::factory('install',$this->ui->config); - $cmd->run('install' ,'', $install); - $this->ui->_widget_done_button->set_sensitive(1); + $this->totalProgressBar->set_percentage(1.0); + $this->ui->_packages->_loadLocalPackages(); + $this->ui->_packages->_mergePackages(); + $this->ui->_packages->loadPackageList(); + + $this->ui->_widget_done_button->set_sensitive(1); } /* * GUI Callback - user presses the 'done button' */ - function _callbackDone() { - $this->ui->_package_list->loadList(); + function callbackDone() { $this->ui->_widget_pages->set_page(0); } /** @@ -97,19 +164,7 @@ * @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 @@ -121,37 +176,32 @@ switch ($msg) { case 'setup': - return; - + case 'done': 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); + $this->fileProgressBar->set_percentage(0); while(gtk::events_pending()) gtk::main_iteration(); return; case 'bytesread': - $this->ui->_widget_downloading_file_progressbar->set_percentage( + $this->fileProgressBar->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"; } + } + + function uninstallOutputData($msg) { + return; } Index: pear/PEAR_Frontend_Gtk/Gtk/PackageData.php diff -u pear/PEAR_Frontend_Gtk/Gtk/PackageData.php:1.1 pear/PEAR_Frontend_Gtk/Gtk/PackageData.php:1.2 --- pear/PEAR_Frontend_Gtk/Gtk/PackageData.php:1.1 Sun Jun 2 03:19:38 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/PackageData.php Mon Jun 3 06:10:45 2002 @@ -9,7 +9,8 @@ class PEAR_Frontend_Gtk_PackageData { - + + var $ui; // the User interface object /* data from remote-list */ var $name; // name -- wel actually not there, but lets use it anyway var $category = ""; // eg. XML @@ -52,12 +53,116 @@ /* data not available yet!!! */ var $dependancies; // list of packages that this depends on. - var $gtkrow; // gtk row that contains the row data.. + var $gtknode; // gtk node for this package - function staticNewFromArray($array) { + function &staticNewFromArray($array) { + $t = new PEAR_Frontend_Gtk_PackageData; - foreach(array as $k=>$v) + foreach($array as $k=>$v) { + + //echo "SETTING $k to $v\n"; $t->$k = $v; + } + return $t; + } + + + function merge($object) { + foreach(get_object_vars($object) as $k=>$v) { + if (!$v) continue; + //echo "SET $k -> $v\n"; + $this->$k = $v; + } } + /* + * create Node + * + * creates a node - current format is: + * Name (Tree), Trash, Installed Version, Latest Version, Add, Info Icon, Summary + * + * + * @params object GtkNode Parent in tree + */ + + function createNode(&$parent) { + + $this->gtknode = $this->ui->_packages->widget->insert_node( + $parent, NULL, //parent, sibling + array($this->name, '','','' ), + 5, + $this->ui->_pixmaps['package.xpm'][0], + $this->ui->_pixmaps['package.xpm'][1], + $this->ui->_pixmaps['package.xpm'][0], + $this->ui->_pixmaps['package.xpm'][1], + false,true + ); + $this->_setIcon(3,'info_icon.xpm',$this->summary); + $this->ui->_packages->widget->node_set_row_data( $this->gtknode, $this->name); + $this->_showDelete(); + $this->_showInstall(); + } + + function _setIcon($col,$name,$string='') { + $ui = PEAR_Command::getFrontendObject(); + $this->ui->_packages->widget->node_set_pixtext( + $this->gtknode, $col,$string,0, + $this->ui->_pixmaps[$name][0], + $this->ui->_pixmaps[$name][1] + ); + } + + function _showDelete() { + if (!$this->version) return; + + $icon = "stock_delete-outline-16.xpm"; + if ($this->QueueRemove) + $icon = "stock_delete-16.xpm"; + $this->_setIcon(1,$icon,' '.$this->version); + } + + function _showInstall() { + if ($this->version == $this->stable) return; + + //foreach(get_object_vars($this) as $k=>$v) echo "$k=>$v\n"; + $icon = "check_no.xpm"; + if ($this->QueueInstall) + $icon = "check_yes.xpm"; + $this->_setIcon(2,$icon, ' '.$this->stable); + } + function toggleRemove() { + if (!$this->version) return; + + $this->QueueRemove = !$this->QueueRemove; + if ($this->QueueRemove) + $this->QueueInstall = FALSE; + + $this->_showDelete(); + $this->_showInstall(); + + } + function toggleInstall() { + if ($this->version == $this->stable) return; + + $this->QueueInstall = !$this->QueueInstall; + if ($this->QueueInstall) + $this->QueueRemove = FALSE; + $this->_showInstall(); + $this->_showDelete(); + } + + function doQueue() { + $cmd = PEAR_Command::factory('install',$this->ui->config); + if ($this->QueueInstall && !$this->isInstalled) { + $cmd->run('install' ,'', array($this->name)); + return; + } else if ($this->QueueInstall) { + $cmd->run('upgrade' ,'', array($this->name)); + return; + } + if (!$this->QueueRemove) return; + $cmd->run('uninstall' ,'', array($this->name)); + + } + } ?> Index: pear/PEAR_Frontend_Gtk/Gtk/Packages.php diff -u pear/PEAR_Frontend_Gtk/Gtk/Packages.php:1.9 pear/PEAR_Frontend_Gtk/Gtk/Packages.php:1.10 --- pear/PEAR_Frontend_Gtk/Gtk/Packages.php:1.9 Sun Jun 2 10:18:31 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/Packages.php Mon Jun 3 06:10:45 2002 @@ -16,7 +16,7 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Packages.php,v 1.9 2002/06/02 14:18:31 alan_k Exp $ + $Id: Packages.php,v 1.10 2002/06/03 10:10:45 alan_k Exp $ */ require('PEAR/Frontend/Gtk/PackageData.php'); /** @@ -35,226 +35,34 @@ function PEAR_Frontend_Gtk_Packages(&$ui) { $this->ui = &$ui; - $this->_loadPackageData(); - $cols = array('Package','Version','','','Summary'); - $this->widget = &new GtkCTree(5,0,$cols); - $this->widget->set_usize(300,20); - $this->widget->set_selection_mode(GTK_SELECTION_BROWSE); - $this->widget->set_expander_style(GTK_CTREE_EXPANDER_TRIANGLE); - $this->widget->set_line_style( GTK_CTREE_LINES_NONE); - $this->widget->connect_after('realize', array(&$this, '_callbackRealize')); - $this->widget->connect_object('tree-select-row', array(&$this, '_callbackSelectRow')); - foreach($cols as $i=>$name) - $this->widget->set_column_auto_resize($i,TRUE); - - $this->widget->show(); - $this->ui->_widget_package_list_holder->add($this->widget); - - $this->ui->_widget_packages_install->connect('pressed',array(&$this,'_callbackInstall')); - return; - //untested - $this->loadLocalPackages(); - $this->loadRemotePackages(); - $this->mergePackages(); - - - + $this->_loadLocalPackages(); + $this->_loadRemotePackages(); + $this->_mergePackages(); } - function _loadPackageData() { - $reg = new PEAR_Registry($this->ui->config->get('php_dir')); - $installed = $reg->packageInfo(); - - foreach ($installed as $i=>$package) - $this->_package_status[$package['package']] = &$installed[$i]; - - // get available - if (!$this->_available_packages) { - $r = new PEAR_Remote($this->ui->config); - $packages = $r->call('package.listAll', true); - if (PEAR::isError($packages)) { - $this->ui->displayFatalError($packages); - return; - } - $this->_available_packages = $packages; - } - - - // merge available - - foreach ($this->_available_packages as $name => $info) { - // installed already? - $info['package'] = $name; - if (@$this->_package_status[$name]) { - // newer - $v = $this->_package_status[$name]['version']; - $this->_package_status[$name] = $info; - $this->_package_status[$name]['version'] = $v; - $this->_package_status[$name]['installed'] = 1; - $this->_package_status[$name]['install'] = TRUE; - if (@$this->_package_status[$name]['version'] < $info['stable']) { - // blank out the 'stable' column (as it is the same! - $this->_package_status[$name]['install'] = FALSE; - } - } else { - $this->_package_status[$name] = $info; - } - } - ksort($this->_package_status); - - } - - - /* - - package info looks like this! - - [packageid] => 22 - [categoryid] => 22 - [category] => XML - [license] => PHP License - [summary] => RSS parser - [description] => Parser for Resource Description Framework (RDF) Site Summary (RSS) -documents. - [lead] => mj - [stable] => 0.9.1 - - - */ - + - var $_package_status; // associative array of packagename => package info - var $_available_packages = array(); // result of rpc call - - function _callbackRealize($widget) { - - $this->_initPixmaps($widget); - $this->loadList(); - } - - - function loadList() { - //while(gtk::events_pending()) gtk::main_iteration(); - $this->widget->clear(); - $this->widget->freeze(); - - - - - $this->_nodes = array(); - - foreach($this->_package_status as $name => $info) { - - $ar = explode('_',$name); - $s = trim($ar[0]); - $parent = NULL; - if ($s && @$this->_nodes[$s]) - $parent = $this->_nodes[$s]; - - if ($s && !$parent && ($ar[0] != $name)) { - // make a parent node - - - $this->_nodes[$s] = $this->widget->insert_node( - NULL, NULL, //parent, sibling - array($s, '','','','',''), - 5, $this->_pixmaps['folder_closed.xpm'][0], - $this->_pixmaps['folder_closed.xpm'][1], - $this->_pixmaps['folder_open.xpm'][0], - $this->_pixmaps['folder_open.xpm'][1], - false,true); - - $parent = $this->_nodes[$s]; - } - - $showversion = $info['stable']; - if (@$info['version'] && (@$info['version'] != $info['stable'])) - $showversion = "New:".$info['stable']; - //$showversion = "**".$info['version'] . "->".$info['stable']. "**"; - - $this->_nodes[$name] = $this->widget->insert_node( - $parent, NULL, //parent, sibling - array( - $name, - $showversion, - '', - '', - $info['summary'] - - ), - 5, - $this->_pixmaps['package.xpm'][0], - $this->_pixmaps['package.xpm'][1], - $this->_pixmaps['package.xpm'][0], - $this->_pixmaps['package.xpm'][1], - false,true); - - - - $this->widget->node_set_pixtext( - $this->_nodes[$name], 3,'',0, - $this->_pixmaps['info_icon.xpm'][0], - $this->_pixmaps['info_icon.xpm'][1] - ); - - - $this->widget->node_set_row_data( $this->_nodes[$name], $name); - $this->_setPackageStatus($this->_nodes[$name], @$this->_package_status[$name]['install']); - } - $this->widget->thaw(); - - } - - /* - * Array of pixmaps - * each pixmap object looks like - * $pixmap->closed, $pixmap->mask_closed, - * $pixmap->open, $pixmap->mask_open, - * - * @var array of StdClass objects - * - */ - var $pixmaps; - /* - * initialize the pixmaps - load the into $_pixmaps[name] ->object - * - */ - function _initPixmaps(&$window) { - - if (@$this->_pixmaps) return; - $dir = dirname(__FILE__).'/xpm'; - $dh = opendir($dir); - if (!$dh) return; - while (($file = readdir($dh)) !== FALSE) { - if (@$file{0} == '.') continue; - if (!preg_match('/\.xpm$/',$file)) continue; - - $this->_pixmaps[$file] = - Gdk::pixmap_create_from_xpm($window->window, NULL, "{$dir}/{$file}"); - - } - - } + /* * call back when a row is pressed - hide/show the details and check it's isntalled status * */ - function _callbackSelectRow($node,$col) { + function callbackSelectRow($widget,$node,$col) { + //echo "GOT CALLBACK?"; $package = $this->widget->node_get_row_data($node); - //if (!$package) return; + if (!$package) return; switch ($col) { - case 0: + case 1: + $this->ui->_summary->hide(); + $this->packages[$package]->toggleRemove(); + break; + case 0: case 2: // install/ toggled - //case 4: - $this->ui->_summary->hide(); - - if (!$package) return; - $this->_setPackageStatus(&$node, !$this->_package_status[$package]['install']); - + $this->packages[$package]->toggleInstall(); break; case 3: // info selected if (!$package) { @@ -262,10 +70,7 @@ return; } - if ($this->_moveto_flag) - $this->widget->node_moveto($node,0,0,0); - $this->_moveto_flag=FALSE; - $this->ui->_summary->toggle($this->_package_status[$package]); + $this->ui->_summary->toggle($this->packages[$package]); break; case -1: // startup! return; @@ -273,55 +78,26 @@ $this->ui->_summary->hide(); break; } + $packages = $this->getQueue(); + $this->ui->_widget_packages_install->set_sensitive(0); + if ($packages) $this->ui->_widget_packages_install->set_sensitive(1); - - } - var $_moveto_flag = FALSE; - function selectPackage($package) { - if (!$this->_nodes[$package]) return; - $this->_moveto_flag=TRUE; - $this->widget->select($this->_nodes[$package]); - - - - } - - function _setPackageStatus(&$node, $status=FALSE) { - $status_icon = 'check_no.xpm'; - if ($status) $status_icon = 'check_yes.xpm'; - - $this->widget->node_set_pixtext( - $node, 2,'',0, - $this->_pixmaps[$status_icon][0], - $this->_pixmaps[$status_icon][1] - ); - $package = $this->widget->node_get_row_data($node); - $this->_package_status[$package]['install'] = $status; + + + /* + * Menu Callback - expand all + */ + function expandAll() { + $this->widget->expand_recursive(); } - - - - function _callbackInstall() { - // send the installer a list of packages to install - // probably the command stuff eventually... - // this method is very chessy - need to work out a more 'consistent way to handle, remove,add etc' - $install = array(); - foreach($this->_package_status as $package) - if ($package['install'] & !$package['installed']) - $install[] = $package; - - $this->ui->_install->start($install); - - - - + /* + * Menu Callback - colllapse all + */ + function collapseAll() { + $this->widget->collapse_recursive(); } - - - /*------------------------------------- New Data stuff.. ----------------------*/ - var $_remotePackageCache; // array of remote packages. var $_localPackageCache; // array of local packages var $packages; // associative array of packagename : package @@ -332,21 +108,23 @@ * Load the local packages into this->_localPackageCache * */ - function loadLocalPackages () { + function _loadLocalPackages () { + clearstatcache(); $reg = new PEAR_Registry($this->ui->config->get('php_dir')); $installed = $reg->packageInfo(); - $this->_localPackagesCache = array(); + $this->_localPackageCache = array(); foreach($installed as $packagear) { $package = PEAR_Frontend_Gtk_PackageData::staticNewFromArray($packagear); $package->name = $package->package; - $this->_localPackagesCache[$package->name] = $package; + $this->_localPackageCache[] = $package; } + } /* * Load the remote packages into this->_remotePackageCache * */ - function loadRemotePackages () { + function _loadRemotePackages () { $r = new PEAR_Remote($this->ui->config); $remote = $r->call('package.listAll', true); if (PEAR::isError($remote)) { @@ -356,35 +134,39 @@ foreach ($remote as $name => $packagear) { $package = PEAR_Frontend_Gtk_PackageData::staticNewFromArray($packagear); $package->name = $name; - $this->_remotemotePackageCache[] = $package; + $this->_remotePackageCache[] = $package; } + } /* * Add local and remote together and store in this->packages * Not: remembers installation status. */ - function mergePackages () { // builds a mreged package list + function _mergePackages () { // builds a mreged package list // start with remote list. - $newpackages = array(); - foreach ($this->_remotePackageCache as $package) - $newpackages[$package->name] = $package; + //if (!$this->packages) + foreach ($this->_remotePackageCache as $package) + $this->packages[$package->name] = $package; + // merge local. - foreach ($this->_localPackageCache as $package) { - if (@$newpackages[$package->name]) { - $newpackages[$package->name]->merge($package); + foreach ($this->_localPackageCache as $package) { + if (@$this->packages[$package->name]) { + $this->packages[$package->name]->merge($package); } else { - $newpackages[$package->name] = $package; + $this->packages[$package->name] = $package; } - $newpackages[$name]->isInstalled = TRUE; + $this->packages[$package->name]->isInstalled = TRUE; } //merge existing status stuff.. - foreach ($this->packages as $name=>$package) { - $newpackages[$name]->QueueInstall = $package->QueueInstall; - $newpackages[$name]->QueueRemove = $package->QueueRemove; - } - ksort($newpackages); - $this->packages = $newpackages; + /*if ($this->packages) + foreach ($this->packages as $name=>$package) { + $this->packages[$name]->QueueInstall = $package->QueueInstall; + $this->packages[$name]->QueueRemove = $package->QueueRemove; + } + */ + ksort($this->packages); + } /* @@ -401,11 +183,15 @@ * *@return array array of PackageData objects */ - function &getInstallQueue() { + function &getQueue() { $ret = array(); foreach(array_keys($this->packages) as $packagename) { - if (!$this->packages[$packagename]->QueueInstall) continue; - $ret[] = &$this->packages[$packagename]; + if ($this->packages[$packagename]->QueueInstall) + $ret[] = &$this->packages[$packagename]; + } + foreach(array_keys($this->packages) as $packagename) { + if ($this->packages[$packagename]->QueueRemove) + $ret[] = &$this->packages[$packagename]; } return $ret; } @@ -414,14 +200,7 @@ * *@return array array of PackageData objects */ - function &getRemoveQueue() { - $ret = array(); - foreach(array_keys($this->packages) as $packagename) { - if (!$this->packages[$packagename]->QueueRemove) continue; - $ret[] = &$this->packages[$packagename]; - } - return $ret; - } + /* * Nodes in a CTreeNodes @@ -437,14 +216,25 @@ *@return array array of PackageData objects */ function loadPackageList() { + $this->ui->_widget_packages_install->set_sensitive(0); + $this->widget->set_row_height(18); + $this->widget->set_expander_style(GTK_CTREE_EXPANDER_TRIANGLE); + $this->widget->set_line_style( GTK_CTREE_LINES_NONE); + + for($i=0;$i<4;$i++) + $this->widget->set_column_auto_resize($i,TRUE); + //while(gtk::events_pending()) gtk::main_iteration(); $this->widget->clear(); $this->widget->freeze(); - + $this->_categoryNodes = array(); foreach (array_keys($this->packages) as $packagename) { + $package = &$this->packages[$packagename]; $parent = $this->_getCategoryNode($package); - $package->CreateNode($this->widget,$parent); + //echo serialize($parent); + $package->ui = &$this->ui; + $package->createNode($parent); } $this->widget->thaw(); @@ -456,19 +246,33 @@ */ function &_getCategoryNode(&$package) { $ret = NULL; - if ($package->category == $package->name) + + // work out category if it does not exist!!!! + $category = $package->name; + $parts = explode('_',$package->name); + if ($parts[0]) + $category = $parts[0]; + $categoryName = $category; + if ($package->category) + $categoryName = $package->category; + + + //echo "GOT: {$package->name}:$categoryName:$category:\n"; + + + if ($category == $package->name) return $ret; - if (@$this->_categoryNodes[$package->category]) - return $this->_categoryNodes[$package->category]; + if (@$this->_categoryNodes[$category]) + return $this->_categoryNodes[$category]; - if (@$this->packages[$package->category]) - return $this->packages[$package->category]->cTreeNode; + if (@$this->packages[$category]) + return $this->packages[$category]->gtknode; - $this->_CategoryNodes[$package->category] = $this->widget->insert_node( + $this->_categoryNodes[$category] = $this->widget->insert_node( NULL, NULL, //parent, sibling - array($package->category, '','','','',''),5, + array($categoryName, '','',''),5, $this->ui->_pixmaps['folder_closed.xpm'][0], $this->ui->_pixmaps['folder_closed.xpm'][1], $this->ui->_pixmaps['folder_open.xpm'][0], @@ -476,7 +280,7 @@ false,true ); - return $this->_categoryNodes[$package->category]; + return $this->_categoryNodes[$category]; } Index: pear/PEAR_Frontend_Gtk/Gtk/Summary.php diff -u pear/PEAR_Frontend_Gtk/Gtk/Summary.php:1.4 pear/PEAR_Frontend_Gtk/Gtk/Summary.php:1.5 --- pear/PEAR_Frontend_Gtk/Gtk/Summary.php:1.4 Sun Jun 2 03:19:38 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/Summary.php Mon Jun 3 06:10:45 2002 @@ -16,7 +16,7 @@ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ - $Id: Summary.php,v 1.4 2002/06/02 07:19:38 alan_k Exp $ + $Id: Summary.php,v 1.5 2002/06/03 10:10:45 alan_k Exp $ */ /** @@ -38,7 +38,6 @@ function PEAR_Frontend_Gtk_Summary(&$ui) { $this->ui = &$ui; - $this->ui->_widget_close_details->connect_object('pressed',array(&$this,'hide')); } /* @@ -64,11 +63,11 @@ /* * show the details tab */ - function show(&$package_info) { + function show(&$package) { $this->ui->_widget_details_area->show(); - $this->active_package = $package_info; + $this->active_package = &$package; //$this->ui->_widget_install->set_sensitive(1); - foreach($package_info as $k=>$v) { + foreach(get_object_vars($package) as $k=>$v) { $v = str_replace("\r", '',$v); $var = "_widget_".strtolower($k); if (!is_object(@$this->ui->$var)) continue; @@ -85,13 +84,13 @@ } } - $this->_detailsVisableFlag = $package_info['package']; + $this->_detailsVisableFlag = $package->name; } - function toggle($package_info) { - if ($this->_detailsVisableFlag != $package_info['package']) { - $this->show($package_info); + function toggle(&$package) { + if ($this->_detailsVisableFlag != $package->name) { + $this->show($package); return; } $this->hide(); Index: pear/PEAR_Frontend_Gtk/Gtk/installer.glade diff -u pear/PEAR_Frontend_Gtk/Gtk/installer.glade:1.7 pear/PEAR_Frontend_Gtk/Gtk/installer.glade:1.8 --- pear/PEAR_Frontend_Gtk/Gtk/installer.glade:1.7 Sun Jun 2 11:58:58 2002 +++ pear/PEAR_Frontend_Gtk/Gtk/installer.glade Mon Jun 3 06:10:45 2002 @@ -20,13 +20,13 @@ <visible>False</visible> <signal> <name>destroy</name> - <handler>on_quit</handler> - <last_modification_time>Wed, 29 May 2002 10:52:35 GMT</last_modification_time> + <handler>_onQuit</handler> + <last_modification_time>Mon, 03 Jun 2002 07:03:48 GMT</last_modification_time> </signal> <signal> <name>delete_event</name> - <handler>on_quit</handler> - <last_modification_time>Wed, 29 May 2002 10:52:17 GMT</last_modification_time> + <handler>_onQuit</handler> + <last_modification_time>Mon, 03 Jun 2002 07:04:16 GMT</last_modification_time> </signal> <title>PEAR Package Manager</title> <type>GTK_WINDOW_TOPLEVEL</type> @@ -111,8 +111,8 @@ </accelerator> <signal> <name>activate</name> - <handler>on_quit</handler> - <last_modification_time>Wed, 29 May 2002 10:51:12 GMT</last_modification_time> + <handler>_onQuit</handler> + <last_modification_time>Mon, 03 Jun 2002 07:04:11 GMT</last_modification_time> </signal> <label>_Quit</label> <right_justify>False</right_justify> @@ -140,8 +140,8 @@ </accelerator> <signal> <name>activate</name> - <handler>on_expand_all_activate</handler> - <last_modification_time>Mon, 27 May 2002 04:09:37 GMT</last_modification_time> + <handler>_packages_expandAll</handler> + <last_modification_time>Mon, 03 Jun 2002 07:01:02 GMT</last_modification_time> </signal> <label>Expand All</label> <right_justify>False</right_justify> @@ -149,7 +149,7 @@ <widget> <class>GtkMenuItem</class> - <name>expand_all</name> + <name>collapse_all</name> <accelerator> <modifiers>GDK_CONTROL_MASK</modifiers> <key>GDK_-</key> @@ -157,8 +157,8 @@ </accelerator> <signal> <name>activate</name> - <handler>on_collapse_all_activate</handler> - <last_modification_time>Wed, 29 May 2002 10:46:10 GMT</last_modification_time> + <handler>_packages_collapseAll</handler> + <last_modification_time>Mon, 03 Jun 2002 07:02:03 GMT</last_modification_time> </signal> <label>Collapse All</label> <right_justify>False</right_justify> @@ -267,8 +267,8 @@ <name>preferences</name> <signal> <name>activate</name> - <handler>on_preferences_activate</handler> - <last_modification_time>Mon, 27 May 2002 04:09:37 GMT</last_modification_time> + <handler>_callbackShowConfig</handler> + <last_modification_time>Mon, 03 Jun 2002 08:12:04 GMT</last_modification_time> </signal> <label>_Preferences</label> <right_justify>False</right_justify> @@ -533,7 +533,7 @@ <widget> <class>GtkScrolledWindow</class> - <name>package_list_holder</name> + <name>scrolledwindow16</name> <hscrollbar_policy>GTK_POLICY_ALWAYS</hscrollbar_policy> <vscrollbar_policy>GTK_POLICY_ALWAYS</vscrollbar_policy> <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> @@ -545,7 +545,71 @@ </child> <widget> - <class>Placeholder</class> + <class>GtkCTree</class> + <name>_packages_widget</name> + <can_focus>True</can_focus> + <signal> + <name>tree_select_row</name> + <handler>_packages_callbackSelectRow</handler> + <last_modification_time>Mon, 03 Jun 2002 05:49:10 GMT</last_modification_time> + </signal> + <columns>4</columns> + <column_widths>80,80,80,80</column_widths> + <selection_mode>GTK_SELECTION_BROWSE</selection_mode> + <show_titles>True</show_titles> + <shadow_type>GTK_SHADOW_IN</shadow_type> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label67</name> + <label>Package</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label68</name> + <label>Installed</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label69</name> + <label>New</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CTree:title</child_name> + <name>label70</name> + <label>Summary</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> </widget> </widget> @@ -722,6 +786,11 @@ <width>0</width> <height>0</height> <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_install_start</handler> + <last_modification_time>Mon, 03 Jun 2002 05:16:53 GMT</last_modification_time> + </signal> <label>Download And Install >></label> <relief>GTK_RELIEF_NORMAL</relief> </widget> @@ -851,7 +920,7 @@ <widget> <class>GtkScrolledWindow</class> - <name>scrolledwindow11</name> + <name>another_scrollwin</name> <hscrollbar_policy>GTK_POLICY_NEVER</hscrollbar_policy> <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> @@ -864,10 +933,10 @@ <widget> <class>GtkCList</class> - <name>download_list</name> + <name>_install_downloadList</name> <can_focus>True</can_focus> - <columns>3</columns> - <column_widths>80,80,80</column_widths> + <columns>4</columns> + <column_widths>80,80,80,80</column_widths> <selection_mode>GTK_SELECTION_SINGLE</selection_mode> <show_titles>False</show_titles> <shadow_type>GTK_SHADOW_IN</shadow_type> @@ -875,8 +944,21 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label47</name> - <label>label47</label> + <name>label72</name> + <label>label72</label> + <justify>GTK_JUSTIFY_CENTER</justify> + <wrap>False</wrap> + <xalign>0.5</xalign> + <yalign>0.5</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + </widget> + + <widget> + <class>GtkLabel</class> + <child_name>CList:title</child_name> + <name>label73</name> + <label>label73</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -888,8 +970,8 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label48</name> - <label>label48</label> + <name>label74</name> + <label>label74</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -901,8 +983,8 @@ <widget> <class>GtkLabel</class> <child_name>CList:title</child_name> - <name>label49</name> - <label>label49</label> + <name>label75</name> + <label>label75</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> <xalign>0.5</xalign> @@ -969,7 +1051,7 @@ <widget> <class>GtkLabel</class> - <name>downloading_filename</name> + <name>_install_fileDownloadLabel</name> <label>Downloading XXXXXXXX</label> <justify>GTK_JUSTIFY_LEFT</justify> <wrap>False</wrap> @@ -986,7 +1068,7 @@ <widget> <class>GtkProgressBar</class> - <name>downloading_file_progressbar</name> + <name>_install_fileProgressBar</name> <value>0</value> <lower>0</lower> <upper>100</upper> @@ -1006,7 +1088,7 @@ <widget> <class>GtkLabel</class> - <name>downloading_total</name> + <name>_install_totalDownloadLabel</name> <label>Total</label> <justify>GTK_JUSTIFY_CENTER</justify> <wrap>False</wrap> @@ -1023,7 +1105,7 @@ <widget> <class>GtkProgressBar</class> - <name>downloading_total_progressbar</name> + <name>_install_totalProgressBar</name> <value>0</value> <lower>0</lower> <upper>100</upper> @@ -1063,6 +1145,11 @@ <sensitive>False</sensitive> <can_default>True</can_default> <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_install_callbackDone</handler> + <last_modification_time>Mon, 03 Jun 2002 05:41:04 GMT</last_modification_time> + </signal> <label>Done</label> <relief>GTK_RELIEF_NORMAL</relief> </widget> @@ -1210,7 +1297,7 @@ <widget> <class>GtkNotebook</class> - <name>config_notebook</name> + <name>_config_notebook</name> <can_focus>True</can_focus> <show_tabs>True</show_tabs> <show_border>True</show_border> @@ -1245,7 +1332,7 @@ <widget> <class>GtkLabel</class> - <name>config_help</name> + <name>_config_help</name> <height>40</height> <label>Help text</label> <justify>GTK_JUSTIFY_LEFT</justify> @@ -1279,13 +1366,13 @@ <widget> <class>GtkButton</class> - <name>config_reset</name> + <name>_config_reset</name> <can_default>True</can_default> <can_focus>True</can_focus> <signal> <name>clicked</name> - <handler>_loadConfig</handler> - <last_modification_time>Fri, 31 May 2002 06:13:05 GMT</last_modification_time> + <handler>_config_loadConfig</handler> + <last_modification_time>Mon, 03 Jun 2002 07:44:39 GMT</last_modification_time> </signal> <label>Reset</label> <relief>GTK_RELIEF_NORMAL</relief> @@ -1293,9 +1380,14 @@ <widget> <class>GtkButton</class> - <name>config_save</name> + <name>_config_save</name> <can_default>True</can_default> <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_config_saveConfig</handler> + <last_modification_time>Mon, 03 Jun 2002 07:44:59 GMT</last_modification_time> + </signal> <label>Save</label> <relief>GTK_RELIEF_NORMAL</relief> </widget> @@ -1331,19 +1423,19 @@ <widget> <class>GtkDialog</class> - <name>dir_selection</name> + <name>_dirselect_window</name> <width>200</width> <height>400</height> <visible>False</visible> <signal> <name>delete_event</name> - <handler>_onDirSelectionCancel</handler> - <last_modification_time>Fri, 31 May 2002 03:41:05 GMT</last_modification_time> + <handler>_dirselect_onCancel</handler> + <last_modification_time>Mon, 03 Jun 2002 07:41:07 GMT</last_modification_time> </signal> <signal> <name>destroy</name> - <handler>_onDirSelectionCancel</handler> - <last_modification_time>Fri, 31 May 2002 05:50:41 GMT</last_modification_time> + <handler>_dirselect_onCancel</handler> + <last_modification_time>Mon, 03 Jun 2002 07:41:00 GMT</last_modification_time> </signal> <title>dialog1</title> <type>GTK_WINDOW_DIALOG</type> @@ -1397,8 +1489,8 @@ <can_focus>True</can_focus> <signal> <name>clicked</name> - <handler>_onDirSelectionOk</handler> - <last_modification_time>Fri, 31 May 2002 03:43:58 GMT</last_modification_time> + <handler>_dirselect_onOk</handler> + <last_modification_time>Mon, 03 Jun 2002 07:40:54 GMT</last_modification_time> </signal> <label>OK</label> <relief>GTK_RELIEF_NORMAL</relief> @@ -1411,8 +1503,8 @@ <can_focus>True</can_focus> <signal> <name>clicked</name> - <handler>_onDirSelectionCancel</handler> - <last_modification_time>Fri, 31 May 2002 03:35:53 GMT</last_modification_time> + <handler>_dirselect_onCancel</handler> + <last_modification_time>Mon, 03 Jun 2002 07:40:43 GMT</last_modification_time> </signal> <label>Cancel</label> <relief>GTK_RELIEF_NORMAL</relief> @@ -1434,7 +1526,7 @@ <widget> <class>GtkOptionMenu</class> - <name>dir_selection_optionmenu</name> + <name>_dirselect_optionMenu</name> <border_width>5</border_width> <can_focus>True</can_focus> <items></items> @@ -1461,17 +1553,17 @@ <widget> <class>GtkCList</class> - <name>dir_selection_clist</name> + <name>_dirselect_cList</name> <can_focus>True</can_focus> <signal> <name>select_row</name> - <handler>_onDirListSelectRow</handler> - <last_modification_time>Fri, 31 May 2002 03:37:01 GMT</last_modification_time> + <handler>_dirselect_onDirListSelectRow</handler> + <last_modification_time>Mon, 03 Jun 2002 07:26:34 GMT</last_modification_time> </signal> <signal> <name>button_press_event</name> - <handler>_onDirListClick</handler> - <last_modification_time>Fri, 31 May 2002 03:37:34 GMT</last_modification_time> + <handler>_dirselect_onDirListClick</handler> + <last_modification_time>Mon, 03 Jun 2002 07:26:31 GMT</last_modification_time> </signal> <columns>1</columns> <column_widths>80</column_widths> @@ -1513,7 +1605,7 @@ <widget> <class>GtkEntry</class> - <name>dir_selection_entry</name> + <name>_dirselect_entry</name> <can_focus>True</can_focus> <editable>False</editable> <text_visible>True</text_visible> @@ -1523,6 +1615,128 @@ <padding>0</padding> <expand>False</expand> <fill>False</fill> + </child> + </widget> + </widget> + </widget> +</widget> + +<widget> + <class>GtkDialog</class> + <name>_info_window</name> + <visible>False</visible> + <signal> + <name>destroy</name> + <handler>_info_close</handler> + <last_modification_time>Mon, 03 Jun 2002 07:49:43 GMT</last_modification_time> + </signal> + <signal> + <name>delete_event</name> + <handler>_info_close</handler> + <last_modification_time>Mon, 03 Jun 2002 07:49:53 GMT</last_modification_time> + </signal> + <title>dialog1</title> + <type>GTK_WINDOW_TOPLEVEL</type> + <position>GTK_WIN_POS_MOUSE</position> + <modal>True</modal> + <allow_shrink>True</allow_shrink> + <allow_grow>True</allow_grow> + <auto_shrink>False</auto_shrink> + + <widget> + <class>GtkVBox</class> + <child_name>Dialog:vbox</child_name> + <name>dialog-vbox2</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + + <widget> + <class>GtkHBox</class> + <child_name>Dialog:action_area</child_name> + <name>dialog-action_area2</name> + <border_width>10</border_width> + <homogeneous>True</homogeneous> + <spacing>5</spacing> + <child> + <padding>0</padding> + <expand>False</expand> + <fill>True</fill> + <pack>GTK_PACK_END</pack> + </child> + + <widget> + <class>GtkHButtonBox</class> + <name>hbuttonbox4</name> + <layout_style>GTK_BUTTONBOX_DEFAULT_STYLE</layout_style> + <spacing>30</spacing> + <child_min_width>85</child_min_width> + <child_min_height>27</child_min_height> + <child_ipad_x>7</child_ipad_x> + <child_ipad_y>0</child_ipad_y> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkButton</class> + <name>button21</name> + <can_default>True</can_default> + <can_focus>True</can_focus> + <signal> + <name>clicked</name> + <handler>_info_close</handler> + <last_modification_time>Mon, 03 Jun 2002 07:49:22 GMT</last_modification_time> + </signal> + <label>OK</label> + <relief>GTK_RELIEF_NORMAL</relief> + </widget> + </widget> + </widget> + + <widget> + <class>GtkHBox</class> + <name>hbox11</name> + <border_width>23</border_width> + <homogeneous>False</homogeneous> + <spacing>8</spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>GtkHBox</class> + <name>_info_iconholder</name> + <homogeneous>False</homogeneous> + <spacing>0</spacing> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> + </child> + + <widget> + <class>Placeholder</class> + </widget> + </widget> + + <widget> + <class>GtkLabel</class> + <name>_info_label</name> + <label>Prompt</label> + <justify>GTK_JUSTIFY_LEFT</justify> + <wrap>True</wrap> + <xalign>0</xalign> + <yalign>0</yalign> + <xpad>0</xpad> + <ypad>0</ypad> + <child> + <padding>0</padding> + <expand>True</expand> + <fill>True</fill> </child> </widget> </widget> Index: pear/PEAR_Frontend_Gtk/Gtk/Config.php +++ pear/PEAR_Frontend_Gtk/Gtk/Config.php <? /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ $Id: Config.php,v 1.1 2002/06/03 10:10:45 alan_k Exp $ */ /** * Gtk Frontend - Configuration * * @author Alan Knowles <alan@akbkhome.com> */ class PEAR_Frontend_Gtk_Config { var $ui; // main interface /** * The GtkLabel that shows the help config * * @var object GtkLabel configuration help text * @access private */ var $help; /** * The GtkNotebook that has all the tabs * * @var object Gtknotebook * @access private */ var $notebook; /** * The Save GtkButton * * @var object GtkButton * @access private */ var $save; /** * The Reset GtkButton * * @var object GtkButton * @access private */ var $reset; /** * Constructor * * @param array see config-show for more details. */ function PEAR_Frontend_Gtk_Config(&$ui) { $this->ui = &$ui; } /** * Load Configuration into widgets (Initialize) * * Clear current config tabs, and calls the Command Show-config * * @param object getbutton from the reset button! * @param string no idea yet! */ function loadConfig($widget=NULL,$what=NULL) { if ($this->_configTabs) foreach (array_keys($this->_configTabs) as $k) { $page = $this->notebook->page_num($this->_configTabs[$k]); $this->notebook->remove_page($page); $this->_configTabs[$k]->destroy(); } // delete any other pages; if ($widget = $this->notebook->get_nth_page(0)) { $this->notebook->remove_page(0); $widget->destroy(); } $this->_configTabs = array(); $cmd = PEAR_Command::factory('config-show',$this->ui->config); $cmd->ui = &$this->ui; $cmd->run('config-show' ,'', array()); $this->save->set_sensitive(FALSE); $this->reset->set_sensitive(FALSE); } /** * Build the widgets based on the return 'data' array from config-show * * @param array see config-show for more details. */ function buildConfig(&$array) { if (!$array) return; foreach ($array as $group=>$items) foreach ($items as $v) { $this->_buildConfigItem($v[1],$v[2]); } } /** * Build the widgets for a configuration item * * @param string configuration 'key' * @param string configuration 'value' */ function _buildConfigItem($k,$v) { //echo "BUIDLING CONF ITME $k $v\n"; $group = $this->ui->config->getGroup($k); $gtktable = $this->_getConfigTab($group); $prompt = $this->ui->config->getPrompt($k); $gtklabel = &new GtkLabel(); $gtklabel->set_text($prompt); $gtklabel->set_justify(GTK_JUSTIFY_LEFT); $gtklabel->set_alignment(0.0, 0.5); $gtklabel->show(); $r = $gtktable->nrows; $gtktable->attach($gtklabel, 0, 1, $r, $r+1, GTK_FILL,GTK_FILL); if ($v == '<not set>') $v = ''; $type = $this->ui->config->getType($k); switch ($type) { case 'string': case 'password': case 'int': // umask: should really be checkboxes.. $gtkentry = &new GtkEntry(); $gtkentry->set_text($v); $gtkentry->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); $gtkentry->connect_object_after('changed', array(&$this,'_ActivateConfigSave')); if ($type == 'password') $gtkentry->set_visibility(FALSE); $gtkentry->show(); $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); break; case 'directory': $gtkentry = &new GtkEntry(); $gtkentry->set_text($v); $gtkentry->set_editable(FALSE); $gtkentry->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); // store in object data the configuration tag $gtkentry->set_data('key',$k); $gtkentry->show(); $gtktable->attach($gtkentry, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); $gtkbutton = &new GtkButton('...'); $gtkbutton->connect_object_after('clicked', array(&$this->ui->_dirselect,'onDirSelect'),$gtkentry); $gtkbutton->show(); $gtktable->attach($gtkbutton, 2, 3, $r, $r+1, GTK_SHRINK,GTK_SHRINK); break; case 'set': $options = $this->ui->config->getSetValues($k); $gtkmenu = &new GtkMenu(); $items = array(); $sel = 0; foreach($options as $i=>$option) { $items[$i] = &new GtkMenuItem($option); //$items[$i]->connect('activate', 'echo_activated', $labels[$i], $pos[$i], $gtkmenu->append($items[$i]); if ($option == $v) $sel = $i; } $gtkmenu->set_active($sel); $gtkmenu->show_all(); $gtkoptionmenu = &new GtkOptionMenu(); $gtkoptionmenu->set_menu($gtkmenu); $gtkoptionmenu->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); $gtkoptionmenu->show(); $gtktable->attach($gtkoptionmenu, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); break; // debug: shourd really be case 'integer': // debug : should really be a set? $gtkadj = &new GtkAdjustment($v, 0.0, 3.0, 1.0, 1.0, 0.0); $gtkspinbutton = &new GtkSpinButton($gtkadj); $gtkspinbutton->show(); $gtkspinbutton->connect_object_after('enter_notify_event', array(&$this,'_setConfigHelp'),$this->ui->config->getDocs($k)); $gtktable->attach($gtkspinbutton, 1, 2, $r, $r+1, GTK_FILL|GTK_EXPAND,GTK_FILL); break; default: echo "$prompt : ". $this->ui->config->getType($k) . "\n"; } } /** * Show the help text for a widget * * @param object gtkevent name of group tab * @param string help text */ function _setConfigHelp($event,$string) { $this->help->set_text($string); } /** * The GtkTables relating to the groups * * @var array associative array of groupname -> gtktable * @access private */ var $_configTabs = array(); // associative array of configGroup -> GtkTable /** * Get (or Make) A 'Group' Config Tab on the config notebook * * @param string name of group tab * @param string no idea yet! * @return object GtkTable table which config elements are added to. */ function &_getConfigTab($group) { if (@$this->_configTabs[$group]) return $this->_configTabs[$group]; $this->_configTabs[$group] = &new GtkTable(); $this->_configTabs[$group]->set_row_spacings(10); $this->_configTabs[$group]->set_col_spacings(10); $this->_configTabs[$group]->set_border_width(15); $this->_configTabs[$group]->show(); $gtklabel = &new GtkLabel($group); $gtklabel->show(); $this->notebook->append_page($this->_configTabs[$group],$gtklabel); return $this->_configTabs[$group]; } /** * Make the Save and reset buttons pressable. * */ function ActivateConfigSave() { $this->save->set_sensitive(TRUE); $this->reset->set_sensitive(TRUE); } function saveConfig() { //mmh now what :) } } ?> Index: pear/PEAR_Frontend_Gtk/Gtk/DirSelect.php +++ pear/PEAR_Frontend_Gtk/Gtk/DirSelect.php <? /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ $Id: DirSelect.php,v 1.1 2002/06/03 10:10:45 alan_k Exp $ */ /** * Gtk Frontend - Configuration * * @author Alan Knowles <alan@akbkhome.com> */ class PEAR_Frontend_Gtk_DirSelect { var $ui; // main interface /** * The GtkEntry that shows the currently seelcted directory * * @var object GtkEntry */ var $entry; /** * The GtkDialog of the window * * @var object GtkDialog */ var $window; /** * The Top pulldown * * @var object GtkOptionMenu */ var $optionMenu; /** * The full list of directories * * @var object GtkClist */ var $cList; /** * Constructor * * @param object PEAR_Frontend_Gtk */ function PEAR_Frontend_Gtk_DirSelect(&$ui) { $this->ui = &$ui; } /** * Currently active widget to save result into (eg. gtkentry) * * @var object gtkentry * @access private */ var $_DirSelectActiveWidget = NULL; /** * Display the Directory selection dialog * * Displays the directory dialog, fills in the data etc. * * @param object gtkentry The text entry to fill in on closing * */ function onDirSelect($widget) { // set the title!! $this->_DirSelectActiveWidget = &$widget; $prompt = 'xxx'; $prompt = $this->ui->config->getPrompt($widget->get_data('key')); $this->window->set_title($prompt); $curvalue = $widget->get_text(); // load the pulldown $this->_DirSelectSetDir(dirname($curvalue), basename($curvalue)); $this->entry->set_text($curvalue); $this->window->show(); } /** * Associated array of Row -> directory name * * It could be possible to get the row string using gtk calls...... * * @var array * @access private */ var $_DirSelectRows = array(); /** * Load the directories into the directory list/pulldown etc. * * Loads the information into the popup / list of directories * TODO: Windows A:D: etc. drive support * * @param string $directory name of directory to browse * @param string $file name of file to select in list. * */ function _DirSelectSetDir($directory, $file='.') { $parts = explode(DIRECTORY_SEPARATOR, $directory); $disp = array(); $i=0; $items = array(); $gtkmenu = &new GtkMenu(); foreach($parts as $dirpart) { $disp[] = $dirpart; $dir = implode(DIRECTORY_SEPARATOR,$disp); if (!$dir && DIRECTORY_SEPARATOR == '/') $dir = '/'; if (!$dir) continue; $items[$i] = &new GtkMenuItem($dir); $items[$i]->connect_object_after('activate', array(&$this,'_DirSelectSetDir'),$dir); $gtkmenu->append($items[$i]); $i++; } $gtkmenu->set_active($i-1); $gtkmenu->show_all(); $this->optionMenu->set_menu($gtkmenu); $base = $directory; $this->cList->select_row(0,0); $this->cList->freeze(); $this->cList->clear(); clearstatcache(); $dh = opendir($base); $dirs = array(); while (($dir = readdir($dh)) !== FALSE) { if (!is_dir($base.DIRECTORY_SEPARATOR.$dir)) continue; $dirs[] = $dir; } sort($dirs); $this->_DirSelectRows = array(); $sel =0; $i=0; foreach($dirs as $dir) { $this->cList->append(array($dir)); $this->_DirSelectRows[] = realpath($base.DIRECTORY_SEPARATOR.$dir); if ($dir == $file) $sel = $i; $i++; } $this->cList->thaw(); if ($file != '.') { $this->cList->select_row($sel,0); $this->cList->moveto($i,0,0,0); $this->entry->set_text($directory); } else { $this->_DirListBlockSel = TRUE; $this->cList->select_row(0,0); $this->_DirListBlockSel = TRUE; } } /** * Flag to block reselecting of current row after update * * Introduced to attempt to fix problem that when you double click to open a * Directory, after refresh, the clist recieves a select signal on the same rows * and hence attemps to select the wrong directory.. * * @var boolean * @access private */ var $_DirListBlockSel = FALSE; /** * Initial Select Row (not double click) * * Makes this selected item the 'active directory' * * @param string $directory name of directory to browse * @param string $row selected line * */ function onDirListSelectRow($widget,$row) { if ($this->_DirListBlockSel) { $this->_DirListBlockSel = FALSE; $widget->select_row(0,0); return; } if ($row < 0) return; $this->entry->set_text($this->_DirSelectRows[$row]); } /** * Callback when the list of directories is clicked * * Used to find the double click to open it. * * @param object gtkclist * @param object gdkevent * */ function onDirListClick($widget,$event) { if ($event->type != 5) return; $this->_DirSelectSetDir($this->entry->get_text()); } /** * Callback when the cancel/destroy window is pressed * * has to return TRUE (see the gtk tutorial on destroy events) * * */ function onCancel() { $this->window->hide(); return TRUE; } /** * Callback when the OK btn is pressed * * hide window and update original widget. * */ function onOk() { if (!$this->_DirSelectActiveWidget) return; $new= $this->entry->get_text(); $old= $this->_DirSelectActiveWidget->get_text(); if ($new != $old) { $this->_DirSelectActiveWidget->set_text($new); $this->ui->_config->ActivateConfigSave(); } $this->_DirSelectActiveWidget = NULL; $this->window->hide(); } } ?> Index: pear/PEAR_Frontend_Gtk/Gtk/Info.php +++ pear/PEAR_Frontend_Gtk/Gtk/Info.php <? /* +----------------------------------------------------------------------+ | PHP Version 4 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available at through the world-wide-web at | | http://www.php.net/license/2_02.txt. | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Author: Alan Knowles <alan@akbkhome.com> | +----------------------------------------------------------------------+ $Id: Info.php,v 1.1 2002/06/03 10:10:45 alan_k Exp $ */ /** * Gtk Frontend -Directory Selection * * @author Alan Knowles <alan@akbkhome.com> */ class PEAR_Frontend_Gtk_Info { var $ui; // main interface /** * holder for the icon * * @var object GtkVbox */ var $iconholder; /** * The text of the message * * @var object GtkLabel */ var $label; /** * The Top pulldown * * @var object GtkOptionMenu */ var $window; var $_message = ""; // the current message /** * Constructor * * @param object PEAR_Frontend_Gtk */ function PEAR_Frontend_Gtk_Info(&$ui) { $this->ui = &$ui; } function show($message) { $this->_message .= $message . "\n"; $this->window->set_title("MESSAGE"); $this->label->set_text($this->_message); $this->window->show(); $this->isShow = TRUE; } function close() { $this->window->hide(); $this->_message = ""; return TRUE; } } ?>