Use NativeFileChoosers on Windows and MacOS
These platforms integrate a file preview in their native filechoosers
This commit is contained in:
parent
913634c4c6
commit
1ecf0ec008
|
@ -18,6 +18,7 @@
|
||||||
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ class FileSaveDialog(NativeFileChooserDialog):
|
||||||
|
|
||||||
class AvatarSaveDialog(FileSaveDialog):
|
class AvatarSaveDialog(FileSaveDialog):
|
||||||
|
|
||||||
if os.name == 'nt':
|
if sys.platform == 'win32':
|
||||||
_filters = [Filter(_('Images'), '*.png;*.jpg;*.jpeg;*.svg', True)]
|
_filters = [Filter(_('Images'), '*.png;*.jpg;*.jpeg;*.svg', True)]
|
||||||
|
|
||||||
|
|
||||||
|
@ -199,14 +200,22 @@ class GtkAvatarChooserDialog(BaseAvatarChooserDialog, GtkFileChooserDialog):
|
||||||
|
|
||||||
|
|
||||||
def FileChooserDialog(*args, **kwargs):
|
def FileChooserDialog(*args, **kwargs):
|
||||||
if app.is_flatpak():
|
if _require_native():
|
||||||
return NativeFileOpenDialog(*args, **kwargs)
|
return NativeFileOpenDialog(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
return GtkFileOpenDialog(*args, **kwargs)
|
return GtkFileOpenDialog(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def AvatarChooserDialog(*args, **kwargs):
|
def AvatarChooserDialog(*args, **kwargs):
|
||||||
if app.is_flatpak():
|
if _require_native():
|
||||||
return NativeAvatarChooserDialog(*args, **kwargs)
|
return NativeAvatarChooserDialog(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
return GtkAvatarChooserDialog(*args, **kwargs)
|
return GtkAvatarChooserDialog(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def _require_native():
|
||||||
|
if app.is_flatpak():
|
||||||
|
return True
|
||||||
|
if sys.platform in ('win32', 'darwin'):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue