Philipp Hörist pushed to branch master at gajim / gajim
Commits:
b379bf77 by André Apitzsch at 2023-04-02T17:27:58+02:00
fix: Flatpak: Fix drag and drop
Fixes #10370.
- - - - -
3 changed files:
- gajim/gtk/avatar_selector.py
- gajim/gtk/chat_stack.py
- gajim/gtk/file_transfer_selector.py
Changes:
=====================================
gajim/gtk/avatar_selector.py
=====================================
@@ -37,6 +37,7 @@
from gajim.common.i18n import _
from gajim.gtk import types
+from gajim.gtk.const import TARGET_TYPE_URI_LIST
from gajim.gtk.dialogs import ErrorDialog
from gajim.gtk.filechoosers import AvatarChooserDialog
from gajim.gtk.util import scale_with_ratio
@@ -73,8 +74,13 @@ def __init__(self) -> None:
spacing=12)
self.get_style_context().add_class('avatar-selector')
+ if app.is_flatpak():
+ target = 'application/vnd.portal.files'
+ else:
+ target = 'text/uri-list'
+
uri_entry = Gtk.TargetEntry.new(
- 'text/uri-list', Gtk.TargetFlags.OTHER_APP, 80)
+ target, Gtk.TargetFlags.OTHER_APP, TARGET_TYPE_URI_LIST)
dst_targets = Gtk.TargetList.new([uri_entry])
self.drag_dest_set(
@@ -147,7 +153,7 @@ def _on_drag_data_received(self,
if not selection.get_data():
return
- if target_type == 80:
+ if target_type == TARGET_TYPE_URI_LIST:
uri_split = selection.get_uris() # Might be more than one
path = get_file_path_from_dnd_dropped_uri(uri_split[0])
if not path or not path.is_file():
=====================================
gajim/gtk/chat_stack.py
=====================================
@@ -125,8 +125,13 @@ def __init__(self):
overlay.connect('drag-motion', self._on_drag_motion)
overlay.connect('drag-leave', self._on_drag_leave)
+ if app.is_flatpak():
+ target = 'application/vnd.portal.files'
+ else:
+ target = 'text/uri-list'
+
uri_entry = Gtk.TargetEntry.new(
- 'text/uri-list',
+ target,
Gtk.TargetFlags.OTHER_APP,
TARGET_TYPE_URI_LIST)
dnd_list = [uri_entry,
=====================================
gajim/gtk/file_transfer_selector.py
=====================================
@@ -41,6 +41,7 @@
from gajim.common.preview_helpers import pixbuf_from_data
from gajim.gtk.builder import get_builder
+from gajim.gtk.const import TARGET_TYPE_URI_LIST
from gajim.gtk.filechoosers import FileChooserDialog
from gajim.gtk.resource_selector import ResourceSelector
@@ -90,8 +91,13 @@ def __init__(self,
'Choose the device you would like to send the '
'files to.') % self._contact.name)
+ if app.is_flatpak():
+ target = 'application/vnd.portal.files'
+ else:
+ target = 'text/uri-list'
+
uri_entry = Gtk.TargetEntry.new(
- 'text/uri-list', Gtk.TargetFlags.OTHER_APP, 80)
+ target, Gtk.TargetFlags.OTHER_APP, TARGET_TYPE_URI_LIST)
dst_targets = Gtk.TargetList.new([uri_entry])
self._ui.listbox.drag_dest_set(
@@ -201,7 +207,7 @@ def _on_drag_data_received(self,
if not selection.get_data():
return
- if target_type == 80:
+ if target_type == TARGET_TYPE_URI_LIST:
self.add_files(selection.get_uris())
def _on_files_changed(self, _listbox: Gtk.ListBox, _row: FileRow) -> None:
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/b379bf77e440591e60150b0d2fa5a0cfb8b9c00c
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/b379bf77e440591e60150b0d2fa5a0cfb8b9c00c
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits