0

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);
});

Screenshot

Thanks in advance!

Anton
  • 68
  • 3
  • 7
  • Missing "\n" in your printf, I think – Jussi Kukkonen Jun 21 '16 at 20:39
  • `file-set` is for when the user clicks Open to choose a file, thus changing the file that the GtkFileChooserButton represents. `file-activated` is for when the user double-clicks a file in a GtkFileChooserWidget; I assume GtkFileChooserDialog and GtkFileChooserButton both that that as clicking Open. [I'm guessing you want `selection-changed`?](https://developer.gnome.org/gtk3/stable/GtkFileChooser.html#GtkFileChooser-selection-changed) That is, assuming that I read your question correctly and that you want to be notified when an item on the list is clicked. Did I? – andlabs Jun 21 '16 at 20:45

1 Answers1

0

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.

Anton
  • 68
  • 3
  • 7