Can someone tell me what type of signal for FileChooserButton
I have to use, to get file path by clicking on the actual file in FileChooserDialog
that was brought up by FileChooserButton
? I've used both file_set
and file_activated
signals but nothing has happened.
I've used an example from Vala language documentation. And I'm not sure whether there should be Open\Cancel buttons in that dialog(See the screenshot below)?
Here is the code, that I've used:
Gtk.FileChooserButton file_chooser = new Gtk.FileChooserButton(
"Select a file",
Gtk.FileChooserAction.OPEN);
file_chooser.set_show_hidden(true);
file_chooser.set_local_only(false);
file_chooser.set_current_folder("/home");
Gtk.FileFilter filter = new Gtk.FileFilter();
filter.add_mime_type("application/x-shellscript");
file_chooser.set_filter(filter);
file_chooser.file_set.connect(() => {
string uri = file_chooser.get_uri();
stdout.printf("Uri: %s", uri);
});
Thanks in advance!
Solved it! The problem was in missing buttons Ok\Cancel
, this occurs only in Elementary OS, I believe.
Command:
gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DialogsUseHeader':<0>}"
did it's job!
Thanks for the replies.