Skip to content

Sidnioulz/SandboxUtils

Repository files navigation

SandboxUtils
============

## SandboxFileChooserDialog
This is a file chooser dialog API for sandboxed apps. Two subclasses: LocalFileChooserDialog and RemoteFileChooserDialog. The local one is used by the server to provide you with a sandbox-traversing file chooser dialog. The remote one should be used by your app to transport each call over GDBus back to the server. In any case, the SandboxFileChooserDialog methods (sfcd_*) will be used in all code, and constructors are used to choose whether to create a local or remote dialog.

See the following examples on how to query the server.

### Create a dialog, verify its default action, run it and close it
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.New "Terrible Choices" "Morpheus" 2 "{'Blue Pill': <3>, 'Red Pill': <0>}"
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.GetAction <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.Run <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.CancelRun <dialog id>

### Make it a Save File dialog, run it and close it
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetAction <dialog id> 3
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.Run <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.CancelRun <dialog id>

### Now set a current name, run it and observe the difference. Try to change again and witness statefulness
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetCurrentName <dialog id> potatoes
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.Run <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetCurrentName <dialog id> carrots

### Get upset and destroy your dialog. Regret it and observe the dialog is gone.
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.Destroy <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.Run <dialog id>

### Another example with a white rabbit and configuring a dialog
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.New "Terrible Choices" "Morpheus" 3 "{'Blue Pill': <3>, 'Red Pill': <0>}"
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetCurrentFolder <dialog id> /home/steve/Pictures
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetCurrentName <dialog id> WhiteRabbit.jpg
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.Run <dialog id> 
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetCurrentName <dialog id> Agents.jpg

### Notice how setting multiple files only works when opening files
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.New "Terrible Choices" "Morpheus" 3 "{'Blue Pill': <3>, 'Red Pill': <0>}"
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetSelectMultiple <dialog id> true
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.GetSelectMultiple <dialog id> 
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetAction <dialog id> 0
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetSelectMultiple <dialog id> true
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.GetSelectMultiple <dialog id> 

### Select multiple files, run the dialog, get the filenames and notice current name isn't set
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.New "Terrible Choices" "Morpheus" 0 "{'Blue Pill': <3>, 'Red Pill': <0>}"
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.SetSelectMultiple <dialog id> true
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.Run <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.GetUri <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.GetFilename <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.GetCurrentName <dialog id>
gdbus call --session --dest org.mupuf.SandboxUtils.SandboxFileChooserDialog --object-path /org/mupuf/SandboxUtils --method org.mupuf.SandboxUtils.SandboxFileChooserDialog.GetFilenames <dialog id>

About

Utilities for accessing resources from within a Linux userland sandbox, through DBus

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages