mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-25 22:15:57 -05:00
Detect Flatpak via environment variable
This commit is contained in:
parent
70248ed4a5
commit
0f63c89a59
@ -432,6 +432,12 @@ class Common:
|
|||||||
r = random.SystemRandom()
|
r = random.SystemRandom()
|
||||||
return "-".join(r.choice(wordlist) for _ in range(word_count))
|
return "-".join(r.choice(wordlist) for _ in range(word_count))
|
||||||
|
|
||||||
|
def is_flatpak(self):
|
||||||
|
"""
|
||||||
|
Returns True if OnionShare is running in a Flatpak sandbox
|
||||||
|
"""
|
||||||
|
return os.environ.get("FLATPAK_ID") == "org.onionshare.OnionShare"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def random_string(num_bytes, output_len=None):
|
def random_string(num_bytes, output_len=None):
|
||||||
"""
|
"""
|
||||||
|
@ -186,7 +186,7 @@ class FileList(QtWidgets.QListWidget):
|
|||||||
dragEnterEvent for dragging files and directories into the widget.
|
dragEnterEvent for dragging files and directories into the widget.
|
||||||
"""
|
"""
|
||||||
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
||||||
if self.common.platform == "Linux" and os.path.exists("/app/manifest.json"):
|
if self.common.is_flatpak():
|
||||||
Alert(self.common, strings._("gui_dragdrop_sandbox_flatpak").format())
|
Alert(self.common, strings._("gui_dragdrop_sandbox_flatpak").format())
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
@ -213,7 +213,7 @@ class FileList(QtWidgets.QListWidget):
|
|||||||
dragLeaveEvent for dragging files and directories into the widget.
|
dragLeaveEvent for dragging files and directories into the widget.
|
||||||
"""
|
"""
|
||||||
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
||||||
if self.common.platform == "Linux" and os.path.exists("/app/manifest.json"):
|
if self.common.is_flatpak():
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ class FileList(QtWidgets.QListWidget):
|
|||||||
dragMoveEvent for dragging files and directories into the widget.
|
dragMoveEvent for dragging files and directories into the widget.
|
||||||
"""
|
"""
|
||||||
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
||||||
if self.common.platform == "Linux" and os.path.exists("/app/manifest.json"):
|
if self.common.is_flatpak():
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ class FileList(QtWidgets.QListWidget):
|
|||||||
dropEvent for dragging files and directories into the widget.
|
dropEvent for dragging files and directories into the widget.
|
||||||
"""
|
"""
|
||||||
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
# Drag and drop doesn't work in Flatpak, because of the sandbox
|
||||||
if self.common.platform == "Linux" and os.path.exists("/app/manifest.json"):
|
if self.common.is_flatpak():
|
||||||
event.ignore()
|
event.ignore()
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -365,12 +365,7 @@ class FileSelection(QtWidgets.QVBoxLayout):
|
|||||||
|
|
||||||
# Sandboxes (for masOS, Flatpak, etc.) need separate add files and folders buttons, in
|
# Sandboxes (for masOS, Flatpak, etc.) need separate add files and folders buttons, in
|
||||||
# order to use native file selection dialogs
|
# order to use native file selection dialogs
|
||||||
|
if self.common.platform == "Darwin" or self.common.is_flatpak():
|
||||||
# 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
|
self.sandbox = True
|
||||||
else:
|
else:
|
||||||
self.sandbox = False
|
self.sandbox = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user