How to pass command line arguments to app in gtk-rs?

Each time when I try to use command line argument like ./app /home/path I have an error:

(czkawka_gui:100584): GLib-GIO-CRITICAL **: 13:24:46.399: This application can not open files.

Why I can’t just use environment variables via env::vars() ?

Why I can’t just use environment variables via env::vars() ?

You can, but you shouldn’t because the purpose of gio::Application is to support receiving arguments/files through D-Bus activation and method calls, which lets you receive command lines from other sources or while the application is running.

To receive just a list of files, you must pass gio::ApplicationFlags::HANDLES_OPEN to the application constructor, and then handle the open signal.

Your application must use gio::ApplicationFlags::HANDLES_OPEN and provide the open method in the gio::ApplicationImpl trait, in order to support opening files from the command line.

For any other command line argument, you will need gio::ApplicationFlags::HANDLES_COMMAND_LINE and the command_line method on the ApplicationImpl trait.

If you are not subclassing gio::Application then you will still need to pass the appropriate flags, but you can use the open and command-line signals, respectively.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.