| View previous topic :: View next topic |
| Author |
Message |
Osiris
Joined: 17 Dec 2005 Posts: 65
|
Posted: Thu Feb 09, 2006 1:44 pm Post subject: example of calling FileDialog from event |
|
|
Hello,
i wan't to open a FileSelectorDialog, when choosing a menuitem (Open).
Within the dialog only a defined file-type should be available to select.
So how do a call to the file-dialog?
Greetings
Christian |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Thu Feb 09, 2006 2:16 pm Post subject: |
|
|
You need to connect the "activate" signal of the menu item to a function.
In that function, create a new file dialog and show that. The class to use is GtkFileChooserDialog. |
|
| Back to top |
|
 |
Osiris
Joined: 17 Dec 2005 Posts: 65
|
Posted: Thu Feb 09, 2006 2:25 pm Post subject: |
|
|
ok, my question was a little bit too indefinite.
- the connect to "activate" runs
- showing the GTLFileChooserDialog runs too
But the definition, wich filetype should be available to select (in my case .catalog) doesn't run.
How to implement this last step?
Application is glade-oriented (maybe important) |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Thu Feb 09, 2006 2:30 pm Post subject: |
|
|
| Osiris wrote: | | But the definition, wich filetype should be available to select (in my case .catalog) doesn't run. |
addFilter()? |
|
| Back to top |
|
 |
inspight
Joined: 08 Feb 2006 Posts: 4
|
Posted: Thu Feb 09, 2006 5:47 pm Post subject: |
|
|
Here is an example call back function for a open file dialog that seems to work for me.
| Code: |
function on_open() {
$fileDialog=new GtkFileChooserDialog("Open", null,
Gtk::FILE_CHOOSER_ACTION_OPEN, array(Gtk::STOCK_CANCEL,
Gtk::RESPONSE_CANCEL,
Gtk::STOCK_OK,
Gtk::RESPONSE_OK));
$filter=new GtkFileFilter();
$filter->set_name("Image Files");
$filter->add_pattern("*.jpg");
$filter->add_pattern("*.gif");
$filter->add_pattern("*.png");
$fileDialog->add_filter($filter);
$return=$fileDialog->run();
$imagePath=$fileDialog->get_filename();
$fileDialog->destroy();
if($return=="-5"){
$this->image=$imagePath;
}
} |
Last edited by inspight on Thu Feb 09, 2006 5:55 pm; edited 3 times in total |
|
| Back to top |
|
 |
cweiske
Joined: 08 Dec 2005 Posts: 454 Location: Leipzig/Germany
|
Posted: Thu Feb 09, 2006 5:50 pm Post subject: |
|
|
| inspight wrote: | | $fileDialog=&new GtkFileChooserDialog( |
No! Don't use the ampersand & any more with php5! |
|
| Back to top |
|
 |
Osiris
Joined: 17 Dec 2005 Posts: 65
|
Posted: Fri Feb 10, 2006 10:13 pm Post subject: |
|
|
ok,
thanks, the example is very good, or to say it with the words of another poster or an artist "I can see clearly now..." |
|
| Back to top |
|
 |
|