| View previous topic :: View next topic |
| Author |
Message |
ragnar
Joined: 01 Apr 2006 Posts: 14
|
Posted: Tue May 23, 2006 6:37 pm Post subject: GtkFileChooserButton |
|
|
hello, ive been testing this widget because i need it and it seem to be broken with the action FILE_CHOOSER_ACTION_SAVE, i tried everything and even with the example of the gtk.php.net the program crash if u change the action to save...
this is the crash message:
[23-may-2006 18:23:01] PHP Fatal error: Uncaught exception 'PhpGtkConstructException' with message 'could not construct GtkFileChooserButton object' in C:\lirio\guardar.phpw:26
Stack trace:
#0 C:\lirio\guardar.phpw(26): GtkFileChooserButton->__construct('Select the File', 3)
#1 {main}
thrown in C:\lirio\guardar.phpw on line 26 |
|
| Back to top |
|
 |
scott
Joined: 16 Feb 2006 Posts: 35
|
Posted: Tue May 23, 2006 7:24 pm Post subject: |
|
|
You can use a file chooser button to save files. Only to open files or directories. Take a look at the Gtk+ docs: http://developer.gnome.org/doc/API/2.0/gtk/GtkFileChooserButton.html
| Quote: | | The GtkFileChooserButton supports the GtkFileChooserActions GTK_FILE_CHOOSER_ACTION_OPEN and GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER. |
|
|
| Back to top |
|
 |
ragnar
Joined: 01 Apr 2006 Posts: 14
|
Posted: Tue May 23, 2006 9:48 pm Post subject: |
|
|
so why its written in gtk.php.net that i can also save files?
and what is more important... if i cant use this to save, which is suposed i have to use? |
|
| Back to top |
|
 |
scott
Joined: 16 Feb 2006 Posts: 35
|
Posted: Tue May 23, 2006 10:12 pm Post subject: |
|
|
Try GtkFileChooserDialog
You can launch by connecting to the clicked signal of a GtkButton if you'd like or the activate signal of a GtkToolButton.
The docs say, "Use this constructor to create a new file-selecting button widget." I will update them to make it more clear that the button is for opening only. |
|
| Back to top |
|
 |
ragnar
Joined: 01 Apr 2006 Posts: 14
|
Posted: Thu May 25, 2006 1:40 pm Post subject: |
|
|
done! GtkFileChooserDialog works pretty good for saving files BUT!! im having problems the cancel button... i mean, the 4th parameter are the buttons, the response of the OK works fine but i could find a response to make work the button cancel and close the window.
| Code: | | $dialogo_destino = new GtkFileChooserDialog("titulo", $this->wn_principal, "GTK_FILE_CHOOSER_ACTION_SAVE", array(Gtk::STOCK_OK, Gtk::RESPONSE_OK, Gtk::STOCK_CANCEL, Gtk::RESPONSE_CANCEL)); |
i also tryed with REJECT, CLOSE and NO that by the way i found the official website of python-gtk with all the constants, somebody could be interested: http://www.pygtk.org/pygtk2reference/gtk-constants.html |
|
| Back to top |
|
 |
scott
Joined: 16 Feb 2006 Posts: 35
|
Posted: Thu May 25, 2006 2:32 pm Post subject: |
|
|
You should use Gtk::RESPONSE_CANCEL. Adding a cancel button does not make the window automatically close. That is still up to you to manage. The easiest way is probably to use the dialog's run() method:
| Code: | $dialog = new GtkFileChooserDialog(...);
$dialog->show_all();
if ($dialog->run() == Gtk::RESPONSE_OK) {
// Save file
}
$dialog->destroy(); // Or hide() if you are planning on using the dialog again. |
|
|
| Back to top |
|
 |
ragnar
Joined: 01 Apr 2006 Posts: 14
|
Posted: Thu May 25, 2006 5:29 pm Post subject: |
|
|
thanks a lot scott, u had been a very good help, im finishing a program that i hope ill publish here soon but i reached the most difficult part and until now it was enough with my programming knowledge and the few documents that i found but its starting to be really desperate without almost documentation.
so thanks a lot scott, and if u come some day to spain just let me know to show u the spanish parties. hehehe |
|
| Back to top |
|
 |
|