diff options
author | Micah Lee <micah@micahflee.com> | 2021-11-14 14:24:02 -0800 |
---|---|---|
committer | Micah Lee <micah@micahflee.com> | 2021-11-14 14:24:02 -0800 |
commit | 94c588d0ce6ce76ffc7714621a04b207e0522c14 (patch) | |
tree | 8c250282975ee94d0888d0764e03db19426769ea /desktop/src/onionshare | |
parent | 365ddc5e3464fe1ad2c006fdd72985299b72cad1 (diff) | |
download | onionshare-94c588d0ce6ce76ffc7714621a04b207e0522c14.tar.gz onionshare-94c588d0ce6ce76ffc7714621a04b207e0522c14.zip |
Make the FileSelection widget use native file browser widgets under Flatpak in order to enable the sandbox
Diffstat (limited to 'desktop/src/onionshare')
-rw-r--r-- | desktop/src/onionshare/tab/mode/file_selection.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/desktop/src/onionshare/tab/mode/file_selection.py b/desktop/src/onionshare/tab/mode/file_selection.py index 302f07b9..6d1c2d65 100644 --- a/desktop/src/onionshare/tab/mode/file_selection.py +++ b/desktop/src/onionshare/tab/mode/file_selection.py @@ -342,8 +342,20 @@ class FileSelection(QtWidgets.QVBoxLayout): self.file_list.files_dropped.connect(self.update) self.file_list.files_updated.connect(self.update) - # Buttons + # Sandboxes (for masOS, Flatpak, etc.) need separate add files and folders buttons, in + # order to use native file selection dialogs + + # macOS if self.common.platform == "Darwin": + self.sandbox = True + # Flatpack + elif self.common.platform == "Linux" and os.path.exists("/app/manifest.json"): + self.sandbox = True + else: + self.sandbox = False + + # Buttons + if self.sandbox: # The macOS sandbox makes it so the Mac version needs separate add files # and folders buttons, in order to use native file selection dialogs self.add_files_button = QtWidgets.QPushButton(strings._("gui_add_files")) @@ -357,7 +369,7 @@ class FileSelection(QtWidgets.QVBoxLayout): self.remove_button.clicked.connect(self.delete) button_layout = QtWidgets.QHBoxLayout() button_layout.addStretch() - if self.common.platform == "Darwin": + if self.sandbox: button_layout.addWidget(self.add_files_button) button_layout.addWidget(self.add_folder_button) else: @@ -376,14 +388,14 @@ class FileSelection(QtWidgets.QVBoxLayout): """ # All buttons should be hidden if the server is on if self.server_on: - if self.common.platform == "Darwin": + if self.sandbox: self.add_files_button.hide() self.add_folder_button.hide() else: self.add_button.hide() self.remove_button.hide() else: - if self.common.platform == "Darwin": + if self.sandbox: self.add_files_button.show() self.add_folder_button.show() else: |