Source for file DirSelect.php
Documentation is available at DirSelect.php
+----------------------------------------------------------------------+
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 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.5 2003/01/04 11:55:55 mj 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
* The GtkDialog of the window
* @var object GtkOptionMenu
* The full list of directories
* @param object PEAR_Frontend_Gtk
function PEAR_Frontend_Gtk_DirSelect (&$ui) {
* Currently active widget to save result into (eg. gtkentry)
var $_DirSelectActiveWidget = NULL;
* Currently active configuration key
var $_DirSelectActiveKey = 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,$key) {
$this->_DirSelectActiveKey = $key;
$this->_DirSelectActiveWidget = &$widget;
$prompt = $this->ui->config ->getPrompt ($widget->get_data ('key'));
$this->window->set_title ($prompt);
$curvalue = $widget->get_text ();
$this->entry->set_text ($curvalue);
* Associated array of Row -> directory name
* It could be possible to get the row string using gtk calls......
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);
$gtkmenu = &new GtkMenu ();
foreach($parts as $dirpart) {
$dir = implode(DIRECTORY_SEPARATOR ,$disp);
if (!$dir && DIRECTORY_SEPARATOR == '/') $dir = '/';
$items[$i] = &new GtkMenuItem ($dir);
$items[$i]->connect_object_after ('activate', array (&$this,'_DirSelectSetDir'),$dir);
$gtkmenu->append ($items[$i]);
$gtkmenu->set_active ($i-1 );
$this->optionMenu->set_menu ($gtkmenu);
$this->cList->select_row (0 ,0 );
while (($dir = readdir($dh)) !== FALSE ) {
if (!is_dir($base.DIRECTORY_SEPARATOR. $dir)) continue;
$this->_DirSelectRows = array ();
$this->cList->append (array ($dir));
$this->_DirSelectRows[] = realpath($base.DIRECTORY_SEPARATOR. $dir);
$this->cList->select_row ($sel,0 );
$this->cList->moveto ($i,0 ,0 ,0 );
$this->entry->set_text ($directory);
$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 $_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 );
$this->entry->set_text (@$this->_DirSelectRows[$row]);
* Callback when the list of directories is clicked
* Used to find the double click to open it.
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)
* Callback when the OK btn is pressed
* hide window and update original widget.
if (!$this->_DirSelectActiveWidget) return;
$new= $this->entry->get_text ();
$old= $this->_DirSelectActiveWidget->get_text ();
$this->_DirSelectActiveWidget->set_text ($new);
$this->ui->_config ->NewConfig [$this->_DirSelectActiveKey] = $new;
$this->ui->_config ->ActivateConfigSave ();
$this->_DirSelectActiveWidget = NULL;
Documentation generated on Mon, 11 Mar 2019 14:28:56 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|