gnope php gtk gui gnope.org  

Function not implemented, or other problem?

 
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners
View previous topic :: View next topic  
Author Message
beidlerj



Joined: 10 Feb 2006
Posts: 55
Location: Oregon, USA

PostPosted: Mon Feb 13, 2006 7:51 pm    Post subject: Function not implemented, or other problem? Reply with quote

Hello -

I've been reading through the PHP-GTK2 documentation on php-gtk2.de, trying to learn about file selection dialogs. I'm trying to make a little app and think I will let the user select multiple files, then (for starters) will show a list of the files they selected with toggle checkboxes.

In the example code for the GtkFileSelection constructor,
Code:
<?php
/* Creating and initialising the file selection prompt */
$filePrompt = new GtkFileSelection('GtkFileSelection Demo');
$filePrompt->connect_simple('destroy', array('gtk', 'main_quit'));
 
/* Adding a quit button that destroys the prompt */
$filePrompt->cancel_button->set_label('Quit');
$filePrompt->cancel_button->connect_simple('clicked', 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(null, 0, Gtk::MESSAGE_INFO,
    Gtk::BUTTONS_OK, 'You selected: ' . $fileName);
    $message->run();
    $message->destroy();
}
 
/* Show the prompt and start the main loop */
$filePrompt->show();
Gtk::main();
?>


I added
Code:
$filePrompt->set_select_multiple('true');
before the function definition, and, inside the definition, changed
Code:
$fileName = $filePrompt->get_filename();
to
Code:
$fileName = $filePrompt->get_selections();
which is the method prescribed in the documentation for getting the list of files selected by the user. When running the code, however, I get the error:
Code:
PHP Fatal error:  Call to undefined method GtkFileSelection::get_selections() in E:\examples.php on line 18


Am I doing something wrong? The documentation doesn't say that the method hasn't been implemented yet... as near as I can tell, it has been. Why the error, then?
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Mon Feb 13, 2006 11:04 pm    Post subject: Reply with quote

Remember that PHP-Gtk2 ist still Alpha-quality software. There hasn't been a beta release yet, and the method you found is one of the methods that's still missing.

Also remember that the version gnope ships is from mid November 2005, and in the meantime a lot of things have been fixed. A new inofficial version will be released in the near future.
Back to top
beidlerj



Joined: 10 Feb 2006
Posts: 55
Location: Oregon, USA

PostPosted: Mon Feb 13, 2006 11:11 pm    Post subject: Reply with quote

Ah, okay.

I just thought I must have been doing something wrong, since I usually see notes that say something like "This function has not yet been implemented."

So what I was doing was the correct way to get at the list of files the user selected in the dialog?

Thanks for the reply! You are the PHP-Gtk MASTER! Smile
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Mon Feb 13, 2006 11:20 pm    Post subject: Reply with quote

beidlerj wrote:
So what I was doing was the correct way to get at the list of files the user selected in the dialog?

There is a PHP-Gtk2 coding blog that dealt with that kind of question:
http://www.writingup.com/phpgtk2/0021_file_dialog_windows_part_i
Back to top
beidlerj



Joined: 10 Feb 2006
Posts: 55
Location: Oregon, USA

PostPosted: Mon Feb 13, 2006 11:45 pm    Post subject: Reply with quote

Nice! I hadn't come across that blog in my searchings. It looks good. Are you the author? You really do know everything!

I appreciate (and hope others do as well) the work you do for PHP(GTK) and your willingness to help out and respond quickly to questions and posts on boards! Thank you! Very Happy
Back to top
cweiske



Joined: 08 Dec 2005
Posts: 454
Location: Leipzig/Germany

PostPosted: Mon Feb 13, 2006 11:50 pm    Post subject: Reply with quote

beidlerj wrote:
Are you the author?

No, I can't do everything :)
Back to top
Display posts from previous:   
Post new topic   Reply to topic    gnope.org Forum Index -> PHP GTK2 Beginners All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Templates enhanced by DigiWiki. Hosting by Tradebit.