1

I have a file chooser button that triggers a change in the titlebar whenever a file is selected with it. And it seems to work fine in my non-flatpak build.

import gtk.Application : Application;
import gtk.ApplicationWindow : ApplicationWindow;
import gio.Application : GioApp = Application;
import gtkc.gtktypes : GApplicationFlags, FileChooserAction;
import gtk.FileChooserButton : FileChooserButton;

const string AppID = `org.github.flatfcbtest`;

int main(string[] args)
{
    auto app = new App();
    return app.run(args);
}

public class App : Application
{
public:
    this(const string appID = AppID, const GApplicationFlags flags = GApplicationFlags.FLAGS_NONE)
    {
        super(appID, flags);

        addOnActivate(delegate void(GioApp _) {

            auto pw = new PrimaryWindow(this);
            pw.showAll();
        });
    }
}

class PrimaryWindow : ApplicationWindow
{
    this(Application app)
    {
        super(app);
        setSizeRequest(500, 300);

        auto fcb = new FileChooserButton(`Select file`, FileChooserAction.OPEN);
        fcb.addOnFileSet(delegate void (FileChooserButton _) {
            setTitle(`file set!`);
        });
        add(fcb);

    }
}

(GtkD reference)

However in my flatpak builds, the file selected with the chooser button does not select anything and it keeps saying (None). However my titlebar is changes accordingly so I know that the signal was emitted by the file chooser button.

Here is my flatpak permissions list:

finish-args:
  - --socket=fallback-x11
  - --share=ipc
  - --filesystem=host
  - --device=all
  - --socket=session-bus

What's causing this?

noconst
  • 639
  • 4
  • 15

1 Answers1

1

Typically if you're shipping a flatpak, you want to avoid --filesystem=host and just use GtkFileChooserNative instead. This class supports portals, allowing a user to select files the application does not have permission to access by itself.

This is a much better approach than giving the application full filesystem access. GtkFileChooserNative will still work in a non-flatpak application and you shouldn't notice any difference unless you're doing something fancy.

As for your question of why GtkFileChooser is not working with --filesystem=host however, I do not know.

andy.holmes
  • 3,383
  • 17
  • 28