GtkFileSelection Constructor

GtkFileSelection ([string title = null]);

Use the constructor to create a prompt for the user to select a file or directory. By default, a GtkTreeView of the application's current working directory and its file listing will be displayed. Operation buttons and the drop-down history of directories are also visible.

Example 67. An example for a GtkFileSelection prompt.

//Creating and initialising the file selection prompt
$filePrompt = new GtkFileSelection('GtkFileSelection Demo');
    array('Gtk', 'main_quit')

//Adding a quit button that destroys the prompt
    array($filePrompt, 'destroy')

//Add an OK button that displays the file selected on click
$filePrompt->ok_button->set_label('Show the file');
$filePrompt->ok_button->connect('clicked', 'showFile');

//Callback function that displays the file name
function showFile($okbutton)
    $filePrompt = $okbutton->get_toplevel();
    $fileName = $filePrompt->get_filename();
    $message = new GtkMessageDialog(
        'You selected: ' . $fileName

//Show the prompt and start the main loop