Philipp Hörist pushed to branch master at gajim / gajim
Commits:
-
b379bf77
by André Apitzsch at 2023-04-02T17:27:58+02:00
3 changed files:
Changes:
| ... | ... | @@ -37,6 +37,7 @@ |
| 37 | 37 | from gajim.common.i18n import _
|
| 38 | 38 | |
| 39 | 39 | from gajim.gtk import types
|
| 40 | +from gajim.gtk.const import TARGET_TYPE_URI_LIST
|
|
| 40 | 41 | from gajim.gtk.dialogs import ErrorDialog
|
| 41 | 42 | from gajim.gtk.filechoosers import AvatarChooserDialog
|
| 42 | 43 | from gajim.gtk.util import scale_with_ratio
|
| ... | ... | @@ -73,8 +74,13 @@ def __init__(self) -> None: |
| 73 | 74 | spacing=12)
|
| 74 | 75 | self.get_style_context().add_class('avatar-selector')
|
| 75 | 76 | |
| 77 | + if app.is_flatpak():
|
|
| 78 | + target = 'application/vnd.portal.files'
|
|
| 79 | + else:
|
|
| 80 | + target = 'text/uri-list'
|
|
| 81 | + |
|
| 76 | 82 | uri_entry = Gtk.TargetEntry.new(
|
| 77 | - 'text/uri-list', Gtk.TargetFlags.OTHER_APP, 80)
|
|
| 83 | + target, Gtk.TargetFlags.OTHER_APP, TARGET_TYPE_URI_LIST)
|
|
| 78 | 84 | dst_targets = Gtk.TargetList.new([uri_entry])
|
| 79 | 85 | |
| 80 | 86 | self.drag_dest_set(
|
| ... | ... | @@ -147,7 +153,7 @@ def _on_drag_data_received(self, |
| 147 | 153 | if not selection.get_data():
|
| 148 | 154 | return
|
| 149 | 155 | |
| 150 | - if target_type == 80:
|
|
| 156 | + if target_type == TARGET_TYPE_URI_LIST:
|
|
| 151 | 157 | uri_split = selection.get_uris() # Might be more than one
|
| 152 | 158 | path = get_file_path_from_dnd_dropped_uri(uri_split[0])
|
| 153 | 159 | if not path or not path.is_file():
|
| ... | ... | @@ -125,8 +125,13 @@ def __init__(self): |
| 125 | 125 | overlay.connect('drag-motion', self._on_drag_motion)
|
| 126 | 126 | overlay.connect('drag-leave', self._on_drag_leave)
|
| 127 | 127 | |
| 128 | + if app.is_flatpak():
|
|
| 129 | + target = 'application/vnd.portal.files'
|
|
| 130 | + else:
|
|
| 131 | + target = 'text/uri-list'
|
|
| 132 | + |
|
| 128 | 133 | uri_entry = Gtk.TargetEntry.new(
|
| 129 | - 'text/uri-list',
|
|
| 134 | + target,
|
|
| 130 | 135 | Gtk.TargetFlags.OTHER_APP,
|
| 131 | 136 | TARGET_TYPE_URI_LIST)
|
| 132 | 137 | dnd_list = [uri_entry,
|
| ... | ... | @@ -41,6 +41,7 @@ |
| 41 | 41 | from gajim.common.preview_helpers import pixbuf_from_data
|
| 42 | 42 | |
| 43 | 43 | from gajim.gtk.builder import get_builder
|
| 44 | +from gajim.gtk.const import TARGET_TYPE_URI_LIST
|
|
| 44 | 45 | from gajim.gtk.filechoosers import FileChooserDialog
|
| 45 | 46 | from gajim.gtk.resource_selector import ResourceSelector
|
| 46 | 47 | |
| ... | ... | @@ -90,8 +91,13 @@ def __init__(self, |
| 90 | 91 | 'Choose the device you would like to send the '
|
| 91 | 92 | 'files to.') % self._contact.name)
|
| 92 | 93 | |
| 94 | + if app.is_flatpak():
|
|
| 95 | + target = 'application/vnd.portal.files'
|
|
| 96 | + else:
|
|
| 97 | + target = 'text/uri-list'
|
|
| 98 | + |
|
| 93 | 99 | uri_entry = Gtk.TargetEntry.new(
|
| 94 | - 'text/uri-list', Gtk.TargetFlags.OTHER_APP, 80)
|
|
| 100 | + target, Gtk.TargetFlags.OTHER_APP, TARGET_TYPE_URI_LIST)
|
|
| 95 | 101 | dst_targets = Gtk.TargetList.new([uri_entry])
|
| 96 | 102 | |
| 97 | 103 | self._ui.listbox.drag_dest_set(
|
| ... | ... | @@ -201,7 +207,7 @@ def _on_drag_data_received(self, |
| 201 | 207 | if not selection.get_data():
|
| 202 | 208 | return
|
| 203 | 209 | |
| 204 | - if target_type == 80:
|
|
| 210 | + if target_type == TARGET_TYPE_URI_LIST:
|
|
| 205 | 211 | self.add_files(selection.get_uris())
|
| 206 | 212 | |
| 207 | 213 | def _on_files_changed(self, _listbox: Gtk.ListBox, _row: FileRow) -> None:
|