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

Source for file Gtk2.php

Documentation is available at Gtk2.php

  1. <?php
  2. require_once 'PEAR/Config.php';
  3. require_once 'PEAR/Frontend.php';
  4.  
  5. require_once 'PEAR/Frontend/Gtk2/About.php';
  6. require_once 'PEAR/Frontend/Gtk2/ChannelDialog.php';
  7. require_once 'PEAR/Frontend/Gtk2/Channels.php';
  8. require_once 'PEAR/Frontend/Gtk2/Config.php';
  9. require_once 'PEAR/Frontend/Gtk2/Packages.php';
  10. require_once 'PEAR/Frontend/Gtk2/Installation.php';
  11.  
  12. /**
  13. *   Graphical frontend for PEAR, based on PHP-Gtk2
  14. *
  15. *   TODO:
  16. *   - Package categories aren't updated/extendet if there is an error at startup loading/packages are refreshed and a new category is required
  17. *   - Drop package file onto install button -> install it
  18. *   - Warn if the package list is older than 5 days
  19. *   - upgrade-all menu option
  20. *   - Filter by upgradeable/installed/installable/all packages
  21. *
  22. *   Don't know how to do:
  23. *   - installation dialog showing has to be updated correctly
  24. *   - Installation: shrink window if expander is collapsed
  25. *
  26. *   Done:
  27. *   - Install pecl packages - error messages aren't shown
  28. *   - channel discovery
  29. *   - better installation ok icon
  30. *   - Window icon - shows the php icon on windows currently
  31. *   - When no internet connection on startup, no categories are loaded and no local packages are shown
  32. *   - When no pear cache directory exists, the check warning is shown - pear cache directory is created now
  33. *   - uninstall: pear/liveuser is required by installed package "pear/Event_Dispatcher"
  34. *   - use menu options (deps, nodeps)
  35. *   - refresh online info (clear cache or so)
  36. *   - offline mode
  37. *   - save and load settings
  38. *   - scroll text in installation
  39. *
  40. *   @author Christian Weiske <cweiske@php.net>
  41. */
  42. class PEAR_Frontend_Gtk2 extends PEAR_Frontend
  43. {
  44.     /**
  45.     *   The widgets which shall be loaded from the glade
  46.     *   file into the $arWidgets array
  47.     *   @var array 
  48.     */
  49.     protected static $arRequestedWidgets = array(
  50.         'dlgInstaller''lstCategories''lstPackages''txtPackageInfo',
  51.         'cmbChannel''imgChannelLogo''lblSelectedCategory''hboxCategoryInfo',
  52.         'btnInstall','btnUninstall','lblBtnInstall','evboxSelectedCategory','expPackageInfo',
  53.  
  54.         'mnuOptDepsNo','mnuOptDepsReq','mnuOptDepsAll','mnuOptDepNothing',
  55.         'mnuOffline','mnuQuit','mnuAbout','mnuUpdateOnline','mnuUpdateLocal',
  56.         'mnuChannels',
  57.  
  58.         'dlgProgress''lblDescription''imgProgress''lblProgress''progBar'
  59.     );
  60.  
  61.     protected $nProgressImage = 1;
  62.  
  63.     /**
  64.     *   Array with images used for the progress animation
  65.     */
  66.     protected $arAnimationImages = array();
  67.  
  68.     /**
  69.     *   Requested widgets are loaded from glade into this array.
  70.     *   So this is an associative array with all required widgets
  71.     *   from the glade file: name => widget object
  72.     *   @var array 
  73.     */
  74.     protected $arWidgets;
  75.  
  76.     /**
  77.     *   The PEAR_Frontend_Gtk2_Installation object to use
  78.     *   @var PEAR_Frontend_Gtk2_Installation 
  79.     */
  80.     protected $installer = null;
  81.  
  82.     /**
  83.     *   The channel dialog
  84.     *   @var PEAR_Frontend_Gtk2_ChannelDialog 
  85.     */
  86.     protected $channelDialog = null;
  87.  
  88.     protected $selectedPackage          = null;
  89.     protected $strSelectedCategoryName  = null;
  90.     protected $strSelectedCategoryKey   = null;
  91.  
  92.     /**
  93.     *   The package information class instance
  94.     *   @var PEAR_Frontend_Gtk2_Packages 
  95.     */
  96.     protected $packages = null;
  97.  
  98.     const CATEGORY_ALL      = 12345678;
  99.     const CATEGORY_SELECTED = 12345679;
  100.  
  101.  
  102.  
  103.     /**
  104.     *   Special categories which are added to the
  105.     *   channel categories
  106.     *   @var array 
  107.     */
  108.     protected static $arSpecialCategories = array(
  109.         PEAR_Frontend_Gtk2::CATEGORY_ALL      => '*All packages',
  110. //        PEAR_Frontend_Gtk2::CATEGORY_SELECTED => '*Selected for install'
  111.     );
  112.  
  113.  
  114.     public function __construct()
  115.     {
  116.         $this->loadConfig();
  117.         $this->buildDialog();
  118.         PEAR_Frontend_Gtk2_Config::loadConfig();
  119.         PEAR_Frontend_Gtk2_Config::loadCurrentConfigIntoGui($this);
  120.         $this->loadChannels(PEAR_Frontend_Gtk2_Config::$strDefaultChannel);
  121.     }//public function __construct()
  122.  
  123.  
  124.  
  125.     function loadConfig()
  126.     {
  127.         $this->config   = PEAR_Config::singleton();
  128.         $this->packages = new PEAR_Frontend_Gtk2_Packages($this->config);
  129.     }//function loadConfig()
  130.  
  131.  
  132.  
  133.     /**
  134.     *   Fill the channel dropdown with channel names
  135.     *
  136.     *   @param string   $strDefaultChannel  The channel to set active
  137.     */
  138.     public function loadChannels($strDefaultChannel = null)
  139.     {
  140.         if ($strDefaultChannel == null{
  141.             $strDefaultChannel $this->arWidgets['cmbChannel']->get_active_text();
  142.         }
  143.  
  144.         //After all has been initiated, load the data
  145.         PEAR_Frontend_Gtk2_Channels::loadChannels(
  146.             $this->arWidgets['cmbChannel'],
  147.             $this->config,
  148.             $strDefaultChannel
  149.         );
  150.     }//public function loadChannels($strDefault = null)
  151.  
  152.  
  153.  
  154.     public function quitApp()
  155.     {
  156.         PEAR_Frontend_Gtk2_Config::loadConfigurationFromGui($this);
  157.         PEAR_Frontend_Gtk2_Config::saveConfig();
  158.         Gtk::main_quit();
  159.     }//public function quitApp()
  160.  
  161.  
  162.  
  163.     /**
  164.     *   load the glade file, load the widgets, connect the signals
  165.     */
  166.     protected function buildDialog()
  167.     {
  168.         $this->glade = new GladeXML(dirname(__FILE__'/Gtk2/installer.glade');
  169.         foreach (self::$arRequestedWidgets as $strWidgetName{
  170.             $this->arWidgets[$strWidgetName$this->glade->get_widget($strWidgetName);
  171.         }
  172.  
  173.         $this->arWidgets['dlgInstaller']->connect_simple('destroy'array($this'quitApp'));
  174.         $strIcon = dirname(__FILE__'/Gtk2/runicon.png';
  175.         if (file_exists($strIcon)) {
  176.             $this->arWidgets['dlgInstaller']->set_icon_from_file($strIcon);
  177.         }
  178.  
  179.         $this->arWidgets['lblSelectedCategory']->set_use_markup(true);
  180.  
  181.         $this->arWidgets['cmbChannel']->connect('changed'array($this'selectChannel'));
  182.  
  183.         $this->arWidgets['lstCategories']->set_model(new GtkListStore(Gtk::TYPE_STRINGGtk::TYPE_STRING));
  184.         $cell_renderer = new GtkCellRendererText();
  185.         $column = new GtkTreeViewColumn('test'$cell_renderer"text"0);
  186.         $this->arWidgets['lstCategories']->append_column($column);
  187.  
  188.         $this->arWidgets['btnInstall']  ->connect_simple('clicked'array($this'installPackage')true);
  189.         $this->arWidgets['btnUninstall']->connect_simple('clicked'array($this'installPackage')false);
  190.  
  191.         $this->arWidgets['dlgProgress']->connect('delete-event'array($this'deleteProgressWindow'));
  192.  
  193.         //Menu entries
  194.         $this->arWidgets['mnuQuit']         ->connect_simple('activate'array($this'quitApp'));
  195.         $this->arWidgets['mnuAbout']        ->connect_simple('activate'array('PEAR_Frontend_Gtk2_About''showMe'));
  196.         $this->arWidgets['mnuUpdateLocal']  ->connect_simple('activate'array($this'refreshLocalPackages'));
  197.         $this->arWidgets['mnuUpdateOnline'->connect_simple('activate'array($this'refreshOnlinePackages'));
  198.         $this->arWidgets['mnuChannels']     ->connect_simple('activate'array($this'showChannelDialog'));
  199.  
  200.  
  201.         //that's channel name and array key of the packages
  202.         $this->arWidgets['lstPackages']->set_model(new GtkListStore(Gtk::TYPE_STRINGGtk::TYPE_STRINGGtk::TYPE_STRINGGtk::TYPE_STRINGGtk::TYPE_PHP_VALUE));
  203.         $cell_renderer = new GtkCellRendererText();
  204.  
  205.         $colName = new GtkTreeViewColumn('Package'$cell_renderer"text"0);
  206.         $colName->set_resizable(true);
  207.         $colName->set_sort_column_id(0);
  208.         $this->arWidgets['lstPackages']->append_column($colName);
  209.  
  210.         $colInstalled = new GtkTreeViewColumn('Installed'$cell_renderer"text"1);
  211.         $colInstalled->set_resizable(true);
  212.         $colInstalled->set_sort_column_id(1);
  213.         $this->arWidgets['lstPackages']->append_column($colInstalled);
  214.  
  215.         $colNew = new GtkTreeViewColumn('New version'$cell_renderer"text"2);
  216.         $colNew->set_resizable(true);
  217.         $colNew->set_sort_column_id(2);
  218.         $this->arWidgets['lstPackages']->append_column($colNew);
  219.  
  220.         $colSummary = new GtkTreeViewColumn('Summary'$cell_renderer"text"3);
  221.         $colSummary->set_resizable(true);
  222.         $colSummary->set_sort_column_id(3);
  223.         $this->arWidgets['lstPackages']->append_column($colSummary);
  224.  
  225.         $selCategories $this->arWidgets['lstCategories']->get_selection();
  226.         $selCategories->set_mode(Gtk::SELECTION_SINGLE);
  227.         $selCategories->connect('changed'array($this'selectCategory'));
  228.  
  229.         $selPackages $this->arWidgets['lstPackages']->get_selection();
  230.         $selPackages->set_mode(Gtk::SELECTION_SINGLE);
  231.         $selPackages->connect('changed'array($this'selectPackage'));
  232.  
  233.         for ($nA = 1; $nA <= 3; $nA++{
  234.             $this->arAnimationImages[= GdkPixbuf::new_from_file(dirname(__FILE__'/Gtk2/pixmaps/progress/load-anim-' $nA '.png');
  235.         }
  236.         $this->nProgressImage = 0;
  237.  
  238.         $this->loadInstaller();
  239.     }//protected function buildDialog()
  240.  
  241.  
  242.  
  243.     protected function loadInstaller()
  244.     {
  245.         $this->installer = new PEAR_Frontend_Gtk2_Installation($this->arWidgets['dlgInstaller']$this->glade);
  246.         PEAR_Frontend::setFrontendObject($this->installer);
  247.     }//protected function loadInstaller()
  248.  
  249.  
  250.  
  251.     public function getInstaller()
  252.     {
  253.         return $this->installer;
  254.     }//public function getInstaller()
  255.  
  256.  
  257.  
  258.     public function showChannelDialog()
  259.     {
  260.         if ($this->channelDialog === null{
  261.             $this->channelDialog = new PEAR_Frontend_Gtk2_ChannelDialog($this->glade$this);
  262.         }
  263.         $this->channelDialog->show();
  264.     }//public function showChannelDialog()
  265.  
  266.  
  267.  
  268.     /**
  269.     *   A channel has been selected from the channel combo box
  270.     *
  271.     *   Has to be public as it is a callback function
  272.     *
  273.     *   @param GtkComboBox  $cmbChannel     The channel selection combo box
  274.     *   @param boolean      $bSecondTime    If the function is being run a second time (because the first run had a problem) - used to detect infinite loops.
  275.     */
  276.     public function selectChannel($cmbChannel$bSecondTime = false)
  277.     {
  278.         $strChannel $cmbChannel->get_active_text();
  279.  
  280.         $this->setChannelStyles($strChannel);
  281.  
  282.         $model $this->arWidgets['lstCategories']->get_model();
  283.         $model->clear();
  284.         $this->arWidgets['lstPackages']->get_model()->clear();
  285.  
  286.         //Channel categories
  287.         $this->packages->setActiveChannel($strChannel);
  288.  
  289.         if (!$this->packages->packagesLoaded()) {
  290.             //show the progress dialog before it gets loaded with the first callback
  291.             $this->showProgressDialog(true);
  292.         }
  293.  
  294.         try {
  295.             $arCategories $this->packages->getCategories(array($this'packagesCallback')$this->getWorkOffline());
  296.         catch (Exception $e{
  297.             $this->hideProgressDialog();
  298.             $dialog = new GtkMessageDialog(
  299.                 $this->arWidgets['dlgInstaller'],
  300.                 0,
  301.                 Gtk::MESSAGE_ERROR,
  302.                 Gtk::BUTTONS_OK,
  303.                 'Can\'t list the categories:' "\r\n"
  304.                 . $e->getCode(': ' $e->getMessage()
  305.                 . "\r\n\r\nMake sure you have an internet connection."
  306.             );
  307.             $dialog->set_transient_for($this->arWidgets['dlgInstaller']);
  308.             $dialog->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
  309.             $dialog->run();
  310.             $dialog->destroy();
  311.  
  312.             if (!$bSecondTime{
  313.                 //The exception code seem to vary on every run - so I can't check for a certain code.
  314.                 //But as we still can load the local packages, we can work offline.
  315.                 $this->setWorkOffline(true);
  316.                 $this->selectChannel($cmbChanneltrue);
  317.                 return;
  318.             else {
  319.                 //no chance to do a fix - do nothing
  320.                 return;
  321.             }
  322.         }
  323.  
  324.         $arCategories $this->appendSpecialCategories(
  325.             $arCategories
  326.         );
  327.  
  328.         foreach ($arCategories as $key => $strCategory{
  329.             $model->set($model->append()0$strCategory1$key);
  330.         }
  331.  
  332.         //Clear packages
  333.         $this->arWidgets['lstPackages']->get_model()->clear();
  334.         $this->arWidgets['lstCategories']->get_selection()->select_path('0');
  335.  
  336.         $this->hideProgressDialog();
  337.     }//public function selectChannel($cmbChannel, $bSecondTime = false)
  338.  
  339.  
  340.  
  341.     protected function setChannelStyles($strChannel)
  342.     {
  343.         //Logo
  344.         $strIcon dirname(__FILE__'/Gtk2/pixmaps/' $strChannel '.png';
  345.         if (!file_exists($strIcon)) {
  346.             $strIcon dirname(__FILE__'/Gtk2/pixmaps/default.png';
  347.         }
  348.         if (file_exists($strIcon)) {
  349.             $this->arWidgets['imgChannelLogo']->set_from_file($strIcon);
  350.         }
  351.  
  352.         //Colors
  353.         $strColorChannel $strChannel;
  354.         if (!isset(PEAR_Frontend_Gtk2_Config::$arChannels[$strColorChannel])) {
  355.             $strColorChannel 'default';
  356.         }
  357.         $colBg = GdkColor::parse(PEAR_Frontend_Gtk2_Config::$arChannels[$strColorChannel]['background-color']);
  358.         $colFg = GdkColor::parse(PEAR_Frontend_Gtk2_Config::$arChannels[$strColorChannel]['color']);
  359.  
  360.         $this->arWidgets['evboxSelectedCategory']->modify_bg(Gtk::STATE_NORMAL$colBg);
  361.         $this->arWidgets['lblSelectedCategory']->modify_fg(Gtk::STATE_NORMAL$colFg);
  362.     }//protected function setChannelStyles($strChannel)
  363.  
  364.  
  365.  
  366.     /**
  367.     *   Appends defined special categories to the given
  368.     *   list
  369.     *
  370.     *   @param  array   Array of categories
  371.     *   @return array   Array of categories with special ones
  372.     */
  373.     function appendSpecialCategories($arCategories)
  374.     {
  375.         foreach (PEAR_Frontend_Gtk2::$arSpecialCategories as $key => $value{
  376.             $arCategories[$key$value;
  377.         }
  378.         return $arCategories;
  379.     }//function appendSpecialCategories($arCategories)
  380.  
  381.  
  382.  
  383.     /**
  384.     *   A category has been selected
  385.     */
  386.     function selectCategory($selection)
  387.     {
  388.         list($model$iter$selection->get_selected();
  389.         if ($iter === null{
  390.             $this->arWidgets['lblSelectedCategory']->set_text('No category selected');
  391.             return;
  392.         }
  393.  
  394.         $this->strSelectedCategoryName  $model->get_value($iter0);
  395.         $this->strSelectedCategoryKey   $model->get_value($iter1);
  396.         $this->arWidgets['lblSelectedCategory']->set_markup('<b>' $this->strSelectedCategoryName '</b>');
  397.  
  398.         if ($this->strSelectedCategoryKey == self::CATEGORY_ALL{
  399.             $this->strSelectedCategoryName = null;
  400.         }
  401.         $this->showPackageList($this->strSelectedCategoryName);
  402.     }//function selectCategory($selection)
  403.  
  404.  
  405.  
  406.     /**
  407.     *   Fill the package list for the given category
  408.     */
  409.     protected function showPackageList($strCategory)
  410.     {
  411.         //Show packages
  412.         $model $this->arWidgets['lstPackages']->get_model();
  413.         $model->clear();
  414.         $arPackages $this->packages->getPackages($strCategory);
  415.         if (count($arPackages> 0{
  416.             foreach ($arPackages as $key => $package{
  417.                 $model->set(
  418.                     $model->append(),
  419.                     0$package->getName(),
  420.                     1$package->getInstalledVersion(),
  421.                     2$package->getLatestVersion(),
  422.                     3$package->getSummary(),
  423.                     4$package
  424.                 );
  425.             }
  426.         }
  427.     }//protected function showPackageList($strCategory)
  428.  
  429.  
  430.  
  431.     /**
  432.     *   Update the package list model entries for the given packages.
  433.     *   Useful after installing/uninstalling a package
  434.     *
  435.     *   @param array    $arPackages     Array of packages which model entry shall be updated
  436.     */
  437.     protected function updatePackageList($arPackages)
  438.     {
  439.         $model $this->arWidgets['lstPackages']->get_model();
  440.         $iter  $model->get_iter_first();
  441.         while ($iter !== null{
  442.             $package $model->get_value($iter4);
  443.             if (in_array($package$arPackages)) {
  444.                 $model->set(
  445.                     $iter,
  446.                     0$package->getName(),
  447.                     1$package->getInstalledVersion(),
  448.                     2$package->getLatestVersion(),
  449.                     3$package->getSummary(),
  450.                     4$package
  451.                 );
  452.             }
  453.             $iter $model->iter_next($iter);
  454.         }
  455.     }//protected function updatePackageList($arPackages)
  456.  
  457.  
  458.  
  459.     /**
  460.     *   Callback for the package loading functions
  461.     */
  462.     function packagesCallback($nPackageCount$nCurrentPackage)
  463.     {
  464.         $dlgProgress $this->arWidgets['dlgProgress'];
  465.         if ($nPackageCount === true{
  466.             //we're done
  467.             $this->hideProgressDialog();
  468.             return;
  469.         }
  470.         $this->showProgressDialog();
  471.         $this->arWidgets['lblProgress']->set_text($nCurrentPackage ' / ' $nPackageCount);
  472.         $this->arWidgets['progBar']->set_fraction(1/$nPackageCount $nCurrentPackage);
  473.  
  474.         $this->nProgressImage++;
  475.         if (!isset($this->arAnimationImages[$this->nProgressImage])) {
  476.             $this->nProgressImage = 0;
  477.         }
  478.         //TODO: hold the images in memory
  479.         $this->arWidgets['imgProgress']->set_from_pixbuf($this->arAnimationImages[$this->nProgressImage]);
  480.         while (Gtk::events_pending()) Gtk::main_iteration();}
  481.     }//function packagesCallback($nPackageCount, $nCurrentPackage)
  482.  
  483.  
  484.  
  485.     public function selectPackage($selection)
  486.     {
  487.         list($model$iter$selection->get_selected();
  488.         if ($iter === null{
  489.             $strDescription '';
  490.             $this->setSelectedPackage(null);
  491.             $this->arWidgets['btnUninstall']->hide();
  492.             $this->arWidgets['btnInstall']  ->set_sensitive(false);
  493.         else {
  494.             $package $model->get_value($iter4);
  495.             $this->setSelectedPackage($package);
  496.             $strDescription $package->getDescription();
  497.             $this->ableInstallButtons($package);
  498.             if ($package->getInstalledVersion(=== null || $package->getInstalledVersion(== ''{
  499.                 $this->arWidgets['lblBtnInstall']->set_label('Inst_all package');
  500.             else {
  501.                 $this->arWidgets['lblBtnInstall']->set_label('Upgr_ade package');
  502.             }
  503.         }
  504.  
  505.         $this->arWidgets['txtPackageInfo']->get_buffer()->set_text($strDescription);
  506.     }//public function selectPackage($selection)
  507.  
  508.  
  509.  
  510.     /**
  511.     *   Enables or disables the install buttons depending
  512.     *   on the installation status of $package
  513.     *
  514.     *   @param PEAR_Frontend_Gtk2_Package $package  The package to check
  515.     */
  516.     protected function ableInstallButtons($package)
  517.     {
  518.         if ($package === null{
  519.             return;
  520.         }
  521.  
  522.         $this->arWidgets['btnInstall']->set_sensitive(
  523.             $package->getLatestVersion(!== null
  524.             && $package->getLatestVersion(!== ''
  525.         );
  526.  
  527.         if ($package->getInstalledVersion(== ''{
  528.             $this->arWidgets['btnUninstall']->hide();
  529.             $this->arWidgets['btnUninstall']->set_sensitive(false);
  530.         else {
  531.             $this->arWidgets['btnUninstall']->show();
  532.             $this->arWidgets['btnUninstall']->set_sensitive(true);
  533.         }
  534.     }//protected function ableInstallButtons($package)
  535.  
  536.  
  537.  
  538.     protected function updateInstallButtons()
  539.     {
  540.         $selection $this->arWidgets['lstPackages']->get_selection();
  541.         list($model$iter$selection->get_selected();
  542.         $package $model->get_value($iter4);
  543.         $this->ableInstallButtons($package);
  544.     }//protected function updateInstallButtons()
  545.  
  546.  
  547.  
  548.     protected function getSelectedPackage()
  549.     {
  550.         return $this->selectedPackage;
  551.     }//protected function getSelectedPackage()
  552.  
  553.  
  554.  
  555.     protected function setSelectedPackage($package)
  556.     {
  557.         $this->selectedPackage $package;
  558.     }//protected function setSelectedPackage($package)
  559.  
  560.  
  561.  
  562.     /**
  563.     *   Installs (or uninstalls) the selected package
  564.     *
  565.     *   @param boolean $bInstall    True if the package shall be installed, false if it shall be uninstalled
  566.     */
  567.     function installPackage($bInstall = true)
  568.     {
  569.         $strChannel $this->packages->getActiveChannel();
  570.         $package $this->getSelectedPackage();
  571.         if ($package === null{
  572.             $dialog = new GtkMessageDialog(
  573.                 $this->arWidgets['dlgInstaller']0Gtk::MESSAGE_ERRORGtk::BUTTONS_OK,
  574.                 'You have to select a package before you can install it.'
  575.             );
  576.             $dialog->run();
  577.             $dialog->destroy();
  578.             return;
  579.         }
  580.  
  581.         //get changes done in gui into config
  582.         PEAR_Frontend_Gtk2_Config::loadConfigurationFromGui($this);
  583.  
  584.         $this->installer->installPackage(
  585.             $strChannel,
  586.             $package->getName(),
  587.             $package->getLatestVersion(),
  588.             $bInstall,
  589.             PEAR_Frontend_Gtk2_Config::$strDepOptions
  590.         );
  591.  
  592.         $package->refreshLocalInfo();
  593.         $this->updatePackageList(array($package));
  594.         $this->updateInstallButtons();
  595.     }//function installPackage($bInstall = true)
  596.  
  597.  
  598.  
  599.     /**
  600.     *   Shows the progress dialog if that hasn't already been done
  601.     *
  602.     *   @param boolean  $bInitWithZero  If the dialog's labels should be initialized (if the dialog has been hidden)
  603.     */
  604.     protected function showProgressDialog($bInitWithZero = false)
  605.     {
  606.         $dlgProgress $this->arWidgets['dlgProgress'];
  607.         if ($dlgProgress->window === null || !$dlgProgress->window->is_visible()) {
  608.             //show it
  609.             $dlgProgress->modify_bg(Gtk::STATE_NORMALGdkColor::parse('#FFFFFF'));
  610.             $dlgProgress->set_transient_for($this->arWidgets['dlgInstaller']);
  611.             $dlgProgress->set_position(Gtk::WIN_POS_CENTER_ON_PARENT);
  612.  
  613.             if ($bInitWithZero{
  614.                 $this->arWidgets['lblProgress']->set_text('');
  615.                 $this->arWidgets['progBar']->set_fraction(0);
  616.             }
  617.  
  618.             $dlgProgress->show_now();
  619.             while (Gtk::events_pending()) Gtk::main_iteration();}
  620.         }
  621.     }//protected function showProgressDialog($bInitWithZero = false)
  622.  
  623.  
  624.  
  625.     /**
  626.     *   Hides the progress dialog
  627.     */
  628.     protected function hideProgressDialog()
  629.     {
  630.         $this->arWidgets['dlgProgress']->hide();
  631.         while (Gtk::events_pending()) Gtk::main_iteration();}
  632.     }//protected function hideProgressDialog()
  633.  
  634.  
  635.  
  636.     /**
  637.     *   The user may not close the progress window by hand
  638.     */
  639.     public function deleteProgressWindow()
  640.     {
  641.         return true;
  642.     }//public function deleteProgressWindow()
  643.  
  644.  
  645.  
  646.     /**
  647.     *   Check if the user wants to work offline
  648.     *   @return boolean     True, if the offline setting is active (work offline), false if working online
  649.     */
  650.     protected function getWorkOffline()
  651.     {
  652.         return $this->arWidgets['mnuOffline']->get_active();
  653.     }//protected function getWorkOffline()
  654.  
  655.  
  656.  
  657.     /**
  658.     *   Set the offline setting
  659.     *   @param boolean $bOffline    If the user wants to work offline (true) or not (false)
  660.     */
  661.     protected function setWorkOffline($bOffline)
  662.     {
  663.         return $this->arWidgets['mnuOffline']->set_active($bOffline);
  664.     }//protected function setWorkOffline($bOffline)
  665.  
  666.  
  667.  
  668.     public function getWidget($strWidget)
  669.     {
  670.         return $this->arWidgets[$strWidget];
  671.     }//public function getWidget($strWidget)
  672.  
  673.  
  674.  
  675.     /**
  676.     *   Reload local package information and update the list.
  677.     */
  678.     public function refreshLocalPackages()
  679.     {
  680.         $this->packages->refreshLocalPackages();
  681.         $this->showPackageList($this->strSelectedCategoryName);
  682.     }//public function refreshLocalPackages()
  683.  
  684.  
  685.  
  686.     /**
  687.     *   Reload the online package list and package information,
  688.     *   and update the list here.
  689.     */
  690.     public function refreshOnlinePackages()
  691.     {
  692.         $this->packages->refreshRemotePackages(nullarray($this'packagesCallback'));
  693.         $this->showPackageList($this->strSelectedCategoryName);
  694.     }//public function refreshOnlinePackages()
  695.  
  696.  
  697.  
  698.     public function userConfirm()
  699.     {
  700.         //just to make sure that the class is recognized as proper PEAR_Frontend class
  701.     }
  702.  
  703.  
  704.  
  705.     /**
  706.     *   A fatal error occured
  707.     *
  708.     *   @param PEAR_Error $error The error
  709.     */
  710.     public function displayFatalError($error)
  711.     {
  712.         $strMessage $error->getMessage();
  713.  
  714.         //404 occurs often and isn't that bad, so we can ignore it
  715.         //404 occurs, if a package exists but hasn't released a version.
  716.         if (strpos(strtolower($strMessage)'404 not found'=== false{
  717.             $dialog = new GtkMessageDialog(
  718.                 $this->arWidgets['dlgInstaller'],
  719.                 Gtk::DIALOG_MODAL,
  720.                 Gtk::MESSAGE_ERROR,
  721.                 Gtk::BUTTONS_OK,
  722.                 'A fatal error occured:' "\r\n" $strMessage
  723.             );
  724.             $answer $dialog->run();
  725.             $dialog->destroy();
  726.         }
  727.     }//public function displayFatalError($error)
  728.  
  729. }//class PEAR_Frontend_Gtk2
  730. ?>

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